Search a table for Point in Polygon using MySQL

后端 未结 2 723
梦如初夏
梦如初夏 2021-02-09 06:03

I have create a table (municipal_border), in MySQL 5.5, that holds some boundaries.

CREATE TABLE `municipal_border` (
  `boundary` polygon NOT NULL,
  `municipal         


        
2条回答
  •  情歌与酒
    2021-02-09 06:51

    Solution of Pavlos Papanikolaou is wonderfull. In my case Table : TestPoly and column : pol Insert Query

    SET @g = 'POLYGON((22.367582117085913 70.71181669186944, 22.225161442616514 70.65582486840117, 22.20736264867434 70.83229276390898, 22.18701840565626 70.9867880031668, 22.22452581029355 71.0918447658621, 22.382709129816103 70.98884793969023, 22.40112042636022 70.94078275414336, 22.411912121843205 70.7849142238699, 22.367582117085913 70.71181669186944))';
    INSERT INTO TestPoly (pol) VALUES (ST_GeomFromText(@g))
    

    Select Query

    set @p = GeomFromText('POINT(22.4053386588057 70.86240663480157)');
    select * FROM TestPoly where ST_Contains(pol, @p);
    

提交回复
热议问题