+def _get_geometry_output(args) -> napi.GeometryFormat:
+ """ Get the requested geometry output format in a API-compatible
+ format.
+ """
+ if not args.polygon_output:
+ return napi.GeometryFormat.NONE
+ if args.polygon_output == 'geojson':
+ return napi.GeometryFormat.GEOJSON
+ if args.polygon_output == 'kml':
+ return napi.GeometryFormat.KML
+ if args.polygon_output == 'svg':
+ return napi.GeometryFormat.SVG
+ if args.polygon_output == 'text':
+ return napi.GeometryFormat.TEXT
+
+ try:
+ return napi.GeometryFormat[args.polygon_output.upper()]
+ except KeyError as exp:
+ raise UsageError(f"Unknown polygon output format '{args.polygon_output}'.") from exp
+
+
+def _get_locales(args, default: Optional[str]) -> napi.Locales:
+ """ Get the locales from the language parameter.
+ """
+ if args.lang:
+ return napi.Locales.from_accept_languages(args.lang)
+ if default:
+ return napi.Locales.from_accept_languages(default)
+
+ return napi.Locales()
+
+
+def _get_layers(args, default: napi.DataLayer) -> Optional[napi.DataLayer]:
+ """ Get the list of selected layers as a DataLayer enum.
+ """
+ if not args.layers:
+ return default
+
+ return reduce(napi.DataLayer.__or__,
+ (napi.DataLayer[s.upper()] for s in args.layers))
+
+