def get_osm_housenumbers_query(self) -> str: """Produces a query which lists house numbers in relation.""" with open( os.path.join(self.__datadir, "street-housenumbers-template.txt")) as stream: return util.process_template(stream.read(), self.get_config().get_osmrelation())
def get_osm_streets_query(self) -> str: """Produces a query which lists streets in relation.""" with open( os.path.join(self.__ctx.get_abspath("data"), "streets-template.txt")) as stream: return util.process_template(stream.read(), self.get_config().get_osmrelation())
def make_turbo_query_for_streets(relation: Relation, streets: List[str]) -> str: """Creates an overpass query that shows all streets from a missing housenumbers table.""" header = """[out:json][timeout:425]; rel(@RELATION@)->.searchRelation; area(@AREA@)->.searchArea; (""" query = util.process_template(header, relation.get_config().get_osmrelation()) for street in streets: query += 'way["name"="' + street + '"](r.searchRelation);\n' query += 'way["name"="' + street + '"](area.searchArea);\n' query += """); out body; >; out skel qt;""" return query
def make_turbo_query_for_street_objs(relation: Relation, streets: List[util.Street]) -> str: """Creates an overpass query that shows all streets from a list.""" header = """[out:json][timeout:425]; rel(@RELATION@)->.searchRelation; area(@AREA@)->.searchArea; (""" query = util.process_template(header, relation.get_config().get_osmrelation()) ids = [] for street in streets: ids.append((street.get_osm_type(), str(street.get_osm_id()))) for osm_type, osm_id in sorted(set(ids)): query += osm_type + "(" + osm_id + ");\n" query += """); out body; >; out skel qt;""" return query
def make_turbo_query_for_streets(relation: Relation, table: List[List[yattag.doc.Doc]]) -> str: """Creates an overpass query that shows all streets from a missing housenumbers table.""" streets: List[str] = [] first = True for row in table: if first: first = False continue streets.append(row[0].getvalue()) header = """[out:json][timeout:425]; rel(@RELATION@)->.searchRelation; area(@AREA@)->.searchArea; (""" query = util.process_template(header, relation.get_config().get_osmrelation()) for street in streets: query += 'way["name"="' + street + '"](r.searchRelation);\n' query += 'way["name"="' + street + '"](area.searchArea);\n' query += """); out body; >; out skel qt;""" return query
def test_happy(self) -> None: """Tests the happy path.""" template = "aaa @RELATION@ bbb @AREA@ ccc" expected = "aaa 42 bbb 3600000042 ccc" actual = util.process_template(template, 42) self.assertEqual(actual, expected)