gemf-map 1.0.2__tar.gz → 1.0.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.
@@ -158,9 +158,9 @@ dmypy.json
158
158
  cython_debug/
159
159
 
160
160
  # custom
161
+ notes.md
161
162
  dev/
162
163
  docs/build/
163
- docs/source/
164
164
  data/
165
165
  external/
166
166
  tests/test_output/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gemf_map
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Python library for reading and writing GEMF map tile files.
5
5
  Project-URL: Homepage, https://github.com/ColinMoldenhauer/GEMF
6
6
  Project-URL: Documentation, https://gemf.readthedocs.io
@@ -22,12 +22,12 @@ Classifier: Programming Language :: Python :: 3.12
22
22
  Requires-Python: >=3.9
23
23
  Requires-Dist: mercantile
24
24
  Requires-Dist: numpy
25
+ Requires-Dist: pillow
25
26
  Provides-Extra: all
26
27
  Requires-Dist: folium; extra == 'all'
27
28
  Requires-Dist: matplotlib; extra == 'all'
28
29
  Requires-Dist: mkdocs-material; extra == 'all'
29
30
  Requires-Dist: mkdocstrings[python]; extra == 'all'
30
- Requires-Dist: pillow; extra == 'all'
31
31
  Requires-Dist: pytest-cov; extra == 'all'
32
32
  Requires-Dist: pytest>=8.0; extra == 'all'
33
33
  Requires-Dist: shapely; extra == 'all'
@@ -39,7 +39,6 @@ Requires-Dist: shapely; extra == 'geometry'
39
39
  Provides-Extra: plot
40
40
  Requires-Dist: folium; extra == 'plot'
41
41
  Requires-Dist: matplotlib; extra == 'plot'
42
- Requires-Dist: pillow; extra == 'plot'
43
42
  Provides-Extra: test
44
43
  Requires-Dist: pytest-cov; extra == 'test'
45
44
  Requires-Dist: pytest>=8.0; extra == 'test'
@@ -71,13 +70,12 @@ pip install gemf-map
71
70
  - spatially subset (crop) a .gemf file
72
71
  - extracting image tiles from binary `.gemf` files via the `save_tiles()` method
73
72
  - adding tiles to an existing `.gemf` file (TODO)
73
+ - combining `GEMF` objects via `stack()`/`+`, `merge()`/`|`, `intersect()`/`&` and `difference()`/`-`
74
74
 
75
75
  **Visualization features**:
76
76
  - show the tiles of a .gemf file on a `folium` map
77
77
  - show tile boundaries on a map
78
78
 
79
- <!-- TODO: explain lazy laoding -->
80
-
81
79
  # Usage
82
80
 
83
81
  ## Core
@@ -97,12 +95,57 @@ new_gemf = GEMF.from_tiles("PATH/TO/TILEDIR")
97
95
  new_gemf.write("PATH/TO/GEMF_FILE.gemf")
98
96
  ```
99
97
 
98
+ ## Lazy loading
99
+ `GEMF.from_file()` and `GEMF.from_tiles()` accept a `lazy` argument (default `False`).
100
+
101
+ With `lazy=False` (the default), the per-tile range details (location and size of every
102
+ tile's data) are read/computed immediately. This gives access to the full range of
103
+ features, but may take a while for files with a large number of tiles.
104
+
105
+ With `lazy=True`, this step is skipped. The following are available right away without
106
+ extra loading:
107
+ - `gemf.num_sources`
108
+ - `gemf.num_tiles`
109
+ - `gemf.get_zoom_levels()`
110
+ - inspecting `gemf.header.range_data` (the per-zoom-level bounding boxes)
111
+
112
+ Any operation that needs per-tile data (e.g. `save_tiles()`, `write()`, `crop()`,
113
+ `set_tile()`, the arithmetic operators) raises `DetailsNotLoadedError` on a lazily loaded
114
+ `GEMF`. Call `gemf.load_details()` first to load the range details on demand:
115
+
116
+ ```python
117
+ my_gemf = GEMF.from_file("MY_GEMF.gemf", lazy=True)
118
+
119
+ # cheap, available immediately
120
+ print(my_gemf.num_tiles)
121
+
122
+ # load range details before performing per-tile operations
123
+ my_gemf.load_details()
124
+ my_gemf.save_tiles("PATH/TO/TILEDIR")
125
+ ```
126
+
100
127
  ## Manipulation
101
128
  ```python
102
129
  # crop to bounding box (all zoom levels will be cropped accordingly)
103
130
  gemf_crop = my_gemf.crop(7, 60, 62, 36, 38)
