Example #1
0
    def transform_tags(self, osmid, tags):
        outtags = { 'intnames'  : {},
                    'top'          : None}
        for k in conf.TAGS_DIFFICULTY_MAP.keys():
            outtags[k] = None
        for k in conf.TAGS_PISTETYPE_MAP.keys():
            outtags[k] = None

        difficulty = 0

        if tags.has_key('piste:name'):
            outtags['name'] = tags['piste:name']
        elif tags.has_key('name'):
            outtags['name'] = tags['name']
        elif tags.has_key('piste:ref'):
            outtags['name'] = '[%s]' % tags['piste:ref']
        elif tags.has_key('ref'):
            outtags['name'] = '[%s]' % tags['ref']
        else:
            outtags['name'] = '(%s)' % osmid

        # default treatment of tags
        for (k,v) in tags.iteritems():
            if k == 'piste:difficulty':
                if v in conf.TAGS_DIFFICULTY_MAP.keys():
                    outtags[v] = True
                    difficulty = conf.TAGS_DIFFICULTY_MAP[v]
            if k == 'piste:type':
                if v in conf.TAGS_PISTETYPE_MAP.keys():
                    outtags[v] = True
            if k.startswith('name:'):
                outtags['intnames'][k[5:]] = v
                    

        outtags['symbol'] = symbols.get_symbol(difficulty, None, tags, symboltypes)

        cur = self.thread.cursor

        if 'name' not in outtags:
            outtags['name'] = '(%s)' % osmid

        if outtags['top'] is None:
            if 'network' in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)",
                              (osmid, tags['network']), cur=cur)
                outtags['top'] = True if (top == 0) else False
            else:
                outtags['top'] = True

        # finally: compute the geometry
        routelines = self.db.select_column("EXECUTE get_route_geometry(%s)", 
                                           (osmid,), cur=cur)
        if routelines:
            outtags['geom'] = sops.linemerge(routelines)
            outtags['geom']._crs = int(conf.DB_SRID)
            
        # Clear elevation profile cache
        clearcache.clearElevationProfileCache(osmid)

        return outtags
    def transform_tags(self, osmid, tags):
        outtags = { 'intnames' : {}, 
                    'level' : 35, 
                    'top' : None}

        # default treatment of tags
        for (k,v) in tags.iteritems():
            if k == 'name':
                outtags[k] = v
            elif k.startswith('name:'):
                outtags['intnames'][k[5:]] = v
            elif k == 'ref':
                if 'name' not in outtags:
                    outtags['name'] = '[%s]' % v
            elif k == 'network':
                outtags['level'] = conf.TAGS_NETWORK_MAP.get(v, 35)


        outtags['symbol'] = symbols.get_symbol(outtags['level'], None, tags, symboltypes)

        cur = self.thread.cursor

        if 'name' not in outtags:
            outtags['name'] = '(%s)' % osmid

        if outtags['top'] is None:
            if 'network' in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)",
                              (osmid, tags['network']), cur=cur)
                outtags['top'] = True if (top == 0) else False
            else:
                outtags['top'] = True

        # finally: compute the geometry
        routelines = self.db.select_column("EXECUTE get_route_geometry(%s)", 
                               (osmid,), cur=cur)
        if routelines:
            outtags['geom'] = sops.linemerge(routelines)
            outtags['geom']._crs = int(conf.DB_SRID)

        # Clear elevation profile cache
        clearcache.clearElevationProfileCache(osmid)
            
        return outtags
    def transform_tags(self, osmid, tags):
        #print "Processing", osmid
        outtags = { 'intnames'   : {}, }
        for k in conf.TAGS_DIFFICULTY_MAP.keys():
            outtags[k] = None
        for k in conf.TAGS_PISTETYPE_MAP.keys():
            outtags[k] = None

        difficulty = 0

        # default treatment of tags
        if tags.has_key('piste:name'):
            outtags['name'] = tags['piste:name']
        elif tags.has_key('piste:ref'):
            outtags['name'] = '[%s]' % tags['piste:ref']
        elif tags.has_key('name'):
            outtags['name'] = tags['name']
        elif tags.has_key('ref'):
            outtags['name'] = '[%s]' % tags['ref']
        else:
            outtags['name'] = '(%s)' % osmid


        for (k,v) in tags.iteritems():
            if k == 'piste:difficulty':
                if v in conf.TAGS_DIFFICULTY_MAP.keys():
                    outtags[v] = True
                    difficulty = conf.TAGS_DIFFICULTY_MAP[v]
            if k == 'piste:type':
                if v in conf.TAGS_PISTETYPE_MAP.keys():
                    outtags[v] = True
            if k.startswith('piste:name:'):
                outtags['intnames'][k[11:]] = v
                    
        outtags['symbol'] = symbols.get_symbol(difficulty, None, tags, symboltypes)

        return outtags
