Compare commits

...

2 Commits

Author SHA1 Message Date
e96a4262a7 partial implementation of search by alias 2023-12-06 16:19:34 -05:00
146ac487ad bug correction in geojson
Should not crash if more than one surface
2023-12-06 15:17:17 -05:00
2 changed files with 7 additions and 3 deletions

View File

@ -213,8 +213,6 @@ class Geojson:
polygon = Polygon(coordinates)
polygon.area = igh.ground_area(coordinates)
surfaces[-1] = Surface(polygon, polygon)
if len(surfaces) > 1:
raise ValueError('too many surfaces!!!!')
building = Building(f'{building_name}', surfaces, year_of_construction, function)
for alias in building_aliases:
building.add_alias(alias)

View File

@ -152,8 +152,14 @@ class CityObject(Repository):
buildings = session.execute(select(Model).where(
Model.city_id.in_(ids), Model.name.in_(names)
))
if len(buildings) == 0:
# search by aliases instead
buildings = session.execute(select(Model).where(
Model.city_id.in_(ids), Model.name.in_(names)
))
results = [r[0] for r in buildings]
print(ids, buildings)
print(ids, [r.name for r in results])
return None
def get_by_name_or_alias_and_city(self, name, city_id) -> Union[Model, None]: