aboutsummaryrefslogtreecommitdiffstats
path: root/web/cobrands/bathnes/assets.js
blob: f508ca97ce7d8971fac6951bb86f63302a768bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
(function(){

if (!fixmystreet.maps) {
    return;
}

fixmystreet.maps.banes_defaults = {
    http_options: {
        url: "https://isharemaps.bathnes.gov.uk/getows.ashx",
        params: {
            mapsource: "BathNES/WFS",
            SERVICE: "WFS",
            VERSION: "1.1.0",
            REQUEST: "GetFeature",
            TYPENAME: "",
            SRSNAME: "urn:ogc:def:crs:EPSG::27700",
            outputFormat: 'application/json'
        }
    },
    format_class: OpenLayers.Format.GeoJSON,
    format_options: {ignoreExtraDims: true},
    strategy_class: OpenLayers.Strategy.FixMyStreet,
    asset_category: "",
    asset_item: "asset",
    asset_type: 'spot',
    max_resolution: 4.777314267158508,
    min_resolution: 0.5971642833948135,
    asset_id_field: 'feature_no',
    attributes: null,
    geometryName: 'msGeometry',
    body: "Bath and North East Somerset Council",
    srsName: "EPSG:27700"
};


fixmystreet.assets.add(fixmystreet.maps.banes_defaults, {
    http_options: {
        params: {
            TYPENAME: "Gritbins"
        }
    },
    asset_category: "Grit bin issue",
    asset_item: "grit bin",
    attributes: {
        asset_details: 'feature_location'
    }
});

fixmystreet.assets.add(fixmystreet.maps.banes_defaults, {
    http_options: {
        params: {
            TYPENAME: "ParksOpenSpacesAssets"
        }
    },
    asset_category: [
        'Abandoned vehicles',
        'Dead animals',
        'Dog fouling',
        'Fly-tipping',
        'Graffiti',
        'Excessive or dangerous littering',
        'Needles',
        'Play area safety issue',
        'Damage to bins, benches, and infrastructure',
        'Allotment issue',
        'Trees and woodland',
        'Obstructive vegetation'
    ],
    asset_item: "park",
    disable_pin_snapping: true,
    stylemap: fixmystreet.assets.stylemap_invisible,
    attributes: {
        asset_details: function() {
            var a = this.attributes;
            return a.description + " " + a.assetid;
        }
    },
    filter_key: 'category',
    filter_value: [
        'Flower Beds',
        'Grass',
        'Hard',
        'Hedgerow',
        'Path',
        'Pitch',
        'Seats'
    ],
    name: "Parks and Grounds"
});



/*
 * Street lights are included/styled according to their owner.
 */

var banes_ownernames = [
    "B&NES CAR PARKS",
    "B&NES PARKS",
    "B&NES PROPERTY",
    "B&NES HIGHWAYS"
];

// Some are excluded from the map entirely
var exclude_ownernames = [
    "EXCEPTIONS"
];

function include_feature(f) {
    return f &&
           f.attributes &&
           f.attributes.ownername &&
           OpenLayers.Util.indexOf(exclude_ownernames, f.attributes.ownername) == -1;
}

function banes_owns_feature(f) {
    return f &&
           f.attributes &&
           f.attributes.ownername &&
           OpenLayers.Util.indexOf(banes_ownernames, f.attributes.ownername) > -1 &&
           include_feature(f);
}

function banes_does_not_own_feature(f) {
    return !banes_owns_feature(f) &&
           include_feature(f);
}

var lighting_default_style = new OpenLayers.Style({
    fillColor: "#868686",
    fillOpacity: 0.6,
    strokeColor: "#000000",
    strokeOpacity: 0.6,
    strokeWidth: 2,
    pointRadius: 4,
    title: '${unitdescription} ${unitno}\r\nNot owned by B&NES. Owned by ${ownername}.'
});

var rule_owned = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.FeatureId({
        type: OpenLayers.Filter.Function,
        evaluate: banes_owns_feature
    }),
    symbolizer: {
        fillColor: "#FFFF00",
        pointRadius: 6,
        title: '${unitdescription} ${unitno}',
    }
});

var rule_not_owned = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.FeatureId({
        type: OpenLayers.Filter.Function,
        evaluate: banes_does_not_own_feature
    })
});
lighting_default_style.addRules([rule_owned, rule_not_owned]);

var lighting_stylemap = new OpenLayers.StyleMap({
    'default': lighting_default_style,
    'select': fixmystreet.assets.style_default_select,
    'hover': new OpenLayers.Style({
        pointRadius: 8,
        cursor: 'pointer'
    })
});

fixmystreet.assets.add(fixmystreet.maps.banes_defaults, {
    http_options: {
        params: {
            TYPENAME: "StreetLighting"
        }
    },
    asset_category: "Street Light Fault",
    asset_item: "street light",
    stylemap: lighting_stylemap,
    attributes: {
        unitid: "unitid",
        asset_details: function() {
            var a = this.attributes;
            return "street: " + a.street + "\n" +
                   "owner: " + a.ownername + "\n" +
                   "unitno: " + a.unitno + "\n" +
                   "lamp: " + a.lamp + "\n" +
                   "lampclass: " + a.lampclass + "\n" +
                   "description: " + a.unitdescription;
        }
    }
});

fixmystreet.assets.add(fixmystreet.maps.banes_defaults, {
    http_options: {
        params: {
            TYPENAME: "AdoptedHighways"
        }
    },
    stylemap: fixmystreet.assets.stylemap_invisible,
    non_interactive: true,
    always_visible: true,
    usrn: {
        attribute: 'usrn',
        field: 'site_code'
    },
    road: true,
    asset_item: "road",
    asset_type: 'road',
    all_categories: true, // Not really, but want to allow on all but one, not stop
    no_asset_msg_id: '#js-not-a-road',
    cat_map: {
      'Damage to pavement': 'pavement',
      'Damage to road': 'road'
    },
    actions: {
        found: fixmystreet.message_controller.road_found,
        not_found: function(layer) {
            var cat = $('select#form_category').val();
            if (cat === 'Damage to pavement' || cat === 'Damage to road') {
                layer.fixmystreet.asset_item = layer.fixmystreet.cat_map[cat];
                fixmystreet.message_controller.road_not_found(layer);
            } else {
                fixmystreet.message_controller.road_found(layer);
            }
        }
    },
    name: "Adopted Highways",
    attribution: " © Crown Copyright. All rights reserved. 1000233344"
});


})();