diff --git a/readme.md b/readme.md
index 5106373..0365aa9 100644
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,4 @@
-**Röntgen** is a
+**Röntgen** is a
* simple Python [OpenStreetMap](http://openstreetmap.org) renderer,
* set of icons,
* and map styles.
@@ -6,13 +6,13 @@
[
](https://travis-ci.org/enzet/Roentgen)
-The idea behind Röntgen project is to have a possibility to *display every
-map feature* represented by OpenStreetMap data tags by means of colors, shapes,
-and icons.
+The idea behind Röntgen project is to have a possibility to *display any map
+feature* represented by OpenStreetMap data tags by means of colors, shapes, and
+icons.
-Röntgen is primarily created for OpenStreetMap contributors. Suppose, you spent
+Röntgen is primarily created for OpenStreetMap contributors. Suppose, you spent
time adding colors for building walls, benches and shelters for bus stops but
-they are not represented on the standard tile layer. Röntgen helps to display
+they are not represented on the standard tile layer. Röntgen helps to display
all changes you made.
Nevertheless, Röntgen map generator can generate precise but messy maps for OSM
@@ -43,16 +43,16 @@ Visualize `direction` tag for `tourism=viewpoint` and `camera:direction` for
Icon set
--------
-If tag is drawable it is displayed using icon combination and colors. All icons
-are under [CC BY 4.0](http://creativecommons.org/licenses/by/4.0/) license. So,
-do whatever you want but give appropriate credit. Icon set is heavily inspired
+If tag is drawable it is displayed using icon combination and colors. All icons
+are under [CC BY 4.0](http://creativecommons.org/licenses/by/4.0/) license. So,
+do whatever you want but give appropriate credit. Icon set is heavily inspired
by [Osmic](https://github.com/gmgeo/osmic) icon set.

Feel free to request new icons via issues for whatever you want to see on the
-map. No matter how frequently the tag is used in OpenStreetMap since final goal
-is to cover all tags. However, common used tags have priority, other things
+map. No matter how frequently the tag is used in OpenStreetMap since final goal
+is to cover all tags. However, common used tags have priority, other things
being equal.
Draw icon grid: `python3 run.py grid`.
@@ -104,51 +104,29 @@ You can run it using:
python3 run.py \
-b ${LONGITUDE_1},${LATITUDE_1},${LONGITUDE_2},${LATITUDE_2} \
-o ${OUTPUT_FILE_NAME} \
- -s ${WIDTH},${HEIGHT}
+ -s ${OSM_ZOOM_LEVEL}
```
Example:
```bash
-python3 run.py -b 2.284,48.86,2.29,48.865 -o map.svg -s 1000,1000
+python3 run.py -b 2.284,48.86,2.29,48.865
```
### Main arguments ###
#### Required ####
-
- Option | Value | Description |
-
- -b, --boundary-box |
-
- <longitude 1>,<latitude 1>,<longitude
- 2>,<latitude 2>
- |
- Boundary box to draw. |
-
-
- -s, --size |
- <width>,<height> |
- Result image size in pixels. |
-
-
- -o |
- <path> |
- Path to output SVG file name. |
-
-
+* `--boundary-box` or `-b`: boundary box to draw. Value:
+ `,,,`. Use space before
+ first `-` to escape negative values.
#### Optional ####
-
- Option | Value | Description |
-
- -i |
- <path> |
- Path to input XML file name. If this argument is not set, XML file
- will be downloaded through OpenStreetMap API. |
-
-
+* `--scale` or `-s`: OSM zoom level. See
+ [OSM wiki](https://wiki.openstreetmap.org/wiki/Zoom_levels). Default is 18.
+* `-o`: path to output SVG file name. Default is map.svg.
+* `-i`: path to input XML file name. If this argument is not set, XML file
+ will be downloaded through OpenStreetMap API.
Check all arguments with `python3 run.py --help`.
diff --git a/roentgen/flinger.py b/roentgen/flinger.py
index 7d98ed9..e0838a2 100644
--- a/roentgen/flinger.py
+++ b/roentgen/flinger.py
@@ -21,20 +21,31 @@ def pseudo_mercator(coordinates: np.array) -> np.array:
np.tan(np.pi / 4 + coordinates[0] * (np.pi / 180) / 2))))
+def osm_zoom_level_to_pixels_per_meter(zoom_level: float):
+ """
+ Convert OSM zoom level (see https://wiki.openstreetmap.org/wiki/Zoom_levels)
+ to pixels per meter on Equator.
+ """
+ return 2 ** zoom_level / 156415
+
+
class Flinger:
"""
Convert geo coordinates into SVG position points.
"""
- def __init__(self, geo_boundaries: MinMax, ratio: float = 1000):
+ def __init__(self, geo_boundaries: MinMax, scale: float = 1000):
"""
:param geo_boundaries: minimum and maximum latitude and longitude
+ :param scale: OSM zoom level
"""
self.geo_boundaries: MinMax = geo_boundaries
- self.ratio: float = ratio
+ self.ratio: float = (
+ osm_zoom_level_to_pixels_per_meter(scale) *
+ EQUATOR_LENGTH / 360)
self.size: np.array = self.ratio * (
pseudo_mercator(self.geo_boundaries.max_) -
pseudo_mercator(self.geo_boundaries.min_))
- self.pixels_per_meter = 360 / EQUATOR_LENGTH * self.ratio
+ self.pixels_per_meter = osm_zoom_level_to_pixels_per_meter(scale)
self.size: np.array = self.size.astype(int).astype(float)
diff --git a/roentgen/ui.py b/roentgen/ui.py
index d0717d6..a08eabe 100644
--- a/roentgen/ui.py
+++ b/roentgen/ui.py
@@ -38,7 +38,8 @@ def parse_options(args):
parser.add_argument(
"-s", "--scale",
metavar="",
- help="map scale",
+ help="OSM zoom level (may not be integer, default is 18)",
+ default=18,
dest="scale",
type=float,
required=True)