我正在使用这个工具 Drawing Tool places为了在 map 内绘制位置,我试图获取覆盖用户位置的位置。
例如:
每个形状都有 long/lat 数组,我已经将它们添加到 places 表中,例如橙色形状数组是:
cursel: polygon [object Object]; pos: undefined ; path: [ 53.750107,-1.459851 , 53.750842,-1.461568 , 53.749954,-1.461825 , 53.749751,-1.464272 , 53.749117,-1.466203 , 53.748812,-1.469336 , 53.742493,-1.466074 , 53.738686,-1.46337 , 53.739143,-1.4538 , 53.740539,-1.45247 , 53.746985,-1.452899 , 53.749345,-1.455903 , 53.749218,-1.458092 ,
用户位置是:53.746858,-1.46513
** 放置表记录:**
placeId | long | lat
1 | 53.750919 | -1.471567
1 | 53.749675 | -1.473541
1 | 53.749066 | -1.472383
........
2 | 53.750107 | -1.459851
2 | 53.750842 | -1.461568
2 | 53.749954 | -1.461825
2 | 53.749751 | -1.464272
.......
我正在做这个查询:
select * from places where lat > '$lat' AND long < '$long'
这是表格结构:
//Place Name and ID
CREATE TABLE IF NOT EXISTS `place` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name ` varchar(70) NOT NULL
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
//Place Long/Lat borders <<-- here where i store the Array of long/lat of the place after it being draw
CREATE TABLE IF NOT EXISTS `places` (
`id` int(10) unsigned NOT NULL,
`lat ` varchar(70) NOT NULL,
`long ` varchar(70) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
My problem with mysql query how to get the correct place within its range if its cover user location
非常感谢任何想法
最佳答案
select * from places where lat > '$lat' AND long < '$long'
只检查是否位于 [$lat, $long] 的西北部。因此,它或它的任何变体可能对这个问题毫无用处。
在 the_polygon
上创建一个 SPATIAL
索引。
使用 WHERE ST_Within(user_point, the_polygon)
查看用户是否在多边形中。
如果您需要更多帮助,请提供SHOW CREATE TABLE
,以便我们在上下文中进行讨论。
关于用户位置自定义绘图工具中的mysql google maps查询存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48365512/