Yes, GEOS support is built in. OGRGeometryFactory::haveGEOS() returns
true, and the within/contains functions will return true when testing a point vs. some (non-LinearRing) geometry.<br><br>Test code demonstrating that within/contains never returns true with two nested, non-identical, closed LineStrings:
<br><br> /* a clockwise square starting at (1,2) (closed) */<br> double x1[] = {1, 2, 2, 1, 1};<br> double y1[] = {2, 2, 1, 1, 2};<br> <br> /* a clockwise square starting at (0,3) (closed) */<br> double x2[] = {0, 3, 3, 0, 0};
<br> double y2[] = {3, 3, 0, 0, 3};<br> <br> OGRLineString inner;<br> inner.setPoints(5, x1, y1);<br> <br> OGRLineString outer;<br> outer.setPoints(5, x2, y2);<br> <br> std::cout << "**********************************************" << std::endl;
<br> std::cout << "inner.Contains(&outer): " << inner.Contains(&outer) << std::endl;<br> std::cout << "inner.Within(&outer): " << inner.Within(&outer) << std::endl;
<br> std::cout << "outer.Contains(&inner): " << outer.Contains(&inner) << std::endl;<br> std::cout << "outer.Within(&inner): " << outer.Within(&inner) << std::endl;
<br><br>Results:<br>**********************************************<br>inner.Contains(&outer): 0<br>inner.Within(&outer): 0<br>outer.Contains(&inner): 0<br>outer.Within(&inner): 0<br><br><br><div><span class="gmail_quote">
On 9/23/07, <b class="gmail_sendername">Mateusz Loskot</b> <<a href="mailto:mateusz@loskot.net">mateusz@loskot.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dan Homerick wrote:<br>> Hello List-Readers,<br>><br>> I notice that the within/contains functions don't work for LinearRing's<br>> (as is indicated in the documentation for rings), but they also don't work
<br>> with two LineStrings (not mentioned, that I see).<br><br>Dan,<br><br>You should know that spatial predicates are implemented using GEOS,<br>so you have to built GDAL/OGR with GEOS support in order to use them.<br>
<br>If this is not the case here and you already have GEOS support in OGR,<br>could you provide us with examples of geometries you're testing and<br>perhaps some code example?<br><br>> Is the best/only way to test if one ring is nested in another to convert
<br>> the LinearRings to LineStrings, then test each point of 'inner' for<br>> containment in 'outer'?<br><br>Yes, I believe OGC predicates (within, contains, etc.) are the best tools<br>to solve this problem.
<br><br>Cheers<br>--<br>Mateusz Loskot<br><a href="http://mateusz.loskot.net">http://mateusz.loskot.net</a><br></blockquote></div><br>