blob: 83c3c4310155d5bef41b9bb12c71e9151f9062d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/perl
use strict;
use warnings;
use FixMyStreet::App;
use FixMyStreet::Geocode::OSM;
my @reports = FixMyStreet::App->model('DB::Problem')->search({
state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
}, {
rows => 40,
})->all;
my (%namecount, %refcount, %operatorcount);
my $cobrand;
my $cobrand_data;
my $total = 0;
$| = 1;
foreach my $row (@reports) {
print ".";
$total++;
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new();
my $osmtags = FixMyStreet::Geocode::OSM::get_nearest_road_tags($cobrand, $row->latitude, $row->longitude);
if (exists $osmtags->{name}) {
$namecount{$osmtags->{name}}++;
}
if (exists $osmtags->{ref}) {
$refcount{$osmtags->{ref}}++;
}
my $operator = $osmtags->{operator} || $osmtags->{operatorguess};
if ($operator) {
$operatorcount{$operator}++;
}
sleep 5;
}
print "\n";
print_stats();
sub print_stats {
print "Names:\n";
for my $name (sort keys %namecount) {
printf("%3d %s\n", $namecount{$name}, $name) if $namecount{$name} > 1;
}
print "Refs:\n";
for my $ref (sort keys %refcount) {
printf("%3d %s\n", $refcount{$ref}, $ref) if $refcount{$ref} > 1;
}
print "Operators:\n";
for my $operator (sort keys %operatorcount) {
printf("%3d %s\n", $operatorcount{$operator}, $operator);
}
print "Total $total\n";
}
|