Hi, <br><br>Thanks for the answer.<br><br>> OGRPoint querypoint = OGRPoint(Point.x_, Point.y_);<br>
> querypoint.assignSpatialReference(new OGRSpatialReference(SrWkt.c_str()));<br><br><span id="result_box" class="short_text" lang="en"><span class="hps">It</span> <span class="hps">is</span> <span class="hps">not necessary</span></span> to transform the query point because the Point is at the same spatial reference system. <br>
<br>> pgeometry->Intersects(pquerypoly)<br><br>Intersects perform a transformation to verify the intersection of the geometries? The two geometries (the one that came from the point and the other that want to intersect) have two different spatial reference systems. <br>
<br>point -> EPSG 4326 (GEO)<br>other geometry -> (WGS 84 /
> UTM zone 21S) (PROJ)<br><br>Thanks,<br>Regards,<br><br><br><div class="gmail_quote">2012/9/4 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le mardi 04 septembre 2012 23:04:16, Gabriel Fusca a écrit :<br>
<div><div class="h5">> Hi,<br>
><br>
> I'm using Gdal 1.9.<br>
><br>
> I have a function that has to perform a intersection of a geometry based on<br>
> the click that is made on the screen.<br>
><br>
> The raster file (Geotiff) that has a projected reference system (WGS 84 /<br>
> UTM zone 21S) and the geometry a georeferenced system (EPSG - 4326 WGS84).<br>
><br>
> The click that comes from the screen (spatial reference of the image)<br>
> create a geometry from calling point.Buffer (radius).<br>
><br>
> When i want to verify that the geometries intersect the intersects method<br>
> from OGRGeometry fails, even if the querypoint is transformed into the<br>
> spatial reference system of the geometry.<br>
><br>
> Envelopes from the 2 geometries.<br>
> QueryPoint<br>
> env.<br>
> if i generates the querypoint from the spatial reference of the geometry<br>
> that i want to intersect)<br>
> minx -61.66, maxx -53.66;<br>
> miny -41.97, maxy -33.97<br>
> else<br>
> minx 443322.50, maxx 443330.50<br>
> miny 5798153.59, maxy 5798161.59<br>
><br>
> Geometry env.<br>
> minx -57.79, maxx -57.59;<br>
> miny -38.08, maxy-37.92<br>
><br>
><br>
> The code is something like this:<br>
><br>
> // spatialfilterwindow image subset transformed into<br>
> // the spatial reference of the vector to intersect<br>
> Extent spatialfilter(spatialfilterwindow);<br>
> player->SetSpatialFilterRect(spatialfilter.min_.x_,<br>
> spatialfilter.min_.y_,<br>
> spatialfilter.max_.x_,<br>
> spatialfilter.max_.y_);<br>
> OGRLayer* player = ...;<br>
> OGRFeature *pfeature = player->GetNextFeature();<br>
> OGRPoint querypoint = OGRPoint(Point.x_, Point.y_);<br>
> querypoint.assignSpatialReference(new OGRSpatialReference(SrWkt.c_str()));<br>
> OGRGeometry* pquerypoly = querypoint.Buffer(radius);<br>
</div></div>> *while *(pfeature) {<br>
<div class="im">> OGRGeometry *pgeometry = pfeature->GetGeometryRef();<br>
</div>> *if *((pgeometry && pgeometry->Intersects(pquerypoly) == TRUE)<br>
<div class="im">><br>
> || (pquerypoly && pquerypoly->Intersects(pgeometry) == TRUE)) {<br>
><br>
> // do something...<br>
</div>> } *else *{<br>
<div class="im">> // handle the intersection fail<br>
> }<br>
> pfeature = player->GetNextFeature();<br>
> }<br>
><br>
> Any idea why it fails?<br>
<br>
</div>I suspect that you assumed assignSpatialReference() would do the reprojection,<br>
which isn't the case (it just blindly assigns the specified SRS, but doesn't<br>
alter the geometry coordinates). You must use the TransformTo() method<br>
instead.<br>
<br>
Incidental comment : you don't need to test ( A->Insersects(B) || B-<br>
>Insersects(A)). Intersects() is a symetrical operation, so just one test will<br>
be enough.<br>
<br>
><br>
> Thanks,<br>
> Regards,<br>
</blockquote></div><br><br clear="all"><br>-- <br><span><font color="#888888">Gabriel Fusca<br>SUR Emprendimientos Tecnológicos<br><br>Perú 345 Piso 5to Oficina "B" (C1067AAG)<br>Ciudad de Buenos Aires, Argentina<br>
Tel. +54 (11) 4342-2976/84<br><a href="mailto:gabrielfusca@suremptec.com.ar" target="_blank">gabrielfusca@suremptec.com.ar</a><br><a href="http://www.suremptec.com/" target="_blank">http://www.suremptec.com/</a><br></font></span><br>