Parse within a specified polygon area using mysql decision points
This article is mainly about parsing in a designated polygon area using mysql decision points. You can check the relevant professional terms on the Internet or find some related books to supplement them. Here, we will not dabble in it and go straight to the topic. I hope it can bring you some practical help.
1. Create a test table
CREATE TABLE `zone` (`id` int (10) unsigned NOT NULL AUTO_INCREMENT, `polygongeo` polygon NOT NULL, PRIMARY KEY (`id`)) ENGINE=MYISAM DEFAULT CHARSET=utf8
Note: spatial indexes can only be created in tables where the storage engine is MYISAM
two。 Insert polygonal data insert into zone (polygongeo) values (POLYGONFROMTEXT ('POLYGON (11-5-5-5-5-1-1); 3. Determine whether the point is in the polygonal area
Test POINT (3,4)
Select AsText (polygongeo) from zone where MBRWithin (POLYGONFROMTEXT ('POINT (3 4)'), polygongeo)
Output: POLYGON ((1, 1, 5, 5, 5, 5, 5, 1, 1))
Indicates that the point POINT (3,4) is in the polygon region.
Test POINT (6, 1)
Select AsText (polygongeo) from zone where MBRWithin (POLYGONFROMTEXT ('POINT (61)'), polygongeo)
Output: empty
Indicates that the point POINT (6,1) is outside the polygon region.
Summary: mysql spatial query is not very suitable for map coordinates, so map coordinates can be queried using mongodb. Refer to: "mongodb's method to determine whether the coordinates are within a specified polygon area"
This article explains whether to judge whether the point is within the specified polygon area by mysql. Please pay attention to more related content.
Related recommendations:
How to call php imagemagick to achieve the effect of old photos
An explanation on the Cartesian Product of php Computing multiple sets
On the use and performance Analysis of php File containing Directory configuration open_basedir
Use the mysql decision point to parse in the designated polygon area and that's it. If you want to know about other related issues, you can continue to follow our industry information. Our section will capture some industry news and professional knowledge to share with you every day.