- params = dict(lat=args.lat, lon=args.lon, format=args.format)
- if args.zoom is not None:
- params['zoom'] = args.zoom
+ if args.format == 'debug':
+ loglib.set_log_output('text')
+
+ api = napi.NominatimAPI(args.project_dir)
+
+ result = api.reverse(napi.Point(args.lon, args.lat),
+ max_rank=zoom_to_rank(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 args.format == 'debug':
+ print(loglib.get_and_disable())
+ return 0
+
+ if result:
+ result.localize(args.get_locales(api.config.DEFAULT_LANGUAGE))
+ output = api_output.format_result(
+ napi.ReverseResults([result]),
+ args.format,
+ {'extratags': args.extratags,
+ 'namedetails': args.namedetails,
+ 'addressdetails': args.addressdetails})
+ if args.format != 'xml':
+ # reformat the result, so it is pretty-printed
+ json.dump(json.loads(output), sys.stdout, indent=4, ensure_ascii=False)
+ else:
+ sys.stdout.write(output)
+ sys.stdout.write('\n')