Example #4
0
    def transform_tags(self, osmid, tags):
        # print "Processing", osmid
        outtags = {"intnames": {}}
        for k in conf.TAGS_DIFFICULTY_MAP.keys():
            outtags[k] = None
        for k in conf.TAGS_PISTETYPE_MAP.keys():
            outtags[k] = None

        difficulty = 0

        # default treatment of tags
        if tags.has_key("piste:name"):
            outtags["name"] = tags["piste:name"]
        elif tags.has_key("piste:ref"):
            outtags["name"] = "[%s]" % tags["piste:ref"]
        elif tags.has_key("name"):
            outtags["name"] = tags["name"]
        elif tags.has_key("ref"):
            outtags["name"] = "[%s]" % tags["ref"]
        else:
            outtags["name"] = "(%s)" % osmid

        for (k, v) in tags.iteritems():
            if k == "piste:difficulty":
                if v in conf.TAGS_DIFFICULTY_MAP.keys():
                    outtags[v] = True
                    difficulty = conf.TAGS_DIFFICULTY_MAP[v]
            if k == "piste:type":
                if v in conf.TAGS_PISTETYPE_MAP.keys():
                    outtags[v] = True
            if k.startswith("piste:name:"):
                outtags["intnames"][k[11:]] = v

        outtags["symbol"] = symbols.get_symbol(difficulty, None, tags, symboltypes)

        return outtags
