Hi, I see your name on the code for the mp2osm python script. I might have asked you about this before.<br><br><br><a href="http://forums.gps.org.nz/viewtopic.php?f=37&t=4141">http://forums.gps.org.nz/viewtopic.php?f=37&t=4141</a><br>

<br>I think i cracked the code, as all i need to do is have that "<a href="http://short.mp">short.mp</a>" file, in the same directory as the python folder.<br>and run it, just as i would with mkgmap or sendmap or groundtruth .. and just let the program do it's magic.<br>

<br>I figured that all i need todo is make sure that my line types & point types that are in the .mp file, will convert to the correct OSM file type.<br><br>Once i have it converted into OSM format, i can then use gpsbabel and make a .gpx track from it.  Or i can use JOSM and right-click and save layer as gpx.   - Not directly related to OSM, but it's a great tool to be able to swap back from the Garmin MapSource maps (ie. the Ontario Snowmobile trails from the last message).  (But not the Ibycus topo 'cause the licence forbids that)<br>

<br>Anyway, would you be able to confirm for me that the script does in fact still work?<br><br>Thanks,<br>Sam<br><br>P.S. I have the grountruthSRTM contours for your area done. Do you want to download the file and test it out?<br>

My contours are 10m .. where the Ibycus is at 20m.   I can make 5meter contours, do you think that's needed?<br><br><br><code>copied below ... the wheel was only invented once :) & duplicated 4 times to make a car. 2 times to make a bicycle.  the later is much more efficient :)<br clear="all">

</code><br>Twitter: @Acrosscanada<br>Blog:  <a href="http://Acrosscanadatrails.blogspot.com">http://Acrosscanadatrails.blogspot.com</a><br>Facebook: <a href="http://www.facebook.com/sam.vekemans">http://www.facebook.com/sam.vekemans</a><br>

Skype: samvekemans<br>OpenStreetMap IRC: <a href="http://irc.openstreetmap.org">http://irc.openstreetmap.org</a><br>@Acrosscanadatrails<br><br><br><dl class="codebox"><dd><code># derived from 'mp2osm_ukraine.py' <br>

# modified by <a href="mailto:simon@mungewell.org">simon@mungewell.org</a><br># modified by Karl Newman (User:SiliconFiend) to preserve routing topology and parse RouteParam <br># license: GPL V2 or later<br><br>import xml.etree.ElementTree as ET<br>

<br>attribution = 'NZ Open GPS Project, LINZ'<br>file_mp = open('<a href="http://short.mp">short.mp</a>')<br><br># flags and global variable<br>poi = False<br>polyline = False<br>polygon = False<br>roadid = ''<br>

rNodeToOsmId = {} # map routing node ids to OSM node ids<br><br># debug/stats counters<br>poi_counter = 0<br>polyline_counter = 0<br>polygon_counter = 0<br><br>osm = ET.Element('osm', version='0.5', generator='mp2osm_NZOGPS' )<br>

osm.text = '\n  '<br>osm.tail = '\n'<br>source = ET.Element('tag', k='source',v=attribution)<br>source.tail = '\n    '<br>nodeid = -1<br># Define the mapping from Garmin type codes to OSM tags<br>

