geopoly_contains_point

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

geopoly_contains_point

Jens Alfke-2
The geopoly docs says that only the geopoly_overlap(P1,P2) and geopoly_within(P1,P2) functions are optimized to use the R-tree index when used as a WHERE test; so that means the geopoly_contains_point function is not.

This implies that, if I want to query for polygons containing a given point, I should avoid using the obvious function geopoly_contains_point; instead I should outset the point (by some epsilon) into a small rectangle, convert that to a polygon, and use one of the two optimized functions. Correct?

Which prompts the question of whether I can use epsilon=0; i.e. how do the overlap and within functions behave if one polygon is an empty (zero area) rectangle? Will they work correctly, or always return false?

—Jens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: geopoly_contains_point

Richard Hipp-3
On 9/13/18, Jens Alfke <[hidden email]> wrote:
> The geopoly docs says that only the geopoly_overlap(P1,P2) and
> geopoly_within(P1,P2) functions are optimized to use the R-tree index when
> used as a WHERE test; so that means the geopoly_contains_point function is
> not.
>
> This implies that, if I want to query for polygons containing a given point,
> I should avoid using the obvious function geopoly_contains_point; instead I
> should outset the point (by some epsilon) into a small rectangle, convert
> that to a polygon, and use one of the two optimized functions. Correct?

Correct.

>
> Which prompts the question of whether I can use epsilon=0; i.e. how do the
> overlap and within functions behave if one polygon is an empty (zero area)
> rectangle? Will they work correctly, or always return false?

I think a zero-area polygon will work.  But, honestly, I don't
remember writing a test case for that.   (Probably, I should go back
and add a few.)  Please try it and see what happens :-)

Do you have specific plans to use geopoly?  Is this new extension
meeting a specific need that you have?  Or are you just curious?

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users