Example #5
0
    def transform_tags(self, osmid, tags):
        outtags = {"intnames": {}, "level": 25, "top": None}

        # default treatment of tags
        for (k, v) in tags.iteritems():
            if k == "name":
                outtags[k] = v
            elif k.startswith("name:"):
                outtags["intnames"][k[5:]] = v
            elif k == "ref":
                if "name" not in outtags:
                    outtags["name"] = "[%s]" % v
            elif k == "network":
                outtags["level"] = conf.TAGS_NETWORK_MAP.get(v, 25)

        outtags["symbol"] = symbols.get_symbol(outtags["level"], None, tags, symboltypes)

        cur = self.thread.cursor

        if "name" not in outtags:
            outtags["name"] = "(%s)" % osmid

        if outtags["top"] is None:
            if "network" in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)", (osmid, tags["network"]), cur=cur)
                outtags["top"] = True if (top == 0) else False
            else:
                outtags["top"] = True

        # finally: compute the geometry
        routelines = self.db.select_column("EXECUTE get_route_geometry(%s)", (osmid,), cur=cur)
        if routelines:
            outtags["geom"] = sops.linemerge(routelines)
            outtags["geom"]._crs = 900913

        return outtags
    def transform_tags(self, osmid, tags):
        #print "Processing", osmid
        outtags = {
            'intnames': {},
            'level': 35,
            'network': '',
            'top': None,
            'geom': None
        }

        # default treatment of tags
        for (k, v) in tags.iteritems():
            if k == 'name':
                outtags[k] = v
            elif k.startswith('name:'):
                outtags['intnames'][k[5:]] = v
            elif k == 'ref':
                if 'name' not in outtags:
                    outtags['name'] = '[%s]' % v
            elif k == 'network':
                if v == 'uk_ldp':
                    outtags['level'] = 10 if tags.get(
                        'operator', '') == 'National Trails' else 20
                else:
                    outtags['level'] = conf.TAGS_NETWORK_MAP.get(v, 35)
            elif k.startswith('kct_'):
                outtags['network'] = 'CT'
                if 'network' not in tags and tags[k] == 'major':
                    outtags['level'] = 11 if k[4:] == 'red' else 21

        cur = self.thread.cursor

        # find out about country and geometry
        cur.execute("EXECUTE get_route_geometry(%s)", (osmid, ))
        routelines = []
        countrydic = defaultdict(int)
        for r in cur:
            routelines.append(r[0])
            if r[1] is not None:
                countrydic[r[1]] += 1

        if countrydic:
            cntry = max(countrydic.iterkeys(), key=lambda x: countrydic[x])
            cntry = cntry.strip().lower()
        else:
            cntry = None

        if routelines:
            outtags['geom'] = sops.linemerge(routelines)
            outtags['geom']._crs = int(self.srid)

        # Clear elevation profile cache
        clearcache.clearElevationProfileCache(osmid)

        # Region-specific tagging:

        # in the UK slightly downgrade nwns (to distinguish them from National Trails)
        if cntry == 'gb' and tags.get('network', '') == 'nwn':
            outtags['level'] = 11

        # find Swiss hiking network
        if cntry == 'ch' and tags.get('network', '') == 'lwn':
            ot = tags.get('osmc:symbol', '')
            if ot.startswith('yellow:'):
                outtags['network'] = 'CH'
                outtags['level'] = 31
            if ot.startswith('red:'):
                outtags['network'] = 'CH'
                outtags['level'] = 32
            if ot.startswith('blue:'):
                outtags['network'] = 'CH'
                outtags['level'] = 33

        # Fränkischer Albverein (around Nürnberg)
        #  too extensive regional network, so we need to downgrade later
        if tags.get('operator') == u'Fränkischer Albverein':
            outtags['network'] = 'FA'

        outtags['symbol'] = symbols.get_symbol(outtags['level'], cntry, tags,
                                               symboltypes)
        outtags['country'] = cntry

        if 'name' not in outtags:
            outtags['name'] = '(%s)' % osmid

        if outtags['top'] is None:
            if 'network' in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)",
                                         (osmid, tags['network']),
                                         cur=cur)
                outtags['top'] = (top is None)
            else:
                outtags['top'] = True

        return outtags
    def transform_tags(self, osmid, tags):
        outtags = {'intnames': {}, 'top': None}
        for k in conf.TAGS_DIFFICULTY_MAP.keys():
            outtags[k] = None
        for k in conf.TAGS_PISTETYPE_MAP.keys():
            outtags[k] = None

        difficulty = 0

        if tags.has_key('piste:name'):
            outtags['name'] = tags['piste:name']
        elif tags.has_key('name'):
            outtags['name'] = tags['name']
        elif tags.has_key('piste:ref'):
            outtags['name'] = '[%s]' % tags['piste:ref']
        elif tags.has_key('ref'):
            outtags['name'] = '[%s]' % tags['ref']
        else:
            outtags['name'] = '(%s)' % osmid

        # default treatment of tags
        for (k, v) in tags.iteritems():
            if k == 'piste:difficulty':
                if v in conf.TAGS_DIFFICULTY_MAP.keys():
                    outtags[v] = True
                    difficulty = conf.TAGS_DIFFICULTY_MAP[v]
            if k == 'piste:type':
                if v in conf.TAGS_PISTETYPE_MAP.keys():
                    outtags[v] = True
            if k.startswith('name:'):
                outtags['intnames'][k[5:]] = v

        outtags['symbol'] = symbols.get_symbol(difficulty, None, tags,
                                               symboltypes)

        cur = self.thread.cursor

        if 'name' not in outtags:
            outtags['name'] = '(%s)' % osmid

        if outtags['top'] is None:
            if 'network' in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)",
                                         (osmid, tags['network']),
                                         cur=cur)
                outtags['top'] = True if (top == 0) else False
            else:
                outtags['top'] = True

        # finally: compute the geometry
        routelines = self.db.select_column("EXECUTE get_route_geometry(%s)",
                                           (osmid, ),
                                           cur=cur)
        if routelines:
            outtags['geom'] = sops.linemerge(routelines)
            outtags['geom']._crs = int(conf.DB_SRID)

        # Clear elevation profile cache
        clearcache.clearElevationProfileCache(osmid)

        return outtags
