From 7ce9a495d90140bdf0d3fcaef0f09a24ba2e85d6 Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Wed, 9 Feb 2022 09:16:17 +0300 Subject: [PATCH] Issue #109: improve negative value warnings. Add alternative approach and examples. --- README.md | 8 ++++---- map_machine/ui/cli.py | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 55198b6..238a331 100644 --- a/README.md +++ b/README.md @@ -173,10 +173,10 @@ will download OSM data to `cache/2.284,48.860,2.290,48.865.osm` and write an out |---|---| | `-i`, `--input` `` | input XML file name or names (if not specified, file will be downloaded using OpenStreetMap API) | | `-o`, `--output` `` | output SVG file name, default value: `out/map.svg` | -| `-b`, `--boundary-box` `,,,` | geo boundary box; if the first value is negative, enclose the value with quotes and use space before `-` | +| `-b`, `--boundary-box` `,,,` | geo boundary box; if the first value is negative, use `=` sign or enclose the value with quotes and use space before `-`, e.g. `-b=-84.752,39.504,-84.749,39.508` or `-b " -84.752,39.504,-84.749,39.508"` | | `--cache` `` | path for temporary OSM files, default value: `cache` | | `-z`, `--zoom` `` | OSM zoom level, default value: 18.0 | -| `-c`, `--coordinates` `,` | coordinates of any location inside the tile | +| `-c`, `--coordinates` `,` | coordinates of any location inside the tile; if the first value is negative, use `=` sign or enclose the value with quotes and use space before `-`, e.g. `-c=-84.752,39.504` or `-c " -84.752,39.504"` | | `-s`, `--size` `,` | resulted image size | plus [map configuration options](#map-options) @@ -188,10 +188,10 @@ Command `tile` is used to generate PNG tiles for [slippy maps](https://wiki.open | Option | Description | |---|---| -| `-c`, `--coordinates` `,` | coordinates of any location inside the tile | +| `-c`, `--coordinates` `,` | coordinates of any location inside the tile; if the first value is negative, use `=` sign or enclose the value with quotes and use space before `-`, e.g. `-c=-84.752,39.504` or `-c " -84.752,39.504"` | | `-t`, `--tile` `//` | tile specification | | `--cache` `` | path for temporary OSM files, default value: `cache` | -| `-b`, `--boundary-box` `,,,` | construct the minimum amount of tiles that cover the requested boundary box | +| `-b`, `--boundary-box` `,,,` | construct the minimum amount of tiles that cover the requested boundary box; if the first value is negative, use `=` sign or enclose the value with quotes and use space before `-`, e.g. `-b=-84.752,39.504,-84.749,39.508` or `-b " -84.752,39.504,-84.749,39.508"` | | `-z`, `--zoom` `` | OSM zoom levels; can be list of numbers or ranges, e.g. `16-18`, `16,17,18`, or `16,18-20`, default value: `18` | | `-i`, `--input` `` | input OSM XML file name (if not specified, the file will be downloaded using OpenStreetMap API) | diff --git a/map_machine/ui/cli.py b/map_machine/ui/cli.py index f7fdfcd..d47682c 100644 --- a/map_machine/ui/cli.py +++ b/map_machine/ui/cli.py @@ -37,6 +37,17 @@ COMMANDS: list[str] = [ "taginfo", ] +BOUNDARY_BOX_WARNING: str = ( + "if the first value is negative, use `=` sign or enclose the value with " + "quotes and use space before `-`, e.g. `-b=-84.752,39.504,-84.749,39.508` " + 'or `-b " -84.752,39.504,-84.749,39.508"`' +) +COORDINATES_WARNING: str = ( + "if the first value is negative, use `=` sign or enclose the value with " + "quotes and use space before `-`, e.g. `-c=-84.752,39.504` or `-c " + '" -84.752,39.504"`' +) + def parse_arguments(args: list[str]) -> argparse.Namespace: """Parse Map Machine command-line arguments.""" @@ -191,7 +202,8 @@ def add_tile_arguments(parser: argparse.ArgumentParser) -> None: "-c", "--coordinates", metavar=",", - help="coordinates of any location inside the tile", + help="coordinates of any location inside the tile; " + + COORDINATES_WARNING, ) parser.add_argument( "-t", @@ -209,7 +221,7 @@ def add_tile_arguments(parser: argparse.ArgumentParser) -> None: "-b", "--boundary-box", help="construct the minimum amount of tiles that cover the requested " - "boundary box", + "boundary box; " + BOUNDARY_BOX_WARNING, metavar=",,,", ) parser.add_argument( @@ -278,8 +290,7 @@ def add_render_arguments(parser: argparse.ArgumentParser) -> None: "-b", "--boundary-box", metavar=",,,", - help="geo boundary box; if the first value is negative, enclose the " - "value with quotes and use space before `-`", + help="geo boundary box; " + BOUNDARY_BOX_WARNING, ) parser.add_argument( "--cache", @@ -299,7 +310,8 @@ def add_render_arguments(parser: argparse.ArgumentParser) -> None: "-c", "--coordinates", metavar=",", - help="coordinates of any location inside the tile", + help="coordinates of any location inside the tile; " + + COORDINATES_WARNING, ) parser.add_argument( "-s",