aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2019-07-10 14:43:35 +0100
committerStruan Donald <struan@exo.org.uk>2019-09-27 17:35:15 +0100
commitc6b4235615fbf7af954c8235cea4611dad6a8ae2 (patch)
tree5a237e7051b0ae172ec571a9f4b8e670fe24d2d1
parent2442aa586fd7729745b8343bb6f24f05fd19e7fb (diff)
[IsleOfWight] add asset layers
This uses the Triage categories as the category names and uses the associated groups to make sure the assets are displayed to staff users. There is a default streets layer as a fallback for site_codes. Some of the categories include both line and point assets so the line assets have `display_zoom_message` in order that both show the details of the currently selected asset.
-rw-r--r--templates/web/isleofwight/footer_extra_js.html1
-rw-r--r--web/cobrands/isleofwight/assets.js306
2 files changed, 307 insertions, 0 deletions
diff --git a/templates/web/isleofwight/footer_extra_js.html b/templates/web/isleofwight/footer_extra_js.html
index f4385d98b..0ad3525e6 100644
--- a/templates/web/isleofwight/footer_extra_js.html
+++ b/templates/web/isleofwight/footer_extra_js.html
@@ -5,5 +5,6 @@
version('/cobrands/fixmystreet-uk-councils/roadworks.js'),
version('/cobrands/fixmystreet-uk-councils/js.js'),
version('/cobrands/isleofwight/js.js'),
+ version('/cobrands/isleofwight/assets.js'),
);
END %]
diff --git a/web/cobrands/isleofwight/assets.js b/web/cobrands/isleofwight/assets.js
new file mode 100644
index 000000000..72a2c4dd2
--- /dev/null
+++ b/web/cobrands/isleofwight/assets.js
@@ -0,0 +1,306 @@
+(function(){
+
+if (!fixmystreet.maps) {
+ return;
+}
+
+var defaults = {
+ http_options: {
+ url: "https://tilma.staging.mysociety.org/mapserver/iow",
+ params: {
+ SERVICE: "WFS",
+ VERSION: "1.1.0",
+ REQUEST: "GetFeature",
+ SRSNAME: "urn:ogc:def:crs:EPSG::27700"
+ }
+ },
+ format_class: OpenLayers.Format.GML.v3.MultiCurveFix,
+ max_resolution: {
+ 'isleofwight': 0.5291677250021167,
+ 'fixmystreet': 1.194328566789627
+ },
+ attributes: {
+ central_asset_id: 'central_asset_id',
+ site_code: 'site_code'
+ },
+ min_resolution: 0.00001,
+ asset_id_field: 'asset_id',
+ geometryName: 'msGeometry',
+ srsName: "EPSG:27700",
+ strategy_class: OpenLayers.Strategy.FixMyStreet,
+ body: "Isle of Wight Council"
+};
+
+var pin_prefix = fixmystreet.pin_prefix || document.getElementById('js-map-data').getAttribute('data-pin_prefix');
+
+var labeled_default = {
+ fillColor: "#FFFF00",
+ fillOpacity: 0.6,
+ strokeColor: "#000000",
+ strokeOpacity: 0.8,
+ strokeWidth: 2,
+ pointRadius: 6
+};
+
+var labeled_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: "${asset_id}",
+ labelOutlineColor: "white",
+ labelOutlineWidth: 3,
+ labelYOffset: 65,
+ fontSize: '15px',
+ fontWeight: 'bold'
+};
+
+var labeled_stylemap = new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style(labeled_default),
+ 'select': new OpenLayers.Style(labeled_select)
+});
+
+fixmystreet.assets.add($.extend(true, {}, defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "streets"
+ }
+ },
+ always_visible: true,
+ non_interactive: true,
+ asset_type: 'area',
+ max_resolution: {
+ 'isleofwight': 6.614596562526458,
+ 'fixmystreet': 4.777314267158508
+ },
+ usrn: {
+ attribute: 'SITE_CODE',
+ field: 'site_code'
+ },
+ stylemap: new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ fill: false,
+ strokeColor: "#5555FF",
+ strokeOpacity: 0.1,
+ strokeWidth: 7
+ })
+ })
+}));
+
+function found_item(layer, asset) {
+ var id = asset.attributes.central_asset_id || '';
+ if (id !== '') {
+ var attrib = asset.attributes;
+ var asset_name = attrib.feature_type_name + '; ' + attrib.site_name + '; ' + attrib.feature_location;
+ $('.category_meta_message').html('You have selected ' + asset_name);
+ } else {
+ $('.category_meta_message').html('Please select an item or a road/pavement/path on the map &raquo;');
+ }
+}
+
+var point_asset_defaults = $.extend(true, {}, defaults, {
+ select_action: true,
+ asset_type: 'spot',
+ asset_item: "item",
+ actions: {
+ asset_found: function(asset) {
+ found_item(this, asset);
+ },
+ asset_not_found: function() {
+ $('.category_meta_message').html('Please select an item or a road/pavement/path on the map &raquo;');
+ }
+ }
+
+});
+
+var line_asset_defaults = $.extend(true, {}, defaults, {
+ display_zoom_message: true,
+ non_interactive: true,
+ road: true,
+ stylemap: fixmystreet.assets.stylemap_invisible,
+ usrn: {
+ attribute: 'site_code',
+ field: 'site_code'
+ },
+ asset_item: 'road',
+ actions: {
+ found: function(layer, feature) {
+ if ( fixmystreet.assets.selectedFeature() ) {
+ return;
+ }
+ found_item(layer, feature);
+ },
+ not_found: function(layer) {
+ if ( fixmystreet.assets.selectedFeature() ) {
+ return;
+ }
+ $('.category_meta_message').html('Please select an item or a road/pavement/path on the map &raquo;');
+ }
+ }
+});
+
+
+var point_category_list = [
+ //"Dog Fouling",
+ "Manholes",
+ "Trees & Hedges",
+ //"Pavements/footpaths",
+ //"Drainage",
+ //"Car Parking",
+ "Street Lighting",
+ "Bus Stops",
+ //"Flyposting",
+ //"Potholes",
+ //"Street Cleaning",
+ "Bridges & Walls",
+ "Traffic Lights",
+ "Street Furniture",
+ //"Roads/Highways",
+ "Road Traffic Signs & Markings",
+ "Grass Verges & Weeds",
+ //"Flytipping",
+ //"Graffiti",
+ "Street Nameplates",
+ //"Abandoned Vehicles"
+];
+
+var line_category_list = [
+ "Dog Fouling",
+ "Drainage",
+ "Car Parking",
+ "Pavements/footpaths",
+ "Potholes",
+ "Street Cleaning",
+ "Roads/Highways",
+ "Flytipping",
+ "Abandoned Vehicles"
+];
+
+var layer_map = {
+ "Dog Fouling": "Dog_Fouling",
+ "Drainage": "Drainage_line",
+ "Car Parking": "Car_Parks",
+ "Trees & Hedges": "Trees_Hedges",
+ "Pavements/footpaths": "Pavements_footpaths",
+ "Street Lighting": "Street_Lighting",
+ "Bus Stops": "Bus_Stops",
+ "Street Cleaning": "Street_Cleaning",
+ "Bridges & Walls": "Bridges_Walls",
+ "Traffic Lights": "Traffic_Lights",
+ "Street Furniture": "Street_Furniture",
+ "Roads/Highways": "Roads_Highways",
+ "Road Traffic Signs & Markings": "Road_Traffic_Signs_Markings",
+ "Grass Verges & Weeds": "Grass_Verges_Weeds",
+ "Street Nameplates": "Street_Nameplates",
+ "Abandoned Vehicles": "Abandoned_Vehicles"
+};
+
+for (i = 0; i < point_category_list.length; i++) {
+ cat = point_category_list[i];
+ layer = layer_map[cat] || cat;
+
+ fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ asset_group: cat,
+ http_options: {
+ params: {
+ TYPENAME: layer
+ }
+ }
+ }));
+}
+
+for (i = 0; i < line_category_list.length; i++) {
+ cat = line_category_list[i];
+ layer = layer_map[cat] || cat;
+
+ fixmystreet.assets.add($.extend(true, {}, line_asset_defaults, {
+ asset_group: cat,
+ asset_category: [
+ cat
+ ],
+ http_options: {
+ params: {
+ TYPENAME: layer
+ }
+ }
+ }));
+}
+
+// non union layers
+fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ snap_threshold: 10,
+ asset_group: "Roads/Highways",
+ http_options: {
+ params: {
+ TYPENAME: "Fords"
+ }
+ }
+}));
+
+fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ snap_threshold: 10,
+ asset_group: "Roads/Highways",
+ http_options: {
+ params: {
+ TYPENAME: "Furn-Grid_and_Stones"
+ }
+ }
+}));
+
+
+fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ snap_threshold: 10,
+ asset_group: "Drainage",
+ http_options: {
+ params: {
+ TYPENAME: "Drainage_spot"
+ }
+ }
+}));
+
+fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ snap_threshold: 10,
+ asset_group: "Car Parking",
+ http_options: {
+ params: {
+ TYPENAME: "Car_Parking"
+ }
+ }
+}));
+
+fixmystreet.assets.add($.extend(true, {}, line_asset_defaults, {
+ asset_group: "Grass Verges & Weeds",
+ asset_category: [
+ "Grass Verges & Weeds"
+ ],
+ http_options: {
+ params: {
+ TYPENAME: "Verges-Natural"
+ }
+ }
+}));
+
+fixmystreet.assets.add($.extend(true, {}, point_asset_defaults, {
+ snap_threshold: 10,
+ asset_group: "Dog Fouling",
+ http_options: {
+ params: {
+ TYPENAME: "Furn-Bins"
+ }
+ }
+}));
+
+fixmystreet.message_controller.add_msg_after_bodies(defaults.body);
+
+
+})();