From 4f97aeef7303d1ca78e734e9e6df44bc15bdad74 Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Wed, 26 Sep 2018 16:50:26 -0600 Subject: [PATCH] Fix encoding of coordinates and map ids (#261) Resolves #259 --- CHANGES | 7 ++++++ mapbox/__init__.py | 2 +- mapbox/services/tilequery.py | 4 +-- tests/test_tilequery.py | 48 ++++++++++++++++++------------------ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/CHANGES b/CHANGES index 6133da9..537d555 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,13 @@ Changes ======= +0.17.1 (2018-09-26) +------------------- + +Bug fixes: + +- Fix for the encoding of Tilequery coordinates (#259). + 0.17.0 (TBD) ------------ diff --git a/mapbox/__init__.py b/mapbox/__init__.py index ddd59cd..7e974c4 100644 --- a/mapbox/__init__.py +++ b/mapbox/__init__.py @@ -1,5 +1,5 @@ # mapbox -__version__ = "0.17.0" +__version__ = "0.17.1" from .services.datasets import Datasets from .services.directions import Directions diff --git a/mapbox/services/tilequery.py b/mapbox/services/tilequery.py index b0380de..8d3a6c9 100644 --- a/mapbox/services/tilequery.py +++ b/mapbox/services/tilequery.py @@ -163,12 +163,12 @@ def tilequery( # Create dict to assist in building URI resource path. path_values = dict( - map_id=map_id, api_name=self.api_name, coordinates="{},{}".format(lon, lat) + api_name=self.api_name, lon=lon, lat=lat ) # Build URI resource path. - path_part = "/{map_id}/{api_name}/{coordinates}.json" + path_part = "/" + map_id + "/{api_name}/{lon},{lat}.json" uri = URITemplate(self.base_uri + path_part).expand(**path_values) # Build URI query_parameters. diff --git a/tests/test_tilequery.py b/tests/test_tilequery.py index e6074e0..9c53da8 100644 --- a/tests/test_tilequery.py +++ b/tests/test_tilequery.py @@ -97,7 +97,7 @@ def test_tilequery_one_mapid(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test", match_querystring=True, body='{"key": "value"}', @@ -117,9 +117,9 @@ def test_tilequery_two_mapids(): method=GET, url="https://api.mapbox.com" + "/v4" - + "/mapbox.mapbox-streets-v9%2Cmapbox.mapbox-streets-v10" + + "/mapbox.mapbox-streets-v9,mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test", match_querystring=True, body='{"key": "value"}', @@ -143,7 +143,7 @@ def test_tilequery_with_radius(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25", match_querystring=True, @@ -168,7 +168,7 @@ def test_tilequery_with_limit(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&limit=25", match_querystring=True, @@ -193,7 +193,7 @@ def test_tilequery_with_dedupe(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&dedupe=true", match_querystring=True, @@ -218,7 +218,7 @@ def test_tilequery_with_geometry(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&geometry=linestring", match_querystring=True, @@ -243,9 +243,9 @@ def test_tilequery_with_layers(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" - + "&layers=layer0%2Clayer1%2Clayer2", + + "&layers=layer0,layer1%2Clayer2", match_querystring=True, body='{"key": "value"}', status=200, @@ -271,7 +271,7 @@ def test_tilequery_with_radius_and_limit(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25", @@ -297,7 +297,7 @@ def test_tilequery_with_radius_and_dedupe(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&dedupe=true", @@ -323,7 +323,7 @@ def test_tilequery_with_radius_and_geometry(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&geometry=linestring", @@ -349,10 +349,10 @@ def test_tilequery_with_radius_and_layers(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" - + "&layers=layer0%2Clayer1%2Clayer2", + + "&layers=layer0,layer1%2Clayer2", match_querystring=True, body='{"key": "value"}', status=200, @@ -379,7 +379,7 @@ def test_tilequery_with_radius_limit_and_dedupe(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" @@ -406,7 +406,7 @@ def test_tilequery_with_radius_limit_and_geometry(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" @@ -438,11 +438,11 @@ def test_tilequery_with_radius_limit_and_layers(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" - + "&layers=layer0%2Clayer1%2Clayer2", + + "&layers=layer0,layer1%2Clayer2", match_querystring=True, body='{"key": "value"}', status=200, @@ -470,7 +470,7 @@ def test_tilequery_with_radius_limit_dedupe_and_geometry(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" @@ -504,12 +504,12 @@ def test_tilequery_with_radius_limit_dedupe_and_layers(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" + "&dedupe=true" - + "&layers=layer0%2Clayer1%2Clayer2", + + "&layers=layer0,layer1%2Clayer2", match_querystring=True, body='{"key": "value"}', status=200, @@ -538,13 +538,13 @@ def test_tilequery_with_radius_limit_dedupe_geometry_and_layers(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test" + "&radius=25" + "&limit=25" + "&dedupe=true" + "&geometry=linestring" - + "&layers=layer0%2Clayer1%2Clayer2", + + "&layers=layer0,layer1%2Clayer2", match_querystring=True, body='{"key": "value"}', status=200, @@ -574,7 +574,7 @@ def test_tilequery_geojson_method(): + "/v4" + "/mapbox.mapbox-streets-v10" + "/tilequery" - + "/0.0%2C1.1.json" + + "/0.0,1.1.json" + "?access_token=pk.test", match_querystring=True, body='{"key": "value"}',