NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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's gravatar image

Smartkid
26335
accept rate: 0%

edited 25 Aug '12, 07:27


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.

permanent link

answered 25 Aug '12, 08:16

cartinus's gravatar image

cartinus
7.0k1066105
accept rate: 27%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×167
×76
×18

question asked: 25 Aug '12, 05:48

question was seen: 3,952 times

last updated: 25 Aug '12, 08:16

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum