在 mysql 中查找多边形或循环上的点的位置
find location of a point on a polygon or cycle in mysql
如何确定具有给定 (Latitude, Longitude) 的点是否位于由 (Latitude, Longitude) 列表定义的多边形内?
现在,如果我将形状保存为由(纬度、经度、半径)定义的圆,我该如何处理?
请解释这两种情况.... thanx
多边形是具有直边且最终连接未打开的形状。圈子不需要申请。他们是装腔作势者。
在时间允许的情况下进行出色的编辑。
编辑:
create table polyThing
(
id int auto_increment primary key,
boundary polygon not null
);
insert polyThing (boundary)
VALUES(
PolygonFromText(
'POLYGON((
9.190586853 45.464518970,
9.190602686 45.463993916,
9.191572471 45.464001929,
9.191613325 45.463884676,
9.192136130 45.463880767,
9.192111509 45.464095594,
9.192427961 45.464117804,
9.192417811 45.464112862,
9.192509035 45.464225851,
9.192493139 45.464371079,
9.192448471 45.464439002,
9.192387444 45.464477861,
9.192051402 45.464483037,
9.192012814 45.464643592,
9.191640825 45.464647090,
9.191622331 45.464506215,
9.190586853 45.464518970))'
)
);
insert polyThing (boundary)
select PolygonFromText(
"POLYGON
((
121.44842136764532 121.44842136764532,
121.45076025390631 31.221990825071376,
121.45402182006842 31.218366658611853,
121.45091045761114 31.217054584347302,
121.44842136764532 31.22119260287111
))
")
-- mysql 5.6.1 and later I believe:
select p.id, ST_Contains(p.boundary,GeomFromText('POINT(23.9999 38.224)'))
from polyThing p
-- older version
select p.id, Contains(p.boundary,GeomFromText('POINT(23.9999 38.224)'))
from polyThing p
select p.id, Contains(p.boundary,GeomFromText('POINT(121.44842136764532 121.44842136764532)'))
from polyThing p
GIS 空间
包含可能有效也可能无效。针对 5.6.1 及更高版本并使用 ST_Contains
如何确定具有给定 (Latitude, Longitude) 的点是否位于由 (Latitude, Longitude) 列表定义的多边形内? 现在,如果我将形状保存为由(纬度、经度、半径)定义的圆,我该如何处理? 请解释这两种情况.... thanx
多边形是具有直边且最终连接未打开的形状。圈子不需要申请。他们是装腔作势者。
在时间允许的情况下进行出色的编辑。
编辑:
create table polyThing
(
id int auto_increment primary key,
boundary polygon not null
);
insert polyThing (boundary)
VALUES(
PolygonFromText(
'POLYGON((
9.190586853 45.464518970,
9.190602686 45.463993916,
9.191572471 45.464001929,
9.191613325 45.463884676,
9.192136130 45.463880767,
9.192111509 45.464095594,
9.192427961 45.464117804,
9.192417811 45.464112862,
9.192509035 45.464225851,
9.192493139 45.464371079,
9.192448471 45.464439002,
9.192387444 45.464477861,
9.192051402 45.464483037,
9.192012814 45.464643592,
9.191640825 45.464647090,
9.191622331 45.464506215,
9.190586853 45.464518970))'
)
);
insert polyThing (boundary)
select PolygonFromText(
"POLYGON
((
121.44842136764532 121.44842136764532,
121.45076025390631 31.221990825071376,
121.45402182006842 31.218366658611853,
121.45091045761114 31.217054584347302,
121.44842136764532 31.22119260287111
))
")
-- mysql 5.6.1 and later I believe:
select p.id, ST_Contains(p.boundary,GeomFromText('POINT(23.9999 38.224)'))
from polyThing p
-- older version
select p.id, Contains(p.boundary,GeomFromText('POINT(23.9999 38.224)'))
from polyThing p
select p.id, Contains(p.boundary,GeomFromText('POINT(121.44842136764532 121.44842136764532)'))
from polyThing p
GIS 空间
包含可能有效也可能无效。针对 5.6.1 及更高版本并使用 ST_Contains