Example #8
0
    def transform_tags(self, osmid, tags):
        #print "Processing", osmid
        outtags = { 'intnames' : {}, 
                    'level' : 35, 
                    'network' : '', 
                    'top' : None,
                    'geom' : None}

        # default treatment of tags
        for (k,v) in tags.iteritems():
            if k == 'name':
                outtags[k] = v
            elif k.startswith('name:'):
                outtags['intnames'][k[5:]] = v
            elif k == 'ref':
                if 'name' not in outtags:
                    outtags['name'] = '[%s]' % v
            elif k == 'network':
                if v == 'uk_ldp':
                    outtags['level'] = 10 if tags.get('operator', '') == 'National Trails' else 20
                else:
                    outtags['level'] = conf.TAGS_NETWORK_MAP.get(v, 35)
            elif k.startswith('kct_'):
                outtags['network'] = 'CT'
                if 'network' not in tags and tags[k] == 'major':
                    outtags['level'] = 11 if k[4:] == 'red' else 21
                    
        cur = self.thread.cursor

        # find out about country and geometry
        cur.execute("EXECUTE get_route_geometry(%s)", (osmid,))
        routelines = []
        countrydic = defaultdict(int)
        for r in cur:
            routelines.append(r[0])
            if r[1] is not None:
                countrydic[r[1]] += 1

        if countrydic:
            cntry = max(countrydic.iterkeys(), key=lambda x: countrydic[x])
            cntry = cntry.strip().lower()
        else:
            cntry = None

        if routelines:
            outtags['geom'] = sops.linemerge(routelines)
            outtags['geom']._crs = 900913


        # Region-specific tagging:

        # in the UK slightly downgrade nwns (to distinguish them from National Trails)
        if cntry == 'gb' and tags.get('network', '') == 'nwn':
            outtags['level'] = 11

        # find Swiss hiking network
        if cntry == 'ch' and tags.get('network', '') == 'lwn':
            ot = tags.get('osmc:symbol', '')
            if ot.startswith('yellow:'):
                outtags['network'] = 'CH'
                outtags['level'] = 31
            if ot.startswith('red:'):
                outtags['network'] = 'CH'
                outtags['level'] = 32
            if ot.startswith('blue:'):
                outtags['network'] = 'CH'
                outtags['level'] = 33

        # Fränkischer Albverein (around Nürnberg)
        #  too extensive regional network, so we need to downgrade later
        if tags.get('operator') == u'Fränkischer Albverein':
            outtags['network'] = 'FA'
            
        outtags['symbol'] = symbols.get_symbol(outtags['level'], cntry, tags, symboltypes)
        outtags['country'] = cntry

        if 'name'not in outtags:
            outtags['name'] = '(%s)' % osmid

        if outtags['top'] is None:
            if 'network' in tags:
                top = self.db.select_one("EXECUTE get_route_top(%s, %s)",
                              (osmid, tags['network']), cur=cur)
                outtags['top'] = (top is None)
            else:
                outtags['top'] = True

        return outtags