Skip to content

Commit

Permalink
Update version to v1.4.0
Browse files Browse the repository at this point in the history
Adds support for GeoJSON ordering of coordinates
frederickjansen committed Jul 2, 2019
1 parent 747c518 commit 3ab5677
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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``.
9 changes: 7 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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
==================
9 changes: 5 additions & 4 deletions polyline/__init__.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3ab5677

Please sign in to comment.