ST_Intersects在Where子句中无法正常工作

问题描述

MySQL版本5.7

我有两个多边形g1和g2:

SET @g1 = ST_GeomFromText(
'POLYGON ((-116.905361513607 33.73293352193649,-116.9113628095131 33.73277669453306,-116.9208047116671 33.73195459382199,-116.927685292699 33.73062425072543,-116.9463053973749 33.72802563743627,-116.9626354759477 33.72586824526348,-116.972084108725 33.72504206932912,-116.9870027158737 33.72215221500214,-117.0019242824137 33.71926025305943,-117.0145526317979 33.71681154263307,-117.0294799179214 33.71391563748596,-117.0367076958363 33.70950131718779,-117.0393418299309 33.70597834419039,-117.0431244579075 33.70223218289046,-117.0492042101544 33.69803949959092,-117.0509603806888 33.69569043681762,-117.0553507878002 33.68981753890825,-117.0577146008867 33.68534223965828,-117.0589298532709 33.68109017682149,-117.0621718797779 33.67543988287238,-117.0642654492901 33.67001280310896,-117.0649402382811 33.66385783512424,-117.0650074988621 33.65982902373219,-117.0646020361002 33.649868888629,-117.0638595655431 33.64298632688885,-117.0633877089637 33.63705507288445,-117.0640642791746 33.63090007301548,-117.0638629526051 33.62592006307725,-117.0631224288577 33.61903760069518,-117.0640696490949 33.61383368103444,-117.0638691967665 33.60885362882225,-117.0642082292823 33.60577598464116,-117.0634691445481 33.59889345198013,-117.0632694904639 33.59391332796482,-117.0642177760301 33.58870904016888,-117.0634799804067 33.58182636924709,-117.0618645110086 33.57611908123044,-117.0602496080225 33.57041180091893,-117.0578283172055 33.56185090199843,-117.056824239886 33.55401688170599,-117.0554801733519 33.54926078311808,-117.0552834893349 33.54428029155504,-117.0545498510444 33.53739722231765,-117.0518644347683 33.52788475856717,-117.0488388321793 33.52145047670857,-117.0460824802688 33.51596742109844,-117.0430587372128 33.50953306867492,-117.0409142639182 33.50192281137973,-117.0393065365662 33.4962150180591,-117.0376993447062 33.4905071305109,-117.0360926859404 33.4847991407006,-117.033875870665 33.4812184319962,-117.0297108019683 33.47500830250544,-117.023255505716 33.46924739414851,-117.0201622065276 33.46684256103002,-117.0128311837775 33.46225737261212,-117.002066345838 33.45834541662837,-116.9969519428303 33.45734051238559,-116.9958068786687 33.45756492080188,-116.9900817975096 33.45868673000007,-116.9797778583094 33.46070496940481,-116.9694754035503 33.46272191465278,-116.9648970378698 33.46361791427788,-116.9568856452849 33.46518529070001,-116.947997137755 33.46792677815127,-116.9422758377574 33.46904521292225,-116.9379653720826 33.47089077093343,-116.932431749164 33.47698729015495,-116.9308630803742 33.48431484224248,-116.9289494967652 33.49471814111455,-116.9266915158084 33.50819648986836,-116.9248574294785 33.51457126954573,-116.9226787831441 33.52402126416189,-116.9208450684796 33.53039519730267,-116.9176004304343 33.53604085240937,-116.914355836703 33.54168608639471,-116.9113779307052 33.54828166770296,-116.9107668110998 33.55040586697302,-116.9104223932621 33.55348078075288,-116.9108782504428 33.55940786321484,-116.9132796453807 33.56796446338452,-116.9132025125291 33.57198996079235,-116.9142703111631 33.57579285773488,-116.9141935107827 33.5798182762552,-116.9146509724134 33.58574508643454,-116.914574491597 33.58977041746245,-116.9147652493593 33.59474643575305,-116.9135440338263 33.59899408732088,-116.9123228159655 33.60324165968935,-116.9104911577778 33.60961282111595,-116.907857690728 33.61313171576128,-116.9020562440974 33.61826762642645,-116.8965983413608 33.62032886178638,-116.8931634116538 33.62099503479929,-116.8885837287388 33.62188307447293,-116.8785472432797 33.62483100027684,-116.871067852496 33.62828491627319,-116.8638556357057 33.63268869926113,-116.8603442241141 33.63737760029535,-116.8619452875601 33.64308117663063,-116.8643477857253 33.65163668303243,-116.8658734297924 33.66136455072436,-116.8667895352354 33.67321545122221,-116.8671721103925 33.68316522677639,-116.8695034888139 33.69574603664307,-116.8719117800724 33.70430291955341,-116.8740534332526 33.71190933539452,-116.8788300398806 33.71599941407348,-116.8824615631269 33.72031098190968,-116.8898004052813 33.72490931096673,-116.8943118308126 33.72804871165452,-116.8979460537637 33.73236057347037,-116.9036055174591 33.73527858192472,-116.9038740122949 33.73622959654575,-116.905361513607 33.73293352193649))');

SET @g2 = ST_GeomFromText(
'POLYGON((-117.05350995975127 33.675359910000005,-116.83677004024872 33.675359910000005,-116.83677004024872 33.85554009,-117.05350995975127 33.85554009,-117.05350995975127 33.675359910000005))');

案例1:当我在下面进行操作时:

SELECT ST_Intersects(@g1,@g2);

然后将其输出为“ 1”(这两个几何形状确实相交)

案例2 :执行查询时:

SELECT latitude,longitude,@g2:= ST_GeomFromText(
'POLYGON((-117.05350995975127 33.675359910000005,-117.05350995975127 33.675359910000005))'),ST_Intersects(@g1,@g2)
FROM 'spatial'
WHERE id=10001

然后它给出正确的结果,如下所示:

latitude           longitude         @g2    ST_Intersects(@g1,@g2) 

33.62483100027684 -116.905361513607  xxxxxx   1

案例3 :当我尝试执行以下查询时:

SELECT latitude,-117.05350995975127 33.675359910000005))') 
FROM 'spatial'
WHERE ST_Intersects(@g1,@g2) AND id=10001

然后给出空白输出。

案例4 :当我尝试执行以下查询时:

SELECT latitude,-117.05350995975127 33.675359910000005))')
FROM 'spatial'
WHERE ST_Intersects(@g1,@g2)=1 AND id=10001

然后它还会提供空白输出。

有人可以帮忙为什么ST_Intersects()在where查询中不起作用。

感谢任何想法。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...