mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
switch API parameters to keyword arguments
This switches the input parameters for API calls to a generic keyword argument catch-all which is then loaded into a dataclass where the parameters are checked and forwarded to internal function. The dataclass gives more flexibility with the parameters and makes it easier to reuse common parameters for the different API calls.
This commit is contained in:
@@ -163,14 +163,12 @@ class APIReverse:
|
||||
def run(self, args: NominatimArgs) -> int:
|
||||
api = napi.NominatimAPI(args.project_dir)
|
||||
|
||||
details = napi.LookupDetails(address_details=True, # needed for display name
|
||||
geometry_output=args.get_geometry_output(),
|
||||
geometry_simplification=args.polygon_threshold or 0.0)
|
||||
|
||||
result = api.reverse(napi.Point(args.lon, args.lat),
|
||||
REVERSE_MAX_RANKS[max(0, min(18, args.zoom or 18))],
|
||||
args.get_layers(napi.DataLayer.ADDRESS | napi.DataLayer.POI),
|
||||
details)
|
||||
max_rank=REVERSE_MAX_RANKS[max(0, min(18, args.zoom or 18))],
|
||||
layers=args.get_layers(napi.DataLayer.ADDRESS | napi.DataLayer.POI),
|
||||
address_details=True, # needed for display name
|
||||
geometry_output=args.get_geometry_output(),
|
||||
geometry_simplification=args.polygon_threshold)
|
||||
|
||||
if result:
|
||||
output = api_output.format_result(
|
||||
@@ -216,13 +214,12 @@ class APILookup:
|
||||
def run(self, args: NominatimArgs) -> int:
|
||||
api = napi.NominatimAPI(args.project_dir)
|
||||
|
||||
details = napi.LookupDetails(address_details=True, # needed for display name
|
||||
geometry_output=args.get_geometry_output(),
|
||||
geometry_simplification=args.polygon_threshold or 0.0)
|
||||
|
||||
places = [napi.OsmID(o[0], int(o[1:])) for o in args.ids]
|
||||
|
||||
results = api.lookup(places, details)
|
||||
results = api.lookup(places,
|
||||
address_details=True, # needed for display name
|
||||
geometry_output=args.get_geometry_output(),
|
||||
geometry_simplification=args.polygon_threshold or 0.0)
|
||||
|
||||
output = api_output.format_result(
|
||||
results,
|
||||
@@ -297,14 +294,15 @@ class APIDetails:
|
||||
|
||||
api = napi.NominatimAPI(args.project_dir)
|
||||
|
||||
details = napi.LookupDetails(address_details=args.addressdetails,
|
||||
linked_places=args.linkedplaces,
|
||||
parented_places=args.hierarchy,
|
||||
keywords=args.keywords)
|
||||
if args.polygon_geojson:
|
||||
details.geometry_output = napi.GeometryFormat.GEOJSON
|
||||
result = api.details(place,
|
||||
address_details=args.addressdetails,
|
||||
linked_places=args.linkedplaces,
|
||||
parented_places=args.hierarchy,
|
||||
keywords=args.keywords,
|
||||
geometry_output=napi.GeometryFormat.GEOJSON
|
||||
if args.polygon_geojson
|
||||
else napi.GeometryFormat.NONE)
|
||||
|
||||
result = api.details(place, details)
|
||||
|
||||
if result:
|
||||
output = api_output.format_result(
|
||||
|
||||
Reference in New Issue
Block a user