[Routing] "Connected Nodes"
Sven Anders
sven at anders-hamburg.de
Mon Oct 8 19:19:35 BST 2007
Has someone has a made a statistic about how many nodes are connected by a
road in OSM?
I think somethink like:
The Bigest Area has: 1.979.999 Nodes (lat is between 1 and 15 and long between
30 and 50)
The 2nd biggest Area has: ...
Or has someone a hint how we can craete such a statistic?
I have tried it with the following perl code, but this is not realy good (my
server needs to much time to get a result):
--- snip --
my $sth = $dbh->prepare("select distinct node_a,node_b from highway_area where
area_id=?");
my $sth_insert = $dbh->prepare("update highway_area set area_id=? where
node_a=? or node_b=?");
my $i=1;
my %nodes;
while ($i>0) {
print "\n$i: Execute\n";
$sth->execute(1) or die $dbh->errstr;
$i=0;
while( ($nodea,$nodeb) = $sth->fetchrow_array ) {
if (!(defined($nodes{$nodea}))) {
$sth_insert->execute(1,$nodea,$nodea);
$nodes{$nodea}=1;
print "$nodea,";
$i++;
}
if (!(defined($nodes{$nodeb}))) {
$sth_insert->execute(1,$nodeb,$nodeb);
$nodes{$nodeb}=1;
print "$nodeb,";
$i++;
}
}
}
-- snap --
Best Regrads
Sven
More information about the Routing
mailing list