polyline 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyline
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: A Python implementation of Google's Encoded Polyline Algorithm Format.
5
5
  Author: Frederick Jansen, Bruno M. Custódio
6
6
  License: Copyright (c) 2023 Frederick Jansen
@@ -28,9 +28,17 @@ Project-URL: homepage, https://github.com/frederickjansen/polyline
28
28
  Project-URL: repository, https://github.com/frederickjansen/polyline
29
29
  Requires-Python: >=3.7
30
30
  Description-Content-Type: text/x-rst
31
+ License-File: LICENSE
31
32
  Provides-Extra: dev
33
+ Requires-Dist: pytest~=7.0; extra == "dev"
34
+ Requires-Dist: pytest-cov~=4.0; extra == "dev"
35
+ Requires-Dist: pylint~=3.0.3; extra == "dev"
36
+ Requires-Dist: sphinx~=5.3.0; extra == "dev"
37
+ Requires-Dist: sphinx-rtd-theme~=1.2.0; extra == "dev"
38
+ Requires-Dist: toml~=0.10.2; extra == "dev"
32
39
  Provides-Extra: publish
33
- License-File: LICENSE
40
+ Requires-Dist: build~=0.8; extra == "publish"
41
+ Requires-Dist: twine~=4.0; extra == "publish"
34
42
 
35
43
  polyline
36
44
  ========
@@ -1,9 +1,7 @@
1
1
  [project]
2
2
  name = "polyline"
3
- version = "2.0.0"
4
- description = """
5
- A Python implementation of Google's Encoded Polyline Algorithm Format.
6
- """
3
+ version = "2.0.2"
4
+ description = "A Python implementation of Google's Encoded Polyline Algorithm Format."
7
5
  license = {file = "LICENSE"}
