mapchete 0.25__tar.gz → 0.26__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.
- home/ungarj/virtualenvs/p3/bin/mapchete +12 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/__init__.py +1 -1
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_core.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/config.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/errors.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/index.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/log.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/tile.cpython-35.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/_core.py +7 -8
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/create.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/execute.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/formats.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/index.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/main.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/pyramid.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/serve.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/tilify.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/utils.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/create.py +88 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/create.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/execute.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/formats.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/index.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/processes.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/pyramid.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/serve.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/execute.py +171 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/index.py +143 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/pyramid.py +0 -1
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/serve.py +2 -3
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/execute.py +115 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/formats.py +21 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/index.py +97 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/main.py +2 -3
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/pyramid.py +127 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/serve.py +131 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/tilify.py +46 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/utils.py +6 -2
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/clip.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/contours.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/hillshade.cpython-35.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/config.py +12 -14
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/base.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/drivers.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/geojson.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/gtiff.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/mapchete_input.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/png.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/png_hillshade.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/raster_file.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/tile_directory.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/vector_file.cpython-35.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/geojson.py +5 -15
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/gtiff.py +4 -9
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/png.py +3 -8
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/png_hillshade.py +3 -8
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/tile_directory.py +4 -5
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/index.py +503 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/__init__.py +68 -14
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/raster.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/vector.cpython-35.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/raster.py +83 -33
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/vector.py +1 -2
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/static/__pycache__/__init__.cpython-35.pyc +0 -0
- home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/static/__pycache__/process_template.cpython-35.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/tile.py +58 -16
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/PKG-INFO +21 -2
- {mapchete-0.25/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/SOURCES.txt +1 -0
- {mapchete-0.25/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/entry_points.txt +2 -1
- {mapchete-0.25/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/requires.txt +5 -1
- mapchete-0.25/README.rst +0 -164
- mapchete-0.25/mapchete/cli/default/execute.py +0 -123
- mapchete-0.25/mapchete/cli/default/index.py +0 -133
- mapchete-0.25/mapchete/index.py +0 -286
- mapchete-0.25/mapchete.egg-info/PKG-INFO +0 -183
- mapchete-0.25/setup.cfg +0 -10
- mapchete-0.25/setup.py +0 -96
- mapchete-0.25/test/test_cli.py +0 -529
- mapchete-0.25/test/test_commons.py +0 -85
- mapchete-0.25/test/test_config.py +0 -245
- mapchete-0.25/test/test_deprecated.py +0 -31
- mapchete-0.25/test/test_errors.py +0 -256
- mapchete-0.25/test/test_formats.py +0 -150
- mapchete-0.25/test/test_formats_geojson.py +0 -120
- mapchete-0.25/test/test_formats_geotiff.py +0 -175
- mapchete-0.25/test/test_formats_png.py +0 -107
- mapchete-0.25/test/test_formats_png_hillshade.py +0 -124
- mapchete-0.25/test/test_formats_tiledir_input.py +0 -148
- mapchete-0.25/test/test_io.py +0 -686
- mapchete-0.25/test/test_log.py +0 -17
- mapchete-0.25/test/test_mapchete.py +0 -424
- mapchete-0.25/test/test_processes.py +0 -85
- mapchete-0.25/test/test_timer.py +0 -24
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/create.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/formats.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/processes.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/clip.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/contours.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/hillshade.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/errors.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/base.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/mapchete_input.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/raster_file.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/vector_file.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/drivers.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/log.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/__init__.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/__init__.pyc +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/index.html +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/mapchete_template.mapchete +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/process_template.py +0 -0
- {mapchete-0.25 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/process_template.pyc +0 -0
- {mapchete-0.25/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/dependency_links.txt +0 -0
- {mapchete-0.25/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.26-py3.5.egg-info}/top_level.txt +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/home/ungarj/virtualenvs/p3/bin/python
|
|
2
|
+
# EASY-INSTALL-ENTRY-SCRIPT: 'mapchete==0.26','console_scripts','mapchete'
|
|
3
|
+
__requires__ = 'mapchete==0.26'
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
from pkg_resources import load_entry_point
|
|
7
|
+
|
|
8
|
+
if __name__ == '__main__':
|
|
9
|
+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
|
10
|
+
sys.exit(
|
|
11
|
+
load_entry_point('mapchete==0.26', 'console_scripts', 'mapchete')()
|
|
12
|
+
)
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/__init__.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_core.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/config.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/errors.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/index.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/log.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/tile.cpython-35.pyc
ADDED
|
Binary file
|
|
@@ -10,7 +10,6 @@ from multiprocessing import cpu_count, current_process
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
import numpy.ma as ma
|
|
12
12
|
from shapely.geometry import shape
|
|
13
|
-
import six
|
|
14
13
|
import threading
|
|
15
14
|
from tilematrix import TilePyramid
|
|
16
15
|
import time
|
|
@@ -424,11 +423,11 @@ class Mapchete(object):
|
|
|
424
423
|
|
|
425
424
|
def _read_existing_output(self, tile, output_tiles):
|
|
426
425
|
if self.config.output.METADATA["data_type"] == "raster":
|
|
427
|
-
mosaic
|
|
426
|
+
mosaic = raster.create_mosaic([
|
|
428
427
|
(output_tile, self.read(output_tile))
|
|
429
428
|
for output_tile in output_tiles
|
|
430
429
|
])
|
|
431
|
-
return raster.extract_from_array(mosaic, affine, tile)
|
|
430
|
+
return raster.extract_from_array(mosaic.data, mosaic.affine, tile)
|
|
432
431
|
elif self.config.output.METADATA["data_type"] == "vector":
|
|
433
432
|
return list(chain.from_iterable([
|
|
434
433
|
self.read(output_tile) for output_tile in output_tiles
|
|
@@ -526,7 +525,7 @@ class Mapchete(object):
|
|
|
526
525
|
return self.config.output.empty(process_tile)
|
|
527
526
|
|
|
528
527
|
def _streamline_output(self, process_data):
|
|
529
|
-
if isinstance(process_data,
|
|
528
|
+
if isinstance(process_data, str) and (
|
|
530
529
|
process_data == "empty"
|
|
531
530
|
):
|
|
532
531
|
raise MapcheteNodataTile
|
|
@@ -562,7 +561,7 @@ class Mapchete(object):
|
|
|
562
561
|
)
|
|
563
562
|
# resample from children tiles
|
|
564
563
|
elif baselevel == "lower":
|
|
565
|
-
mosaic
|
|
564
|
+
mosaic = raster.create_mosaic([
|
|
566
565
|
(
|
|
567
566
|
child_tile,
|
|
568
567
|
self.get_raw_output(child_tile, _baselevel_readonly=True)
|
|
@@ -572,8 +571,8 @@ class Mapchete(object):
|
|
|
572
571
|
).get_children()
|
|
573
572
|
])
|
|
574
573
|
process_data = raster.resample_from_array(
|
|
575
|
-
in_raster=mosaic,
|
|
576
|
-
in_affine=
|
|
574
|
+
in_raster=mosaic.data,
|
|
575
|
+
in_affine=mosaic.affine,
|
|
577
576
|
out_tile=tile,
|
|
578
577
|
resampling=self.config.baselevels["lower"],
|
|
579
578
|
nodataval=self.config.output.nodata
|
|
@@ -691,7 +690,7 @@ class MapcheteProcess(object):
|
|
|
691
690
|
tiled input data : InputTile
|
|
692
691
|
reprojected input data within tile
|
|
693
692
|
"""
|
|
694
|
-
if not isinstance(input_id,
|
|
693
|
+
if not isinstance(input_id, str):
|
|
695
694
|
return input_id.open(self.tile, **kwargs)
|
|
696
695
|
if input_id not in self.params["input"]:
|
|
697
696
|
raise ValueError("%s not found in config as input file" % input_id)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/index.cpython-35.pyc
ADDED
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/main.cpython-35.pyc
ADDED
|
Binary file
|
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/serve.cpython-35.pyc
ADDED
|
Binary file
|
|
Binary file
|
home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/utils.cpython-35.pyc
ADDED
|
Binary file
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Create dummy Mapchete and python process files."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from string import Template
|
|
5
|
+
from shutil import copyfile
|
|
6
|
+
from yaml import dump
|
|
7
|
+
import pkg_resources
|
|
8
|
+
|
|
9
|
+
FORMAT_MANDATORY = {
|
|
10
|
+
"GTiff": {
|
|
11
|
+
"bands": None,
|
|
12
|
+
"dtype": None
|
|
13
|
+
},
|
|
14
|
+
"PNG": {
|
|
15
|
+
"bands": None,
|
|
16
|
+
"dtype": None
|
|
17
|
+
},
|
|
18
|
+
"PNG_hillshade": {
|
|
19
|
+
"bands": 4,
|
|
20
|
+
"dtype": "uint8"
|
|
21
|
+
},
|
|
22
|
+
"GeoJSON": {
|
|
23
|
+
"schema": {}
|
|
24
|
+
},
|
|
25
|
+
"PostGIS": {
|
|
26
|
+
"schema": {},
|
|
27
|
+
"db_params": {
|
|
28
|
+
"host": None,
|
|
29
|
+
"port": None,
|
|
30
|
+
"db": None,
|
|
31
|
+
"user": None,
|
|
32
|
+
"password": None,
|
|
33
|
+
"table": None
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def create_empty_process(args):
|
|
40
|
+
"""
|
|
41
|
+
Create an empty Mapchete and process file in a given directory.
|
|
42
|
+
|
|
43
|
+
``Namespace`` object should have the following attributes:
|
|
44
|
+
* process_file : name of the python file
|
|
45
|
+
* mapchete_file : name of the mapchete process configuration file
|
|
46
|
+
* out_format : optional output format
|
|
47
|
+
* out_path : optional output path
|
|
48
|
+
* pyramid_type : optional output type
|
|
49
|
+
* force : if True, it will replace already existing files
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
args : argparse.Namespace
|
|
54
|
+
"""
|
|
55
|
+
if os.path.isfile(args.process_file) or os.path.isfile(args.mapchete_file):
|
|
56
|
+
if not args.force:
|
|
57
|
+
raise IOError("file(s) already exists")
|
|
58
|
+
|
|
59
|
+
out_path = args.out_path if args.out_path else os.path.join(
|
|
60
|
+
os.getcwd(), "output")
|
|
61
|
+
|
|
62
|
+
# copy process file template to target directory
|
|
63
|
+
process_template = pkg_resources.resource_filename(
|
|
64
|
+
"mapchete.static", "process_template.py")
|
|
65
|
+
process_file = os.path.join(os.getcwd(), args.process_file)
|
|
66
|
+
copyfile(process_template, process_file)
|
|
67
|
+
|
|
68
|
+
# modify and copy mapchete file template to target directory
|
|
69
|
+
mapchete_template = pkg_resources.resource_filename(
|
|
70
|
+
"mapchete.static", "mapchete_template.mapchete")
|
|
71
|
+
|
|
72
|
+
output_options = {
|
|
73
|
+
'format': args.out_format,
|
|
74
|
+
'path': out_path}
|
|
75
|
+
output_options.update(FORMAT_MANDATORY[args.out_format])
|
|
76
|
+
|
|
77
|
+
pyramid_options = {'grid': args.pyramid_type}
|
|
78
|
+
|
|
79
|
+
substitute_elements = {
|
|
80
|
+
'process_file': process_file,
|
|
81
|
+
'output': dump({'output': output_options}, default_flow_style=False),
|
|
82
|
+
'pyramid': dump({'pyramid': pyramid_options}, default_flow_style=False)
|
|
83
|
+
}
|
|
84
|
+
with open(mapchete_template, 'r') as config_template:
|
|
85
|
+
config = Template(config_template.read())
|
|
86
|
+
customized_config = config.substitute(substitute_elements)
|
|
87
|
+
with open(args.mapchete_file, 'w') as target_config:
|
|
88
|
+
target_config.write(customized_config)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Command line utility to execute a Mapchete process."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
import click_spinner
|
|
5
|
+
import logging
|
|
6
|
+
from multiprocessing import cpu_count
|
|
7
|
+
import os
|
|
8
|
+
from shapely import wkt
|
|
9
|
+
import sys
|
|
10
|
+
import tqdm
|
|
11
|
+
import yaml
|
|
12
|
+
|
|
13
|
+
import mapchete
|
|
14
|
+
from mapchete.cli import utils
|
|
15
|
+
from mapchete.config import get_zoom_levels, _map_to_new_config
|
|
16
|
+
from mapchete.index import zoom_index_gen
|
|
17
|
+
from mapchete.tile import BufferedTilePyramid
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# workaround for https://github.com/tqdm/tqdm/issues/481
|
|
21
|
+
tqdm.monitor_interval = 0
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@click.command(help="Execute a process.")
|
|
27
|
+
@utils.arg_mapchete_files
|
|
28
|
+
@utils.opt_zoom
|
|
29
|
+
@utils.opt_bounds
|
|
30
|
+
@utils.opt_point
|
|
31
|
+
@utils.opt_wkt_geometry
|
|
32
|
+
@utils.opt_tile
|
|
33
|
+
@utils.opt_overwrite
|
|
34
|
+
@utils.opt_multi
|
|
35
|
+
@utils.opt_input_file
|
|
36
|
+
@utils.opt_logfile
|
|
37
|
+
@utils.opt_verbose
|
|
38
|
+
@utils.opt_no_pbar
|
|
39
|
+
@utils.opt_debug
|
|
40
|
+
@utils.opt_max_chunksize
|
|
41
|
+
@utils.opt_vrt
|
|
42
|
+
@utils.opt_idx_out_dir
|
|
43
|
+
def execute(
|
|
44
|
+
mapchete_files,
|
|
45
|
+
zoom=None,
|
|
46
|
+
bounds=None,
|
|
47
|
+
point=None,
|
|
48
|
+
wkt_geometry=None,
|
|
49
|
+
tile=None,
|
|
50
|
+
overwrite=False,
|
|
51
|
+
multi=None,
|
|
52
|
+
input_file=None,
|
|
53
|
+
logfile=None,
|
|
54
|
+
verbose=False,
|
|
55
|
+
no_pbar=False,
|
|
56
|
+
debug=False,
|
|
57
|
+
max_chunksize=None,
|
|
58
|
+
vrt=False,
|
|
59
|
+
idx_out_dir=None
|
|
60
|
+
):
|
|
61
|
+
"""Execute a Mapchete process."""
|
|
62
|
+
multi = multi if multi else cpu_count()
|
|
63
|
+
mode = "overwrite" if overwrite else "continue"
|
|
64
|
+
# send verbose output to /dev/null if not activated
|
|
65
|
+
if debug or not verbose:
|
|
66
|
+
verbose_dst = open(os.devnull, 'w')
|
|
67
|
+
else:
|
|
68
|
+
verbose_dst = sys.stdout
|
|
69
|
+
|
|
70
|
+
for mapchete_file in mapchete_files:
|
|
71
|
+
|
|
72
|
+
tqdm.tqdm.write("preparing to process %s" % mapchete_file, file=verbose_dst)
|
|
73
|
+
|
|
74
|
+
with click_spinner.spinner(disable=debug) as spinner:
|
|
75
|
+
|
|
76
|
+
def _raw_conf():
|
|
77
|
+
return _map_to_new_config(
|
|
78
|
+
yaml.load(open(mapchete_file, "r").read())
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def _tp():
|
|
82
|
+
return BufferedTilePyramid(
|
|
83
|
+
_raw_conf()["pyramid"]["grid"],
|
|
84
|
+
metatiling=_raw_conf()["pyramid"].get("metatiling", 1),
|
|
85
|
+
pixelbuffer=_raw_conf()["pyramid"].get("pixelbuffer", 0)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# process single tile
|
|
89
|
+
if tile:
|
|
90
|
+
tile = _tp().tile(*tile)
|
|
91
|
+
with mapchete.open(
|
|
92
|
+
mapchete_file, mode=mode, bounds=tile.bounds,
|
|
93
|
+
zoom=tile.zoom, single_input_file=input_file
|
|
94
|
+
) as mp:
|
|
95
|
+
spinner.stop()
|
|
96
|
+
tqdm.tqdm.write("processing 1 tile")
|
|
97
|
+
for result in mp.batch_processor(tile=tile):
|
|
98
|
+
utils.write_verbose_msg(result, dst=verbose_dst)
|
|
99
|
+
|
|
100
|
+
if vrt:
|
|
101
|
+
tqdm.tqdm.write("creating VRT")
|
|
102
|
+
for tile in tqdm.tqdm(
|
|
103
|
+
zoom_index_gen(
|
|
104
|
+
mp=mp,
|
|
105
|
+
zoom=tile.zoom,
|
|
106
|
+
out_dir=(
|
|
107
|
+
idx_out_dir if idx_out_dir else mp.config.output.path
|
|
108
|
+
),
|
|
109
|
+
vrt=vrt,
|
|
110
|
+
),
|
|
111
|
+
total=mp.count_tiles(tile.zoom, tile.zoom),
|
|
112
|
+
unit="tile",
|
|
113
|
+
disable=debug
|
|
114
|
+
):
|
|
115
|
+
logger.debug(tile)
|
|
116
|
+
|
|
117
|
+
# initialize and run process
|
|
118
|
+
else:
|
|
119
|
+
if wkt_geometry:
|
|
120
|
+
bounds = wkt.loads(wkt_geometry).bounds
|
|
121
|
+
elif point:
|
|
122
|
+
x, y = point
|
|
123
|
+
zoom_levels = get_zoom_levels(
|
|
124
|
+
process_zoom_levels=_raw_conf()["zoom_levels"],
|
|
125
|
+
init_zoom_levels=zoom
|
|
126
|
+
)
|
|
127
|
+
bounds = _tp().tile_from_xy(x, y, max(zoom_levels)).bounds
|
|
128
|
+
else:
|
|
129
|
+
bounds = bounds
|
|
130
|
+
with mapchete.open(
|
|
131
|
+
mapchete_file, bounds=bounds, zoom=zoom,
|
|
132
|
+
mode=mode, single_input_file=input_file
|
|
133
|
+
) as mp:
|
|
134
|
+
spinner.stop()
|
|
135
|
+
tiles_count = mp.count_tiles(
|
|
136
|
+
min(mp.config.init_zoom_levels),
|
|
137
|
+
max(mp.config.init_zoom_levels))
|
|
138
|
+
tqdm.tqdm.write(
|
|
139
|
+
"processing %s tile(s) on %s worker(s)" % (tiles_count, multi)
|
|
140
|
+
)
|
|
141
|
+
for process_info in tqdm.tqdm(
|
|
142
|
+
mp.batch_processor(
|
|
143
|
+
multi=multi, zoom=zoom,
|
|
144
|
+
max_chunksize=max_chunksize),
|
|
145
|
+
total=tiles_count,
|
|
146
|
+
unit="tile",
|
|
147
|
+
disable=debug or no_pbar
|
|
148
|
+
):
|
|
149
|
+
utils.write_verbose_msg(process_info, dst=verbose_dst)
|
|
150
|
+
|
|
151
|
+
if vrt:
|
|
152
|
+
tqdm.tqdm.write("creating VRT(s)")
|
|
153
|
+
for z in mp.config.init_zoom_levels:
|
|
154
|
+
logger.debug("zoom %s", z)
|
|
155
|
+
for tile in tqdm.tqdm(
|
|
156
|
+
zoom_index_gen(
|
|
157
|
+
mp=mp,
|
|
158
|
+
zoom=z,
|
|
159
|
+
out_dir=(
|
|
160
|
+
idx_out_dir if idx_out_dir
|
|
161
|
+
else mp.config.output.path
|
|
162
|
+
),
|
|
163
|
+
vrt=vrt
|
|
164
|
+
),
|
|
165
|
+
total=mp.count_tiles(z, z),
|
|
166
|
+
unit="tile",
|
|
167
|
+
disable=debug
|
|
168
|
+
):
|
|
169
|
+
logger.debug(tile)
|
|
170
|
+
|
|
171
|
+
tqdm.tqdm.write("process finished", file=verbose_dst)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Create index for process output."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
import click_spinner
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from shapely import wkt
|
|
8
|
+
import sys
|
|
9
|
+
import tqdm
|
|
10
|
+
import yaml
|
|
11
|
+
|
|
12
|
+
import mapchete
|
|
13
|
+
from mapchete.cli import utils
|
|
14
|
+
from mapchete.config import _map_to_new_config
|
|
15
|
+
from mapchete.index import zoom_index_gen
|
|
16
|
+
from mapchete.tile import BufferedTilePyramid
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# workaround for https://github.com/tqdm/tqdm/issues/481
|
|
20
|
+
tqdm.monitor_interval = 0
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@click.command(help="Create index of output tiles.")
|
|
26
|
+
@utils.arg_mapchete_files
|
|
27
|
+
@utils.opt_idx_out_dir
|
|
28
|
+
@utils.opt_geojson
|
|
29
|
+
@utils.opt_gpkg
|
|
30
|
+
@utils.opt_shp
|
|
31
|
+
@utils.opt_vrt
|
|
32
|
+
@utils.opt_txt
|
|
33
|
+
@utils.opt_fieldname
|
|
34
|
+
@utils.opt_basepath
|
|
35
|
+
@utils.opt_for_gdal
|
|
36
|
+
@utils.opt_zoom
|
|
37
|
+
@utils.opt_bounds
|
|
38
|
+
@utils.opt_wkt_geometry
|
|
39
|
+
@utils.opt_tile
|
|
40
|
+
@utils.opt_verbose
|
|
41
|
+
@utils.opt_debug
|
|
42
|
+
@utils.opt_logfile
|
|
43
|
+
def index(
|
|
44
|
+
mapchete_files,
|
|
45
|
+
idx_out_dir=None,
|
|
46
|
+
geojson=False,
|
|
47
|
+
gpkg=False,
|
|
48
|
+
shp=False,
|
|
49
|
+
vrt=False,
|
|
50
|
+
txt=False,
|
|
51
|
+
fieldname=None,
|
|
52
|
+
basepath=None,
|
|
53
|
+
for_gdal=False,
|
|
54
|
+
zoom=None,
|
|
55
|
+
bounds=None,
|
|
56
|
+
wkt_geometry=None,
|
|
57
|
+
tile=None,
|
|
58
|
+
verbose=False,
|
|
59
|
+
debug=False,
|
|
60
|
+
logfile=None
|
|
61
|
+
):
|
|
62
|
+
if not any([geojson, gpkg, shp, txt, vrt]):
|
|
63
|
+
raise click.MissingParameter(
|
|
64
|
+
"""At least one of '--geojson', '--gpkg', '--shp', '--vrt' or '--txt'"""
|
|
65
|
+
"""must be provided.""",
|
|
66
|
+
param_type="option"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# send verbose output to /dev/null if not activated
|
|
70
|
+
verbose_dst = open(os.devnull, 'w') if debug or not verbose else sys.stdout
|
|
71
|
+
|
|
72
|
+
for mapchete_file in mapchete_files:
|
|
73
|
+
tqdm.tqdm.write("create index for %s" % mapchete_file, file=verbose_dst)
|
|
74
|
+
with click_spinner.spinner(disable=debug) as spinner:
|
|
75
|
+
# process single tile
|
|
76
|
+
if tile:
|
|
77
|
+
conf = _map_to_new_config(
|
|
78
|
+
yaml.load(open(mapchete_file, "r").read()))
|
|
79
|
+
tile = BufferedTilePyramid(
|
|
80
|
+
conf["pyramid"]["grid"],
|
|
81
|
+
metatiling=conf["pyramid"].get("metatiling", 1),
|
|
82
|
+
pixelbuffer=conf["pyramid"].get("pixelbuffer", 0)
|
|
83
|
+
).tile(*tile)
|
|
84
|
+
with mapchete.open(
|
|
85
|
+
mapchete_file, mode="readonly", bounds=tile.bounds,
|
|
86
|
+
zoom=tile.zoom
|
|
87
|
+
) as mp:
|
|
88
|
+
spinner.stop()
|
|
89
|
+
for tile in tqdm.tqdm(
|
|
90
|
+
zoom_index_gen(
|
|
91
|
+
mp=mp,
|
|
92
|
+
zoom=tile.zoom,
|
|
93
|
+
out_dir=idx_out_dir if idx_out_dir else mp.config.output.path,
|
|
94
|
+
geojson=geojson,
|
|
95
|
+
gpkg=gpkg,
|
|
96
|
+
shapefile=shp,
|
|
97
|
+
vrt=vrt,
|
|
98
|
+
txt=txt,
|
|
99
|
+
fieldname=fieldname,
|
|
100
|
+
basepath=basepath,
|
|
101
|
+
for_gdal=for_gdal
|
|
102
|
+
),
|
|
103
|
+
total=mp.count_tiles(tile.zoom, tile.zoom),
|
|
104
|
+
unit="tile",
|
|
105
|
+
disable=debug
|
|
106
|
+
):
|
|
107
|
+
logger.debug(tile)
|
|
108
|
+
|
|
109
|
+
else:
|
|
110
|
+
with mapchete.open(
|
|
111
|
+
mapchete_file,
|
|
112
|
+
mode="readonly",
|
|
113
|
+
zoom=zoom,
|
|
114
|
+
bounds=wkt.loads(wkt_geometry).bounds if wkt_geometry else bounds
|
|
115
|
+
) as mp:
|
|
116
|
+
spinner.stop()
|
|
117
|
+
logger.debug("process bounds: %s", mp.config.init_bounds)
|
|
118
|
+
logger.debug("process zooms: %s", mp.config.init_zoom_levels)
|
|
119
|
+
logger.debug("fieldname: %s", fieldname)
|
|
120
|
+
for z in mp.config.init_zoom_levels:
|
|
121
|
+
logger.debug("zoom %s", z)
|
|
122
|
+
for tile in tqdm.tqdm(
|
|
123
|
+
zoom_index_gen(
|
|
124
|
+
mp=mp,
|
|
125
|
+
zoom=z,
|
|
126
|
+
out_dir=(
|
|
127
|
+
idx_out_dir if idx_out_dir else mp.config.output.path
|
|
128
|
+
),
|
|
129
|
+
geojson=geojson,
|
|
130
|
+
gpkg=gpkg,
|
|
131
|
+
shapefile=shp,
|
|
132
|
+
vrt=vrt,
|
|
133
|
+
txt=txt,
|
|
134
|
+
fieldname=fieldname,
|
|
135
|
+
basepath=basepath,
|
|
136
|
+
for_gdal=for_gdal),
|
|
137
|
+
total=mp.count_tiles(z, z),
|
|
138
|
+
unit="tile",
|
|
139
|
+
disable=debug
|
|
140
|
+
):
|
|
141
|
+
logger.debug(tile)
|
|
142
|
+
|
|
143
|
+
tqdm.tqdm.write("index creation finished", file=verbose_dst)
|
|
@@ -7,7 +7,6 @@ import logging.config
|
|
|
7
7
|
import os
|
|
8
8
|
import pkgutil
|
|
9
9
|
from rasterio.io import MemoryFile
|
|
10
|
-
import six
|
|
11
10
|
|
|
12
11
|
import mapchete
|
|
13
12
|
from mapchete.cli import utils
|
|
@@ -76,7 +75,7 @@ def create_app(
|
|
|
76
75
|
for mapchete_file in mapchete_files
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
mp = next(
|
|
78
|
+
mp = next(iter(mapchete_processes.values()))
|
|
80
79
|
pyramid_type = mp.config.process_pyramid.grid
|
|
81
80
|
pyramid_srid = mp.config.process_pyramid.srid
|
|
82
81
|
process_bounds = ",".join([str(i) for i in mp.config.bounds_at_zoom()])
|
|
@@ -92,7 +91,7 @@ def create_app(
|
|
|
92
91
|
srid=pyramid_srid,
|
|
93
92
|
process_bounds=process_bounds,
|
|
94
93
|
is_mercator=(pyramid_srid == 3857),
|
|
95
|
-
process_names=
|
|
94
|
+
process_names=mapchete_processes.keys()
|
|
96
95
|
)
|
|
97
96
|
|
|
98
97
|
@app.route(
|