aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlist-observations88
1 files changed, 44 insertions, 44 deletions
diff --git a/list-observations b/list-observations
index be8961f..0a9764c 100755
--- a/list-observations
+++ b/list-observations
@@ -114,53 +114,53 @@ for k in ['since', 'until']:
setattr(args, k, d)
geometry = None
-for path in args.geometry:
- path = path.as_posix()
- ds = ogr.Open(path, update=0)
-
- layer = None
- for i in range(ds.GetLayerCount()):
- lyr = ds.GetLayerByIndex(i)
- if lyr.GetGeomType() in [ogr.wkbPolygon,
- ogr.wkbMultiPolygon,
- ogr.wkbPolygonM,
- ogr.wkbMultiPolygonM,
- ogr.wkbPolygonZM,
- ogr.wkbMultiPolygonZM,
- ogr.wkbPolygon25D,
- ogr.wkbMultiPolygon25D]:
- layer = lyr
- break
- if layer is None:
- raise Exception(f'{path}: does not have any layer of geometry type Polygon')
-
- source_srs = layer.GetSpatialRef()
- transform_srs = osr.CoordinateTransformation(source_srs, target_srs)
+if args.geometry is not None:
+ for path in args.geometry:
+ path = path.as_posix()
+ ds = ogr.Open(path, update=0)
+
+ layer = None
+ for i in range(ds.GetLayerCount()):
+ lyr = ds.GetLayerByIndex(i)
+ if lyr.GetGeomType() in [ogr.wkbPolygon,
+ ogr.wkbMultiPolygon,
+ ogr.wkbPolygonM,
+ ogr.wkbMultiPolygonM,
+ ogr.wkbPolygonZM,
+ ogr.wkbMultiPolygonZM,
+ ogr.wkbPolygon25D,
+ ogr.wkbMultiPolygon25D]:
+ layer = lyr
+ break
+ if layer is None:
+ raise Exception(f'{path}: does not have any layer of geometry type Polygon')
+
+ source_srs = layer.GetSpatialRef()
+ transform_srs = osr.CoordinateTransformation(source_srs, target_srs)
- feature = layer.GetNextFeature()
- while feature is not None:
- geom = feature.GetGeometryRef()
- geom = geom.Clone()
- geom.FlattenTo2D()
- geom.Transform(transform_srs)
-
- if geometry is None:
- geometry = ogr.Geometry(ogr.wkbMultiPolygon)
-
- geometryType = geom.GetGeometryType()
- if geometryType == ogr.wkbPolygon:
- geometry.AddGeometry(geom)
- elif geometryType == ogr.wkbMultiPolygon:
- for i in range(geom.GetGeometryCount()):
- geom2 = geom.GetGeometryRef(i)
- geometry.AddGeometry(geom2)
- else:
- raise Exception(f'Unsuported geometry {geometryType}')
feature = layer.GetNextFeature()
- layer = None
- ds = None
+ while feature is not None:
+ geom = feature.GetGeometryRef()
+ geom = geom.Clone()
+ geom.FlattenTo2D()
+ geom.Transform(transform_srs)
+
+ if geometry is None:
+ geometry = ogr.Geometry(ogr.wkbMultiPolygon)
+
+ geometryType = geom.GetGeometryType()
+ if geometryType == ogr.wkbPolygon:
+ geometry.AddGeometry(geom)
+ elif geometryType == ogr.wkbMultiPolygon:
+ for i in range(geom.GetGeometryCount()):
+ geom2 = geom.GetGeometryRef(i)
+ geometry.AddGeometry(geom2)
+ else:
+ raise Exception(f'Unsuported geometry {geometryType}')
+ feature = layer.GetNextFeature()
+ layer = None
+ ds = None
-if geometry is not None:
geometry = geometry.UnionCascaded()