<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Kedar Deshpande wrote:
<blockquote
cite="mid:CA+_hAHfsaM-PVEn5nV_qAxwSEP0h3RVn1MX=EA9dTHMV6Cs4OQ@mail.gmail.com"
type="cite">Thanks David, it is now clear to me why do we get multiple
features.
<div>So, for example, if we have a small zipcode which is kind of
embedded in a large zipcode of 'L' shape, for any point inside the
inner zipcode, it will return both zipcodes since the envelope of the L
zipcode always overlaps the inner one. (real example : zipcodes 98367
and 98359)</div>
<div><br>
</div>
<div>
<div>So, instead of comparing only the envelope overlap, is it not
possible to check the overlap of that specific polygon shape? so that
the result would be more accurate. The feature should have the polygon
information, right ? .. Is there a way to filter it out based on its
shape (not just rectangular envelope), in this library?</div>
</div>
</blockquote>
As Frank mentioned before not without linking in the geos library.
Otherwise what you can do is test to see if your point is in any of the
polygons returned by OGR. So let OGR do the initial checks then grab
the vertices yourself and run a point in polygon test. There are
multiple examples of the crossings test available on the web search for
code point in polygon to see a bunch in google. Just pick the one
that's appropriate for whatever language you're using.<br>
<blockquote
cite="mid:CA+_hAHfsaM-PVEn5nV_qAxwSEP0h3RVn1MX=EA9dTHMV6Cs4OQ@mail.gmail.com"
type="cite">
<div>
<div>
<div><br>
<div class="gmail_quote">On Tue, Jun 12, 2012 at 11:34 AM, David J.
Bakeman <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dbakeman@comcast.net" target="_blank">dbakeman@comcast.net</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">I think a picture is needed
here so here is one with zip code boundary
polygons I emphasized the envelopes of the polygons near the purple
point and you can see that 3 of the envelopes (in yellow) are
intersected by the purple point and would all be returned by an
overlapped envelope test.<br>
<br>
<br>
<br>
Here I zoomed in<br>
<br>
<br>
<div>
<div><br>
<br>
<br>
kedardeshpande87 wrote:
<blockquote type="cite">
<pre>Frank,
Thank you very much for the reply.
I am still really curious about what could be the reason that it returns
multiple features for a single point.
The code for filtering which I have written is like this :
...
OGRDataSource *ds = OGRSFDriverRegistrar::Open("shapefile_path", FALSE);
OGRLayer *layer = ds->GetLayer(0);
OGRGeometry *g = new OGRPoint(longitude, latitude);
layer->SetSpatialFilter(g);
OGRFeature *feature = NULL;
while((feature = layer->GetNextFeature()) != NULL) {
// do something with feature ...
}
As per the API doc, it says : "it is guaranteed that all features who's
envelope (as returned by OGRGeometry::getEnvelope()) overlaps the envelope
of the spatial filter will be returned."
I checked the envelope the OGRPoint geometry I have created. This envelope
is also a single point (minX, maxX are same and minY, maxY are same). So,
how is it possible that multiple features overlap on the same point ?
For the same shapefile, I checked results by using some other libraries as
well. Those libraries return a single zipcode. So I am guessing the
shapefile which I am using does not have overlapping data.
Could it be that the vector math done while calculating the intersection of
filter-geometry and features has some limitations?
Could you please give me some idea about this ?
Thanks,
Kedar
--
View this message in context: <a moz-do-not-send="true"
href="http://osgeo-org.1560.n6.nabble.com/Re-Accuracy-of-OGRLayer-SetSpatialFilter-API-tp4980063p4980907.html"
target="_blank">http://osgeo-org.1560.n6.nabble.com/Re-Accuracy-of-OGRLayer-SetSpatialFilter-API-tp4980063p4980907.html</a>
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
<a moz-do-not-send="true" href="mailto:gdal-dev@lists.osgeo.org"
target="_blank">gdal-dev@lists.osgeo.org</a>
<a moz-do-not-send="true"
href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>