<commit_before>package FixMyStreet::Cobrand::Bromley;
use parent 'FixMyStreet::Cobrand::UKCouncils';

use strict;
use warnings;

sub council_id { return 2482; }
sub council_area { return 'Bromley'; }
sub council_name { return '<NAME>'; }
sub council_url { return 'bromley'; }

sub base_url {
    return FixMyStreet->config('BASE_URL') if FixMyStreet->config('STAGING_SITE');
    return 'https://fix.bromley.gov.uk';
}

sub disambiguate_location {
    my $self    = shift;
    my $string  = shift;

    my $town = 'Bromley';

    # Helpful regexes that are used often
    my $road = 'r(?:oa)?d';
    my $street = 'st(\.|reet)?';

    # Bing turns High St Bromley into Bromley High St which is in
    # Bromley by Bow.
    $town .= ', BR1' if $string =~ /^high\s+${street}$/i;

    # Disambiguations required for BR5
    $town .= ', BR5' if $string =~ /^kelsey\s+${road}$/i;
    $town = 'BR5 Bromley' if $string =~ /^leith\s+hill$/i; # doesn't like appended BR5 for some reason

    #  There has also been a road name change for a section of Ramsden Road
    #  (BR5) between Church Hill and Court Road has changed to 'Old Priory
    #  Avenue' - presently entering Old Priory Avenue simply takes the user to
    #  a different Priory Avenue in Petts Wood
    #  From Google maps search, "BR6 0PL" is a valid postcode for Old Priory Avenue
    if ($string =~/^old\s+priory\s+av\w*$/i) {
        $string = 'Ramsden Road';
        $town = ', BR6 0PL';
    }
    $town .= ', BR5' if $string =~ /^meadway/i;
    $town .= ', BR5' if $string =~ /^mill\s+brook\s+${road}$/i;
    $town .= ', BR5' if $string =~ /^kent\s+${road}$/i;
    $town .= ', BR5' if $string =~ /^the\s+landway$/i;
    $town .= ', BR5' if $string =~ /^mountfield\s+way$/i;
    $town .= ', BR5 3' if $string =~ /^star\s+lane$/i;
    $town .= ', BR5 4AX' if $string =~ /^high\s+${street}?(,)?\s?st\.?\s+mary\s+cray$/i;

    # and BR6
    $town .= ', BR6' if $string =~ /^berrylands/i;
    $town .= ', BR6' if $string =~ /^crofton\s+${road}$/i;
    $town .= ', BR6' if $string =~ /^crofton\s+lane$/i;

    # White Horse Hill is on boundary with Greenwich, so need a
    # specific postcode
    $town = 'chislehurst, BR7 6DH' if $string =~ /^white\s+horse/i;

    # Mottingham Lane is 90% inside Bromley, but goes outside too and Bing
    # defaults to the top end of it.
    $town = 'Mottingham Lane, SE9 4RW' if $string =~ /^mottingham\s+lane/i;

    $town = '' if $string =~ /orpington/i;

    return {
        %{ $self->SUPER::disambiguate_location() },
        town => $town,
        centre => '51.366836,0.040623',
        span   => '0.154963,0.24347',
        bounds => [ 51.289355, -0.081112, 51.444318, 0.162358 ],
    };
}
<commit_msg>[Bromley] Switch from Bing to OSM geocoder for Bromley<commit_after>package FixMyStreet::Cobrand::Bromley;
use parent 'FixMyStreet::Cobrand::UKCouncils';

use strict;
use warnings;

sub council_id { return 2482; }
sub council_area { return 'Bromley'; }
sub council_name { return 'Bromley Council'; }
sub council_url { return 'bromley'; }

sub base_url {
    return FixMyStreet->config('BASE_URL') if FixMyStreet->config('STAGING_SITE');
    return 'https://fix.bromley.gov.uk';
}

sub disambiguate_location {
    my $self    = shift;
    my $string  = shift;

    my $town = 'Bromley';

    #  There has been a road name change for a section of Ramsden Road
    #  (BR5) between Church Hill and Court Road has changed to 'Old Priory
    #  Avenue' - presently entering Old Priory Avenue simply takes the user to
    #  a different Priory Avenue in Petts Wood
    #  From Google maps search, "BR6 0PL" is a valid postcode for Old Priory Avenue
    if ($string =~/^old\s+priory\s+av\w*$/i) {
        $string = 'Ramsden Road';
        $town = ', BR6 0PL';
    }

    # White Horse Hill is on boundary with Greenwich, so need a
    # specific postcode
    $string = 'BR7 6DH' if $string =~ /^white\s+horse/i;

    $town = '' if $string =~ /orpington/i;

    return {
        %{ $self->SUPER::disambiguate_location() },
        town => $town,
        centre => '51.366836,0.040623',
        span   => '0.154963,0.24347',
        bounds => [ 51.289355, -0.081112, 51.444318, 0.162358 ],
    };
}

sub get_geocoder {
    return 'OSM'; # default of Bing gives poor results, let's try overriding.
}

{'fraction_non_alphanumeric': 0.15560214302352668, 'fraction_numerical': 0.03726997437689262, 'mean_word_length': 2.875451263537906, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4877208', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1549, 'n_words': 451}