OpenStreetMap

How can I view a full old version of a relation with API?

Posted by wieland on 27 September 2009 in English (English)

I can view a full version with
http://www.openstreetmap.org/api/0.6/relation/30035/full

I can view an old version with
http://www.openstreetmap.org/api/0.6/relation/30035/60

But how to view the full old version?
http://www.openstreetmap.org/api/0.6/relation/30035/60/full
ist not working

Comment from Edgemaster on 27 September 2009 at 22:39

This is not possible.

The server does not store versions of nodes, ways and relations when they're added to a relation.

To get the full version of a historic relation, you need to compare timestamps of the historic versions of its members.

The server will not support this in the near future, due to the expense of this calculation.

Hide this comment

Comment from wieland on 28 September 2009 at 06:08

Ok. A full version with correct versions of ways and nodes would be expensiv with this datamodel. I could live with the last version of the ways and nodes.

E.g. I want to see the last version of a relation. This works:
http://www.openstreetmap.org/?relation=30035

When I try to see an old version:
http://www.openstreetmap.org/?relation=30035/60
I get an error:
http://www.openstreetmap.org/api/0.6/relation/30035/60/full
is not supported.

Somebody changed the relation between version 60 and 81. It's hard to find out who did it and when. Don't mistake me, the change is good. I don't want to blame him but thank him.

My idea was to download the old version, save it and load the file with JOSM. Than download all the way and node while working with the relation. But this allways loads all ways of the current version.

Do I have to write a program for that?

Hide this comment

Comment from wieland on 28 September 2009 at 07:03

This is my quick solution:
use strict;

use LWP::Simple;

my $rel = get "http://www.openstreetmap.org/api/0.6/relation/$ARGV[0]/$ARGV[1]";
my $insert;
my %nd;

while ($rel =~ m/\s*(.*)<\/osm>\s*$/\1/sm;
$insert .= $element;
$nd{$id} = 1 if $type eq "node";
}
$rel =~ s/(\n*)/\1$insert/sm;
$insert = "";
while ($rel =~ m/\s*(.*)<\/osm>\s*$/\1/sm;
$insert .= $element;
$nd{$id} = 1;
}
$rel =~ s/(\n*)/\1$insert/sm;
print $rel;

Hide this comment

Comment from wieland on 28 September 2009 at 16:00

Only a test to insert code into the blog:

  code 

with
pre

asdfasdf

code
with
code

end of test

Hide this comment

Comment from wieland on 28 September 2009 at 16:04

another test:

  code
with
pre
and not lf but br

Hide this comment

Comment from wieland on 28 September 2009 at 16:06

The same code, but nices formatted:

use strict;

use LWP::Simple;

my $rel = get "http://www.openstreetmap.org/api/0.6/relation/$ARGV[0]/$ARGV[1]";
my $insert;
my %nd;

while ($rel =~ m/ my ($type, $id) = ($1, $2);
my $element = get "http://www.openstreetmap.org/api/0.6/$type/$id";
$element =~ s/^\s*(.*)<\/osm>\s*$/\1/sm;
$insert .= $element;
$nd{$id} = 1 if $type eq "node";
}
$rel =~ s/(\n*)/\1$insert/sm;
$insert = "";
while ($rel =~ m/ my ($id) = ($1);
next if $nd{$id};
my $element = get "http://www.openstreetmap.org/api/0.6/node/$id";
$element =~ s/^\s*(.*)<\/osm>\s*$/\1/sm;
$insert .= $element;
$nd{$id} = 1;
}
$rel =~ s/(\n*)/\1$insert/sm;
print $rel;

Hide this comment

Leave a comment

Parsed with Markdown

  • Headings

    # Heading
    ## Subheading

  • Unordered list

    * First item
    * Second item

  • Ordered list

    1. First item
    2. Second item

  • Link

    [Text](URL)
  • Image

    ![Alt text](URL)

Login to leave a comment