104
131
  ```
105
132
 
133
+ ## Combining GEMF objects
134
+ ```python
135
+ # stack: add all sources of gemf2 onto gemf1 as new sources
136
+ combined = gemf1 + gemf2
137
+
138
+ # merge: union of tiles for sources present in both (matched by name)
139
+ # on conflicting tiles, "|" keeps gemf1's tile by default
140
+ merged = gemf1 | gemf2
141
+
142
+ # intersect: keep only tiles present in both, for shared sources
143
+ shared = gemf1 & gemf2
144
+
145
+ # difference: keep gemf1's tiles that are not present in gemf2's matching source
146
+ diff = gemf1 - gemf2
147
+ ```
148
+
106
149
 
107
150
  ## Visualization
108
151
  <!-- TODO: limitations for large gemf files -->
@@ -24,13 +24,12 @@ pip install gemf-map
24
24
  - spatially subset (crop) a .gemf file
25
25
  - extracting image tiles from binary `.gemf` files via the `save_tiles()` method
26
26
  - adding tiles to an existing `.gemf` file (TODO)
27
+ - combining `GEMF` objects via `stack()`/`+`, `merge()`/`|`, `intersect()`/`&` and `difference()`/`-`
27
28
 
28
29
  **Visualization features**:
29
30
  - show the tiles of a .gemf file on a `folium` map
30
31
  - show tile boundaries on a map
31
32
 
32
- <!-- TODO: explain lazy laoding -->
33
-
34
33
  # Usage
35
34
 
36
35
  ## Core
@@ -50,12 +49,57 @@ new_gemf = GEMF.from_tiles("PATH/TO/TILEDIR")
50
49
  new_gemf.write("PATH/TO/GEMF_FILE.gemf")
51
50
  ```
52
51
 
52
+ ## Lazy loading
53
+ `GEMF.from_file()` and `GEMF.from_tiles()` accept a `lazy` argument (default `False`).
54
+
55
+ With `lazy=False` (the default), the per-tile range details (location and size of every
56
+ tile's data) are read/computed immediately. This gives access to the full range of
57
+ features, but may take a while for files with a large number of tiles.
58
+
59
+ With `lazy=True`, this step is skipped. The following are available right away without
60
+ extra loading:
61
+ - `gemf.num_sources`
62
+ - `gemf.num_tiles`
63
+ - `gemf.get_zoom_levels()`
64
+ - inspecting `gemf.header.range_data` (the per-zoom-level bounding boxes)
65
+
66
+ Any operation that needs per-tile data (e.g. `save_tiles()`, `write()`, `crop()`,
67
+ `set_tile()`, the arithmetic operators) raises `DetailsNotLoadedError` on a lazily loaded
68
+ `GEMF`. Call `gemf.load_details()` first to load the range details on demand:
69
+
70
+ ```python
71
+ my_gemf = GEMF.from_file("MY_GEMF.gemf", lazy=True)
72
+
73
+ # cheap, available immediately
74
+ print(my_gemf.num_tiles)
75
+
76
+ # load range details before performing per-tile operations
77
+ my_gemf.load_details()
78
+ my_gemf.save_tiles("PATH/TO/TILEDIR")
79
+ ```
80
+
53
81
  ## Manipulation
54
82
  ```python
55
83
  # crop to bounding box (all zoom levels will be cropped accordingly)
56
84
  gemf_crop = my_gemf.crop(7, 60, 62, 36, 38)
57
85
  ```
58
86
 
87
+ ## Combining GEMF objects
88
+ ```python
89
+ # stack: add all sources of gemf2 onto gemf1 as new sources
90
+ combined = gemf1 + gemf2
91
+
92
+ # merge: union of tiles for sources present in both (matched by name)
93
+ # on conflicting tiles, "|" keeps gemf1's tile by default
94
+ merged = gemf1 | gemf2
95
+
96
+ # intersect: keep only tiles present in both, for shared sources
97
+ shared = gemf1 & gemf2
98
+
99
+ # difference: keep gemf1's tiles that are not present in gemf2's matching source
100
+ diff = gemf1 - gemf2
101
+ ```
102
+
59
103
 
60
104
  ## Visualization
61
105
  <!-- TODO: limitations for large gemf files -->
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.0.2'
22
- __version_tuple__ = version_tuple = (1, 0, 2)
21
+ __version__ = version = '1.0.4'
22
+ __version_tuple__ = version_tuple = (1, 0, 4)
23
23
 
24
24
  __commit_id__ = commit_id = None