]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/lookup.py
move localization into add_result_details
[nominatim.git] / nominatim / api / lookup.py
index 0e1fd9cec6303ed188adf5d8e54223e732e3c165..81e6f74d244e23fe786354c5bb58a1dd0e340848 100644 (file)
@@ -38,6 +38,7 @@ async def find_in_placex(conn: SearchConnection, place: ntyp.PlaceRef,
                     t.c.importance, t.c.wikipedia, t.c.indexed_date,
                     t.c.parent_place_id, t.c.rank_address, t.c.rank_search,
                     t.c.linked_place_id,
                     t.c.importance, t.c.wikipedia, t.c.indexed_date,
                     t.c.parent_place_id, t.c.rank_address, t.c.rank_search,
                     t.c.linked_place_id,
+                    t.c.geometry.ST_Expand(0).label('bbox'),
                     t.c.centroid)
 
     if isinstance(place, ntyp.PlaceID):
                     t.c.centroid)
 
     if isinstance(place, ntyp.PlaceID):
@@ -207,16 +208,16 @@ async def get_simple_place(conn: SearchConnection, place: ntyp.PlaceRef,
         out = []
 
         if details.geometry_simplification > 0.0:
         out = []
 
         if details.geometry_simplification > 0.0:
-            col = col.ST_SimplifyPreserveTopology(details.geometry_simplification)
+            col = sa.func.ST_SimplifyPreserveTopology(col, details.geometry_simplification)
 
         if details.geometry_output & ntyp.GeometryFormat.GEOJSON:
 
         if details.geometry_output & ntyp.GeometryFormat.GEOJSON:
-            out.append(col.ST_AsGeoJSON().label('geometry_geojson'))
+            out.append(sa.func.ST_AsGeoJSON(col).label('geometry_geojson'))
         if details.geometry_output & ntyp.GeometryFormat.TEXT:
         if details.geometry_output & ntyp.GeometryFormat.TEXT:
-            out.append(col.ST_AsText().label('geometry_text'))
+            out.append(sa.func.ST_AsText(col).label('geometry_text'))
         if details.geometry_output & ntyp.GeometryFormat.KML:
         if details.geometry_output & ntyp.GeometryFormat.KML:
-            out.append(col.ST_AsKML().label('geometry_kml'))
+            out.append(sa.func.ST_AsKML(col).label('geometry_kml'))
         if details.geometry_output & ntyp.GeometryFormat.SVG:
         if details.geometry_output & ntyp.GeometryFormat.SVG:
-            out.append(col.ST_AsSVG().label('geometry_svg'))
+            out.append(sa.func.ST_AsSVG(col).label('geometry_svg'))
 
         return sql.add_columns(*out)
 
 
         return sql.add_columns(*out)
 
@@ -232,7 +233,8 @@ async def get_simple_place(conn: SearchConnection, place: ntyp.PlaceRef,
 
     # add missing details
     assert result is not None
 
     # add missing details
     assert result is not None
-    result.bbox = getattr(row, 'bbox', None)
+    if hasattr(row, 'bbox'):
+        result.bbox = ntyp.Bbox.from_wkb(row.bbox)
 
     await nres.add_result_details(conn, [result], details)
 
 
     await nres.add_result_details(conn, [result], details)