X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/16b6484c650eef161e64153f748643ca61553753..46a10cf8146e16d9da7bb21e5976d9c62b69fdd1:/nominatim/api/core.py diff --git a/nominatim/api/core.py b/nominatim/api/core.py index 54f02a93..415cd0aa 100644 --- a/nominatim/api/core.py +++ b/nominatim/api/core.py @@ -18,8 +18,12 @@ import asyncpg from nominatim.db.sqlalchemy_schema import SearchTables from nominatim.config import Configuration -from nominatim.api.status import get_status, StatusResult from nominatim.api.connection import SearchConnection +from nominatim.api.status import get_status, StatusResult +from nominatim.api.lookup import get_place_by_id +from nominatim.api.types import PlaceRef, LookupDetails +from nominatim.api.results import SearchResult + class NominatimAPIAsync: """ API loader asynchornous version. @@ -122,6 +126,16 @@ class NominatimAPIAsync: return status + async def lookup(self, place: PlaceRef, + details: LookupDetails) -> Optional[SearchResult]: + """ Get detailed information about a place in the database. + + Returns None if there is no entry under the given ID. + """ + async with self.begin() as db: + return await get_place_by_id(db, place, details) + + class NominatimAPI: """ API loader, synchronous version. """ @@ -141,7 +155,20 @@ 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. """ return self._loop.run_until_complete(self._async_api.status()) + + + def lookup(self, place: PlaceRef, + details: LookupDetails) -> Optional[SearchResult]: + """ Get detailed information about a place in the database. + """ + return self._loop.run_until_complete(self._async_api.lookup(place, details))