topo_map_processor 0.1.8__tar.gz → 0.1.9__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.
Files changed (19) hide show
  1. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/PKG-INFO +1 -1
  2. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/_version.py +2 -2
  3. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/bash_scripts/upload_to_release.sh +3 -4
  4. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/download_mosaic.py +14 -12
  5. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/partition.py +15 -10
  6. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/tile_sources.py +4 -4
  7. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/.gitignore +0 -0
  8. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/LICENSE +0 -0
  9. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/README.md +0 -0
  10. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/pyproject.toml +0 -0
  11. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/__init__.py +0 -0
  12. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/bash_scripts/__init__.py +0 -0
  13. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/bash_scripts/generate_lists.sh +0 -0
  14. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/processor.py +0 -0
  15. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/__init__.py +0 -0
  16. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/collect_bounds.py +0 -0
  17. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/execute_bash.py +0 -0
  18. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/retile.py +0 -0
  19. {topo_map_processor-0.1.8 → topo_map_processor-0.1.9}/topo_map_processor/tools/tile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: topo_map_processor
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Library for processing topographic maps
5
5
  Project-URL: homepage, https://github.com/ramSeraph/topo_map_processor
6
6
  Project-URL: repository, https://github.com/ramSeraph/topo_map_processor.git
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.8'
21
- __version_tuple__ = version_tuple = (0, 1, 8)
20
+ __version__ = version = '0.1.9'
21
+ __version_tuple__ = version_tuple = (0, 1, 9)
@@ -81,10 +81,6 @@ for release in $RELEASES_TO_PROCESS; do
81
81
  fi
82
82
  done
83
83
 
84
- if [ -z "$EXISTING_ASSETS_WITH_RELEASES" ]; then
85
- echo "Could not fetch any assets. This could mean the releases do not have assets, or you lack permissions."
86
- fi
87
-
88
84
  # Determine available releases and their current asset counts
89
85
  AVAILABLE_RELEASES=()
90
86
  AVAILABLE_ASSET_COUNTS=()
@@ -107,8 +103,11 @@ echo "Starting upload process from folder '$FOLDER'..."
107
103
  # Find all files in the folder that are not yet in any release and loop through them.
108
104
  find "${FOLDER}" -type f | grep "^.*\.${EXT}$" | while read -r FILE_PATH; do
109
105
  FILENAME=$(basename "$FILE_PATH")
106
+ echo "Processing file: $FILENAME"
110
107
 
108
+ set +o pipefail
111
109
  RELEASE_FOR_ASSET=$(echo -n "$EXISTING_ASSETS_WITH_RELEASES" | grep "^${FILENAME} " | head -n 1 | awk '{print $2}')
110
+ set -o pipefail
112
111
 
113
112
  if [ -n "$RELEASE_FOR_ASSET" ]; then
114
113
  # Asset exists
@@ -191,6 +191,18 @@ def cli():
191
191
 
192
192
  mosaic_fname = get_filename_from_url(mosaic_url)
193
193
 
194
+ global session, timeout
195
+ session = requests.session()
196
+ retries = args.num_http_retries
197
+ retry = Retry(
198
+ total=retries,
199
+ read=retries,
200
+ connect=retries,
201
+ )
202
+ session.mount('http://', HTTPAdapter(max_retries=retry))
203
+ session.mount('https://', HTTPAdapter(max_retries=retry))
204
+ timeout = args.request_timeout_secs
205
+
194
206
  mosaic_file = Path(mosaic_fname)
195
207
  mosaic_data = get_mosaic(mosaic_file, mosaic_url)
196
208
  metadata = get_metadata(mosaic_data)
@@ -221,24 +233,14 @@ def cli():
221
233
  initialize_tables(cursor, metadata)
222
234
  mark_done(tracker_file, 'table_init')
223
235
 
224
- global session, timeout
225
- session = requests.session()
226
- retries = args.num_http_retries
227
- retry = Retry(
228
- total=retries,
229
- read=retries,
230
- connect=retries,
231
- )
232
- session.mount('http://', HTTPAdapter(max_retries=retry))
233
- session.mount('https://', HTTPAdapter(max_retries=retry))
234
- timeout = args.request_timeout_secs
235
-
236
236
  for k in mosaic_data.keys():
237
237
  pmtiles_url = get_pmtiles_url(mosaic_url, k)
238
238
  if stage_done(tracker_file, k):
239
239
  continue
240
240
 
241
241
  pmtiles_fname = get_filename_from_url(pmtiles_url)
242
+ if Path(pmtiles_fname).exists():
243
+ raise Exception(f'{pmtiles_fname} already exists, delete existing file to continue')
242
244
  download_file(pmtiles_url, pmtiles_fname)
243
245
  add_to_mbtiles(pmtiles_fname, cursor, conn)
244
246
  mark_done(tracker_file, k)
@@ -298,7 +298,7 @@ def create_pmtiles(partition_info, reader, to_pmtiles_prefix):
298
298
  tiles_to_suffix_idx[t] = i
299
299
  i += 1
300
300
 
301
- curr_zs = {}
301
+ curr_low_zs = {}
302
302
  max_lats = {}
303
303
  min_lats = {}
304
304
  max_lons = {}
@@ -306,7 +306,7 @@ def create_pmtiles(partition_info, reader, to_pmtiles_prefix):
306
306
  min_zooms = {}
