geovizpy 0.1.3__tar.gz → 0.1.4__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.
- {geovizpy-0.1.3 → geovizpy-0.1.4}/PKG-INFO +3 -3
- {geovizpy-0.1.3 → geovizpy-0.1.4}/geovizpy/__init__.py +217 -9
- {geovizpy-0.1.3 → geovizpy-0.1.4}/geovizpy.egg-info/PKG-INFO +3 -3
- {geovizpy-0.1.3 → geovizpy-0.1.4}/setup.py +5 -3
- {geovizpy-0.1.3 → geovizpy-0.1.4}/README.md +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.4}/geovizpy.egg-info/SOURCES.txt +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.4}/geovizpy.egg-info/dependency_links.txt +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.4}/geovizpy.egg-info/top_level.txt +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.4}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: geovizpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A Python wrapper for the geoviz JavaScript library
|
|
5
|
-
Author:
|
|
6
|
-
Project-URL: Source, https://codeberg.org/
|
|
5
|
+
Author: fbxyz
|
|
6
|
+
Project-URL: Source, https://codeberg.org/fbxyz/geovizpy
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
9
|
Classifier: Operating System :: OS Independent
|
|
@@ -6,159 +6,371 @@ class Geoviz:
|
|
|
6
6
|
Allows creating maps by chaining commands and rendering them to an HTML file.
|
|
7
7
|
"""
|
|
8
8
|
def __init__(self, **kwargs):
|
|
9
|
+
"""
|
|
10
|
+
Initialize the Geoviz object.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
width (int): Width of the SVG.
|
|
14
|
+
height (int): Height of the SVG.
|
|
15
|
+
margin (list): Margins [top, right, bottom, left].
|
|
16
|
+
domain (object): GeoJSON to define the domain.
|
|
17
|
+
projection (string): Projection name (e.g., "mercator", "EqualEarth").
|
|
18
|
+
zoomable (bool): If True, the map is zoomable.
|
|
19
|
+
background (string): Background color.
|
|
20
|
+
"""
|
|
9
21
|
self.commands = []
|
|
10
22
|
self.commands.append({"name": "create", "args": kwargs})
|
|
11
23
|
|
|
12
24
|
def _add_command(self, name, args):
|
|
25
|
+
"""Add a command to the list of commands to be executed."""
|
|
13
26
|
self.commands.append({"name": name, "args": args})
|
|
14
27
|
return self
|
|
15
28
|
|
|
16
29
|
# Marks
|
|
17
30
|
def outline(self, **kwargs):
|
|
31
|
+
"""
|
|
32
|
+
Add an outline to the map (graticule sphere).
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
fill (string): Fill color.
|
|
36
|
+
stroke (string): Stroke color.
|
|
37
|
+
strokeWidth (number): Stroke width.
|
|
38
|
+
"""
|
|
18
39
|
return self._add_command("outline", kwargs)
|
|
19
40
|
|
|
20
41
|
def graticule(self, **kwargs):
|
|
42
|
+
"""
|
|
43
|
+
Add a graticule to the map.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
stroke (string): Stroke color.
|
|
47
|
+
strokeWidth (number): Stroke width.
|
|
48
|
+
step (list): Step [x, y] in degrees.
|
|
49
|
+
"""
|
|
21
50
|
return self._add_command("graticule", kwargs)
|
|
22
51
|
|
|
23
52
|
def path(self, **kwargs):
|
|
53
|
+
"""
|
|
54
|
+
Draw a path (geometry) on the map.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
datum (object): GeoJSON Feature or FeatureCollection.
|
|
58
|
+
fill (string): Fill color.
|
|
59
|
+
stroke (string): Stroke color.
|
|
60
|
+
strokeWidth (number): Stroke width.
|
|
61
|
+
"""
|
|
24
62
|
return self._add_command("path", kwargs)
|
|
25
63
|
|
|
26
64
|
def header(self, **kwargs):
|
|
65
|
+
"""
|
|
66
|
+
Add a header (title) to the map.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
text (string): Title text.
|
|
70
|
+
fontSize (number): Font size.
|
|
71
|
+
fontFamily (string): Font family.
|
|
72
|
+
fill (string): Text color.
|
|
73
|
+
anchor (string): Text anchor ("start", "middle", "end").
|
|
74
|
+
"""
|
|
27
75
|
return self._add_command("header", kwargs)
|
|
28
76
|
|
|
29
77
|
def footer(self, **kwargs):
|
|
78
|
+
"""
|
|
79
|
+
Add a footer (source, author) to the map.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
text (string): Footer text.
|
|
83
|
+
fontSize (number): Font size.
|
|
84
|
+
fill (string): Text color.
|
|
85
|
+
anchor (string): Text anchor.
|
|
86
|
+
"""
|
|
30
87
|
return self._add_command("footer", kwargs)
|
|
31
88
|
|
|
32
89
|
def circle(self, **kwargs):
|
|
90
|
+
"""
|
|
91
|
+
Draw circles on the map (low-level mark).
|
|
92
|
+
For proportional circles with legend, use prop().
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
data (object): GeoJSON FeatureCollection.
|
|
96
|
+
r (string|number): Radius value or property name.
|
|
97
|
+
fill (string): Fill color.
|
|
98
|
+
stroke (string): Stroke color.
|
|
99
|
+
tip (string|bool): Tooltip content.
|
|
100
|
+
"""
|
|
33
101
|
return self._add_command("circle", kwargs)
|
|
34
102
|
|
|
35
103
|
def square(self, **kwargs):
|
|
104
|
+
"""
|
|
105
|
+
Draw squares on the map (low-level mark).
|
|
106
|
+
For proportional squares with legend, use prop(symbol="square").
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
data (object): GeoJSON FeatureCollection.
|
|
110
|
+
side (string|number): Side length or property name.
|
|
111
|
+
fill (string): Fill color.
|
|
112
|
+
"""
|
|
36
113
|
return self._add_command("square", kwargs)
|
|
37
114
|
|
|
38
115
|
def spike(self, **kwargs):
|
|
116
|
+
"""
|
|
117
|
+
Draw spikes on the map (low-level mark).
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
data (object): GeoJSON FeatureCollection.
|
|
121
|
+
height (string|number): Height value or property name.
|
|
122
|
+
width (number): Width of the spike.
|
|
123
|
+
fill (string): Fill color.
|
|
124
|
+
"""
|
|
39
125
|
return self._add_command("spike", kwargs)
|
|
40
126
|
|
|
41
127
|
def text(self, **kwargs):
|
|
128
|
+
"""
|
|
129
|
+
Add text labels to the map.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
data (object): GeoJSON FeatureCollection.
|
|
133
|
+
text (string): Property name for the text.
|
|
134
|
+
fontSize (number): Font size.
|
|
135
|
+
fill (string): Text color.
|
|
136
|
+
"""
|
|
42
137
|
return self._add_command("text", kwargs)
|
|
43
138
|
|
|
44
139
|
def tile(self, **kwargs):
|
|
140
|
+
"""
|
|
141
|
+
Add a tile layer (basemap).
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
url (string): URL template or keyword (e.g., "worldStreet", "openstreetmap").
|
|
145
|
+
opacity (number): Opacity (0 to 1).
|
|
146
|
+
"""
|
|
45
147
|
return self._add_command("tile", kwargs)
|
|
46
148
|
|
|
47
149
|
def scalebar(self, **kwargs):
|
|
150
|
+
"""
|
|
151
|
+
Add a scale bar.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
x (number): X position.
|
|
155
|
+
y (number): Y position.
|
|
156
|
+
units (string): "km" or "mi".
|
|
157
|
+
"""
|
|
48
158
|
return self._add_command("scalebar", kwargs)
|
|
49
159
|
|
|
50
160
|
def north(self, **kwargs):
|
|
161
|
+
"""
|
|
162
|
+
Add a north arrow.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
x (number): X position.
|
|
166
|
+
y (number): Y position.
|
|
167
|
+
width (number): Width of the arrow.
|
|
168
|
+
"""
|
|
51
169
|
return self._add_command("north", kwargs)
|
|
52
170
|
|
|
53
171
|
def plot(self, **kwargs):
|
|
172
|
+
"""
|
|
173
|
+
Generic plot function.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
type (string): Type of plot ("choro", "prop", "typo", etc.).
|
|
177
|
+
data (object): GeoJSON data.
|
|
178
|
+
var (string): Variable to map.
|
|
179
|
+
"""
|
|
54
180
|
return self._add_command("plot", kwargs)
|
|
55
181
|
|
|
56
182
|
def tissot(self, **kwargs):
|
|
183
|
+
"""Draw Tissot's indicatrix to visualize distortion."""
|
|
57
184
|
return self._add_command("tissot", kwargs)
|
|
58
185
|
|
|
59
186
|
def rhumbs(self, **kwargs):
|
|
187
|
+
"""Draw rhumb lines."""
|
|
60
188
|
return self._add_command("rhumbs", kwargs)
|
|
61
189
|
|
|
62
190
|
def earth(self, **kwargs):
|
|
191
|
+
"""Draw the earth (background)."""
|
|
63
192
|
return self._add_command("earth", kwargs)
|
|
64
193
|
|
|
65
194
|
def empty(self, **kwargs):
|
|
195
|
+
"""Create an empty layer."""
|
|
66
196
|
return self._add_command("empty", kwargs)
|
|
67
197
|
|
|
68
198
|
def halfcircle(self, **kwargs):
|
|
199
|
+
"""Draw half-circles."""
|
|
69
200
|
return self._add_command("halfcircle", kwargs)
|
|
70
201
|
|
|
71
202
|
def symbol(self, **kwargs):
|
|
203
|
+
"""Draw symbols."""
|
|
72
204
|
return self._add_command("symbol", kwargs)
|
|
73
205
|
|
|
74
206
|
def grid(self, **kwargs):
|
|
207
|
+
"""Draw a grid."""
|
|
75
208
|
return self._add_command("grid", kwargs)
|
|
76
209
|
|
|
77
210
|
# Plot shortcuts (sugar syntax for plot({type: ...}))
|
|
78
211
|
def choro(self, **kwargs):
|
|
212
|
+
"""
|
|
213
|
+
Draw a choropleth map.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
data (object): GeoJSON FeatureCollection.
|
|
217
|
+
var (string): Variable name containing numeric values.
|
|
218
|
+
method (string): Classification method ('quantile', 'jenks', 'equal', etc.).
|
|
219
|
+
nb (int): Number of classes.
|
|
220
|
+
colors (string|list): Color palette name or list of colors.
|
|
221
|
+
legend (bool): Whether to show the legend (default: True).
|
|
222
|
+
leg_pos (list): Legend position [x, y].
|
|
223
|
+
leg_title (string): Legend title.
|
|
224
|
+
"""
|
|
79
225
|
return self._add_command("plot", {"type": "choro", **kwargs})
|
|
80
226
|
|
|
81
227
|
def typo(self, **kwargs):
|
|
228
|
+
"""
|
|
229
|
+
Draw a typology map (categorical data).
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
data (object): GeoJSON FeatureCollection.
|
|
233
|
+
var (string): Variable name containing categories.
|
|
234
|
+
colors (string|list): Color palette or list.
|
|
235
|
+
legend (bool): Show legend.
|
|
236
|
+
"""
|
|
82
237
|
return self._add_command("plot", {"type": "typo", **kwargs})
|
|
83
238
|
|
|
84
239
|
def prop(self, **kwargs):
|
|
240
|
+
"""
|
|
241
|
+
Draw a proportional symbol map.
|
|
242
|
+
|
|
243
|
+
Args:
|
|
244
|
+
data (object): GeoJSON FeatureCollection.
|
|
245
|
+
var (string): Variable name containing numeric values.
|
|
246
|
+
symbol (string): Symbol type ("circle", "square", "spike").
|
|
247
|
+
k (number): Size of the largest symbol.
|
|
248
|
+
fill (string): Fill color.
|
|
249
|
+
legend (bool): Show legend.
|
|
250
|
+
leg_type (string): Legend style ("nested", "separate").
|
|
251
|
+
"""
|
|
85
252
|
return self._add_command("plot", {"type": "prop", **kwargs})
|
|
86
253
|
|
|
87
254
|
def propchoro(self, **kwargs):
|
|
255
|
+
"""
|
|
256
|
+
Draw proportional symbols colored by a choropleth variable.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
data (object): GeoJSON FeatureCollection.
|
|
260
|
+
var (string): Variable for symbol size.
|
|
261
|
+
var2 (string): Variable for color.
|
|
262
|
+
method (string): Classification method for color.
|
|
263
|
+
colors (string|list): Color palette.
|
|
264
|
+
"""
|
|
88
265
|
return self._add_command("plot", {"type": "propchoro", **kwargs})
|
|
89
266
|
|
|
90
267
|
def proptypo(self, **kwargs):
|
|
268
|
+
"""
|
|
269
|
+
Draw proportional symbols colored by categories.
|
|
270
|
+
|
|
271
|
+
Args:
|
|
272
|
+
data (object): GeoJSON FeatureCollection.
|
|
273
|
+
var (string): Variable for symbol size.
|
|
274
|
+
var2 (string): Variable for category color.
|
|
275
|
+
"""
|
|
91
276
|
return self._add_command("plot", {"type": "proptypo", **kwargs})
|
|
92
277
|
|
|
93
278
|
def picto(self, **kwargs):
|
|
279
|
+
"""Draw a pictogram map."""
|
|
94
280
|
return self._add_command("plot", {"type": "picto", **kwargs})
|
|
95
281
|
|
|
96
282
|
def bertin(self, **kwargs):
|
|
283
|
+
"""
|
|
284
|
+
Draw a Bertin map (dots).
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
data (object): GeoJSON FeatureCollection.
|
|
288
|
+
var (string): Variable name.
|
|
289
|
+
n (int): Number of dots per unit.
|
|
290
|
+
"""
|
|
97
291
|
return self._add_command("plot", {"type": "bertin", **kwargs})
|
|
98
292
|
|
|
99
293
|
# Legends
|
|
100
294
|
def legend_circles_nested(self, **kwargs):
|
|
295
|
+
"""Draw a nested circles legend."""
|
|
101
296
|
return self._add_command("legend.circles_nested", kwargs)
|
|
102
297
|
|
|
103
298
|
def legend_circles(self, **kwargs):
|
|
299
|
+
"""Draw a circles legend."""
|
|
104
300
|
return self._add_command("legend.circles", kwargs)
|
|
105
301
|
|
|
106
302
|
def legend_squares(self, **kwargs):
|
|
303
|
+
"""Draw a squares legend."""
|
|
107
304
|
return self._add_command("legend.squares", kwargs)
|
|
108
305
|
|
|
109
306
|
def legend_squares_nested(self, **kwargs):
|
|
307
|
+
"""Draw a nested squares legend."""
|
|
110
308
|
return self._add_command("legend.squares_nested", kwargs)
|
|
111
309
|
|
|
112
310
|
def legend_circles_half(self, **kwargs):
|
|
311
|
+
"""Draw a half-circles legend."""
|
|
113
312
|
return self._add_command("legend.circles_half", kwargs)
|
|
114
313
|
|
|
115
314
|
def legend_spikes(self, **kwargs):
|
|
315
|
+
"""Draw a spikes legend."""
|
|
116
316
|
return self._add_command("legend.spikes", kwargs)
|
|
117
317
|
|
|
118
318
|
def legend_mushrooms(self, **kwargs):
|
|
319
|
+
"""Draw a mushrooms legend."""
|
|
119
320
|
return self._add_command("legend.mushrooms", kwargs)
|
|
120
321
|
|
|
121
322
|
def legend_choro_vertical(self, **kwargs):
|
|
323
|
+
"""Draw a vertical choropleth legend."""
|
|
122
324
|
return self._add_command("legend.choro_vertical", kwargs)
|
|
123
325
|
|
|
124
326
|
def legend_choro_horizontal(self, **kwargs):
|
|
327
|
+
"""Draw a horizontal choropleth legend."""
|
|
125
328
|
return self._add_command("legend.choro_horizontal", kwargs)
|
|
126
329
|
|
|
127
330
|
def legend_typo_vertical(self, **kwargs):
|
|
331
|
+
"""Draw a vertical typology legend."""
|
|
128
332
|
return self._add_command("legend.typo_vertical", kwargs)
|
|
129
333
|
|
|
130
334
|
def legend_typo_horizontal(self, **kwargs):
|
|
335
|
+
"""Draw a horizontal typology legend."""
|
|
131
336
|
return self._add_command("legend.typo_horizontal", kwargs)
|
|
132
337
|
|
|
133
338
|
def legend_symbol_vertical(self, **kwargs):
|
|
339
|
+
"""Draw a vertical symbol legend."""
|
|
134
340
|
return self._add_command("legend.symbol_vertical", kwargs)
|
|
135
341
|
|
|
136
342
|
def legend_symbol_horizontal(self, **kwargs):
|
|
343
|
+
"""Draw a horizontal symbol legend."""
|
|
137
344
|
return self._add_command("legend.symbol_horizontal", kwargs)
|
|
138
345
|
|
|
139
346
|
def legend_box(self, **kwargs):
|
|
347
|
+
"""Draw a box legend."""
|
|
140
348
|
return self._add_command("legend.box", kwargs)
|
|
141
349
|
|
|
142
350
|
# Effects
|
|
143
351
|
def effect_blur(self, **kwargs):
|
|
352
|
+
"""Apply a blur effect."""
|
|
144
353
|
return self._add_command("effect.blur", kwargs)
|
|
145
354
|
|
|
146
355
|
def effect_shadow(self, **kwargs):
|
|
356
|
+
"""Apply a shadow effect."""
|
|
147
357
|
return self._add_command("effect.shadow", kwargs)
|
|
148
358
|
|
|
149
359
|
def effect_radialGradient(self, **kwargs):
|
|
360
|
+
"""Apply a radial gradient effect."""
|
|
150
361
|
return self._add_command("effect.radialGradient", kwargs)
|
|
151
362
|
|
|
152
363
|
def effect_clipPath(self, **kwargs):
|
|
364
|
+
"""Apply a clip path effect."""
|
|
153
365
|
return self._add_command("effect.clipPath", kwargs)
|
|
154
366
|
|
|
155
367
|
def get_config(self):
|
|
156
|
-
"""
|
|
157
|
-
Returns the configuration as a JSON-compatible list of commands.
|
|
158
|
-
"""
|
|
368
|
+
"""Return the configuration as a JSON-compatible list of commands."""
|
|
159
369
|
def process_args(args):
|
|
160
370
|
new_args = {}
|
|
161
371
|
for k, v in args.items():
|
|
372
|
+
if v is None:
|
|
373
|
+
continue # Skip None values
|
|
162
374
|
if isinstance(v, str) and (v.strip().startswith("(") or v.strip().startswith("function") or "=>" in v):
|
|
163
375
|
new_args[k] = {"__js_func__": v}
|
|
164
376
|
elif isinstance(v, dict):
|
|
@@ -174,15 +386,11 @@ class Geoviz:
|
|
|
174
386
|
return processed_commands
|
|
175
387
|
|
|
176
388
|
def to_json(self):
|
|
177
|
-
"""
|
|
178
|
-
Returns the configuration as a JSON string.
|
|
179
|
-
"""
|
|
389
|
+
"""Return the configuration as a JSON string."""
|
|
180
390
|
return json.dumps(self.get_config())
|
|
181
391
|
|
|
182
392
|
def render_html(self, filename="map.html"):
|
|
183
|
-
"""
|
|
184
|
-
Renders the map to an HTML file.
|
|
185
|
-
"""
|
|
393
|
+
"""Render the map to an HTML file."""
|
|
186
394
|
json_commands = self.to_json()
|
|
187
395
|
|
|
188
396
|
html_content = f"""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: geovizpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A Python wrapper for the geoviz JavaScript library
|
|
5
|
-
Author:
|
|
6
|
-
Project-URL: Source, https://codeberg.org/
|
|
5
|
+
Author: fbxyz
|
|
6
|
+
Project-URL: Source, https://codeberg.org/fbxyz/geovizpy
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
9
|
Classifier: Operating System :: OS Independent
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Setup script for the geovizpy package."""
|
|
2
|
+
|
|
1
3
|
from setuptools import setup, find_packages
|
|
2
4
|
|
|
3
5
|
# Read the contents of your README file
|
|
@@ -7,15 +9,15 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
7
9
|
|
|
8
10
|
setup(
|
|
9
11
|
name="geovizpy",
|
|
10
|
-
version="0.1.
|
|
12
|
+
version="0.1.4",
|
|
11
13
|
description="A Python wrapper for the geoviz JavaScript library",
|
|
12
14
|
long_description=long_description,
|
|
13
15
|
long_description_content_type='text/markdown',
|
|
14
|
-
author="
|
|
16
|
+
author="fbxyz",
|
|
15
17
|
packages=find_packages(),
|
|
16
18
|
install_requires=[],
|
|
17
19
|
project_urls={
|
|
18
|
-
'Source': 'https://codeberg.org/
|
|
20
|
+
'Source': 'https://codeberg.org/fbxyz/geovizpy',
|
|
19
21
|
},
|
|
20
22
|
classifiers=[
|
|
21
23
|
"Programming Language :: Python :: 3",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|