aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-03-13 15:43:40 +0000
committerDave Arter <davea@mysociety.org>2019-06-04 14:54:30 +0100
commit1def9598bee006b52ca8a6223cf552bebaefe555 (patch)
tree87bd91b925b59a0eb8b60005492bbb6428aedf85
parentf47fb864a4926822aa0bd60060518616d07776bb (diff)
[Hounslow] Add asset layers & site code lookup
-rw-r--r--perllib/FixMyStreet/Cobrand/Hounslow.pm23
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm2
-rw-r--r--perllib/FixMyStreet/Map/Hounslow.pm21
-rw-r--r--t/map/tests.t1
-rw-r--r--templates/web/fixmystreet.com/footer_extra_js.html1
-rw-r--r--web/cobrands/hounslow/assets.js235
6 files changed, 283 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm
index 04533ce80..ac8d904ee 100644
--- a/perllib/FixMyStreet/Cobrand/Hounslow.pm
+++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm
@@ -10,6 +10,8 @@ sub council_name { 'Hounslow Borough Council' }
sub council_url { 'hounslow' }
sub example_places { ( 'TW3 1SN', "Depot Road" ) }
+sub map_type { 'Hounslow' }
+
sub base_url {
my $self = shift;
return $self->next::method() if FixMyStreet->config('STAGING_SITE');
@@ -68,6 +70,18 @@ sub open311_config {
{ name => 'description',
value => $row->detail };
+ # Reports made via FMS.com or the app probably won't have a site code
+ # value because we don't display the adopted highways layer on those
+ # frontends. Instead we'll look up the closest asset from the WFS
+ # service at the point we're sending the report over Open311.
+ if (!$row->get_extra_field_value('site_code')) {
+ if (my $site_code = $self->lookup_site_code($row)) {
+ push @$extra,
+ { name => 'site_code',
+ value => $site_code };
+ }
+ }
+
$row->set_extra_fields(@$extra);
}
@@ -80,4 +94,13 @@ sub should_skip_sending_update {
}
+sub lookup_site_code_config { {
+ buffer => 50, # metres
+ url => "https://tilma.mysociety.org/mapserver/hounslow",
+ srsname => "urn:ogc:def:crs:EPSG::27700",
+ typename => "streets",
+ property => "SITE_CODE",
+ accept_feature => sub { 1 }
+} }
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 09ca6c535..c21ed6401 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -282,6 +282,8 @@ sub lookup_site_code {
my $response = get($uri);
+ return '' unless $response;
+
my $j = JSON->new->utf8->allow_nonref;
try {
$j = $j->decode($response);
diff --git a/perllib/FixMyStreet/Map/Hounslow.pm b/perllib/FixMyStreet/Map/Hounslow.pm
new file mode 100644
index 000000000..231fc4258
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Hounslow.pm
@@ -0,0 +1,21 @@
+# FixMyStreet:Map::Hounslow
+# More JavaScript, for street assets
+
+package FixMyStreet::Map::Hounslow;
+use base 'FixMyStreet::Map::FMS';
+
+use strict;
+
+sub map_javascript { [
+ '/vendor/OpenLayers/OpenLayers.wfs.js',
+ '/vendor/OpenLayers.Projection.OrdnanceSurvey.js',
+ '/js/map-OpenLayers.js',
+ '/js/map-bing-ol.js',
+ '/js/map-fms.js',
+ '/cobrands/fixmystreet-uk-councils/roadworks.js',
+ '/cobrands/fixmystreet/assets.js',
+ '/cobrands/hounslow/js.js',
+ '/cobrands/hounslow/assets.js',
+] }
+
+1;
diff --git a/t/map/tests.t b/t/map/tests.t
index 7cc8f6860..692cf6790 100644
--- a/t/map/tests.t
+++ b/t/map/tests.t
@@ -11,6 +11,7 @@ my $requires = {
'FMS' => 'map-fms.js',
'Google' => 'map-google.js',
'GoogleOL' => 'map-google-ol.js',
+ 'Hounslow' => 'hounslow/assets.js',
'OSM' => 'OpenStreetMap.js',
'CycleMap' => 'OpenStreetMap.js',
'MapQuest' => 'OpenStreetMap.js',
diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html
index 61f260fe8..7835e1eac 100644
--- a/templates/web/fixmystreet.com/footer_extra_js.html
+++ b/templates/web/fixmystreet.com/footer_extra_js.html
@@ -13,6 +13,7 @@ IF bodyclass.match('mappage');
scripts.push( version('/cobrands/lincolnshire/assets.js') );
scripts.push( version('/cobrands/northamptonshire/assets.js') );
scripts.push( version('/cobrands/oxfordshire/assets.js') );
+ scripts.push( version('/cobrands/hounslow/assets.js') );
scripts.push( version('/cobrands/highways/assets.js') );
scripts.push( version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js') );
scripts.push(
diff --git a/web/cobrands/hounslow/assets.js b/web/cobrands/hounslow/assets.js
new file mode 100644
index 000000000..4029ac7cd
--- /dev/null
+++ b/web/cobrands/hounslow/assets.js
@@ -0,0 +1,235 @@
+(function(){
+
+if (!fixmystreet.maps) {
+ return;
+}
+
+var defaults = {
+ http_options: {
+ url: "https://tilma.mysociety.org/mapserver/hounslow",
+ params: {
+ SERVICE: "WFS",
+ VERSION: "1.1.0",
+ REQUEST: "GetFeature",
+ SRSNAME: "urn:ogc:def:crs:EPSG::3857"
+ }
+ },
+ format_class: OpenLayers.Format.GML.v3.MultiCurveFix,
+ asset_type: 'spot',
+ max_resolution: 2.388657133579254,
+ min_resolution: 0.5971642833948135,
+ asset_id_field: 'CentralAssetId',
+ attributes: {
+ central_asset_id: 'CentralAssetId',
+ asset_details: 'FeatureId'
+ },
+ geometryName: 'msGeometry',
+ srsName: "EPSG:3857",
+ strategy_class: OpenLayers.Strategy.FixMyStreet,
+ body: "Hounslow Borough Council"
+};
+
+fixmystreet.assets.add($.extend(true, {}, defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "bins"
+ }
+ },
+ asset_category: "Litter Bins",
+ asset_item: 'bin'
+}));
+
+fixmystreet.assets.add($.extend(true, {}, defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "trees"
+ }
+ },
+ asset_id_field: 'central_asset_id',
+ attributes: {
+ central_asset_id: 'central_asset_id',
+ asset_details: 'asset_Id'
+ },
+ asset_category: [
+ "Tree Danger/Obstruction",
+ "Branches overhanging",
+ "Damage By Tree",
+ "Dead/Dying/Diseased",
+ "Dying or dangerous tree",
+ "Empty tree Pit",
+ "Fallen or leaning tree",
+ "General Maintenance and pruning",
+ "Illuminated Traffic signal obstructed by vegetation",
+ "Traffic signal obstructed by vegetation",
+ "Pest: Tree/Shrub",
+ "Pests in trees and shrubs",
+ "Tree Branches Overhanging",
+ "Tree Maintenance",
+ "Tree causing damage to property",
+ "Tree obstructing street light",
+ "Trees or shrubs blocking visibility",
+ "Trees or shrubs causing obstruction of highway",
+ "Trees"
+ ],
+ asset_item: 'tree'
+}));
+
+fixmystreet.assets.add($.extend(true, {}, defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "signs"
+ }
+ },
+ asset_category: [
+ "Sign Obstructed: Vegetation",
+ "Missing sign",
+ "Missing/ damaged traffic sign",
+ "Sign or road marking missing following works",
+ "Street nameplate damaged",
+ "Traffic Sign obstructed (vegetation)",
+ "Unlit sign knocked down"
+ ],
+ asset_item: 'sign'
+}));
+
+// "We do not want to show gullies as an asset layer, until we are
+// confident that the inventory is accurate."
+// https://3.basecamp.com/4020879/buckets/10951425/todos/1780668464
+// fixmystreet.assets.add($.extend(true, {}, defaults, {
+// http_options: {
+// params: {
+// TYPENAME: "gulleys"
+// }
+// },
+// asset_category: [
+// "Bad smell",
+// "Flooding",
+// "Blocked gully",
+// "Damaged/ cracked drain or man hole cover",
+// "Missing drain or man hole cover"
+// ],
+// asset_item: 'gulley'
+// }));
+
+var pin_prefix = fixmystreet.pin_prefix || document.getElementById('js-map-data').getAttribute('data-pin_prefix');
+
+var streetlight_default = {
+ fillColor: "#FFFF00",
+ fillOpacity: 0.6,
+ strokeColor: "#000000",
+ strokeOpacity: 0.8,
+ strokeWidth: 2,
+ pointRadius: 6
+};
+
+var streetlight_select = {
+ externalGraphic: pin_prefix + "pin-spot.png",
+ fillColor: "#55BB00",
+ graphicWidth: 48,
+ graphicHeight: 64,
+ graphicXOffset: -24,
+ graphicYOffset: -56,
+ backgroundGraphic: pin_prefix + "pin-shadow.png",
+ backgroundWidth: 60,
+ backgroundHeight: 30,
+ backgroundXOffset: -7,
+ backgroundYOffset: -22,
+ popupYOffset: -40,
+ graphicOpacity: 1.0,
+
+ label: "${FeatureId}",
+ labelOutlineColor: "white",
+ labelOutlineWidth: 3,
+ labelYOffset: 65,
+ fontSize: '15px',
+ fontWeight: 'bold'
+};
+
+// The label for street light markers should be everything after the final
+// '/' in the feature's FeatureId attribute.
+// This seems to be the easiest way to perform custom processing
+// on style attributes in OpenLayers...
+var select_style = new OpenLayers.Style(streetlight_select);
+select_style.createLiterals = function() {
+ var literals = Object.getPrototypeOf(this).createLiterals.apply(this, arguments);
+ if (literals.label && literals.label.split) {
+ literals.label = literals.label.split("/").slice(-1)[0];
+ }
+ return literals;
+};
+
+var streetlight_stylemap = new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style(streetlight_default),
+ 'select': select_style
+});
+
+var labeled_defaults = $.extend(true, {}, defaults, {
+ select_action: true,
+ stylemap: streetlight_stylemap,
+ feature_code: 'FeatureId',
+ actions: {
+ asset_found: function(asset) {
+ var id = asset.attributes[this.fixmystreet.feature_code] || '';
+ if (id !== '' && id.split) {
+ var code = id.split("/").slice(-1)[0];
+ $('.category_meta_message').html('You have selected column <b>' + code + '</b>');
+ } else {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ },
+ asset_not_found: function() {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ }
+});
+
+fixmystreet.assets.add($.extend(true, {}, labeled_defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "lighting"
+ }
+ },
+ asset_category: [
+ "Damage to paintwork",
+ "Damage to paintwork/ column",
+ "Door Missing/ open",
+ "Lights too bright/ dull",
+ "New LED lights not working",
+ "New LED lights too bright",
+ "New LED lights too dull",
+ "Not coming on/ faulty",
+ "Street light leaning",
+ "Street light not working",
+ "Street light on during the day",
+ "Street light wiring exposed",
+ "Street lights on during the day",
+ "Unauthorised sign",
+ "Veg Obstructed: Street Light",
+ "Zebra crossing beacon fault"
+ ],
+ asset_item: 'light'
+}));
+
+fixmystreet.assets.add($.extend(true, {}, defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "streets"
+ }
+ },
+ max_resolution: 4.777314267158508,
+ always_visible: true,
+ non_interactive: true,
+ usrn: {
+ attribute: 'SITE_CODE',
+ field: 'site_code'
+ },
+ stylemap: new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ fill: false,
+ stroke: false
+ })
+ })
+}));
+
+
+})();