Hi, On 10/2/19 20:36, yves wrote: > What would be a cheap way to find ways that once were highway=* and are > now a piste:type=nordic but no more a highway=* ?
Define "cheap" ;) I usually tackle issue like this with a contraption of history file, osmium, and a script in a programming language of choice (for easy cases even shell script works). The first step is to have osmium convert the history file into "OPL" format which gives you one ascii text line for every version of an object, neatly sorted by type, ID, and version: osmium cat somefile.osh.pbf -tway -fopl From there, the following Perl script would for example solve your problem: #!/usr/bin/perl use strict; my $lastid; my $was_highway; my $lost; while(<>) { /^w(\d+) .*T(\S+)/ or next; my ($id, $tags) = ($1, $2); my $piste = ($tags =~ /piste:type=nordic/); if ($id eq $lastid) { $lost = ($piste && $was_highway && $tags !~ /highway=/); } else { print "way $lastid lost its highway tag\n" if ($lost); $lastid = $id; undef $was_highway; undef $lost; } $was_highway = $was_highway || ($tags =~ /highway=/); } save that in foo.pl and simply do a osmium cat somefile.osh.pbf -tway -fopl | perl foo.pl You will find that it is a bit rough around the edges, e.g. it doesn't correctly handle deleted objects and disregards the very last way in the file, but it works *in general*. Bye Frederik PS: Slightly more sophisticated Perl snippets from some of my scripts lying around include while(<>) { my $part; my @parts = split(/ /, $_); my $obj = shift(@parts); foreach (@parts) { $part->{substr($_,0,1)}=substr($_,1); } (this splits the OPL line into a hash that you can then access with $part->{'v'} for the version, $part->{'T'} for the tags etc.etc.) and my @tags = split(/,/, $part->{'T'}); my $tag; foreach (@tags) { /(.*)=(.*)/; $tag->{$1}=$2; } which further splits the "tags" part into a hash with tags so that you can then write code like "if defined $tag->{'highway'}" etc. -- Frederik Ramm ## eMail frede...@remote.org ## N49°00'09" E008°23'33" _______________________________________________ dev mailing list dev@openstreetmap.org https://lists.openstreetmap.org/listinfo/dev