[OSM-talk] Getting roles of relation's members in PostGIS using osm2pgsql

Ciprian Talaba cipriantalaba at gmail.com
Sun Nov 15 08:33:48 GMT 2009


Hello Jon,

On Sat, Nov 14, 2009 at 10:49 PM, Jon Burgess <jburgess777 at googlemail.com>wrote:

> On Sat, 2009-11-14 at 21:58 +0200, Ciprian Talaba wrote:
> > I am trying to do some work with the public transport network, and for
> > that I need to get the roles (forward/backward mainly) of the route
> > members as attributes of ways(lines) in PostGIS. I am using osm2pgsql
> > and I hoped to get this done by modifying the default style. I have
> > added a new line in the style file "way   role    text    linear" but
> > this is not working (maybe it's obvious why not for some of you).
> >
> > Also I was looking at the osm2pgsql source code and I saw that getting
> > information about the cycling network is treated separated in the code
> > (in output-pgsql.c), and I was thinking of doing the same for public
> > transport.
> >
> > Do you know if there is a way for doing this with the style, or I have
> > to dig more in the code? Any pointers will be appreciated.
>
> I'm afraid the relation roles are not accessible in the style file.
> Pretty much all the relation processing is handled in the C code and
> each type of relation needs special handling.
>
> When a route relation is converted into a postgis geometry all of the
> constituent ways are joined into a single linestring. There is no
> obvious place where the role of each individual way could be recorded on
> this linestring.
>
> One possibility might be to keep the members as separate linestrings for
> and then add an artificial tag, say route_role=... in the output.
>
> Another approach might be for you to query the planet_osm_rels table
> (provided you imported the data in --slim mode). This contains the raw
> data listing all the relations and their members. Armed with this
> information you could then query the planet_osm_line table to obtain the
> geometry for each of these ways (all the members will probably appear as
> distinct roads in this table).
>
>        Jon
>
>
>
Thank you about this info. I will probably start with the last approach
(using planet_osm_rels and planet_osm_line tables) because this will keep my
code separate from osm2pgsql. I will try to publish my tries because I
believe others will be interested in something like this.

Regards,
Ciprian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/talk/attachments/20091115/e81d8d1e/attachment.html>


More information about the talk mailing list