def export_place(self, export, place, match, entity): tags = dict(place) tags.pop("COBE", None) tags.pop("radius", None) tags.pop("population") tags["source"] = "csu:uir-zsj" place = PlaceNode.from_jtsk(tags.pop("xy"), tags) if match is None: self.reporter.add_place(place, match, entity) export.add(place) else: self.remove(match) attr = { "tags_odbl": set(), "dist": int(round(uir.distance(place.xy, match.xy))) } if match.odbl_problems is not None: attr["tags_odbl"] = set( filter(lambda k: self.tags_harmless.match(k) is None, match.tags.keys())) if len(match.refs["way"]) == 0 and len( match.refs["relation"]) == 0 and len( attr["tags_odbl"]) == 0: self.reporter.add_place(place, match, entity, attr) export.add(place) if place not in export: if len(match.refs["way"]) > 0 or len( match.refs["relation"] ) > 0 or match.odbl_problems is not None: place.tags["fixme"] = self.reporter.add_place( place, match, entity, attr) if match.odbl_problems is None: self.merge_tags(match, place) export.add(match) export.add(place) else: self.reporter.add_place(place, match, entity, attr) self.merge_tags(match, place) for k, v in match.attribs.items(): if k not in ("lat", "lon"): place.attribs[k] = v export.add(place) for adm_rel in match.refs["admin"]: for member in adm_rel.members: if member["role"] == "admin_centre" and member[ "ref"] == match.id: member["ref"] = place.id if entity == "OBCE" and match != self.admin_centre: for member in export.relations[self.rel_id].members: if member["type"] == "node" and member[ "role"] == "admin_centre": member["ref"] = place.id self.admin_centre.refs["admin"].remove( export.relations[self.rel_id])
def find_by_ascii_name(self, place, score): place_name = to_ascii(place["name"]) match = None for node in self.nodes.values(): if to_ascii(node.name) != place_name: continue dist = uir.distance(node.xy, place["xy"]) if dist > score: continue score = dist match = node return match
def find_by_ref(self, place, score, ref_key): place_ref = place[ref_key] match = None for node in self.nodes.values(): if node.tags.get(ref_key) != place_ref: continue dist = uir.distance(node.xy, place["xy"]) if dist > score: continue score = dist match = node return match
def export_place(self, export, place, match, entity): tags = dict(place) tags.pop("COBE", None) tags.pop("radius", None) tags.pop("population") tags["source"] = "csu:uir-zsj" place = PlaceNode.from_jtsk(tags.pop("xy"), tags) if match is None: self.reporter.add_place(place, match, entity) export.add(place) else: self.remove(match) attr = {"tags_odbl": set(), "dist": int(round(uir.distance(place.xy, match.xy)))} if match.odbl_problems is not None: attr["tags_odbl"] = set(filter(lambda k: self.tags_harmless.match(k) is None, match.tags.keys())) if len(match.refs["way"]) == 0 and len(match.refs["relation"]) == 0 and len(attr["tags_odbl"]) == 0: self.reporter.add_place(place, match, entity, attr) export.add(place) if place not in export: if len(match.refs["way"]) > 0 or len(match.refs["relation"]) > 0 or match.odbl_problems is not None: place.tags["fixme"] = self.reporter.add_place(place, match, entity, attr) if match.odbl_problems is None: self.merge_tags(match, place) export.add(match) export.add(place) else: self.reporter.add_place(place, match, entity, attr) self.merge_tags(match, place) for k, v in match.attribs.items(): if k not in ("lat", "lon"): place.attribs[k] = v export.add(place) for adm_rel in match.refs["admin"]: for member in adm_rel.members: if member["role"] == "admin_centre" and member["ref"] == match.id: member["ref"] = place.id if entity == "OBCE" and match != self.admin_centre: for member in export.relations[self.rel_id].members: if member["type"] == "node" and member["role"] == "admin_centre": member["ref"] = place.id self.admin_centre.refs["admin"].remove(export.relations[self.rel_id])