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

Is it possible to render marks with current distance from a road start to map tiles in Mapnik ? We are looking for some way how to configure, or add rendering of a distance from road start point near to roads in some sensible frequency and only for higher zoom levels in kilometers. Here is an example of what we would like to prerender on our tiles (of course, it would be enough to show just a number of kilometers in some uniquely looking mark):

alt text

These values are "statical", so it would be great to have them prerendered on our tiles. We're using Mapnik renderer as part of the Switch2osm server.

Is that even possible ? If so, did we miss an existing settings or do we need to write some plugin for this feature ?

Thanks

asked 24 Jan '14, 09:20

TLama's gravatar image

TLama
6114
accept rate: 0%

edited 24 Jan '14, 10:11


It is certainly possible but OSM does not necessarily know where the "starting point" of a certain road is, and the road will consist of many many pieces in OSM, so first you have to puzzle together the pieces and know where to count from, then you could go about measuring the length. It's not somthing that can simply be "configured", it will require programming.

permanent link

answered 24 Jan '14, 10:36

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

2

Most likely the creation of an SQL function, which returns points with the distances as attributes. But I don't fancy trying to write the string-together-linestrings-sort-merge-and-handle-dual-carriageways query!

(24 Jan '14, 10:58) Andy Allan

If you are dealing with the US, the national and state routes have all been put into relations which will help you "puzzle together the bits and know where to count from". My understanding is that there route relations are frowned upon in other parts of the world, so they may not be available where you need it.

(24 Jan '14, 20:38) n76

@Andy Allan is quite right transforming OSM data to be able to calculate this distance markers is horrendous. Creating lots of routes using a routing engine, transforming them into linestrings & chopping them up might work. (more or less what @Richard says below)

(26 Jan '14, 16:00) SK53 ♦

It's certainly possible, but far from trivial.

First, you need to create linestrings for the roads where you want to show these mileages, chainages or whatever modern measurement system you may be using ;) .

It's possible to do this algorithmically from the raw data in OSM. Andy has mentioned in his comment above one way of doing it; I've also done it by downloading the data for an OSM route relation, then processing it in Ruby to order it correctly and smooth out the little hiccups along the way. But don't underestimate the complexity of this, especially where dual carriageways are concerned.

Instead, if you're dealing with a manageable dataset (say, "all the autoroutes in France" rather than "all the trunk roads in the world"), I would suggest that you manually create these linestrings with a routing program. In particular, OSRM makes it easy to plan a route and export it as an easily parseable GPX file. Do this for all the motorways you need. Motorways don't move very often so it should be a one-time task!

You can then load these linestrings into your PostGIS database. PostGIS and Mapnik ninjas will doubtless be able to write a query that automatically generates shields with the correct value every 1km. I'd personally prefer to precompute the kilometre points into a separate table. Whatever, you probably want to loop using ST_LocateAlong to find the point at each kilometre. Finally, add rendering rules for this in your Mapnik stylesheet.

Footnote: I've done something related, but using user-generated routes and rendering the mile/kilometre points dynamically in Leaflet rather than Mapnik. Have a look at cycle.travel/map - plan a route and see the yellow dots along the way.

permanent link

answered 24 Jan '14, 17:38

Richard's gravatar image

Richard ♦
30.9k44279412
accept rate: 18%

Hi and welcome to the world of OSM :)

As I understand your question, you want to do a distance (here: by traveltime) anaylsis and visualize it on top of the default mapnik map style?

This is something that Pascal neis realized some time ago to do analysis for the coverage of firefighters. Unfortunatly the OpenLS service is still down, so you might migrate the idea to OpenRouteServe AAS.

permanent link

answered 24 Jan '14, 09:31

iii's gravatar image

iii
4.9k84082
accept rate: 10%

Thank you! I'm not sure if I explained our needs well (I've added an example image). The information we'd like to render are quite "statical", so I'm not so sure if routing services are the best for us (we were hoping for some style settings, but maybe your suggestion is the way to go). Basically, on tiles we would like to show that you're looking e.g. on 115th km of the road (from its starting point).

(24 Jan '14, 10:12) TLama

Thanks for the update. Obviously I had a misunderstanding on your request. Sorry!

(24 Jan '14, 11:11) iii
Your answer
toggle preview

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:

×362
×341
×223
×63
×36

question asked: 24 Jan '14, 09:20

question was seen: 7,492 times

last updated: 26 Jan '14, 16:00

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