Point that is part of way does not intersect way

If you're wondering why a point that is obviously part of a way does not intersect the way, it's because coordinates are stored differently in planet_osm_point vs. planet_osm_line.

Case in point, a subway station drawn as a node on a subway railway is reported by postgis as not intersecting the railway.

Screenshot of JOSM showing a subway station on a subway railway

The apparent cause is that, when saving coordinates in planet_osm_line, osm2pgsql rounds them to two decimal places (I've only checked for SRID 900913):


openmapdb=# select st_asewkt(way) from planet_osm_point where osm_id = 293317918;
SRID=900913;POINT(2905477.18172046 5539892.28016006)
(1 row)



openmapdb=# select st_asewkt(way) from planet_osm_line where osm_id = 45736605;
SRID=900913;LINESTRING([..]2905477.18 5539892.28


The side effect of this rounding is that st_intersects applied to the point and the line will return false because the distance difference caused by the rounding is larger then the margin used by the intersection function.