using openstreetmap data (in a postgis database), I would like to highlight all roads with a certain surface
tag in tilemill.
I can query for the tag, doing
SELECT * FROM planet_osm_ways WHERE 'cobblestone'=any(tags)
which returns id
, nodes
, tags
:
24204652 {262087470,262087665,262087666} {highway,residential,maxspeed,30,name,Landréstraße,postal_code,12621,surface,cobblestone}
...
I'm not sure how to proceed though, as tilemill expects geometry. I suppose, I somehow have to look up each id in nodes
and combine everything to lines(?).
update:
I think I managed to make linestrings from node coordinates, doing
SELECT way_id, st_makeline(coord) AS way
INTO __test
FROM (SELECT b.id AS way_id, ST_SetSRID(st_makepoint(lon, lat), 3857) AS coord
FROM (SELECT id, unnest(nodes) AS node_id FROM planet_osm_ways WHERE 'cobblestone'=any(tags)) a
INNER JOIN planet_osm_nodes b
ON a.node_id=b.id
ORDER BY way_id
) c
GROUP BY way_id
but in tilemill nothing shows up.
update 2:
after adjusting the layer settings in tilemill, I'm getting an error now:
Detected out of bounds geographic extent (180,85.0511287798066,180,85.051) for layer 'cobblestone'. Please ensure that the SRS for this layer is correct. Its native extent is '686159783,145786972,692158671,153144983'
geometry
data type. Do you have a table with linestring geometry, perhaps calledways
? If so, the value inid
probably corresponds to that geometry. You can then do a table join, see here: tutorialspoint.com/postgresql/postgresql_using_joins.htm