diff options
author | Struan Donald <struan@exo.org.uk> | 2020-04-17 16:18:13 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-04-29 10:09:29 +0100 |
commit | e41476b0ab7307912f04dd9d876976c63f3076b9 (patch) | |
tree | 0b7c9af62e6a9fb66b4a327e9ddd8a6ac50e07aa /web | |
parent | 4f9f8e20121cda727beef8c5e3b25e9e187a8d81 (diff) |
[EastSussex] display assets on .com
Add assets for drains, grit bins and street lights. Uses east sussex
specific protocol and format
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/eastsussex/assets.js | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/web/cobrands/eastsussex/assets.js b/web/cobrands/eastsussex/assets.js new file mode 100644 index 000000000..a84ad11e9 --- /dev/null +++ b/web/cobrands/eastsussex/assets.js @@ -0,0 +1,97 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + + +OpenLayers.Format.EastSussex = OpenLayers.Class(OpenLayers.Format.JSON, { + read: function(json, type, filter) { + var obj = json; + if (typeof json == "string") { + obj = OpenLayers.Format.JSON.prototype.read.apply(this, + [json, filter]); + } + + var results = []; + for (var i=0, len=obj.length; i<len; i++) { + var item = obj[i]; + var geom = new OpenLayers.Geometry.Point(item.Mid_Location__c.longitude, item.Mid_Location__c.latitude); + var vec = new OpenLayers.Feature.Vector(geom, item); + results.push(vec); + } + + return results; + }, + CLASS_NAME: "OpenLayers.Format.EastSussex" +}); + +OpenLayers.Protocol.EastSussex = OpenLayers.Class(OpenLayers.Protocol.HTTP, { + read: function(options) { + OpenLayers.Protocol.prototype.read.apply(this, arguments); + options = options || {}; + options.params = OpenLayers.Util.applyDefaults( + options.params, this.options.params); + options = OpenLayers.Util.applyDefaults(options, this.options); + var types = options.types.join('&types='); + var coords = fixmystreet.map.getCenterWGS84(); + options.url = options.url + '?longitude=' + coords.lat + '&latitude=' + coords.lon + '&types=' + types; + var resp = new OpenLayers.Protocol.Response({requestType: "read"}); + resp.priv = OpenLayers.Request.GET({ + url: options.url, + callback: this.createCallback(this.handleRead, resp, options), + params: options.params, + headers: options.headers + }); + }, + CLASS_NAME: "OpenLayers.Protocol.EastSussex" +}); + +var defaults = { + http_options: { + url: fixmystreet.staging ? "https://tilma.staging.mysociety.org/proxy/escc/" : "https://tilma.mysociety.org/proxy/escc/" + }, + max_resolution: 1.194328566789627, + geometryName: 'msGeometry', + srsName: "EPSG:4326", + body: "East Sussex County Council", + format_class: OpenLayers.Format.EastSussex, + protocol_class: OpenLayers.Protocol.EastSussex, + asset_id_field: 'asset_id', + attributes: { + asset_id: 'id' + } +}; + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Bollard", "Central Refuge Beacon", "External Illuminated Sign", "Floodlight", "Internal Illuminated Sign", "Lighting Column", "Reflect Bollard", "Safety bollards", "Solar Bollard", "Subway Unit", "Zebra X Beacon" + ] + }, + asset_item: 'street light', + asset_category: ["Burning By Day", "Intermittent", "Knocked Down", "Lamp Dim", "Vandalism", "Wires Exposed"] +}); + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Grit bin" + ] + }, + asset_item: 'grit bin', + asset_category: ["Broken Grit Bin", "Request To Refill Grit Bin"] +}); + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Filter Drain", "Gully and Catchpit" + ] + }, + asset_id_field: 'id', + asset_item: 'drain', + asset_category: ["Blocked Drain", "Broken Drain Cover", "Ditches", "Missing Drain Cover"] +}); + +})(); |