在我的PostGIS数据库(Postgres 8.4.1上的PostGIS 1.5)中,我有两个表:道路(由线串组成)和崩溃(由点组成)。我一直在尝试将每次撞车事故与道路相关联,但是在执行以下操作时遇到了问题:
SELECT ST_ClosestPoint(road.the_geom, crash.the_geom),
ST_Intersects(ST_ClosestPoint(road.the_geom, crash.the_geom), road.the_geom)
ST_Distance(ST_ClosestPoint(road.the_geom, crash.the_geom), crash.the_geom) AS distance
FROM
--Table crashes is already in SRID 4326
(SELECT the_geom FROM crashes WHERE gid = 360) as crash,
(SELECT ST_SetSrid(the_geom, 4326) as the_geom from roads) as road
ORDER BY distance;
该查询应该在每条道路上使用gid 360返回最接近崩溃的点,但是ST_Intersects函数对于第一个结果将返回false(所有道路上的真实最近点)。难道我做错了什么?还有另一种方法可以将撞车事故与最近的道路联系起来吗?