From ff36c699ed1ad1ed48d39c38165cadacee49bc5a Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 29 May 2023 12:43:32 +0000 Subject: automatic import of python-py-staticmaps --- .gitignore | 1 + python-py-staticmaps.spec | 735 ++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 737 insertions(+) create mode 100644 python-py-staticmaps.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..1892020 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/py-staticmaps-0.4.0.tar.gz diff --git a/python-py-staticmaps.spec b/python-py-staticmaps.spec new file mode 100644 index 0000000..f6679ff --- /dev/null +++ b/python-py-staticmaps.spec @@ -0,0 +1,735 @@ +%global _empty_manifest_terminate_build 0 +Name: python-py-staticmaps +Version: 0.4.0 +Release: 1 +Summary: Create static map images (SVG, PNG) with markers, geodesic lines, ... +License: MIT License +URL: https://github.com/flopp/py-staticmaps +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz +BuildArch: noarch + + +%description +# py-staticmaps +A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. + + +## Features + +- Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles +- Automatic computation of best center + zoom from the added map objects +- Several pre-configured map tile providers +- Proper tile provider attributions display +- On-disc caching of map tile images for faster drawing and reduced load on the tile servers +- Non-anti-aliased drawing via `PILLOW` +- Anti-aliased drawing via `pycairo` (optional; only if `pycairo` is installed properly) +- SVG creation via `svgwrite` + + +## Installation + +### SVG + non-anti-aliased PNG version + +```shell +pip install py-staticmaps +``` + +### SVG + anti-aliased PNG version (via Cairo) + +```shell +pip install py-staticmaps[cairo] +``` + +`py-staticmaps` uses `pycairo` for creating anti-aliased raster-graphics, so make sure `libcairo2` is installed on your system (on Ubuntu just install the `libcairo2-dev` package, i.e. `sudo apt install libcairo2-dev`). + + +## Examples + +Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. + +### Markers and Geodesic Lines + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +frankfurt = staticmaps.create_latlng(50.110644, 8.682092) +newyork = staticmaps.create_latlng(40.712728, -74.006015) + +context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) +context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) +context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("frankfurt_newyork.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("frankfurt_newyork.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Transparent Polygons + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +freiburg_polygon = [ + (47.96881, 7.79045), + (47.96866, 7.78610), + (47.97134, 7.77874), + ... +] + +context.add_object( + staticmaps.Area( + [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], + fill_color=staticmaps.parse_color("#00FF003F"), + width=2, + color=staticmaps.BLUE, + ) +) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("freiburg_area.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("freiburg_area.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("freiburg_area.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Drawing a GPX Track + Image Marker (PNG) + +```python +import sys + +import gpxpy +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) + +with open(sys.argv[1], "r") as file: + gpx = gpxpy.parse(file) + +for track in gpx.tracks: + for segment in track.segments: + line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] + context.add_object(staticmaps.Line(line)) + +for p in gpx.walk(only_points=True): + pos = staticmaps.create_latlng(p.latitude, p.longitude) + marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) + context.add_object(marker) + break + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("draw_gpx.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("draw_gpx.cairo.png") +``` + + + +### US State Capitals + +```python +import json +import requests +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +URL = ( + "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" + "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" +) +response = requests.get(URL) +for _, data in json.loads(response.text).items(): + capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) + context.add_object(staticmaps.Marker(capital, size=5)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("us_capitals.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("us_capitals.cairo.png") +``` + + + +### Geodesic Circles + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +center1 = staticmaps.create_latlng(66, 0) +center2 = staticmaps.create_latlng(0, 0) + +context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) +context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) +context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) +context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("geodesic_circles.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 600) +image.write_to_png("geodesic_circles.cairo.png") +``` + + + +### Other Examples + +Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` + + +### Dependencies + +`py-staticmaps` uses + +- `PILLOW` for rendering raster-graphics +- `pycairo` for rendering antialiased raster-graphics (optional!) +- `svgwrite` for writing SVG files +- `s2sphere` for geo coordinates handling +- `geographiclib` for geodesic computations +- `appdirs` for finding the user's default cache directory +- `requests` for downloading tile files + + +## License + +[MIT](LICENSE) © 2020-2021 Florian Pigorsch + +%package -n python3-py-staticmaps +Summary: Create static map images (SVG, PNG) with markers, geodesic lines, ... +Provides: python-py-staticmaps +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-py-staticmaps +# py-staticmaps +A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. + + +## Features + +- Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles +- Automatic computation of best center + zoom from the added map objects +- Several pre-configured map tile providers +- Proper tile provider attributions display +- On-disc caching of map tile images for faster drawing and reduced load on the tile servers +- Non-anti-aliased drawing via `PILLOW` +- Anti-aliased drawing via `pycairo` (optional; only if `pycairo` is installed properly) +- SVG creation via `svgwrite` + + +## Installation + +### SVG + non-anti-aliased PNG version + +```shell +pip install py-staticmaps +``` + +### SVG + anti-aliased PNG version (via Cairo) + +```shell +pip install py-staticmaps[cairo] +``` + +`py-staticmaps` uses `pycairo` for creating anti-aliased raster-graphics, so make sure `libcairo2` is installed on your system (on Ubuntu just install the `libcairo2-dev` package, i.e. `sudo apt install libcairo2-dev`). + + +## Examples + +Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. + +### Markers and Geodesic Lines + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +frankfurt = staticmaps.create_latlng(50.110644, 8.682092) +newyork = staticmaps.create_latlng(40.712728, -74.006015) + +context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) +context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) +context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("frankfurt_newyork.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("frankfurt_newyork.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Transparent Polygons + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +freiburg_polygon = [ + (47.96881, 7.79045), + (47.96866, 7.78610), + (47.97134, 7.77874), + ... +] + +context.add_object( + staticmaps.Area( + [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], + fill_color=staticmaps.parse_color("#00FF003F"), + width=2, + color=staticmaps.BLUE, + ) +) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("freiburg_area.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("freiburg_area.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("freiburg_area.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Drawing a GPX Track + Image Marker (PNG) + +```python +import sys + +import gpxpy +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) + +with open(sys.argv[1], "r") as file: + gpx = gpxpy.parse(file) + +for track in gpx.tracks: + for segment in track.segments: + line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] + context.add_object(staticmaps.Line(line)) + +for p in gpx.walk(only_points=True): + pos = staticmaps.create_latlng(p.latitude, p.longitude) + marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) + context.add_object(marker) + break + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("draw_gpx.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("draw_gpx.cairo.png") +``` + + + +### US State Capitals + +```python +import json +import requests +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +URL = ( + "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" + "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" +) +response = requests.get(URL) +for _, data in json.loads(response.text).items(): + capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) + context.add_object(staticmaps.Marker(capital, size=5)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("us_capitals.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("us_capitals.cairo.png") +``` + + + +### Geodesic Circles + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +center1 = staticmaps.create_latlng(66, 0) +center2 = staticmaps.create_latlng(0, 0) + +context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) +context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) +context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) +context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("geodesic_circles.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 600) +image.write_to_png("geodesic_circles.cairo.png") +``` + + + +### Other Examples + +Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` + + +### Dependencies + +`py-staticmaps` uses + +- `PILLOW` for rendering raster-graphics +- `pycairo` for rendering antialiased raster-graphics (optional!) +- `svgwrite` for writing SVG files +- `s2sphere` for geo coordinates handling +- `geographiclib` for geodesic computations +- `appdirs` for finding the user's default cache directory +- `requests` for downloading tile files + + +## License + +[MIT](LICENSE) © 2020-2021 Florian Pigorsch + +%package help +Summary: Development documents and examples for py-staticmaps +Provides: python3-py-staticmaps-doc +%description help +# py-staticmaps +A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. + + +## Features + +- Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles +- Automatic computation of best center + zoom from the added map objects +- Several pre-configured map tile providers +- Proper tile provider attributions display +- On-disc caching of map tile images for faster drawing and reduced load on the tile servers +- Non-anti-aliased drawing via `PILLOW` +- Anti-aliased drawing via `pycairo` (optional; only if `pycairo` is installed properly) +- SVG creation via `svgwrite` + + +## Installation + +### SVG + non-anti-aliased PNG version + +```shell +pip install py-staticmaps +``` + +### SVG + anti-aliased PNG version (via Cairo) + +```shell +pip install py-staticmaps[cairo] +``` + +`py-staticmaps` uses `pycairo` for creating anti-aliased raster-graphics, so make sure `libcairo2` is installed on your system (on Ubuntu just install the `libcairo2-dev` package, i.e. `sudo apt install libcairo2-dev`). + + +## Examples + +Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. + +### Markers and Geodesic Lines + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +frankfurt = staticmaps.create_latlng(50.110644, 8.682092) +newyork = staticmaps.create_latlng(40.712728, -74.006015) + +context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) +context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) +context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("frankfurt_newyork.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("frankfurt_newyork.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Transparent Polygons + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +freiburg_polygon = [ + (47.96881, 7.79045), + (47.96866, 7.78610), + (47.97134, 7.77874), + ... +] + +context.add_object( + staticmaps.Area( + [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], + fill_color=staticmaps.parse_color("#00FF003F"), + width=2, + color=staticmaps.BLUE, + ) +) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("freiburg_area.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("freiburg_area.cairo.png") + +# render svg +svg_image = context.render_svg(800, 500) +with open("freiburg_area.svg", "w", encoding="utf-8") as f: + svg_image.write(f, pretty=True) +``` + + + +### Drawing a GPX Track + Image Marker (PNG) + +```python +import sys + +import gpxpy +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) + +with open(sys.argv[1], "r") as file: + gpx = gpxpy.parse(file) + +for track in gpx.tracks: + for segment in track.segments: + line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] + context.add_object(staticmaps.Line(line)) + +for p in gpx.walk(only_points=True): + pos = staticmaps.create_latlng(p.latitude, p.longitude) + marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) + context.add_object(marker) + break + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("draw_gpx.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("draw_gpx.cairo.png") +``` + + + +### US State Capitals + +```python +import json +import requests +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_OSM) + +URL = ( + "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" + "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" +) +response = requests.get(URL) +for _, data in json.loads(response.text).items(): + capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) + context.add_object(staticmaps.Marker(capital, size=5)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("us_capitals.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 500) +image.write_to_png("us_capitals.cairo.png") +``` + + + +### Geodesic Circles + +```python +import staticmaps + +context = staticmaps.Context() +context.set_tile_provider(staticmaps.tile_provider_StamenToner) + +center1 = staticmaps.create_latlng(66, 0) +center2 = staticmaps.create_latlng(0, 0) + +context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) +context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) +context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) +context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) + +# render non-anti-aliased png +image = context.render_pillow(800, 500) +image.save("geodesic_circles.pillow.png") + +# render anti-aliased png (this only works if pycairo is installed) +image = context.render_cairo(800, 600) +image.write_to_png("geodesic_circles.cairo.png") +``` + + + +### Other Examples + +Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` + + +### Dependencies + +`py-staticmaps` uses + +- `PILLOW` for rendering raster-graphics +- `pycairo` for rendering antialiased raster-graphics (optional!) +- `svgwrite` for writing SVG files +- `s2sphere` for geo coordinates handling +- `geographiclib` for geodesic computations +- `appdirs` for finding the user's default cache directory +- `requests` for downloading tile files + + +## License + +[MIT](LICENSE) © 2020-2021 Florian Pigorsch + +%prep +%autosetup -n py-staticmaps-0.4.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-py-staticmaps -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot - 0.4.0-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..c643993 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +377fcf4aef6bbb33567258bec4406791 py-staticmaps-0.4.0.tar.gz -- cgit v1.2.3