我有一个MySQL空间搜索的奇怪行为.
我在GEOM字段(葡萄牙边界)中创建了一个多边形,然后我试图在里面找到一个点 – 它被发现没问题.
下一个尝试是找到一个多边形之外的点,但查询仍然返回1找到的行.
请帮忙,我做错了什么?为什么在多边形外面找到一个点?
用于测试的sql代码如下:
@H_419_14@CREATE table IF NOT EXISTS `test` ( `ID` int(11) NOT NulL auto_INCREMENT,`bounds` geometry NOT NulL,PRIMARY KEY (`ID`)) ENGINE=InnoDB DEFAulT CHARSET=utf8 auto_INCREMENT=1 ;INSERT INTO `test` (`ID`,`bounds`) VALUES (null,GEOMFROMTEXT('polyGON((-8.876953125 41.8695608269946,-8.7451171875 41.9839942709356,-8.63525390625 42.0656067540572,-8.162841796875 42.1389684045809,-8.0859375 42.0248136078178,-8.23974609375 41.8859210281474,-8.15185546875 41.8204550961403,-7.899169921875 41.918628865183,-7.40478515625 41.8204550961403,-7.174072265625 41.9104534766642,-7.130126953125 42.0003251483162,-6.52587890625 41.951319946797,-6.50390625 41.6811175629065,-6.15234375 41.590796851056,-6.427001953125 41.2695495028426,-6.646728515625 41.2282490151853,-6.85546875 41.0296433871664,-6.8115234375 40.3549167507906,-7.03125 40.2334119071151,-6.866455078125 40.0213046873971,-6.9927978515625 39.687110247163,-7.53936767578125 39.6125651748163,-7.34024047851563 39.4820504550432,-7.22969055175781 39.1871628720445,-6.96533203125 39.0618491342915,-7.064208984375 38.8824811975508,-7.27294921875 38.7198047426424,-7.31689453125 38.3890334067591,-7.0751953125 38.2295504553262,-6.92550659179688 38.223077534953,-6.98799133300781 37.9994092820024,-7.20428466796875 37.9831748335134,-7.5421142578125 37.5707052423312,-7.44873046875 37.1953305828007,-7.91015625 36.985003092856,-8.32763671875 37.1252862849668,-8.63525390625 37.1340453712645,-8.98681640625 37.0025526721596,-8.7945556640625 37.6098799437471,-8.89617919921875 37.9463634508748,-8.800048828125 38.2295504553262,-8.90167236328125 38.5116391414586,-9.2230224609375 38.4320766853821,-9.23675537109375 38.6705005336435,-9.5361328125 38.7112325389523,-9.349365234375 39.364032338048,-8.8330078125 40.1956590933647,-8.822021484375 40.5096228495967,-8.61328125 41.0710691308064,-8.843994140625 41.4303718826528,-8.876953125 41.8695608269946))'));
http://i.crisp-studio.cz/i/080e83c5bd3f3a27c3ecab9086a3.png
内:
@H_419_14@SELECT *FROM `test`WHERE CONTAINS(`bounds`,geomfromtext('Point(-8.050232 39.882343)'))
外:
@H_419_14@SELECT *FROM `test`WHERE CONTAINS(`bounds`,geomfromtext('Point(-6.663208 40.05495)'))
http://i.crisp-studio.cz/i/33b1115ef912647e82fead98abd1.png最佳答案CONTAINS函数不搜索精确的对象形状.它使用多边形周围的边界矩形.
您可以尝试使用MysqL 5.6.1中的ST_CONTAINS函数
Functions That Test Spatial Relationships Between Geometries 总结
以上是内存溢出为你收集整理的MySQL Spatial CONTAINS显示错误的结果全部内容,希望文章能够帮你解决MySQL Spatial CONTAINS显示错误的结果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)