# Note that single items in parentheses need a trailing comma<br>poitagmap = {# Warning: this particular 'gate' typecode usage is specific to Calgary Trails maps<br>     (0x1612, 0x1c00, 0x6400): {'highway': 'gate'}, <br>

     (0x2b00,): {'tourism': 'hotel'},<br>     (0x2b01,): {'tourism': 'motel'},<br>     (0x2b03,): {'tourism': 'caravan_site'},<br>     (0x2e02,): {'shop': 'supermarket'},<br>

     (0x2f08,): {'amenity': 'bus_station'},<br>     (0x4400,): {'amenity': 'fuel'},<br>     (0x4700,): {'leisure': 'slipway'},<br>     (0x4800,): {'tourism': 'campsite'},<br>

     (0x4900,): {'leisure': 'park'},<br>     (0x4a00,): {'tourism': 'picnic_site'},<br>     (0x4c00,): {'tourism': 'information'},<br>     (0x4d00,): {'amenity': 'parking'},<br>

     (0x4e00,): {'amenity': 'toilets'},<br>     (0x5100,): {'amenity': 'telephone'},<br>     (0x5200,): {'tourism': 'viewpoint'},<br>     (0x5400,): {'sport': 'swimming'},<br>

     (0x5904,): {'aeroway': 'helipad'},<br>     (0x5905,): {'aeroway': 'aerodrome'},<br>     (0x5904,): {'aeroway': 'helipad'},<br>     (0x5a00,): {'distance_marker': 'yes'}, # Not approved<br>

     (0x6401,): {'bridge': 'yes'}, # Apply to points?<br>     (0x6401,): {'building': 'yes'},<br>     (0x6406,): {'highway': 'crossing'},<br>     (0x640c,): {'man_made': 'mineshaft'},<br>

     (0x640d,): {'man_made': 'pumping_rig', 'type': 'oil'},<br>     (0x6411,): {'man_made': 'tower'},<br>     (0x6412,): {'highway': 'trailhead'}, # This is not even a proposed value<br>

     (0x6413,): {'tunnel': 'yes'}, # Apply to points?<br>     (0x6500, 0x650d): {'natural': 'water'},<br>     (0x6508,): {'waterway': 'waterfall'},<br>     (0x6605,): {'natural': 'bench'},<br>

     (0x6616,): {'natural': 'peak'}<br>    }<br>polylinetagmap = {<br>     (0x2,): {'highway': 'trunk'},<br>     (0x3,): {'highway': 'primary'},<br>     (0x4,): {'highway': 'secondary'},<br>

     (0x5,): {'highway': 'tertiary'},<br>     (0x6,): {'highway': 'residential'},<br>     (0xa,): {'highway': 'track', 'surface': 'unpaved'},<br>     (0x16,): {'highway': 'footway'},<br>

     (0x18,): {'waterway': 'stream'},<br>     (0x1f,): {'waterway': 'river'},<br>     (0x29,): {'power': 'line'}<br>    }<br>polygontagmap = {<br>     (0x5,): {'amenity': 'parking', 'area': 'yes'},<br>

     (0xd,): {'landuse': 'reservation', 'area': 'yes'}, # reservation is not even a proposed value<br>     (0x3c, 0x40, 0x41): {'natural': 'water', 'area': 'yes'},<br>

     (0x48, 0x49): {'waterway': 'riverbank', 'area': 'yes'},<br>     (0x4c,): {'waterway': 'intermittent', 'area': 'yes'},<br>     (0x51,): {'natural': 'marsh', 'area': 'yes'}<br>

    }<br><br>for line in file_mp:<br>    # Marker for start of sections<br>    if line.startswith(('[POI]','[RGN10]','[RGN20]')):<br>        node = ET.Element('node', visible='true', id=str(nodeid))<br>

        nodeid -= 1<br>        node.append(source)<br>        poi = True<br>        elementtagmap = poitagmap<br>        poi_counter += 1<br><br>    if line.startswith(('[POLYLINE]','[RGN40]')):<br>        node = ET.Element('way', visible='true', id=str(nodeid))<br>

        nodeid -= 1<br>        node.append(source)<br>        polyline = True<br>        elementtagmap = polylinetagmap<br>        rnodes = {} # Track routing nodes for current polyline<br>        polyline_counter += 1<br>

