matplotlib-map-utils 1.0.2__py3-none-any.whl → 2.0.0__py3-none-any.whl
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.
- matplotlib_map_utils/__init__.py +5 -1
- matplotlib_map_utils/core/__init__.py +4 -0
- matplotlib_map_utils/{north_arrow.py → core/north_arrow.py} +56 -55
- matplotlib_map_utils/core/scale_bar.py +1200 -0
- matplotlib_map_utils/defaults/__init__.py +4 -0
- matplotlib_map_utils/{defaults.py → defaults/north_arrow.py} +4 -4
- matplotlib_map_utils/defaults/scale_bar.py +377 -0
- matplotlib_map_utils/validation/__init__.py +2 -0
- matplotlib_map_utils/validation/functions.py +231 -0
- matplotlib_map_utils/validation/north_arrow.py +175 -0
- matplotlib_map_utils/validation/scale_bar.py +274 -0
- matplotlib_map_utils-2.0.0.dist-info/METADATA +281 -0
- matplotlib_map_utils-2.0.0.dist-info/RECORD +18 -0
- {matplotlib_map_utils-1.0.2.dist-info → matplotlib_map_utils-2.0.0.dist-info}/WHEEL +1 -1
- matplotlib_map_utils/validation.py +0 -332
- matplotlib_map_utils-1.0.2.dist-info/METADATA +0 -131
- matplotlib_map_utils-1.0.2.dist-info/RECORD +0 -11
- {matplotlib_map_utils-1.0.2.dist-info → matplotlib_map_utils-2.0.0.dist-info}/LICENSE +0 -0
- {matplotlib_map_utils-1.0.2.dist-info → matplotlib_map_utils-2.0.0.dist-info}/top_level.txt +0 -0
matplotlib_map_utils/__init__.py
CHANGED
@@ -1,2 +1,6 @@
|
|
1
1
|
# This handles importing of all the functions and classes
|
2
|
-
from . import north_arrow
|
2
|
+
from .core.north_arrow import NorthArrow, north_arrow
|
3
|
+
from .core.scale_bar import ScaleBar, scale_bar, dual_bars
|
4
|
+
|
5
|
+
# This defines what wildcard imports should import
|
6
|
+
__all__ = ["NorthArrow", "north_arrow", "ScaleBar", "scale_bar", "dual_bars"]
|
@@ -26,15 +26,16 @@ import matplotlib.rcsetup
|
|
26
26
|
# The types we use in this script
|
27
27
|
from typing import Literal
|
28
28
|
# The information contained in our helper scripts (validation and defaults)
|
29
|
-
import
|
30
|
-
import
|
29
|
+
from ..defaults import north_arrow as nad
|
30
|
+
from ..validation import north_arrow as nat
|
31
|
+
from ..validation import functions as naf
|
31
32
|
|
32
33
|
### INITIALIZATION ###
|
33
34
|
|
34
35
|
# Setting the defaults to the "medium" size, which is roughly optimized for A4/Letter paper
|
35
36
|
# Making these as globals is important for the set_size() function to work later
|
36
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
37
|
-
_DEFAULT_ROTATION =
|
37
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["md"]
|
38
|
+
_DEFAULT_ROTATION = nad._ROTATION_ALL
|
38
39
|
|
39
40
|
### CLASSES ###
|
40
41
|
|
@@ -46,9 +47,9 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
46
47
|
## INITIALIZATION ##
|
47
48
|
def __init__(self, location: Literal["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]="upper right",
|
48
49
|
scale: None | float | int=None,
|
49
|
-
base: None | bool |
|
50
|
-
label: None | bool |
|
51
|
-
pack: None |
|
50
|
+
base: None | bool | nat._TYPE_BASE = None, fancy: None | bool | nat._TYPE_FANCY = None,
|
51
|
+
label: None | bool | nat._TYPE_LABEL = None, shadow: None | bool | nat._TYPE_SHADOW = None,
|
52
|
+
pack: None | nat._TYPE_PACK = None, aob: None | nat._TYPE_AOB = None, rotation: None | nat._TYPE_ROTATION = None):
|
52
53
|
# Starting up the object with the base properties of a matplotlib Artist
|
53
54
|
matplotlib.artist.Artist.__init__(self)
|
54
55
|
|
@@ -57,35 +58,35 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
57
58
|
# If a specific component is not desired, it should be set to False during initialization
|
58
59
|
|
59
60
|
# Location is stored as just a string
|
60
|
-
location =
|
61
|
+
location = naf._validate(nat._VALIDATE_PRIMARY, "location", location)
|
61
62
|
self._location = location
|
62
63
|
|
63
64
|
# Scale will set to the default size if no value is passed
|
64
|
-
scale =
|
65
|
+
scale = naf._validate(nat._VALIDATE_PRIMARY, "scale", scale)
|
65
66
|
if scale is None:
|
66
67
|
self._scale = _DEFAULT_SCALE
|
67
68
|
else:
|
68
69
|
self._scale = scale
|
69
70
|
|
70
71
|
# Main elements
|
71
|
-
base =
|
72
|
+
base = naf._validate_dict(base, _DEFAULT_BASE, nat._VALIDATE_BASE, return_clean=True, parse_false=False)
|
72
73
|
self._base = base
|
73
74
|
|
74
|
-
fancy =
|
75
|
+
fancy = naf._validate_dict(fancy, _DEFAULT_FANCY, nat._VALIDATE_FANCY, return_clean=True, parse_false=False)
|
75
76
|
self._fancy = fancy
|
76
77
|
|
77
|
-
label =
|
78
|
+
label = naf._validate_dict(label, _DEFAULT_LABEL, nat._VALIDATE_LABEL, return_clean=True, parse_false=False)
|
78
79
|
self._label = label
|
79
80
|
|
80
|
-
shadow =
|
81
|
+
shadow = naf._validate_dict(shadow, _DEFAULT_SHADOW, nat._VALIDATE_SHADOW, return_clean=True, parse_false=False)
|
81
82
|
self._shadow = shadow
|
82
83
|
|
83
84
|
# Other properties
|
84
|
-
pack =
|
85
|
+
pack = naf._validate_dict(pack, _DEFAULT_PACK, nat._VALIDATE_PACK, return_clean=True, parse_false=False)
|
85
86
|
self._pack = pack
|
86
|
-
aob =
|
87
|
+
aob = naf._validate_dict(aob, _DEFAULT_AOB, nat._VALIDATE_AOB, return_clean=True, parse_false=False)
|
87
88
|
self._aob = aob
|
88
|
-
rotation =
|
89
|
+
rotation = naf._validate_dict(rotation, _DEFAULT_ROTATION | rotation, nat._VALIDATE_ROTATION, return_clean=True, parse_false=False)
|
89
90
|
self._rotation = rotation
|
90
91
|
|
91
92
|
# We do set the zorder for our objects individually,
|
@@ -106,7 +107,7 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
106
107
|
|
107
108
|
@location.setter
|
108
109
|
def location(self, val: Literal["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]):
|
109
|
-
val =
|
110
|
+
val = naf._validate(nat._VALIDATE_PRIMARY, "location", val)
|
110
111
|
self._location = val
|
111
112
|
|
112
113
|
@property
|
@@ -115,7 +116,7 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
115
116
|
|
116
117
|
@loc.setter
|
117
118
|
def loc(self, val: Literal["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]):
|
118
|
-
val =
|
119
|
+
val = naf._validate(nat._VALIDATE_PRIMARY, "location", val)
|
119
120
|
self._location = val
|
120
121
|
|
121
122
|
# scale
|
@@ -125,7 +126,7 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
125
126
|
|
126
127
|
@scale.setter
|
127
128
|
def scale(self, val: None | float | int):
|
128
|
-
val =
|
129
|
+
val = naf._validate(nat._VALIDATE_PRIMARY, "scale", val)
|
129
130
|
if val is None:
|
130
131
|
self._scale = _DEFAULT_SCALE
|
131
132
|
else:
|
@@ -138,8 +139,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
138
139
|
|
139
140
|
@base.setter
|
140
141
|
def base(self, val: dict):
|
141
|
-
val =
|
142
|
-
val =
|
142
|
+
val = naf._validate_type("base", val, dict)
|
143
|
+
val = naf._validate_dict(val, self._base, nat._VALIDATE_BASE, return_clean=True, parse_false=False)
|
143
144
|
self._base = val
|
144
145
|
|
145
146
|
# fancy
|
@@ -149,8 +150,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
149
150
|
|
150
151
|
@fancy.setter
|
151
152
|
def fancy(self, val: dict):
|
152
|
-
val =
|
153
|
-
val =
|
153
|
+
val = naf._validate_type("fancy", val, dict)
|
154
|
+
val = naf._validate_dict(val, self._fancy, nat._VALIDATE_FANCY, return_clean=True, parse_false=False)
|
154
155
|
self._fancy = val
|
155
156
|
|
156
157
|
# label
|
@@ -160,8 +161,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
160
161
|
|
161
162
|
@label.setter
|
162
163
|
def label(self, val: dict):
|
163
|
-
val =
|
164
|
-
val =
|
164
|
+
val = naf._validate_type("label", val, dict)
|
165
|
+
val = naf._validate_dict(val, self._label, nat._VALIDATE_LABEL, return_clean=True, parse_false=False)
|
165
166
|
self._label = val
|
166
167
|
|
167
168
|
# shadow
|
@@ -171,8 +172,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
171
172
|
|
172
173
|
@shadow.setter
|
173
174
|
def shadow(self, val: dict):
|
174
|
-
val =
|
175
|
-
val =
|
175
|
+
val = naf._validate_type("shadow", val, dict)
|
176
|
+
val = naf._validate_dict(val, self._shadow, nat._VALIDATE_SHADOW, return_clean=True, parse_false=False)
|
176
177
|
self._shadow = val
|
177
178
|
|
178
179
|
# pack
|
@@ -182,8 +183,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
182
183
|
|
183
184
|
@pack.setter
|
184
185
|
def pack(self, val: dict):
|
185
|
-
val =
|
186
|
-
val =
|
186
|
+
val = naf._validate_type("pack", val, dict)
|
187
|
+
val = naf._validate_dict(val, self._pack, nat._VALIDATE_PACK, return_clean=True, parse_false=False)
|
187
188
|
self._pack = val
|
188
189
|
|
189
190
|
# aob
|
@@ -193,8 +194,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
193
194
|
|
194
195
|
@aob.setter
|
195
196
|
def aob(self, val: dict):
|
196
|
-
val =
|
197
|
-
val =
|
197
|
+
val = naf._validate_type("aob", val, dict)
|
198
|
+
val = naf._validate_dict(val, self._aob, nat._VALIDATE_AOB, return_clean=True, parse_false=False)
|
198
199
|
self._aob = val
|
199
200
|
|
200
201
|
# rotation
|
@@ -204,8 +205,8 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
204
205
|
|
205
206
|
@rotation.setter
|
206
207
|
def rotation(self, val: dict):
|
207
|
-
val =
|
208
|
-
val =
|
208
|
+
val = naf._validate_type("rotation", val, dict)
|
209
|
+
val = naf._validate_dict(val, self._rotation, nat._VALIDATE_ROTATION, return_clean=True, parse_false=False)
|
209
210
|
self._rotation = val
|
210
211
|
|
211
212
|
## COPY FUNCTION ##
|
@@ -242,15 +243,15 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
242
243
|
global _DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB
|
243
244
|
# Changing the global default values as required
|
244
245
|
if size.lower() in ["xs","xsmall","x-small"]:
|
245
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
246
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["xs"]
|
246
247
|
elif size.lower() in ["sm","small"]:
|
247
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
248
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["sm"]
|
248
249
|
elif size.lower() in ["md","medium"]:
|
249
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
250
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["md"]
|
250
251
|
elif size.lower() in ["lg","large"]:
|
251
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
252
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["lg"]
|
252
253
|
elif size.lower() in ["xl","xlarge","x-large"]:
|
253
|
-
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB =
|
254
|
+
_DEFAULT_SCALE, _DEFAULT_BASE, _DEFAULT_FANCY, _DEFAULT_LABEL, _DEFAULT_SHADOW, _DEFAULT_PACK, _DEFAULT_AOB = nad._DEFAULTS_NA["xl"]
|
254
255
|
else:
|
255
256
|
raise ValueError("Invalid value supplied, try one of ['xsmall', 'small', 'medium', 'large', 'xlarge'] instead")
|
256
257
|
|
@@ -261,33 +262,33 @@ class NorthArrow(matplotlib.artist.Artist):
|
|
261
262
|
def north_arrow(ax, draw=True,
|
262
263
|
location: Literal["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]="upper right",
|
263
264
|
scale: None | float | int=None,
|
264
|
-
base: None | bool |
|
265
|
-
fancy: None | bool |
|
266
|
-
label: None | bool |
|
267
|
-
shadow: None | bool |
|
268
|
-
pack: None |
|
269
|
-
aob: None |
|
270
|
-
rotation: None |
|
265
|
+
base: None | bool | nat._TYPE_BASE=None,
|
266
|
+
fancy: None | bool | nat._TYPE_FANCY=None,
|
267
|
+
label: None | bool | nat._TYPE_LABEL=None,
|
268
|
+
shadow: None | bool | nat._TYPE_SHADOW=None,
|
269
|
+
pack: None | nat._TYPE_PACK=None,
|
270
|
+
aob: None | nat._TYPE_AOB=None,
|
271
|
+
rotation: None | nat._TYPE_ROTATION=None):
|
271
272
|
|
272
273
|
# First, validating the two primary inputs
|
273
|
-
_location =
|
274
|
+
_location = naf._validate(nat._VALIDATE_PRIMARY, "location", location)
|
274
275
|
|
275
276
|
if scale is None:
|
276
277
|
_scale = _DEFAULT_SCALE
|
277
278
|
else:
|
278
|
-
_scale =
|
279
|
+
_scale = naf._validate(nat._VALIDATE_PRIMARY, "scale", scale)
|
279
280
|
|
280
281
|
# This works the same as it does with the NorthArrow object
|
281
282
|
# If a dictionary is passed to any of the elements, first validate that it is "correct"
|
282
283
|
# Note that we also merge the provided dict with the default style dict, so no keys are missing
|
283
284
|
# If a specific component is not desired, it should be set to False in the function call
|
284
|
-
_base =
|
285
|
-
_fancy =
|
286
|
-
_label =
|
287
|
-
_shadow =
|
288
|
-
_pack =
|
289
|
-
_aob =
|
290
|
-
_rotation =
|
285
|
+
_base = naf._validate_dict(base, _DEFAULT_BASE, nat._VALIDATE_BASE, return_clean=True)
|
286
|
+
_fancy = naf._validate_dict(fancy, _DEFAULT_FANCY, nat._VALIDATE_FANCY, return_clean=True)
|
287
|
+
_label = naf._validate_dict(label, _DEFAULT_LABEL, nat._VALIDATE_LABEL, return_clean=True)
|
288
|
+
_shadow = naf._validate_dict(shadow, _DEFAULT_SHADOW, nat._VALIDATE_SHADOW, return_clean=True)
|
289
|
+
_pack = naf._validate_dict(pack, _DEFAULT_PACK, nat._VALIDATE_PACK, return_clean=True)
|
290
|
+
_aob = naf._validate_dict(aob, _DEFAULT_AOB, nat._VALIDATE_AOB, return_clean=True)
|
291
|
+
_rotation = naf._validate_dict(rotation, _DEFAULT_ROTATION, nat._VALIDATE_ROTATION, return_clean=True)
|
291
292
|
|
292
293
|
# First, getting the figure for our axes
|
293
294
|
fig = ax.get_figure()
|
@@ -380,7 +381,7 @@ def north_arrow(ax, draw=True,
|
|
380
381
|
## DRAWING ##
|
381
382
|
# If this option is set to true, we'll draw the final artists as desired
|
382
383
|
if draw==True:
|
383
|
-
ax.add_artist(aob_box)
|
384
|
+
_ = ax.add_artist(aob_box)
|
384
385
|
# If not, we'll return the aob_box as an artist object (the NorthArrow draw() function uses this)
|
385
386
|
else:
|
386
387
|
return aob_box
|