[OSM-dev] Distance Grid

Matt Amos zerebubuth at gmail.com
Tue Dec 1 20:27:08 GMT 2009

On Tue, Dec 1, 2009 at 7:03 PM, Ævar Arnfjörð Bjarmason
<avarab at gmail.com> wrote:
> On Tue, Dec 1, 2009 at 17:06, Matt Amos <zerebubuth at gmail.com> wrote:
>> On Tue, Dec 1, 2009 at 4:04 PM, Vitor George <vitor.george at gmail.com> wrote:
>>> I want to start a project in Brazil that is similar to the Tiger Fixup 250
>>> Cities [1], and I looking forward to build a script that generates a
>>> distance grid, like this:
>>> http://matt.sandbox.cloudmade.com/usa-routes.html
>>> I've tried to contact the authors via wiki, but I was unsuccessful, so I
>>> want to develop it by myself. I'm not a professional programmer, but I have
>>> some experience in java. Is the LibOSM the easiest way tool to implement it?
>> sorry you missed us on the wiki. i have to say, i don't really check
>> the discussion pages like a good wikian should :-(
>> the script is very simple, and uses cloudmade's ruby API [1] to get
>> the routes. you'll need to sign up for a cloudmade API key, if you
>> haven't already. the script i've attached will output CSV on stdout,
>> but i usually put them in a database for easy access.
>> run it like "ruby routes.rb <conf file>". i've attached an example
>> configuration file, which is just a yaml map of string to lat/lon
>> array.
>> i look forward to seeing brazil's 250 cities :-)
> I made a hacky script to generate .yml from XAPI output (attached):
> wget 'http://www.informationfreeway.org/api/0.6/node[place=city|town|village|hamlet][bbox=-25.74085,62.84553,-12.41708,67.50085]'
> -O iceland-places.osm
> perl -CI place2yaml.pl < place.osm  > place.yml
> But I just get internal server errors from the CM API:
> $ ruby routes.rb place.yml
> [Tue Dec 01 18:59:57 +0000 2009] HTTP error: Couldn't read data. HTTP
> status: #<Net::HTTPInternalServerError:0xb769348c>, retrying...

interesting. if you could send me a trace of what's going on that
would be very helpful.

> Anyway do you have a script to generate that cute HTML matrix? And how
> can I link to a route on CM's website. I have to supply lat/lon/zoom
> it seems and not just starting/ending lat/lon (at least the URLs I've
> seen are all like that).

i've just thrown something together here - might be buggy, etc...
you'll need to play with the factor variable to see what looks right
for your area.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: to_html.rb
Type: application/x-ruby
Size: 3139 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20091201/496e3b9c/attachment.rb>

More information about the dev mailing list