简体   繁体   English

选择POINT()的100米半径内的所有点

[英]Select all points that are within a 100 metre radius of a POINT()

I have a table in a database with over a million geospatial points that we'll call 'flags' . 我在数据库中有一个表,其中包含超过一百万个地理空间点,我们将其称为“标志” I also have a feed of live 'vehicles' which report their latitude and longitude positions. 我还提供了一些实时“车辆”的提要,其中报告了它们的纬度和经度位置。

Every time a vehicle's position comes through I need to run code that does this: 每当车辆进入位置时,我都需要运行执行此操作的代码:

Select all flags that are within a 100 metre radius of this vehicle's position. 选择距离该车辆位置半径100米以内的所有标志

Is this possible with SQL? SQL可能吗? If so how could I go about doing it? 如果是这样,我该怎么做呢?

Should be doable using the formula 应该可以使用公式

(x-center_x)^2 + (y - center_y)^2 < radius^2

You have all the component parts to do 您需要完成所有组成部分

SELECT foo
  FROM point p
 WHERE (((p.x - vehicle.x) * (p.x - vehicle.x)) + ((p.y - vehicle.y) * (p.y - vehicle.y))) < 1000

Or somethign like that, I've taken a few syntax punts 或类似的东西,我采取了一些语法措施

Check these resources: 检查以下资源:

  1. Selecting points within a bounding circle -- gives detailed information about optimal solution: select rectangular area and then filter out points that do not fall into the circle inside that square; 选择边界圆内的点 -提供有关最佳解决方案的详细信息:选择矩形区域,然后过滤掉不落入该正方形内圆的点;
  2. Select coordinates which fall within a radius of a central point? 选择落在中心点半径内的坐标? -- similar question on stackoverflow. -关于stackoverflow的类似问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM