Question

I have found the following mysql spatial functions which can check a given lattitude and longtitude is inside the polygon or not.

1 - MBR_Contains

2 - MBR_Within

Please guide me, which will give fast and accurate result to check a given point is inside or outside of the polygon in MySql server by the query itself.

Also Suggest me, If you found any better solution than this ( It should be checked by query in Mysql Server.)?

Regards, ArunRaj

Was it helpful?

Solution

They're likely the same (in terms of speed), but you should run your own tests using both functions.

That said, Assuming you can use MySQL 5.6.1, you should refrain from the MBR functions and use the ST functions:

ST_Contains()
ST_Within()

The reason, MBR stands for minimum bounding rectangle, therefore a point can be within the minimum bounding rectangle, but not actually within the Polygon. The ST methods are exact to the shape and will give you a more precise answer.

Edit, Addressing which one should I use? I believe you can use either as you're testing a point within a polygon, but again test on a point you know to be in a polygon for safety.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top