Skip to main content

Open Street Map route screenshot

Project description

Описание

Библиотека для создания скриншотов маршрута в Open Street Map

pip install OsmRouteScreenLib

Написана на основе статьи: https://smyt.ru/blog/statc-osm-map-with-python/

Использование

import OsmRouteScreenLib.startup as st
import OsmRouteScreenLib.options as o

options = o.make_options('http://tile-server.domain.com/{zoom}/{x}/{y}.png',
               'https://route.domain.com/route/v1/driving/{startPoint};{endPoint}?overview=full&geometries=geojson')

st.get_route_screen_by_points((47.232565,56.141757), (47.220063,56.139836), options)

Доступны следующие опции:

  • url_tile: str - путь к тайловому серверу;
  • url_routing: str - путь к серверу для получения маршрута;
  • padding: float - отступ карты от краёв маршрута в процентах от 0 до 1;
  • zoom: int - zoom карты;
  • output: str - путь к выходному файлу;
  • line_width: int - ширина линии;
  • marker_text: str - метки;
  • show_geodesic: bool - отображать метку с пройденной дистанцией (км);
  • split_line: bool - цветовое разделение маршрута.

Получение расстояния между координатами

import OsmRouteScreenLib.startup as st
import OsmRouteScreenLib.options as o

options = o.make_options('http://tile-server.domain.com/{zoom}/{x}/{y}.png',
               'https://route.domain.com/route/v1/driving/{startPoint};{endPoint}?overview=full&geometries=geojson')

distance, duration = st.get_distance((47.212137, 56.140760), (47.229151, 56.141994), options=options)
print(distance)

По умолчанию дистанция будет получена для марштура с автотранспортом (driving), если требуется узнать расстояние (или время) пешком, то указать walking (https://osm.server.com/route/v1/walking).

Сборка Ubuntu 22.04

Устанавливаем дополнительные библиотека: sudo apt install libcairo2-dev pkg-config python3-dev

python3 -m venv routing-service
source routing-service/bin/activate
pip install -r requirements.txt

Публикация пакета

Устанавливаем библиотеки для публикации в pypi.org

pip install setuptools wheel twine

Выполняем в корне проекта

python setup.py sdist bdist_wheel
twine upload --repository pypi dist/*

Внимание: перед сборкой не забываем поменять версию в файле setup.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osmroutescreenlib-0.0.6-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file osmroutescreenlib-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for osmroutescreenlib-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d27eb42885587de078e17f3d70f983a3e16108a3e5220cc4cc6a62649926054
MD5 57cb9c576bba95271cfbc60123dc48f6
BLAKE2b-256 5a2600247d99cd2c8261ede756933785b4c022624114265d07807b5008c113dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page