def _construct_row(self, obj, conn): tags = TagStore(obj['tags']) is_node_network = tags.get('network:type') == 'node_network' outtags = RouteRow(id=obj['id'], name=tags.get('name'), ref=tags.get('ref'), intnames=tags.get_prefixed('name:'), itinerary=make_itinerary(tags)) if 'symbol' in tags: outtags.intnames['symbol'] = tags['symbol'] if is_node_network: outtags.level = Network.LOC.min() elif 'network' in tags: outtags.level = self._compute_route_level(tags['network']) # child relations members, relids = self._filter_members(obj['id'], obj['members']) # geometry geom = make_geometry(conn, members, self.ways, self.data) if geom is None: return None # find the country outtags.country = self._find_country(relids, geom) # create the symbol outtags.symbol = self._write_symbol( tags, outtags.country, Network.from_int(outtags.level).name) # custom filter callback if self.config.tag_filter is not None: self.config.tag_filter(outtags, tags) if outtags.network is None and is_node_network: outtags.network = 'NDS' if 'network' in tags and not is_node_network: h = self.rtree.data r = self.rels.data sel = sa.select([sa.text("'a'")])\ .where(h.c.child == obj['id'])\ .where(r.c.id == h.c.parent)\ .where(h.c.depth == 2)\ .where(r.c.tags['network'].astext == tags['network'])\ .limit(1) top = self.thread.conn.scalar(sel) outtags.top = (top is None) outtags = dataclasses.asdict(outtags) outtags['geom'] = geom return outtags
def basic_tag_transform(tags: TagStore, config): difficulty = tags.get('piste:difficulty') difficulty = config.difficulty_map.get(difficulty, 0) return dict(intnames=tags.get_prefixed('name:'), name=tags.firstof('piste:name', 'name'), ref=tags.firstof('piste:ref', 'ref'), difficulty=difficulty, piste=config.piste_type.get(tags.get('piste:type'), 0))