[OSM-talk] zones for motorway/in town/outof town?

Ben Laenen benlaenen at gmail.com
Fri May 22 11:52:51 BST 2009


On Friday 22 May 2009, you wrote:
> See if you think that my stuff was about rendering, then you are
> missing the point. It's all about data processing. Even the bit about
> translucent colouring is not about rendering (that's easy -
> opacity=0.7) it's about *processing* (unwinding relations into linear
> features).

Well, you shouldn't unwind relations into linear features, you have to 
do it the opposite way: take a road you're interested in and get 
information from the relations that way is a member of.

in pseudo-code:


say you want traffic rules of way X

find out default traffic rules for that road given the tags on the way 
(e.g. motorway → maxspeed=130, trunk → access=no) under current 
conditions (time of day, vehicle type) -- assume nothing special about 
that road, so no need to know about built-up areas at that point.

for each "traffic rule" relation Y of which X is a member {
  read the relation tags
  if the conditions in that relation apply to you (e.g. time of day) {
    store the data of that relation you're interested in (e.g.
    maxspeed):
      * using a table to translate implicit rules to explicit maxspeed
        at current conditions (country, type of vehicle, type of day
        etc) if needed (e.g. when the relation has zone=built_up_area)
      * keep a precedence number for each data item (maxspeed,
        overtaking...) you're interested in (which is the precedence
        number of that relation, which can be explicit or implicit), so
        you don't override them with another relation later on which has
        lower precedence
  }
}


Since 99% of all roads inside a country will belong to at most three 
such traffic rule relations (and most probably will belong to none at 
all), this isn't exactly a computationally hard algorithm (much worse 
if you're using polygons for zonal restrictions).


Please tell me where ST_Intersects should be in there somewhere. I can 
only think of the issue where you have to decide in which country 
you're in. But you probably should know that already if you're doing 
some serious preprocessing anyway, given the fact that a lot of tags 
are defined on the country level and mean something different in e.g. 
Japan and Australia.

Ben





More information about the talk mailing list