polyline 2.0.4__tar.gz → 2.0.5__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.4
2
2
  Name: polyline
3
- Version: 2.0.4
3
+ Version: 2.0.5
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "polyline"
3
- version = "2.0.4"
3
+ version = "2.0.5"
4
4
  description = "A Python implementation of Google's Encoded Polyline Algorithm Format."
5
5
  license = {file = "LICENSE"}
6
6
  authors = [
@@ -80,6 +80,9 @@ def encode(coordinates: List[Tuple[float, float]], precision: int = 5, geojson:
80
80
  :param geojson: Set to True in order to encode (lon, lat) tuples.
81
81
  :return: The encoded polyline string.
82
82
  """
83
+ if len(coordinates) == 0:
84
+ return ''
85
+
83
86
  if geojson is True:
84
87
  coordinates = [t[::-1] for t in coordinates]
85
88
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyline
3
- Version: 2.0.4
3
+ Version: 2.0.5
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
@@ -4,7 +4,6 @@ pyproject.toml
4
4
  src/polyline/__init__.py
5
5
  src/polyline/polyline.py
6
6
  src/polyline/py.typed
7
- src/polyline/test.py
8
7
  src/polyline.egg-info/PKG-INFO
9
8
  src/polyline.egg-info/SOURCES.txt
10
9
  src/polyline.egg-info/dependency_links.txt
@@ -155,6 +155,12 @@ def test_encode_single_point():
155
155
  assert e == 'ux`wF~bys@'
156
156
 
157
157
 
158
+ def test_encode_empty():
159
+ assert polyline.encode([]) == ''
160
+ assert polyline.encode([], geojson=True) == ''
161
+ assert polyline.decode(polyline.encode([])) == []
162
+
163
+
158
164
  def test_encode_single_point_rounding():
159
165
  e = polyline.encode([
160
166
  (0, 0.000006),
@@ -1,59 +0,0 @@
1
- from PIL import Image
2
- import numpy as np
3
-
4
- # --- CONFIG ---
5
- INPUT = "/Users/fjansen/Downloads/Table&Tulip/T&T_Logos_Final/T&T_Monogram.png"
6
- OUTPUT_PNG = "/Users/fjansen/Downloads/Table&Tulip/T&T_Logos_Final/favicon-tight-512.png"
7
- OUTPUT_ICO = "/Users/fjansen/Downloads/Table&Tulip/T&T_Logos_Final/favicon-tight.ico"
8
- TARGET_SIZE = 480 # favicon base size
9
- PADDING = 0.08 # % of edge padding after cropping
10
-
11
-
12
- # --- LOAD IMAGE ---
13
- img = Image.open(INPUT).convert("RGBA")
14
- arr = np.asarray(img)
15
-
16
- # --- DETECT NON-WHITE / NON-EMPTY PIXELS ---
17
- # Treat nearly-white or transparent as background
18
- mask = ~(
19
- ((arr[...,0] > 245) & (arr[...,1] > 245) & (arr[...,2] > 245)) |
20
- (arr[...,3] < 10)
21
- )
22
-
23
- coords = np.argwhere(mask)
24
-
25
- # If nothing detected, fallback
26
- if coords.size == 0:
27
- cropped = img
28
- else:
29
- y0, x0 = coords.min(axis=0)[:2]
30
- y1, x1 = coords.max(axis=0)[:2] + 1
31
- cropped = img.crop((x0, y0, x1, y1))
32
-
33
-
34
- # --- ADD MINIMAL PADDING ---
35
- cw, ch = cropped.size
36
- pad = int(max(cw, ch) * PADDING)
37
-
38
- square_size = max(cw, ch) + pad * 2
39
-
40
- #canvas = Image.new("RGBA", (square_size, square_size), (0,0,0,0))
41
- #canvas.paste(cropped, ((square_size - cw)//2, (square_size - ch)//2))
42
- # *** White background version ***
43
- canvas = Image.new("RGBA", (square_size, square_size), (255, 255, 255, 255))
44
- canvas.paste(cropped, ((square_size - cw)//2, (square_size - ch)//2), cropped)
45
-
46
- # --- RESIZE FOR FAVORICON ---
47
- favicon = canvas.resize((TARGET_SIZE, TARGET_SIZE), Image.LANCZOS)
48
-
49
- # Save PNG
50
- favicon.save(OUTPUT_PNG)
51
-
52
- # Save ICO in multiple resolutions
53
- favicon.save(
54
- OUTPUT_ICO,
55
- format="ICO",
56
- sizes=[(16,16),(32,32),(48,48),(64,64),(128,128),(256,256)]
57
- )
58
-
59
- OUTPUT_PNG, OUTPUT_ICO
File without changes
File without changes
File without changes
File without changes