Skip to content

Commit

Permalink
Merge pull request #316 from johntruckenbrodt/bugfix/archive_select_f…
Browse files Browse the repository at this point in the history
…eatures

[Archive.select] do not accept multi-feature vectorobjects
  • Loading branch information
johntruckenbrodt committed Jul 23, 2024
2 parents 5f0a555 + 4513d25 commit 0ca33cb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyroSAR/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2957,7 +2957,7 @@ def select(self, vectorobject=None, mindate=None, maxdate=None, date_strict=True
Parameters
----------
vectorobject: :class:`~spatialist.vector.Vector` or None
a geometry with which the scenes need to overlap
a geometry with which the scenes need to overlap. The object may only contain one feature.
mindate: str or datetime.datetime or None
the minimum acquisition date; strings must be in format YYYYmmddTHHMMSS; default: None
maxdate: str or datetime.datetime or None
Expand Down Expand Up @@ -3029,14 +3029,15 @@ def select(self, vectorobject=None, mindate=None, maxdate=None, date_strict=True

if vectorobject:
if isinstance(vectorobject, Vector):
if vectorobject.nfeatures > 1:
raise RuntimeError("'vectorobject' contains more than one feature.")
with vectorobject.clone() as vec:
vec.reproject(4326)
site_geom = vec.convert2wkt(set3D=False)[0]
# postgres has a different way to store geometries
if self.driver == 'postgresql':
arg_format.append("st_intersects(geometry, 'SRID=4326; {}')".format(
site_geom
))
statement = f"st_intersects(geometry, 'SRID=4326; {site_geom}')"
arg_format.append(statement)
else:
arg_format.append('st_intersects(GeomFromText(?, 4326), geometry) = 1')
vals.append(site_geom)
Expand Down

0 comments on commit 0ca33cb

Please sign in to comment.