我一直在使用MBRWithin功能很多次.突然我在谷歌地图上注意到这个POINT(101.11857 4.34475)是我指定的地理围栏之外但它仍然在mysql中给出值1任何原因或需要调整?
SELECT MBRWithin(GeomFromText( ‘POINT(101.11857 4.34475)’),GeomFromText(‘POLYGON((101.12112522125244 4.3531723687957164,101.11846446990967 4.351417913665312,101.13138198852539 4.336397898951581,101.13477230072021 4.33211863778494,101.14065170288086 4.321933898868271,101.14992141723633 4.306699328215635,101.15455627441406 4.30978050198082,101.1397933959961 4.334600612212089,101.12112522125244 4.3531723687957164,101.12112522125244 4.3531723687957164) ))))作为geoFenceStatus
解决方法:
除了仅在MBR上运行的早期函数之外,MySQL 5.6.1及更高版本还具有精确的几何算法.
您可以使用ST_WITHIN而不是MBR_WITHIN.见documentation.喜欢这个
SELECT ST_Within(GeomFromText('POINT(101.11857 4.34475)'),
GeomFromText('POLYGON((101.12112522125244 4.3531723687957164,101.11846446990967
4.351417913665312,101.13138198852539 4.336397898951581,101.13477230072021
4.33211863778494,101.14065170288086 4.321933898868271,101.14992141723633
4.306699328215635,101.15455627441406 4.30978050198082,101.1397933959961
4.334600612212089,101.12112522125244 4.3531723687957164,101.12112522125244
4.3531723687957164))')) As geoFenceStatus