aboutsummaryrefslogtreecommitdiffstats
path: root/gis-observation-map
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2023-09-27 18:39:26 +0200
committerGuilhem Moulin <guilhem@fripost.org>2023-09-27 18:39:26 +0200
commite71199db931894a32c855554c1410b4305c18926 (patch)
treee1e907870aae239d991ac0277e332a37b072dce6 /gis-observation-map
parent991f99e6c7f98d7febc94f3a9d38065cfb146d17 (diff)
Without --geometry, set extent on the first --point ± --margin.
Diffstat (limited to 'gis-observation-map')
-rwxr-xr-xgis-observation-map11
1 files changed, 10 insertions, 1 deletions
diff --git a/gis-observation-map b/gis-observation-map
index 19dabd3..e2740c7 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -36,7 +36,9 @@ from qgis.core import (
QgsLayerDefinition,
QgsLayerTreeModel,
QgsMapLayer,
+ QgsPointXY,
QgsProject,
+ QgsRectangle,
QgsUnitTypes,
QgsVectorLayer,
QgsWkbTypes
@@ -152,7 +154,6 @@ if projectInstance is not None:
#layerTreeView.setCurrentLayer(layer)
canvas = QgsMapCanvas()
canvas.setExtent( layer.extent() )
- canvas.refresh()
def gpkg_intersects(path, geometries):
ds = gpkg_drv.Open(path, update=0)
@@ -266,6 +267,14 @@ for path in args.geometry:
geometries.append(geometry)
feature = layer.GetNextFeature()
+if len(args.geometry) == 0:
+ r = geometries[0].GetGeometryRef(0)
+ pt0X, pt0Y = r.GetPoint_2D(0)
+ pt1X, pt1Y = r.GetPoint_2D(2)
+ canvas = QgsMapCanvas()
+ extent = QgsRectangle(QgsPointXY(pt0X, pt0Y), QgsPointXY(pt1X, pt1Y))
+ canvas.setExtent(extent)
+
def geometricFilterPolygon(polygon):
polygon2 = []
if polygon.GetGeometryType() != ogr.wkbPolygon: