mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
add unit tests for lookup function
This commit is contained in:
@@ -20,4 +20,11 @@ from .status import (StatusResult as StatusResult)
|
||||
from .types import (PlaceID as PlaceID,
|
||||
OsmID as OsmID,
|
||||
PlaceRef as PlaceRef,
|
||||
GeometryFormat as GeometryFormat,
|
||||
LookupDetails as LookupDetails)
|
||||
from .results import (SourceTable as SourceTable,
|
||||
AddressLine as AddressLine,
|
||||
AddressLines as AddressLines,
|
||||
WordInfo as WordInfo,
|
||||
WordInfos as WordInfos,
|
||||
SearchResult as SearchResult)
|
||||
|
||||
@@ -155,6 +155,12 @@ class NominatimAPI:
|
||||
self._loop.close()
|
||||
|
||||
|
||||
@property
|
||||
def config(self) -> Configuration:
|
||||
""" Return the configuration used by the API.
|
||||
"""
|
||||
return self._async_api.config
|
||||
|
||||
def status(self) -> StatusResult:
|
||||
""" Return the status of the database.
|
||||
"""
|
||||
|
||||
@@ -23,8 +23,8 @@ def _select_column_geometry(column: SaColumn,
|
||||
"""
|
||||
if geometry_output & ntyp.GeometryFormat.GEOJSON:
|
||||
return sa.literal_column(f"""
|
||||
ST_AsGeoJSON(CASE WHEN ST_NPoints({0}) > 5000
|
||||
THEN ST_SimplifyPreserveTopology({0}, 0.0001)
|
||||
ST_AsGeoJSON(CASE WHEN ST_NPoints({column.name}) > 5000
|
||||
THEN ST_SimplifyPreserveTopology({column.name}, 0.0001)
|
||||
ELSE {column.name} END)
|
||||
""").label('geometry_geojson')
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class AddressLine:
|
||||
names: Dict[str, str]
|
||||
extratags: Optional[Dict[str, str]]
|
||||
|
||||
admin_level: int
|
||||
admin_level: Optional[int]
|
||||
fromarea: bool
|
||||
isaddress: bool
|
||||
rank_address: int
|
||||
@@ -187,10 +187,16 @@ def _result_row_to_address_row(row: SaRow) -> AddressLine:
|
||||
if 'place_type' in row:
|
||||
extratags['place_type'] = row.place_type
|
||||
|
||||
names = row.name
|
||||
if getattr(row, 'housenumber', None) is not None:
|
||||
if names is None:
|
||||
names = {}
|
||||
names['housenumber'] = row.housenumber
|
||||
|
||||
return AddressLine(place_id=row.place_id,
|
||||
osm_object=(row.osm_type, row.osm_id),
|
||||
osm_object=None if row.osm_type is None else (row.osm_type, row.osm_id),
|
||||
category=(getattr(row, 'class'), row.type),
|
||||
names=row.name,
|
||||
names=names,
|
||||
extratags=extratags,
|
||||
admin_level=row.admin_level,
|
||||
fromarea=row.fromarea,
|
||||
@@ -235,7 +241,7 @@ def _placex_select_address_row(conn: SearchConnection,
|
||||
t = conn.t.placex
|
||||
return sa.select(t.c.place_id, t.c.osm_type, t.c.osm_id, t.c.name,
|
||||
t.c.class_.label('class'), t.c.type,
|
||||
t.c.admin_level,
|
||||
t.c.admin_level, t.c.housenumber,
|
||||
sa.literal_column("""ST_GeometryType(geometry) in
|
||||
('ST_Polygon','ST_MultiPolygon')""").label('fromarea'),
|
||||
t.c.rank_address,
|
||||
|
||||
Reference in New Issue
Block a user