topo_map_processor 0.1.12__tar.gz → 0.1.13__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.
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/PKG-INFO +1 -1
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/_version.py +2 -2
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/processor.py +44 -6
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/retile.py +3 -2
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/tile.py +1 -1
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/.gitignore +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/LICENSE +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/README.md +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/pyproject.toml +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/__init__.py +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/__init__.py +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/collect_bounds.py +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/retile_e2e.py +0 -0
- {topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: topo_map_processor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
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
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.1.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
31
|
+
__version__ = version = '0.1.13'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 1, 13)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -85,6 +85,8 @@ class TopoMapProcessor:
|
|
|
85
85
|
self.extents = extra.get('extents', None)
|
|
86
86
|
self.pixel_cutlines = extra.get('pixel_cutlines', [])
|
|
87
87
|
|
|
88
|
+
self.inset_pixel_cutlines = extra.get('inset_pixel_cutlines', None)
|
|
89
|
+
self.inset_inpaint_color = extra.get('inset_inpaint_color', (255, 255, 255))
|
|
88
90
|
# rotation related
|
|
89
91
|
self.auto_rotate_thresh = extra.get('auto_rotate_thresh', 0.0)
|
|
90
92
|
|
|
@@ -490,6 +492,10 @@ class TopoMapProcessor:
|
|
|
490
492
|
#cv2.imwrite('temp.jpg', img_strip)
|
|
491
493
|
|
|
492
494
|
line_poly_t = translate(line_poly, xoff=-bb[0], yoff=-bb[1])
|
|
495
|
+
# if empty then nothing to do
|
|
496
|
+
if line_poly_t.is_empty:
|
|
497
|
+
print('line poly empty, nothing to do')
|
|
498
|
+
return
|
|
493
499
|
mask = np.zeros(img_strip.shape[:2], dtype=np.uint8)
|
|
494
500
|
poly_coords = np.array([ [int(x[0]), int(x[1])] for x in line_poly_t.exterior.coords ])
|
|
495
501
|
cv2.fillPoly(mask, pts=[poly_coords], color=1)
|
|
@@ -767,7 +773,7 @@ class TopoMapProcessor:
|
|
|
767
773
|
map_contour = ctuples[map_inner_contour_idx][0]
|
|
768
774
|
|
|
769
775
|
return map_contour
|
|
770
|
-
|
|
776
|
+
|
|
771
777
|
def get_maparea(self):
|
|
772
778
|
workdir = self.get_workdir()
|
|
773
779
|
|
|
@@ -827,7 +833,6 @@ class TopoMapProcessor:
|
|
|
827
833
|
print('already rotated.. skipping rotation')
|
|
828
834
|
return
|
|
829
835
|
|
|
830
|
-
|
|
831
836
|
map_bbox, map_min_rect, _ = self.get_maparea()
|
|
832
837
|
_, _, angle = map_min_rect
|
|
833
838
|
if angle > 45:
|
|
@@ -1588,9 +1593,6 @@ class TopoMapProcessor:
|
|
|
1588
1593
|
self.remove_grid_lines()
|
|
1589
1594
|
from_file = workdir.joinpath('nogrid.jpg')
|
|
1590
1595
|
|
|
1591
|
-
ibox = self.get_sheet_ibox()
|
|
1592
|
-
print(ibox)
|
|
1593
|
-
|
|
1594
1596
|
crs_proj = self.get_crs_proj()
|
|
1595
1597
|
|
|
1596
1598
|
gcps = self.get_gcps()
|
|
@@ -1604,6 +1606,7 @@ class TopoMapProcessor:
|
|
|
1604
1606
|
creation_options = '-co TILED=YES -co COMPRESS=DEFLATE -co PREDICTOR=2'
|
|
1605
1607
|
perf_options = '--config GDAL_CACHEMAX 128 --config GDAL_NUM_THREADS ALL_CPUS'
|
|
1606
1608
|
|
|
1609
|
+
self.ensure_dir(workdir)
|
|
1607
1610
|
translate_cmd = f'gdal_translate {creation_options} {perf_options} {gcp_str} -a_srs "{crs_proj}" -of GTiff {str(from_file)} {str(georef_file)}'
|
|
1608
1611
|
self.run_external(translate_cmd)
|
|
1609
1612
|
|
|
@@ -1749,7 +1752,13 @@ class TopoMapProcessor:
|
|
|
1749
1752
|
reproj_options = f'-tps -ts 0 {self.warp_output_height} -r bilinear -t_srs "EPSG:3857"'
|
|
1750
1753
|
else:
|
|
1751
1754
|
res = self.get_resolution()
|
|
1752
|
-
|
|
1755
|
+
if res == 'auto':
|
|
1756
|
+
reproj_options = '-tps -r bilinear -t_srs "EPSG:3857"'
|
|
1757
|
+
else:
|
|
1758
|
+
if type(res) is not list:
|
|
1759
|
+
res = [res, res]
|
|
1760
|
+
reproj_options = f'-tps -tr {res[0]} {res[1]} -r bilinear -t_srs "EPSG:3857"'
|
|
1761
|
+
|
|
1753
1762
|
#nodata_options = '-dstnodata 0'
|
|
1754
1763
|
nodata_options = '-dstalpha'
|
|
1755
1764
|
perf_options = '-multi -wo NUM_THREADS=ALL_CPUS --config GDAL_CACHEMAX 1024 -wm 1024'
|
|
@@ -1772,6 +1781,22 @@ class TopoMapProcessor:
|
|
|
1772
1781
|
|
|
1773
1782
|
return sheet_ibox
|
|
1774
1783
|
|
|
1784
|
+
def inpaint_insets(self, img, inset_pixel_cutlines, inpaint_color):
|
|
1785
|
+
cv_img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
|
|
1786
|
+
|
|
1787
|
+
for inset_pixel_cutline in inset_pixel_cutlines:
|
|
1788
|
+
print(f'filling in inset with pixel cutline: {inset_pixel_cutline}')
|
|
1789
|
+
# Create a mask for the inset area
|
|
1790
|
+
mask = np.zeros(cv_img.shape[:2], dtype=np.uint8)
|
|
1791
|
+
pts = np.array([inset_pixel_cutline], dtype=np.int32)
|
|
1792
|
+
cv2.fillPoly(mask, pts, 255)
|
|
1793
|
+
# fill the area in cv_img with inpaint_color
|
|
1794
|
+
cv_img[mask == 255] = inpaint_color
|
|
1795
|
+
|
|
1796
|
+
inpainted_img = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)
|
|
1797
|
+
return Image.fromarray(inpainted_img)
|
|
1798
|
+
|
|
1799
|
+
|
|
1775
1800
|
def export_bounds_file(self):
|
|
1776
1801
|
bounds_dir = self.get_bounds_dir()
|
|
1777
1802
|
|
|
@@ -1800,6 +1825,7 @@ class TopoMapProcessor:
|
|
|
1800
1825
|
|
|
1801
1826
|
sheet_ibox = self.get_updated_sheet_ibox()
|
|
1802
1827
|
|
|
1828
|
+
self.ensure_dir(workdir)
|
|
1803
1829
|
self.warp_file(sheet_ibox, cutline_file, georef_file, final_file, self.warp_jpeg_export_quality)
|
|
1804
1830
|
|
|
1805
1831
|
def export_gtiff(self, filename, out_filename, jpeg_export_quality):
|
|
@@ -1825,12 +1851,24 @@ class TopoMapProcessor:
|
|
|
1825
1851
|
|
|
1826
1852
|
self.export_gtiff(str(final_file), str(export_file), self.jpeg_export_quality)
|
|
1827
1853
|
|
|
1854
|
+
def remove_insets(self):
|
|
1855
|
+
if self.inset_pixel_cutlines is None or len(self.inset_pixel_cutlines) == 0:
|
|
1856
|
+
return
|
|
1857
|
+
full_img = self.get_full_img()
|
|
1858
|
+
inpainted_img = self.inpaint_insets(full_img, self.inset_pixel_cutlines, self.inset_inpaint_color)
|
|
1859
|
+
workdir = self.get_workdir()
|
|
1860
|
+
inpainted_file = workdir.joinpath('full.jpg')
|
|
1861
|
+
self.ensure_dir(workdir)
|
|
1862
|
+
inpainted_img.save(inpainted_file)
|
|
1863
|
+
self.full_img = None
|
|
1864
|
+
|
|
1828
1865
|
|
|
1829
1866
|
def process(self):
|
|
1830
1867
|
export_file = self.get_export_file()
|
|
1831
1868
|
if export_file.exists():
|
|
1832
1869
|
return True
|
|
1833
1870
|
|
|
1871
|
+
self.remove_insets()
|
|
1834
1872
|
self.rotate()
|
|
1835
1873
|
|
|
1836
1874
|
# pause to debug
|
|
@@ -24,7 +24,8 @@ from osgeo_utils.gdal2tiles import (
|
|
|
24
24
|
DividedCache,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
-
from pmtiles_mosaic.tile_sources import create_source_from_paths
|
|
27
|
+
from pmtiles_mosaic.tile_sources import create_source_from_paths
|
|
28
|
+
from pmtiles_mosaic.tiles_common import MissingTileError
|
|
28
29
|
|
|
29
30
|
from .utils import relax_open_file_limit
|
|
30
31
|
|
|
@@ -84,7 +85,7 @@ class DiskTilesHandler:
|
|
|
84
85
|
print(f'deleted {delete_count} files at level {z}')
|
|
85
86
|
|
|
86
87
|
def save_metadata(self, metadata):
|
|
87
|
-
metadata_file = self.dir.joinpath('
|
|
88
|
+
metadata_file = self.dir.joinpath('metadata.json')
|
|
88
89
|
metadata_file.write_text(json.dumps(metadata, indent=2))
|
|
89
90
|
|
|
90
91
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/__init__.py
RENAMED
|
File without changes
|
{topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/collect_bounds.py
RENAMED
|
File without changes
|
{topo_map_processor-0.1.12 → topo_map_processor-0.1.13}/topo_map_processor/tools/retile_e2e.py
RENAMED
|
File without changes
|
|
File without changes
|