Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql PostGIS:从其他点查找一定半径内的点_Postgresql_Geospatial_Postgis - Fatal编程技术网

Postgresql PostGIS:从其他点查找一定半径内的点

Postgresql PostGIS:从其他点查找一定半径内的点,postgresql,geospatial,postgis,Postgresql,Geospatial,Postgis,我在PostgreSQL/PostGIS中有一个名为“trip”的表,其中有两个几何列:“source_geom”(“POINT”)和“destination_geom”(“POINT”)指示旅程的开始和结束位置 我还有一个单独的表名为“business”,其中的几何列“office_geom”(“POINT”)表示办公室的位置 我的目标是从表“trip”中选择记录,其目的地距离任何办公地点都在1000米以内 我需要启动什么查询才能获得所需的结果?可以使用子查询或联接来完成。使用子查询的示例:

我在PostgreSQL/PostGIS中有一个名为“trip”的表,其中有两个几何列:“source_geom”(“POINT”)和“destination_geom”(“POINT”)指示旅程的开始和结束位置

我还有一个单独的表名为“business”,其中的几何列“office_geom”(“POINT”)表示办公室的位置

我的目标是从表“trip”中选择记录,其目的地距离任何办公地点都在1000米以内


我需要启动什么查询才能获得所需的结果?

可以使用子查询或联接来完成。使用子查询的示例:

SELECT * FROM business 
WHERE EXISTS(
    SELECT 1 FROM trip
    WHERE ST_Distance_Sphere(trip.destination_geom, business.office_geom) < 1000
)
select * 
  from business b
  join trip t on ST_DWithin(trip.destination_geogr, business.office_geogr, 1000)