[gdal-dev] Problems with OGRGeometry Intersects

Gabriel Fusca gabrielfusca at suremptec.com.ar
Tue Sep 4 14:08:33 PDT 2012


Sorry, I forget to say that I built Gdal with GEOS

2012/9/4 Gabriel Fusca <gabrielfusca at suremptec.com.ar>

> Hi,
>
> I'm using Gdal 1.9.
>
> I have a function that has to perform a intersection of a geometry based
> on the click that is made on the screen.
>
> The raster file (Geotiff) that has a projected reference system (WGS 84 /
> UTM zone 21S)  and the geometry a georeferenced system (EPSG - 4326 WGS84).
>
> The click that comes from the screen (spatial reference of the image)
> create a geometry from calling point.Buffer (radius).
>
> When i want to verify that the geometries intersect the intersects method
> from OGRGeometry fails, even if the querypoint is transformed into the
> spatial reference system of the geometry.
>
> Envelopes from the 2 geometries.
> QueryPoint
> env.
> if i generates the querypoint from the spatial reference of the geometry
> that i want to intersect)
> minx -61.66, maxx -53.66;
> miny -41.97, maxy -33.97
> else
> minx 443322.50, maxx 443330.50
> miny 5798153.59, maxy 5798161.59
>
> Geometry env.
> minx -57.79, maxx -57.59;
> miny -38.08, maxy-37.92
>
>
> The code is something like this:
>
> // spatialfilterwindow image subset transformed into
> // the spatial reference of the vector to intersect
> Extent spatialfilter(spatialfilterwindow);
> player->SetSpatialFilterRect(spatialfilter.min_.x_,
>                             spatialfilter.min_.y_,
>                             spatialfilter.max_.x_,
>                             spatialfilter.max_.y_);
> OGRLayer* player = ...;
> OGRFeature *pfeature = player->GetNextFeature();
> OGRPoint querypoint = OGRPoint(Point.x_, Point.y_);
> querypoint.assignSpatialReference(new OGRSpatialReference(SrWkt.c_str()));
> OGRGeometry* pquerypoly = querypoint.Buffer(radius);
>  *while *(pfeature) {
>     OGRGeometry *pgeometry = pfeature->GetGeometryRef();
>     *if *((pgeometry && pgeometry->Intersects(pquerypoly) == TRUE)
>         || (pquerypoly && pquerypoly->Intersects(pgeometry) == TRUE)) {
>         // do something...
>     } *else *{
>         // handle the intersection fail
>     }
>     pfeature = player->GetNextFeature();
> }
>
> Any idea why it fails?
>
> Thanks,
> Regards,
>
> --
> Gabriel Fusca
> SUR Emprendimientos Tecnológicos
>
> Perú 345  Piso 5to Oficina "B" (C1067AAG)
> Ciudad de Buenos Aires, Argentina
> Tel. +54 (11) 4342-2976/84
> gabrielfusca at suremptec.com.ar
> http://www.suremptec.com/
>
>


-- 
Gabriel Fusca
SUR Emprendimientos Tecnológicos

Perú 345  Piso 5to Oficina "B" (C1067AAG)
Ciudad de Buenos Aires, Argentina
Tel. +54 (11) 4342-2976/84
gabrielfusca at suremptec.com.ar
http://www.suremptec.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120904/bcafc80d/attachment.html>


More information about the gdal-dev mailing list