mysql中判断一个矩形是否跟多边形有交集
答案:2 悬赏:60 手机版
解决时间 2021-02-09 05:00
- 提问者网友:容嬷嬷拿针来
- 2021-02-08 08:38
mysql中判断一个矩形是否跟多边形有交集
最佳答案
- 五星知识达人网友:一秋
- 2021-02-08 10:09
首先,建立一张简单的地理数据表,
[sql]
CREATE TABLE `ci_special_zone` (
`id` int(11) NOT NULL auto_increment,
`ploygongeo` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
并插入几条数据
[sql]
INSERT INTO ci_special_zone (ploygongeo) VALUES('POLYGON((113.547 22.186,113.549 22.186,113.549 22.188, 113.547 22.188,113.547 22.186))');
INSERT INTO ci_special_zone (ploygongeo) VALUES('POLYGON((112.547 21.186,112.549 212.186,112.549 21.188, 112.547 212.188,112.547 21.186))');
最后,执行如下的sql语句
[sql]
SELECt substring(ploygongeo,10,length(ploygongeo)-11) from ci_special_zone
where MBRContains(PolygonFromText(ploygongeo),PolygonFromText('Point(113.547 22.186)'))>0 limit 0,1
坐标点113.547 22.186是经纬度,若有返回值,则表示坐标点落在所在的区间。
[sql]
CREATE TABLE `ci_special_zone` (
`id` int(11) NOT NULL auto_increment,
`ploygongeo` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
并插入几条数据
[sql]
INSERT INTO ci_special_zone (ploygongeo) VALUES('POLYGON((113.547 22.186,113.549 22.186,113.549 22.188, 113.547 22.188,113.547 22.186))');
INSERT INTO ci_special_zone (ploygongeo) VALUES('POLYGON((112.547 21.186,112.549 212.186,112.549 21.188, 112.547 212.188,112.547 21.186))');
最后,执行如下的sql语句
[sql]
SELECt substring(ploygongeo,10,length(ploygongeo)-11) from ci_special_zone
where MBRContains(PolygonFromText(ploygongeo),PolygonFromText('Point(113.547 22.186)'))>0 limit 0,1
坐标点113.547 22.186是经纬度,若有返回值,则表示坐标点落在所在的区间。
全部回答
- 1楼网友:千夜
- 2021-02-08 11:36
也许是的。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