aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fiksgatami/showroadinfo
blob: 658fca01c3cf54b19c1b4d6be346dfbc04cf95f9 (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
#!/usr/bin/perl

use strict;
use warnings;

use FixMyStreet::App;
use FixMyStreet::Geocode::OSM;
use Data::Dumper;

FixMyStreet::App->model('DB::Problem')->send_reports();

my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('fiksgatami')->new();

sub isRoadOperator {
    my ($latitude, $longitude, $operatorname) = @_;
    my $osmtags = FixMyStreet::Geocode::OSM::get_nearest_road_tags(
        $cobrand, $latitude, $longitude);
    print STDERR Dumper($osmtags);
    my $operator = $osmtags->{operator} || $osmtags->{operatorguess};
    if ($operator) {
        my ($name, $ref) = ('','');
        $name = " named $osmtags->{name}" if exists $osmtags->{name};
        $ref = " ($osmtags->{ref})" if exists $osmtags->{ref};
        print STDERR "Claiming operator $operator for way$name$ref\n";
        return ($operator eq $operatorname);
    }
    return undef;
}

my $latitude = $ARGV[0] || 63.37638;
my $longitude = $ARGV[1] || 10.37595;

unless (isRoadOperator($latitude, $longitude, "Statens vegvesen")) {
    print STDERR "Operator is not Statens vegvesen\n";
}