aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2023-09-27 23:41:23 +0200
committerGuilhem Moulin <guilhem@fripost.org>2023-09-28 00:23:05 +0200
commit41a98b7737428e3a691f00569e91ba1481180aff (patch)
treed336c16032178987767b39a19e68530e622b6d37
parentf9620eb43d8b97b249b908d06591399b05f167a6 (diff)
--topo-basedir: Default to the value from the configuration file.
-rwxr-xr-xgis-observation-map42
1 files changed, 22 insertions, 20 deletions
diff --git a/gis-observation-map b/gis-observation-map
index 62e5642..c5889e4 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -68,7 +68,7 @@ parser = argparse.ArgumentParser(
%(prog)s {--geometry=FILE|--point=X,Y} ...'''
)
parser.add_argument('--margin', type=int, help='Margin (in meters) from geometry envelopes')
-parser.add_argument('--topo-basedir', default='.', help='Base directory for "Topografi 10", "Topografi 50", etc.')
+parser.add_argument('--topo-basedir', default=config['QGIS']['topo-basedir'], help='Base directory for "Topografi 10", "Topografi 50", etc.')
parser.add_argument('--project-name', help='Project filename (and title)')
parser.add_argument('--project-home', help='Project home directory')
parser.add_argument('--geometry', nargs='*', default=[], help='Geometry filename(s)')
@@ -667,7 +667,7 @@ searchFilter['taxon'] = {
getObservations(taxonLists, taxonRedlistCategories, searchFilter)
topo_maps = ['Topografi 10', 'Topografi 50', 'Topografi 100']
-if projectInstance is not None:
+if args.topo_basedir is not None:
basedir = Path(args.topo_basedir)
basedir = basedir.expanduser()
@@ -704,7 +704,7 @@ if projectInstance is not None:
qlr_paths.append(qlr_path)
- if len(qlr_paths) > 0:
+ 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)
@@ -723,22 +723,24 @@ if projectInstance is not None:
lyr.setFlags(QgsMapLayer.Removable)
rootGroup.setExpanded(False)
- maxScale = 1
- for topo in topo_maps:
- minScale = None
- if topo == 'Topografi 10':
- minScale = 50000
- elif topo == 'Topografi 50':
- minScale = 100000
- elif topo == 'Topografi 100':
- minScale = 10000000
-
- if minScale is not None:
- for lt in QgsProject.instance().layerTreeRoot().findGroup(topo).findLayers():
- lyr = lt.layer()
- lyr.setScaleBasedVisibility(True)
- lyr.setMinimumScale(minScale)
- lyr.setMaximumScale(maxScale)
- maxScale = minScale
+ if projectInstance is not None:
+ maxScale = 1
+ for topo in topo_maps:
+ minScale = None
+ if topo == 'Topografi 10':
+ minScale = 50000
+ elif topo == 'Topografi 50':
+ minScale = 100000
+ elif topo == 'Topografi 100':
+ minScale = 10000000
+
+ if minScale is not None:
+ for lt in QgsProject.instance().layerTreeRoot().findGroup(topo).findLayers():
+ lyr = lt.layer()
+ lyr.setScaleBasedVisibility(True)
+ lyr.setMinimumScale(minScale)
+ lyr.setMaximumScale(maxScale)
+ maxScale = minScale
+if projectInstance is not None:
projectInstance.write()