Hello OSM, I'm working on a custom application where I will eventually be running a DFS on the entire OSM DB (limited by state boundaries). FOR NOW, I'm learning OSM by writing my own map renderer. I am currently plotting all of the ways in my "chunk" of the OSM DB (Florida). My current method of plotting a way seems very inefficient, I grab a way using this: SELECT nodes, id from public.ways LIMIT 1 OFFSET ... Then I convert the list of nodes into an array in Java and I run the following SQL command to get the X/Y pair for each node: SELECT ST_X(geom) as x, ST_Y(geom) as y from public.nodes WHERE id=" + nodes[i] + "LIMIT 1" I feel as if this process could be done in one step all by the database and preferably for many ways at a time. As this seems like something that people around here likely have to do often I figured I'd ask, is there a better way to do this? Any help is greatly appreciated! - Thanks -Cody asked 25 Aug '12, 05:48 Smartkid |
The database schema of the Rails-port is designed for the api which is mainly used by editors. Other applications like rendering or routing usually preprocess the raw osm data into another database scheme. For rendering the connectivity between ways (and areas) is irrelevant. So in a datamodel for rendering only the nodes for point features are retained with a geometry. For ways the geometry is calculated from their nodes during the prepocessing using tools like osm2pgsql and Imposm. Both these tools are open source, so have a look at their code. answered 25 Aug '12, 08:16 cartinus |