Tai,<br><br>You can use the spatial filter of the ogr layer to filter the point features to speed things up. You will still have to test if the point is within the polygon but it will be faster.<br><br>Also, make sure the test is like point->Within(polygon) and not polygon->Within(point)<br>
<br>OGRLayer::SetSpatialFilter()<br><a href="http://www.gdal.org/ogr/classOGRLayer.html#a0b4ab45cf97cbc470f0d60474d3e4169">http://www.gdal.org/ogr/classOGRLayer.html#a0b4ab45cf97cbc470f0d60474d3e4169</a><br><br><div class="gmail_quote">
On Fri, Jul 20, 2012 at 9:29 AM, Bui Chi Tai <span dir="ltr"><<a href="mailto:taibc_coltech@yahoo.com" target="_blank">taibc_coltech@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div><span>Chaitanya,</span></div><div><br><span></span></div><div><span>I am checking my code. Maybe it is not successful because I used two different layers (of one file).</span></div>
<div><br><span></span></div><div><span>As you know, one .dgn files only has one layer, that include many features, and Texts (Point Geometry), Polygons are treated as features.</span></div><div><span>My idea is: <br></span></div>
<div><span>First, I will read each feature to identify whether this feature is a polygon. Then, I need to use a loop to read and check all features of layer to identify whether a Text (point) is belong to that polygon. But, this will affect to the first reading times, and give unexpected result.</span></div>
<div><br></div><div>Do you have any ideas ?</div><div><br></div><div>Thanks and
 regards,</div><div><br>Tai<br><span></span></div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div dir="ltr">
 <font face="Arial"><div class="im"> <hr size="1">  <b><span style="font-weight:bold">From:</span></b> Chaitanya kumar CH <<a href="mailto:chaitanya.ch@gmail.com" target="_blank">chaitanya.ch@gmail.com</a>><br> </div>
<b><span style="font-weight:bold">To:</span></b> Bui Chi Tai <<a href="mailto:taibc_coltech@yahoo.com" target="_blank">taibc_coltech@yahoo.com</a>> <br> <b><span style="font-weight:bold">Sent:</span></b> Friday, July 20, 2012 10:39 AM<div>
<div class="h5"><br> <b><span style="font-weight:bold">Subject:</span></b> Re: [gdal-dev] How to identify a point is belong to a polygon ?<br> </div></div></font> </div><div><div class="h5"> <br>
<div>Tai,<br><br>I don't understand why it would happen. Can you provide some more details? Code, data?<br><br><div>On Fri, Jul 20, 2012 at 9:05 AM, Bui Chi Tai <span dir="ltr"><<a rel="nofollow" href="mailto:taibc_coltech@yahoo.com" target="_blank">taibc_coltech@yahoo.com</a>></span> wrote:<br>

<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div><span>Thanks Chaitanya,</span></div>
<div><br><span></span></div><div><span>I am trying to use this method. But, it is not successful. <br></span></div><div><br></div><div>For example: One file .dgn includes Text (treated as a point geometry) and Shapes (Polygon).</div>

<div><br></div><div>I used the method OGRGeometry::Within(OGRGeometry * other) to identify whether the Text is belong to the polygon. But it doesn't return an expected result (Actually, there are some texts that belong to each polygon).</div>

<div><br></div><div>Kind regards,</div><div><br></div><div>Tai<br><div><span></span></div></div><div><div><br></div>  </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div> </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div> <div dir="ltr"> <font face="Arial"> <hr size="1">  <b><span style="font-weight:bold">From:</span></b> Chaitanya kumar CH <<a rel="nofollow" href="mailto:chaitanya.ch@gmail.com" target="_blank">chaitanya.ch@gmail.com</a>><br>

 <b><span style="font-weight:bold">To:</span></b> taibc <<a rel="nofollow" href="mailto:taibc_coltech@yahoo.com" target="_blank">taibc_coltech@yahoo.com</a>> <br><b><span style="font-weight:bold">Cc:</span></b> <a rel="nofollow" href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a> <br>

 <b><span style="font-weight:bold">Sent:</span></b> Friday, July 20, 2012 10:11 AM<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [gdal-dev] How to identify a point is belong to a polygon ?<br> </font> </div>

</div><div><div> <br>
<div>Tai,<br><br>You can use OGR_G_Within()<br>OGR_G_WIthin(point,polygon) will return true if the point is within the polygon.<br><br>You can access various other geometry functions from the OGRGeometry class.<br><br><a href="http://www.gdal.org/ogr/ogr__api_8h.html#a80ba9e516ccae381ae7240cc9684eb72" target="_blank">http://www.gdal.org/ogr/ogr__api_8h.html#a80ba9e516ccae381ae7240cc9684eb72</a><br>


<br><div>On Fri, Jul 20, 2012 at 7:04 AM, taibc <span dir="ltr"><<a rel="nofollow" href="mailto:taibc_coltech@yahoo.com" target="_blank">taibc_coltech@yahoo.com</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi everyone,<br>
<br>
Do you know how to identify whether a point (OGRPoint) is belong to a<br>
polygon (OGRPolygon) ? (the polygon covers the point)<br>
<br>
Thanks and regards,<br>
<br>
Tai<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/How-to-identify-a-point-is-belong-to-a-polygon-tp4989501.html" target="_blank">http://osgeo-org.1560.n6.nabble.com/How-to-identify-a-point-is-belong-to-a-polygon-tp4989501.html</a><br>



Sent from the GDAL - Dev mailing list archive at <a rel="nofollow" href="http://nabble.com/" target="_blank">Nabble.com</a>.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a rel="nofollow" href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br><a rel="nofollow">+91-9494447584</a><br>17.2416N 80.1426E<br>
</div><br><br> </div></div></div> </div>  </div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br><a href="tel:%2B91-9494447584" value="+919494447584" target="_blank">+91-9494447584</a><br>
17.2416N 80.1426E<br>
</div><br><br> </div></div></div> </div>  </div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>