diff options
author | Dave Whiteland <dave@mysociety.org> | 2012-12-19 13:23:00 +0000 |
---|---|---|
committer | Dave Whiteland <dave@mysociety.org> | 2012-12-19 13:23:00 +0000 |
commit | 6595518c17ddc9e05f598bc33aec37705ae9bfe4 (patch) | |
tree | f7dca5bc0afc4675afb8811582da445e86129637 | |
parent | 46d81c2bdbd4dd4877d36ce8864bf318e70eb960 (diff) |
pass closest_address string straight into OCC's ce_location field, which was the Right Thing to do at the very start, gah
-rwxr-xr-x | bin/oxfordshire/open311_service_request.cgi | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/bin/oxfordshire/open311_service_request.cgi b/bin/oxfordshire/open311_service_request.cgi index 61cb4f899..a0f2fa03c 100755 --- a/bin/oxfordshire/open311_service_request.cgi +++ b/bin/oxfordshire/open311_service_request.cgi @@ -289,30 +289,6 @@ sub insert_into_pem { my $service_code = $$h{$F{SERVICE_CODE}}; my $description = $$h{$F{DESCRIPTION}}; my $media_url = $$h{$F{MEDIA_URL}}; - - # closest_address may be wildly off: may be entirely blank, or contain - # odd or unexpected structure; this is a best-guess approach - my $address = $$h{$F{CLOSEST_ADDRESS}}; - my ($building_number, $street_name, $locality, $town_name, $postcode); - - # note: postcodes may be partial (will PEM reject partial postcodes?) - if ($address=~s/\s*(\b[a-z]+\d+\s*(\d+[a-z]*))\s*$//i) { - $postcode = uc $1; # postcode must be in upper case... - $postcode =~s/\s+//g; # ...and no spaces in postcode - } - if ($address=~/(^\d+\w?)?(.*)\s*/i) { - $building_number = $1; - $street_name = $2; - if ($street_name=~/(.*),\s*((\w+\s*)\w+)\s*$/) { - $street_name = $1; - $town_name = $2; - } - if ($street_name=~/(.*),\s*((\w+\s*)\w+)\s*$/) { - $street_name = $1; - $locality = $2; - } - $street_name =~ s/(^\s+|\s+$)//g; - } if ($media_url) { $description .= ($STRIP_CONTROL_CHARS ne 'ruthless'? "\n\n":" ") . "Photo: $media_url"; @@ -326,11 +302,7 @@ sub insert_into_pem { ce_forename => :ce_forename, ce_surname => :ce_surname, ce_contact_type => :ce_contact_type, - ce_postcode => :ce_postcode, - ce_building_no => :ce_building_no, - ce_locality => :ce_locality, - ce_town => :ce_town, - ce_street => :ce_street, + ce_location => :ce_location, ce_work_phone => :ce_work_phone, ce_email => :ce_email, ce_description => :ce_description, @@ -374,13 +346,9 @@ sub insert_into_pem { $bindings{":ce_work_phone"} = substr($$h{$F{PHONE}}, 0, 25); # '0117 600 4200' $bindings{":ce_email"} = substr($$h{$F{EMAIL}}, 0, 50); # 'info@exor.co.uk' $bindings{":ce_description"} = substr($description, 0, 2000); # 'Large Pothole' - + # nearest address guesstimate - $bindings{":ce_building_no"} = substr($building_number, 0, 6); - $bindings{":ce_street"} = substr($street_name, 0, 80); - $bindings{":ce_locality"} = substr($locality, 0, 80); - $bindings{":ce_town"} = substr($town_name, 0, 60); - $bindings{":ce_postcode"} = substr($postcode, 0, 8); + $bindings{":ce_location"} = substr($$h{$F{CLOSEST_ADDRESS}}, 0, 254); foreach my $name (sort keys %bindings) { next if grep {$name eq $_} (':error_value', ':error_product', ':ce_doc_id'); # return values (see below) |