Skip to content

Commit

Permalink
[Archive.select] do not accept multi-feature vectorobjects (instead o…
Browse files Browse the repository at this point in the history
…f just selecting the first feature for search)
  • Loading branch information
johntruckenbrodt committed Jul 22, 2024
1 parent a044cf1 commit dd12dfa
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 dd12dfa

Please sign in to comment.