aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgis-observation-map73
1 files changed, 54 insertions, 19 deletions
diff --git a/gis-observation-map b/gis-observation-map
index 96eacfa..11f4473 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -819,26 +819,55 @@ if args.topo_basedir is not None and projectInstance is not None:
idxContains = {}
for topo in topo_maps:
qlr_paths = []
+ qlr_merged = None
d = args.topo_basedir.joinpath(topo)
if not d.is_dir():
continue
- if args.project_home is not None:
- l = args.project_home.joinpath(topo)
- l.symlink_to(d, target_is_directory=True)
- d = l
-
idx = d.joinpath('index.geojson')
if idx.is_file():
tiles, idxContains[topo] = idx_intersects(idx.as_posix(), geometries)
- for tile in tiles:
- t = d.joinpath(tile)
- qlr_path = find_qlr(t)
+ if len(tiles) == 0:
+ continue
+
+ if args.project_home is None:
+ for tile in tiles:
+ t = d.joinpath(tile)
+ qlr_path = find_qlr(t)
+ if qlr_path is None:
+ continue
+ qlr_paths.append(qlr_path)
+ else:
+ t0 = d.joinpath(tiles[0])
+ qlr_path = find_qlr(d)
if qlr_path is None:
continue
- qlr_paths.append(qlr_path)
+
+ d2 = args.project_home.joinpath(topo)
+ d2.mkdir(mode=0o755, exist_ok=True)
+ d2.joinpath(qlr_path.name).symlink_to(qlr_path, target_is_directory=False)
+ qlr_merged = d2.joinpath(qlr_path.name)
+
+ gpkgs = set()
+ for tile in tiles:
+ for gpkg in d.joinpath(tile).glob('*.gpkg'):
+ gpkgs.add(gpkg.name)
+
+ for gpkg in gpkgs:
+ dst = d2.joinpath(gpkg)
+ if dst.exists():
+ raise Exception(f'{dst}: file exists')
+ for tile in tiles:
+ src = d.joinpath(tile).joinpath(gpkg)
+ if src.is_file():
+ gdal.VectorTranslate(dst.as_posix(), src.as_posix(), format='GPKG', accessMode='upsert')
else:
+ if args.project_home is not None:
+ l = args.project_home.joinpath(topo)
+ l.symlink_to(d, target_is_directory=True)
+ d = l
+
for t in sorted(d.glob('*')):
qlr_path = find_qlr(t)
if qlr_path is None:
@@ -855,15 +884,22 @@ if args.topo_basedir is not None and projectInstance is not None:
qlr_paths.append(qlr_path)
- if projectInstance is not None and len(qlr_paths) > 0:
- rootGroup = layerTreeRoot.addGroup(topo)
- for qlr_path in qlr_paths:
- QgsLayerDefinition.loadLayerDefinition(qlr_path.as_posix(), projectInstance, rootGroup)
- lyrSubTree = rootGroup.children()
- if len(lyrSubTree) == len(qlr_paths):
- for i, lt in enumerate(lyrSubTree):
- name = qlr_paths[i].parent.stem
- lt.setName(name)
+ if projectInstance is not None:
+ if qlr_merged is not None:
+ QgsLayerDefinition.loadLayerDefinition(qlr_merged.as_posix(), projectInstance, layerTreeRoot)
+ lt = layerTreeRoot.children()[-1]
+ lt.setName(topo)
+ lyrSubTree = [lt]
+ elif len(qlr_paths) > 0:
+ rootGroup = layerTreeRoot.addGroup(topo)
+ for qlr_path in qlr_paths:
+ QgsLayerDefinition.loadLayerDefinition(qlr_path.as_posix(), projectInstance, rootGroup)
+ lyrSubTree = rootGroup.children()
+ rootGroup.setExpanded(False)
+ if len(lyrSubTree) == len(qlr_paths):
+ for i, lt in enumerate(lyrSubTree):
+ name = qlr_paths[i].parent.stem
+ lt.setName(name)
for lt in lyrSubTree:
lt.setExpanded(False)
lt.setItemVisibilityChecked(True)
@@ -872,7 +908,6 @@ if args.topo_basedir is not None and projectInstance is not None:
lyr = lyr.layer()
lyr.setReadOnly(True)
lyr.setFlags(QgsMapLayer.Removable)
- rootGroup.setExpanded(False)
if projectInstance is not None:
maxScale = 1