<br>    if line.startswith(('[POLYGON]','[RGN80]')):<br>        node = ET.Element('way', visible='true', id=str(nodeid))<br>        nodeid -= 1<br>        node.append(source)<br>        polygon = True<br>

        elementtagmap = polygontagmap<br>        polygon_counter += 1<br><br>    # parsing data<br>    if poi or polyline or polygon:<br>        <br>        if line.startswith('Label'):<br>            label = line.split('=')[1].strip()<br>

            # Now strip out control codes such as ~[0x2f]<br>            codestart = label.find('~[')<br>            if codestart != -1:<br>                codeend = label.find(']',codestart)<br>                if codeend != -1:<br>

                    label = label[0:codestart] + ' ' + label[codeend+1:]<br>            tag = ET.Element('tag', k='name',v=label.strip().title()) # convert to title case<br>            tag.tail = '\n    '<br>

            node.append(tag)<br>        if line.startswith('Type'):<br>            typecode = line.split('=')[1].strip()<br>            tag = ET.Element('tag', k='garmin_type',v=typecode)<br>

            tag.tail = '\n    '<br>            node.append(tag)<br>            typecode = int(typecode, 16) <br>            for codes, taglist in elementtagmap.iteritems():<br>                if typecode in codes:<br>

                    for key, value in taglist.iteritems():<br>                        tag = ET.Element('tag', k=key, v=value)<br>                        tag.tail = '\n    '<br>                        node.append(tag)<br>

        if line.startswith('RoadID'):<br>            roadid = line.split('=')[1].strip()<br>            tag = ET.Element('tag', k='catmp-RoadID',v=roadid)<br>            tag.tail = '\n    '<br>

            node.append(tag)<br>        if line.startswith('RouteParam'):<br>            rparams = line.split('=')[1].split(',')<br>            # speedval has speeds in km/h corresponding to RouteParam speed value index<br>

            speedval = [8, 20, 40, 56, 72, 93, 108, 128]<br>            speed = ET.Element('tag', k='maxspeed', v=str(speedval[int(rparams[0])]))<br>            speed.tail = '\n    '<br>            node.append(speed)<br>

            rclass = ET.Element('tag', k='garmin_road_class', v=str(rparams[1]))<br>            rclass.tail = '\n    '<br>            node.append(rclass)<br>            for att, attval in zip(('oneway', 'toll'), rparams[2:3]):<br>

                if int(attval):<br>                    attrib = ET.Element('tag', k=att, v='true')<br>                    attrib.tail = '\n    '<br>                    node.append(attrib)<br>            # Note: taxi is not an approved access key<br>

            vehicles = ['emergency', 'goods', 'motorcar', 'psv', 'taxi', 'foot', 'bicycle', 'hgv']<br>            for veh, res in zip(vehicles, rparams[4:]):<br>

                vehtag = ET.Element('tag', k=veh, v=('yes', 'no')[int(res)]) <br>                vehtag.tail = '\n    '<br>                node.append(vehtag)<br><br>        # Get nodes from all zoom levels (ie. Data0, Data1, etc)<br>

        # TODO: Only grab the lowest-numbered data line (highest-resolution) and ignore the rest<br>        if line.startswith('Data'):<br>            if poi:<br>                coords = line.split('=')[1].strip()<br>

                coords = coords.split(',')<br>                node.set('lat',str(float(coords[0][1:])))<br>                node.set('lon',str(float(coords[1][:-1])))<br>            if polyline or polygon:<br>

                # Just grab the line and parse it later when the [END] element is encountered<br>                coords = line.split('=')[1].strip() + ','<br>                # TODO: parse out "holes" in a polygon by reading multiple Data0 lines and<br>

                # constructing a multipolygon relation<br>        if line.startswith('Nod'):<br>            if polyline:<br>                # Store the point index and routing node id for later use<br>                nod = line.split('=')[1].strip().split(',', 2)<br>

                rnodes[nod[0]] = nod[1]<br>        if line.startswith('[END]'):<br>            if polyline or polygon:<br>                # Have to write out nodes as they are parsed<br>                nodidx = 0<br>

                nodIds = []<br>                reused = False<br>                while coords != '':<br>                    coords = coords.split(',', 2)<br>                    if str(nodidx) in rnodes:<br>

                        if rnodes[str(nodidx)] in rNodeToOsmId:<br>                            curId = rNodeToOsmId[str(rnodes[str(nodidx)])]<br>                            reused = True<br>                        else:<br>

                            curId = nodeid<br>                            nodeid -= 1<br>                            rNodeToOsmId[str(rnodes[str(nodidx)])] = curId<br>                    else:<br>                        curId = nodeid<br>

                        nodeid -= 1<br>                    nodIds.append(curId)<br>                    # Don't write another node element if we reused an existing one<br>                    if not reused:<br> 
                      nodes = ET.Element('node', visible='true',
id=str(curId), lat=str(float(coords[0][1:])),
lon=str(float(coords[1][:-1])))<br>                        nodes.text = '\n    '<br>                        nodes.tail = '\n  '<br>                        osm.append(nodes)<br>                    coords = coords[2]<br>

                    reused = False<br>                    nodidx += 1<br>                nodidx = 0<br>                for ndid in nodIds:<br>                    nd = ET.Element('nd', ref=str(ndid))<br>                    nd.tail = '\n    '<br>

                    node.append(nd)<br>            if polygon:<br>                nd = ET.Element('nd', ref=str(nodIds[0]))<br>                nd.tail = '\n    '<br>                node.append(nd)<br><br>
            poi = False <br>
            polyline = False <br>            polygon = False <br>            roadid = ''<br>            rnodes = {} # Clear out routing nodes to prepare for next entity<br><br>            node.text = '\n    '<br>

            node.tail = '\n  '<br>            <br>            osm.append(node)<br><br># writing to file<br>f = open('out.osm', 'w')<br>f.write(ET.tostring(osm))<br><br># dump some stats<br>print '======'<br>

print 'Totals'<br>print '======'<br>print 'POI', poi_counter<br>print 'POLYLINE', polyline_counter<br>print 'POLYGON', polygon_counter<br>print 'Last nodeid', nodeid<br></code></dd>

</dl><br>
<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden"><div id="refHTML"></div>