I am working on a perl script which can fix a "braided street" in US TIGER data, as described at
osm.wiki/index.php/TIGER_fixup
It is a command-line tool which will download and fix the ways and produce a file which you can open in JOSM to verify and upload.
It should be ready for others to try out within the next few days.
Ideally it would be a JOSM plugin, but I don't know Java. Yet. This just may be the project that pushes me to learn it.
Discussion
Kommentti käyttäjältä Edward 23. April 2008 klo 10.24
Excellent, this is been on my todo list. Here is some Perl to find braided streets in a OSM data dump:
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, "data.osm" or die $!;
my $state = 1;
my $way_id;
my %node_way;
my %way_node;
my %way_tag;
my %node_loc;
while (<$fh>) {
if ($state == 1) {
if (/ $2, lon => $3 };
next;
}
/^ !) {
$state = 2; next;
}
}
}
close $fh;
my %look_at;
while (my ($k, $v) = each %node_way) {
@$v > 1 or next;
$way_tag{$_}{highway} and $look_at{$_} = 1 for @$v;
}
my %seen;
$seen{$_} or linked_ways($_) for keys %look_at;
sub api {
my $way = shift;
return "$way_tag{$way}{name} ([http://api.openstreetmap.org/api/0.5/way/$way $way])";
}
sub linked_ways {
my $way = shift;
my $name = $way_tag{$way}{name} or return;
$way_node{$way} or die $way;
my %cross_way;
foreach my $node (@{$way_node{$way}}) {
my @ways = grep { $way_tag{$_}{name} } @{$node_way{$node}};
@ways or next;
$cross_way{$_}++ for @ways;
$cross_way{$way}--;
}
while (my ($k, $v) = each %cross_way) {
$v < 3 and delete $cross_way{$k}
}
%cross_way or return;
my $loc = $node_loc{$way_node{$way}[0]};
print "# [http://informationfreeway.org/?lat=$loc->{lat}&lon=$loc->{lon}&zoom=17 map]: ";
$seen{$_} = 1 for keys %cross_way;
print join (", ", map api($_), $way, keys %cross_way);
print "\n";
}
Kommentti käyttäjältä Edward 23. April 2008 klo 10.26
Actually, just take a look at http://www.edwardbetts.com/osm/find_braided_streets