8
6
  authors = [
9
7
  {name = "Frederick Jansen"},
@@ -23,9 +21,9 @@ repository = "https://github.com/frederickjansen/polyline"
23
21
  dev = [
24
22
  "pytest~=7.0",
25
23
  "pytest-cov~=4.0",
26
- "pylint~=2.15.10",
27
- "sphinx~=4.2.0",
28
- "sphinx-rtd-theme~=1.0.0",
24
+ "pylint~=3.0.3",
25
+ "sphinx~=5.3.0",
26
+ "sphinx-rtd-theme~=1.2.0",
29
27
  "toml~=0.10.2",
30
28
  ]
31
29
  publish = [
@@ -35,9 +33,7 @@ publish = [
35
33
 
36
34
  [build-system]
37
35
  requires = [
38
- "build~=0.8",
39
- "setuptools~=65.0",
40
- "wheel~=0.37"
36
+ "setuptools>=65.0"
41
37
  ]
42
38
  build-backend = "setuptools.build_meta"
43
39
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyline
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: A Python implementation of Google's Encoded Polyline Algorithm Format.
5
5
  Author: Frederick Jansen, Bruno M. Custódio
6
6
  License: Copyright (c) 2023 Frederick Jansen
@@ -28,9 +28,17 @@ Project-URL: homepage, https://github.com/frederickjansen/polyline
28
28
  Project-URL: repository, https://github.com/frederickjansen/polyline
29
29
  Requires-Python: >=3.7
30
30
  Description-Content-Type: text/x-rst
31
+ License-File: LICENSE
31
32
  Provides-Extra: dev
33
+ Requires-Dist: pytest~=7.0; extra == "dev"
34
+ Requires-Dist: pytest-cov~=4.0; extra == "dev"
35
+ Requires-Dist: pylint~=3.0.3; extra == "dev"
36
+ Requires-Dist: sphinx~=5.3.0; extra == "dev"
37
+ Requires-Dist: sphinx-rtd-theme~=1.2.0; extra == "dev"
38
+ Requires-Dist: toml~=0.10.2; extra == "dev"
32
39
  Provides-Extra: publish
33
- License-File: LICENSE
40
+ Requires-Dist: build~=0.8; extra == "publish"
41
+ Requires-Dist: twine~=4.0; extra == "publish"
34
42
 
35
43
  polyline
36
44
  ========
@@ -7,4 +7,5 @@ src/polyline.egg-info/PKG-INFO
7
7
  src/polyline.egg-info/SOURCES.txt
8
8
  src/polyline.egg-info/dependency_links.txt
9
9
  src/polyline.egg-info/requires.txt
10
- src/polyline.egg-info/top_level.txt
10
+ src/polyline.egg-info/top_level.txt
11
+ tests/test_polyline.py
@@ -2,9 +2,9 @@
2
2
  [dev]
3
3
  pytest~=7.0
4
4
  pytest-cov~=4.0
5
- pylint~=2.15.10
6
- sphinx~=4.2.0
7
- sphinx-rtd-theme~=1.0.0
5
+ pylint~=3.0.3
6
+ sphinx~=5.3.0
7
+ sphinx-rtd-theme~=1.2.0
8
8
  toml~=0.10.2
9
9
 
10
10
  [publish]
@@ -0,0 +1,222 @@
1
+ from random import uniform, randint
2
+ import time
3
+
4
+ import polyline
5
+
6
+
7
+ def test_decode_multiple_points():
8
+ d = polyline.decode('gu`wFnfys@???nKgE??gE?????oK????fE??fE')
9
+ assert d == [
10
+ (40.641, -8.654),
11
+ (40.641, -8.654),
12
+ (40.641, -8.656),
13
+ (40.642, -8.656),
14
+ (40.642, -8.655),
15
+ (40.642, -8.655),
16
+ (40.642, -8.655),
17
+ (40.642, -8.653),
18
+ (40.642, -8.653),
19
+ (40.642, -8.653),
20
+ (40.641, -8.653),
21
+ (40.641, -8.654)
22
+ ]
23
+
24
+
25
+ def test_decode_multiple_points_precision():
26
+ d = polyline.decode('_epolA~ieoOnF??~{Bo}@??o}@?????_|B????n}@??n}@', 6)
27
+ assert d == [
28
+ (40.64112, -8.654),
29
+ (40.641, -8.654),
30
+ (40.641, -8.656),
31
+ (40.642, -8.656),
32
+ (40.642, -8.655),
33
+ (40.642, -8.655),
34
+ (40.642, -8.655),
35
+ (40.642, -8.653),
36
+ (40.642, -8.653),
37
+ (40.642, -8.653),
38
+ (40.641, -8.653),
39
+ (40.641, -8.654)
40
+ ]
41
+
42
+
43
+ def test_decode_official_example():
44
+ d = polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@')
45
+ assert d == [
46
+ (38.500, -120.200),
47
+ (40.700, -120.950),
48
+ (43.252, -126.453)
49
+ ]
50
+
51
+
52
+ def test_decode_geojson():
53
+ d = polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@', geojson=True)
54
+ assert d == [
55
+ (-120.200, 38.500),
56
+ (-120.950, 40.700),
57
+ (-126.453, 43.252)
58
+ ]
59
+
60
+
61
+ def test_decode_official_example_precision():
62
+ d = polyline.decode('_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI', 6)
63
+ assert d == [
64
+ (38.500, -120.200),
65
+ (40.700, -120.950),
66
+ (43.252, -126.453)
67
+ ]
68
+
69
+
70
+ def test_decode_single_point():
71
+ d = polyline.decode('gu`wFf`ys@')
72
+ assert d == [
73
+ (40.641, -8.653)
74
+ ]
75
+
76
+
77
+ def test_decode_single_point_precision():
78
+ d = polyline.decode('o}oolAnkcoO', 6)
79
+ assert d == [
80
+ (40.641, -8.653)
81
+ ]
82
+
83
+
84
+ def test_encode_multiple_points():
85
+ e = polyline.encode([
86
+ (40.641, -8.654),
87
+ (40.641, -8.654),
88
+ (40.641, -8.656),
89
+ (40.642, -8.656),
90
+ (40.642, -8.655),
91
+ (40.642, -8.655),
92
+ (40.642, -8.655),
93
+ (40.642, -8.653),
94
+ (40.642, -8.653),
95
+ (40.642, -8.653),
96
+ (40.641, -8.653),
97
+ (40.641, -8.654)
98
+ ])
99
+ assert e == 'gu`wFnfys@???nKgE??gE?????oK????fE??fE'
100
+
101
+
102
+ def test_encode_multiple_points_precision():
103
+ e = polyline.encode([
104
+ (40.64112345, -8.654),
105
+ (40.641, -8.654),
106
+ (40.641, -8.656),
107
+ (40.642, -8.656),
108
+ (40.642, -8.655),
109
+ (40.642, -8.655),
110
+ (40.642, -8.655),
111
+ (40.642, -8.653),
112
+ (40.642, -8.653),
113
+ (40.642, -8.653),
114
+ (40.641, -8.653),
115
+ (40.641, -8.654)
116
+ ], 6)
117
+ assert e == 'eepolA~ieoOtF??~{Bo}@??o}@?????_|B????n}@??n}@'
118
+
119
+ def test_encode_official_example():
120
+ e = polyline.encode([
121
+ (38.500, -120.200),
122
+ (40.700, -120.950),
123
+ (43.252, -126.453)
124
+ ])
125
+ assert e == '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
126
+
127
+
128
+ def test_encode_geojson():
129
+ e = polyline.encode([
130
+ (-120.200, 38.500),
131
+ (-120.950, 40.700),
132
+ (-126.453, 43.252)
133
+ ], geojson=True)
134
+ assert e == '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
135
+
136
+
137
+ def test_encode_official_example_precision():
138
+ e = polyline.encode([
139
+ (38.500, -120.200),
140
+ (40.700, -120.950),
141
+ (43.252, -126.453)
142
+ ], 6)
143
+ assert e == '_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI'
144
+
145
+
146
+ def test_encode_single_point():
147
+ e = polyline.encode([
148
+ (40.64155, -8.65344)
149
+ ])
150
+ assert e == 'ux`wF~bys@'
151
+
152
+ e = polyline.encode([
153
+ (40.641552, -8.653441)
154
+ ])
155
+ assert e == 'ux`wF~bys@'
156
+
157
+
158
+ def test_encode_single_point_rounding():
159
+ e = polyline.encode([
160
+ (0, 0.000006),
161
+ (0, 0.000002)
162
+ ])
163
+ assert e == '?A?@'
164
+
165
+
166
+ def test_rounding_py3_match_py2():
167
+ e = polyline.encode([
168
+ (36.05322, -112.084004),
169
+ (36.053573, -112.083914),
170
+ (36.053845, -112.083965)])
171
+ assert e == 'ss`{E~kbkTeAQw@J'
172
+
173
+
174
+ def test_encode_single_point_precision():
175
+ e = polyline.encode([
176
+ (40.641123, -8.653321)
177
+ ], 6)
178
+ assert e == 'eepolAp_doO'
179
+
180
+ e = polyline.encode([
181
+ (40.6411233123, -8.6533214234)
182
+ ], 6)
183
+ assert e == 'eepolAp_doO'
184
+
185
+
186
+ def test_a_variety_of_precisions():
187
+ """uses a generator to create a variety of lat-lon's across the global
188
+ and tests a range of precision settings from 4 to 8"""
189
+
190
+ def generator():
191
+ while True:
192
+ coords = []
193
+ for i in range(2, randint(4, 10)):
194
+ lat, lon = uniform(-180.0, 180.0), uniform(-180.0, 180.0)
195
+ coords.append((lat, lon))
196
+ yield coords
197
+
198
+ patience = 3 # seconds.
199
+ waypoints, okays = 0, 0
200
+
201
+ g = generator()
202
+ start = time.time()
203
+ while time.time() < start + patience:
204
+ precision = randint(4, 8)
205
+ wp = next(g)
206
+ waypoints += len(wp)
207
+ poly = polyline.encode(wp, precision)
208
+ wp2 = polyline.decode(poly, precision)
209
+ if wp == wp2:
210
+ okays += len(wp2)
211
+ else:
212
+ for idx, _ in enumerate(wp):
213
+ dx, dy = abs(wp[idx][0] - wp2[idx][0]), abs(wp[idx][1] - wp2[idx][1])
214
+ if dx > 10 ** -(precision - 1) or dy > 10 ** -(precision - 1):
215
+ print(f"idx={idx}, dx={dx}, dy={dy}")
216
+ else:
217
+ okays += 1
218
+
219
+ assert okays == waypoints
220
+ print(
221
+ f"encoded and decoded {100 * okays / float(waypoints):.2f}% correctly for {waypoints} "
222
+ f"waypoints @ {round(waypoints / patience, 0)} wp/sec")
File without changes
File without changes
File without changes