307
307
  max_zooms = {}
308
308
  for suffix in suffix_arr:
309
- curr_zs[suffix] = None
309
+ curr_low_zs[suffix] = None
310
310
  max_lats[suffix] = min_lats[suffix] = max_lons[suffix] = min_lons[suffix] = None
311
311
  min_zooms[suffix] = max_zooms[suffix] = None
312
312
 
@@ -319,21 +319,21 @@ def create_pmtiles(partition_info, reader, to_pmtiles_prefix):
319
319
  suffix = suffix_arr[tiles_to_suffix_idx[t]]
320
320
  writer = writers[suffix]
321
321
 
322
- if curr_zs[suffix] is None or curr_zs[suffix] < t.z:
322
+ if curr_low_zs[suffix] is None or curr_low_zs[suffix] > t.z:
323
323
  max_lats[suffix] = min_lats[suffix] = max_lons[suffix] = min_lons[suffix] = None
324
- curr_zs[suffix] = t.z
324
+ curr_low_zs[suffix] = t.z
325
325
 
326
326
  t_bounds = mercantile.bounds(t)
327
- if curr_zs[suffix] == t.z and (max_lats[suffix] is None or t_bounds.north > max_lats[suffix]):
327
+ if curr_low_zs[suffix] == t.z and (max_lats[suffix] is None or t_bounds.north > max_lats[suffix]):
328
328
  max_lats[suffix] = t_bounds.north
329
329
 
330
- if curr_zs[suffix] == t.z and (min_lats[suffix] is None or t_bounds.south < min_lats[suffix]):
330
+ if curr_low_zs[suffix] == t.z and (min_lats[suffix] is None or t_bounds.south < min_lats[suffix]):
331
331
  min_lats[suffix] = t_bounds.south
332
332
 
333
- if curr_zs[suffix] == t.z and (max_lons[suffix] is None or t_bounds.east > max_lons[suffix]):
333
+ if curr_low_zs[suffix] == t.z and (max_lons[suffix] is None or t_bounds.east > max_lons[suffix]):
334
334
  max_lons[suffix] = t_bounds.east
335
335
 
336
- if curr_zs[suffix] == t.z and (min_lons[suffix] is None or t_bounds.west < min_lons[suffix]):
336
+ if curr_low_zs[suffix] == t.z and (min_lons[suffix] is None or t_bounds.west < min_lons[suffix]):
337
337
  min_lons[suffix] = t_bounds.west
338
338
 
339
339
  if min_zooms[suffix] is None or min_zooms[suffix] > t.z:
@@ -357,10 +357,15 @@ def create_pmtiles(partition_info, reader, to_pmtiles_prefix):
357
357
  if format_string == "jpg":
358
358
  format_string = "jpeg"
359
359
 
360
- is_vector_tiles = format_string == "pbf"
360
+ is_vector_tiles = (format_string == "pbf")
361
+
362
+ if is_vector_tiles or src_metadata.get('compression', None) == "gzip":
363
+ tile_compression = Compression.GZIP
364
+ else:
365
+ tile_compression = Compression.NONE
361
366
 
362
367
  header = {
363
- "tile_compression": Compression.GZIP if is_vector_tiles else Compression.NONE,
368
+ "tile_compression": tile_compression,
364
369
  "min_lon_e7": int(min_lons[suffix] * 10000000),
365
370
  "min_lat_e7": int(min_lats[suffix] * 10000000),
366
371
  "max_lon_e7": int(max_lons[suffix] * 10000000),
@@ -199,7 +199,7 @@ class MBTilesSource:
199
199
  all_metadata[k] = v
200
200
 
201
201
  metadata = {}
202
- for k in ['type', 'format', 'attribution', 'description', 'name', 'version', 'vector_layers', 'maxzoom', 'minzoom']:
202
+ for k in ['type', 'format', 'attribution', 'description', 'name', 'version', 'vector_layers', 'maxzoom', 'minzoom', 'compression']:
203
203
  if k not in all_metadata:
204
204
  continue
205
205
  metadata[k] = all_metadata[k]
@@ -320,7 +320,7 @@ class StackedTileSource:
320
320
  def for_all_z(self, z):
321
321
  seen = set()
322
322
  for i, src in enumerate(self.srcs):
323
- print(f'iterating over source {i} for {z}')
323
+ #print(f'iterating over source {i} for {z}')
324
324
  for (tile, size) in src.for_all_z(z):
325
325
  if tile in seen:
326
326
  continue
@@ -330,7 +330,7 @@ class StackedTileSource:
330
330
  def all(self):
331
331
  seen = set()
332
332
  for i, src in enumerate(self.srcs):
333
- print(f'iterating over source {i} for all levels')
333
+ #print(f'iterating over source {i} for all levels')
334
334
  for (tile, data) in src.all():
335
335
  if tile in seen:
336
336
  continue
@@ -340,7 +340,7 @@ class StackedTileSource:
340
340
  def all_sizes(self):
341
341
  seen = set()
342
342
  for i, src in enumerate(self.srcs):
343
- print(f'iterating over source {i} for all levels')
343
+ #print(f'iterating over source {i} for all levels')
344
344
  for (tile, size) in src.all_sizes():
345
345
  if tile in seen:
346
346
  continue