diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2014-11-07 15:29:25 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-11-19 14:19:06 +0000 |
commit | 55dbf51f98b523f41c83959875295853e1457dcf (patch) | |
tree | bd87d80aea045e3ff0ddea7414cb13ceec19b8c9 /bin/fiksgatami/showroadstats | |
parent | a8f45b97bd0b91f714ff77fa9d3fbdf0e6981a15 (diff) |
[FiksGataMi] Add two testing scripts for roads.
Diffstat (limited to 'bin/fiksgatami/showroadstats')
-rwxr-xr-x | bin/fiksgatami/showroadstats | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/fiksgatami/showroadstats b/bin/fiksgatami/showroadstats new file mode 100755 index 000000000..83c3c4310 --- /dev/null +++ b/bin/fiksgatami/showroadstats @@ -0,0 +1,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"; +} |