mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 01:47:57 +00:00
Adds layer filtering option to search command
Introduces a cli argument to restrict search results to specified data layers, enabling more targeted queries.
This commit is contained in:
@@ -173,6 +173,10 @@ class APISearch:
|
||||
help='Preferred area to find search results')
|
||||
group.add_argument('--bounded', action='store_true',
|
||||
help='Strictly restrict results to viewbox area')
|
||||
group.add_argument('--layer', metavar='LAYER',
|
||||
choices=[n.name.lower() for n in napi.DataLayer if n.name],
|
||||
action='append', required=False, dest='layers',
|
||||
help='Restrict results to one or more layers (may be repeated)')
|
||||
group.add_argument('--no-dedupe', action='store_false', dest='dedupe',
|
||||
help='Do not remove duplicates from the result list')
|
||||
_add_list_format(parser)
|
||||
@@ -189,6 +193,8 @@ class APISearch:
|
||||
raise UsageError(f"Unsupported format '{args.format}'. "
|
||||
'Use --list-formats to see supported formats.')
|
||||
|
||||
layers = _get_layers(args, napi.DataLayer.ADDRESS | napi.DataLayer.POI)
|
||||
|
||||
try:
|
||||
with napi.NominatimAPI(args.project_dir) as api:
|
||||
params: Dict[str, Any] = {'max_results': args.limit + min(args.limit, 10),
|
||||
@@ -199,6 +205,7 @@ class APISearch:
|
||||
'excluded': args.exclude_place_ids,
|
||||
'viewbox': args.viewbox,
|
||||
'bounded_viewbox': args.bounded,
|
||||
'layers': layers,
|
||||
'entrances': args.entrances,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user