From 3ab56774b4f76d46fc97643a42364d56527a049b Mon Sep 17 00:00:00 2001 From: Frederick Jansen Date: Tue, 2 Jul 2019 12:47:40 -0400 Subject: [PATCH] Update version to v1.4.0 Adds support for GeoJSON ordering of coordinates --- LICENSE | 2 +- Makefile | 7 +++++++ README.rst | 8 ++++---- docs/index.rst | 9 +++++++-- polyline/__init__.py | 9 +++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/LICENSE b/LICENSE index 810c7df..d6b6be2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2014 Bruno M. Custódio -Copyright (c) 2016 Frederick Jansen +Copyright (c) 2019 Frederick Jansen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 001afba..2f69209 100644 --- a/Makefile +++ b/Makefile @@ -13,3 +13,10 @@ unit-tests: reqs: setup-base-dependencies setup-test-dependencies test: pep8-tests unit-tests + +publish: + pip install 'twine>=1.5.0' + pip install wheel + python setup.py sdist bdist_wheel --universal + twine upload dist/* + rm -fr build dist .egg requests.egg-info diff --git a/README.rst b/README.rst index 9cdcaf9..17ba0c3 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ API Documentation Encoding -------- -To get the encoded polyline representation of a given set of coordinates:: +To get the encoded polyline representation of a given set of (lat, lon) coordinates:: import polyline polyline.encode([(38.5, -120.2), (40.7, -120.9), (43.2, -126.4)], 5) @@ -35,7 +35,7 @@ This should return ``_p~iF~ps|U_ulL~ugC_hgN~eq`@``. You can set the required precision with the optional ``precision`` parameter. The default value is 5. -You can encode lon-lat tuples by setting ``geojson=True``. +You can encode (lon, lat) tuples by setting ``geojson=True``. Decoding -------- @@ -45,6 +45,6 @@ To get a set of coordinates represented by a given encoded polyline string:: import polyline polyline.decode('u{~vFvyys@fS]') -This should return ``[(40.63179, -8.65708), (40.62855, -8.65693)]``. +This should return ``[(40.63179, -8.65708), (40.62855, -8.65693)]`` in (lat, lon) order. -You can decode into lon-lat tuples by setting ``geojson=True``. +You can decode into (lon, lat) tuples by setting ``geojson=True``. diff --git a/docs/index.rst b/docs/index.rst index c114ce2..f29d710 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,7 +20,7 @@ API Documentation Encoding -------- -To get the encoded polyline representation of a given set of coordinates:: +To get the encoded polyline representation of a given set of (lat, lon) coordinates:: import polyline polyline.encode([(38.5, -120.2), (40.7, -120.9), (43.2, -126.4)], 5) @@ -29,6 +29,8 @@ This should return ``_p~iF~ps|U_ulL~ugC_hgN~eq`@``. You can set the required precision with the optional ``precision`` parameter. The default value is 5. +You can encode (lon, lat) tuples by setting ``geojson=True``. + Decoding -------- @@ -37,7 +39,10 @@ To get a set of coordinates represented by a given encoded polyline string:: import polyline polyline.decode('u{~vFvyys@fS]') -This should return ``[(40.63179, -8.65708), (40.62855, -8.65693)]``. +This should return ``[(40.63179, -8.65708), (40.62855, -8.65693)]`` in (lat, lon) order. + +You can decode into (lon, lat) tuples by setting ``geojson=True``. + Indices and tables ================== diff --git a/polyline/__init__.py b/polyline/__init__.py index ab0b038..99bd7b6 100644 --- a/polyline/__init__.py +++ b/polyline/__init__.py @@ -1,6 +1,6 @@ from .codec import PolylineCodec -__version__ = '1.3.2' +__version__ = '1.4.0' def decode(expression, precision=5, geojson=False): @@ -11,7 +11,7 @@ def decode(expression, precision=5, geojson=False): :param precision: Precision of the encoded coordinates. Google Maps uses 5, OpenStreetMap uses 6. The default value is 5. :param geojson: Set output of tuples to (lon, lat), as per https://tools.ietf.org/html/rfc7946#section-3.1.1 - :return: List of coordinate tuples + :return: List of coordinate tuples in (lat, lon) order, unless geojson is set to True. """ return PolylineCodec().decode(expression, precision, geojson) @@ -20,10 +20,11 @@ def encode(coordinates, precision=5, geojson=False): """ Encode a set of coordinates in a polyline string. - :param coordinates: List of coordinate tuples, e.g. [(0, 0), (1, 0)]. + :param coordinates: List of coordinate tuples, e.g. [(0, 0), (1, 0)]. Unless geojson is set to True, the order + is expected to be (lat, lon). :param precision: Precision of the coordinates to encode. Google Maps uses 5, OpenStreetMap uses 6. The default value is 5. - :param geojson: Set to True in order to encode lon-lat tuples. + :param geojson: Set to True in order to encode (lon, lat) tuples. :return: The encoded polyline string. """ return PolylineCodec().encode(coordinates, precision, geojson)