I used osm2pgsql to import data into my PostgreSQL database and it put gave me the following 4 tables, planet_osm_point, planet_osm_line, planet_osm_polygon and planet_osm_roads.
I have looked at the schema for osm2pgsql and inside the planet_osm_point table there is a column 'way' of type point. I tried to query it as an array like it says in the documentation here (http://www.postgresql.org/docs/current/static/functions-geometry.html):
It is possible to access the two component numbers of a point as though the point were an array with indexes 0 and 1. For example, if t.p is a point column then SELECT p FROM t retrieves the X coordinate and UPDATE t SET p = ... changes the Y coordinate. In the same way, a value of type box or lseg can be treated as an array of two point values.
Anyone know the correct query the planet_osm tables from osm2pgsql based on long/lat? For example if I wanted to retrieve the information for Big Ben (London) I would query along the lines of:
SELECT * FROM planet_osm_point WHERE ST_Y(ST_Transform(way, 4326)) = '-0.12' AND ST_X(ST_Transform(way, 4326)) = '51.5';
There is no error message, it comes out with the table names, but no data is output either. (Its an empty table). What am I doing wrong here?
Perhaps it is too precise, i.e. there are no coordinates that match it exactly? Perhaps I need to try being more general, say 51 < long < 52 and -0.5 < lat < 0. Although this would throw back multiple results so would not be quite as accurate.