aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-03-19 09:42:29 +0000
committerStruan Donald <struan@exo.org.uk>2020-03-31 09:58:58 +0100
commit9768e1dc6beb788d5602062c58380b4d88aaa7b2 (patch)
tree2777baebd790a491264fe2ad5d569df117b862c1
parent2587263cca9b6711f4f63d3d4ad185e9c2fdca14 (diff)
[UK] Allow "jct" in junction lookup.
-rw-r--r--perllib/HighwaysEngland.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/perllib/HighwaysEngland.pm b/perllib/HighwaysEngland.pm
index d4ef65369..dc5b494bb 100644
--- a/perllib/HighwaysEngland.pm
+++ b/perllib/HighwaysEngland.pm
@@ -9,14 +9,18 @@ use Utils;
sub database_file { FixMyStreet->path_to('../data/roads.sqlite') }
+my $junction = '(junction|junc|jct|j)\.?\s*(?<junction>.*?)';
+my $road = '(?<road>[AM][0-9MT]*)';
+my $space = '[\s,.]*';
+
sub junction_lookup {
my $s = shift;
- if ($s =~ /^\s*(?<road>[AM][0-9MT]*)[\s,.]*(junction|junc|j)\s*(?<junction>.*?)\s*$/i
- || $s =~ /^\s*(junction|junc|j)\s*(?<junction>.*?)[,.\s]*(?<road>[AM][0-9MT]*)\s*$/i
+ if ($s =~ /^\s*$road$space$junction\s*$/i
+ || $s =~ /^\s*$junction$space$road\s*$/i
) {
return _lookup_db($+{road}, 'junction', $+{junction}, 'name') || undef;
- } elsif ($s =~ /^\s*(?<road>[AM][^ ]*)\s*(?<dist>[0-9.]+)\s*$/i
- || $s =~ /^\s*(?<dist>[0-9.]+)\s*(?<road>[AM][^ ]*)\s*$/i
+ } elsif ($s =~ /^\s*(?<road>[AM][^ ]*)$space(?<dist>[0-9.]+)\s*$/i
+ || $s =~ /^\s*(?<dist>[0-9.]+)$space(?<road>[AM][^ ]*)\s*$/i
) {
return _lookup_db($+{road}, 'sign', $+{dist}, 'distance') || undef;
}