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.
- {polyline-2.0.4/src/polyline.egg-info → polyline-2.0.5}/PKG-INFO +1 -1
- {polyline-2.0.4 → polyline-2.0.5}/pyproject.toml +1 -1
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline/polyline.py +3 -0
- {polyline-2.0.4 → polyline-2.0.5/src/polyline.egg-info}/PKG-INFO +1 -1
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline.egg-info/SOURCES.txt +0 -1
- {polyline-2.0.4 → polyline-2.0.5}/tests/test_polyline.py +6 -0
- polyline-2.0.4/src/polyline/test.py +0 -59
- {polyline-2.0.4 → polyline-2.0.5}/LICENSE +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/README.rst +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/setup.cfg +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline/__init__.py +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline/py.typed +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline.egg-info/dependency_links.txt +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline.egg-info/requires.txt +0 -0
- {polyline-2.0.4 → polyline-2.0.5}/src/polyline.egg-info/top_level.txt +0 -0
|
@@ -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
|
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|