ekylibre-cartography 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +3 -0
  3. data/Rakefile +10 -0
  4. data/app/assets/javascripts/cartography.coffee +535 -0
  5. data/app/assets/javascripts/cartography/base.coffee +11 -0
  6. data/app/assets/javascripts/cartography/controls.coffee +463 -0
  7. data/app/assets/javascripts/cartography/events.coffee +36 -0
  8. data/app/assets/javascripts/cartography/layers.coffee +127 -0
  9. data/app/assets/javascripts/cartography/layers/simple.coffee +37 -0
  10. data/app/assets/javascripts/cartography/leaflet/controls.coffee +420 -0
  11. data/app/assets/javascripts/cartography/leaflet/handlers.coffee +461 -0
  12. data/app/assets/javascripts/cartography/leaflet/i18n.coffee +31 -0
  13. data/app/assets/javascripts/cartography/leaflet/layers.coffee +60 -0
  14. data/app/assets/javascripts/cartography/leaflet/toolbars.coffee +450 -0
  15. data/app/assets/javascripts/cartography/patches.js +8 -0
  16. data/app/assets/javascripts/cartography/util.coffee +18 -0
  17. data/app/assets/javascripts/main.js +18 -0
  18. data/app/assets/stylesheets/cartography.css +86 -0
  19. data/app/helpers/cartography_helper.rb +55 -0
  20. data/lib/cartography.rb +1 -0
  21. data/lib/cartography/engine.rb +11 -0
  22. data/lib/cartography/version.rb +3 -0
  23. data/vendor/assets/components/d3-array/dist/d3-array.js +590 -0
  24. data/vendor/assets/components/d3-array/dist/d3-array.min.js +2 -0
  25. data/vendor/assets/components/geojson-equality/dist/geojson-equality.js +295 -0
  26. data/vendor/assets/components/geojson-equality/dist/geojson-equality.js.map +21 -0
  27. data/vendor/assets/components/geojson-equality/dist/geojson-equality.min.js +1 -0
  28. data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.css +29 -0
  29. data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.js +269 -0
  30. data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.css +1 -0
  31. data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.js +8 -0
  32. data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.css +0 -0
  33. data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.js +48026 -0
  34. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.css +326 -0
  35. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.js +4653 -0
  36. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.map +1 -0
  37. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.css +10 -0
  38. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.js +10 -0
  39. data/vendor/assets/components/leaflet-geographicutil/dist/leaflet.geographicutil.js +3220 -0
  40. data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.css +30 -0
  41. data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.js +3764 -0
  42. data/vendor/assets/components/leaflet/dist/leaflet-src.js +13609 -0
  43. data/vendor/assets/components/leaflet/dist/leaflet-src.js.map +1 -0
  44. data/vendor/assets/components/leaflet/dist/leaflet-src.map +1 -0
  45. data/vendor/assets/components/leaflet/dist/leaflet.css +632 -0
  46. data/vendor/assets/components/leaflet/dist/leaflet.js +5 -0
  47. data/vendor/assets/components/leaflet/dist/leaflet.js.map +1 -0
  48. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.min.js +9 -0
  49. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js +1716 -0
  50. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js.map +1 -0
  51. data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.js +279 -0
  52. data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.min.js +1 -0
  53. data/vendor/assets/components/rtree/dist/rtree.js +911 -0
  54. data/vendor/assets/components/rtree/dist/rtree.min.js +1 -0
  55. data/vendor/assets/components/splaytree/dist/splay.es6.js +765 -0
  56. data/vendor/assets/components/splaytree/dist/splay.es6.js.map +1 -0
  57. data/vendor/assets/components/splaytree/dist/splay.js +797 -0
  58. data/vendor/assets/components/splaytree/dist/splay.js.map +1 -0
  59. metadata +156 -0
@@ -0,0 +1,31 @@
1
+ L.drawLocal ||= {}
2
+ _.merge(L.drawLocal, {
3
+ split: {
4
+ toolbar: {
5
+ actions: {
6
+ save: {
7
+ title: 'Save changes',
8
+ text: 'Save'
9
+ },
10
+ cancel: {
11
+ title: 'Cancel splitting, discards all changes',
12
+ text: 'Cancel'
13
+ }
14
+ },
15
+ buttons: {
16
+ cutPolyline: 'Split layer'
17
+ }
18
+ }
19
+ },
20
+ zoom: {
21
+ zoomInTitle: 'Zoom in',
22
+ zoomOutTitle: 'Zoom out'
23
+ },
24
+ home: {
25
+ toolbar: {
26
+ buttons: {
27
+ home: 'Center to polygons'
28
+ }
29
+ }
30
+ }
31
+ })
@@ -0,0 +1,60 @@
1
+ class L.IndexedGeoJSON extends L.GeoJSON
2
+
3
+ constructor: (geojson, options) ->
4
+ @_onEachFeature = options.onEachFeature
5
+
6
+ onEachFeature = (geojson, layer) ->
7
+ layer.on 'add', =>
8
+ @indexLayer layer
9
+ layer.on 'remove', =>
10
+ @unindexLayer layer
11
+
12
+ if @_onEachFeature
13
+ @_onEachFeature geojson, layer
14
+
15
+ return
16
+
17
+ options.onEachFeature = L.Util.bind onEachFeature, @
18
+
19
+ super geojson, options
20
+
21
+ L.IndexedGeoJSON.include L.LayerIndexMixin
22
+
23
+ class L.GhostIcon extends L.DivIcon
24
+ options:
25
+ iconSize: [20, 20]
26
+ className: "plus-ghost-icon"
27
+ html: ""
28
+
29
+ L.LayerGroup.include
30
+ getLayerUUID: (layer) ->
31
+ layer.feature.properties.uuid
32
+
33
+ hasUUIDLayer: (layer) ->
34
+ if !!layer && layerUUID = @getLayerUUID(layer)
35
+ for id, l of @_layers
36
+ if @getLayerUUID(l) == layerUUID
37
+ return true
38
+ return false
39
+
40
+ getLayerID: (layer) ->
41
+ layer.feature.properties.id
42
+
43
+ hasIDLayer: (layer) ->
44
+ if !!layer && layerID = @getLayerID(layer)
45
+ for id, l of @_layers
46
+ if @getLayerID(l) == layerID
47
+ return true
48
+
49
+ bindInit: (event, callback) ->
50
+ unless @initialized && @initialized[event]
51
+ @on event, callback, @
52
+ @initialized[event] = true
53
+
54
+ unbind: (event, callback) ->
55
+ @off event, callback, @
56
+ @initialized[event] = false
57
+
58
+ L.LayerGroup.addInitHook ->
59
+ @initialized = {}
60
+
@@ -0,0 +1,450 @@
1
+ ((C) ->
2
+ "use strict"
3
+
4
+ class L.SnapEditToolbar extends L.EditToolbar
5
+ @TYPE: 'snapedit'
6
+
7
+ options:
8
+ edit:
9
+ selectedPathOptions:
10
+ dashArray: '10, 10'
11
+ fill: true
12
+ fillColor: '#fe57a1'
13
+ fillOpacity: 0.1
14
+ maintainColor: false
15
+ disabledPathOptions:
16
+ dashArray: null
17
+ fill: true
18
+ fillColor: '#fe57a1'
19
+ fillOpacity: 0.1
20
+ maintainColor: true
21
+ remove: {}
22
+ poly: null
23
+ featureGroup: null
24
+
25
+ constructor: (options = {}) ->
26
+ C.Util.setOptions @, options
27
+ @type = @constructor.TYPE
28
+
29
+ # fallback for toolbar
30
+ @options.featureGroup = @options.edit.featureGroup
31
+
32
+
33
+ super @options
34
+ @_selectedFeatureCount = 0
35
+ this
36
+
37
+ #Get mode handlers information
38
+ getModeHandlers: (map) ->
39
+ featureGroup = @options.featureGroup
40
+ [
41
+ {
42
+ enabled: @options.edit
43
+ handler: new L.EditToolbar.SelectableSnapEdit map,
44
+ snapOptions: @options.snap
45
+ featureGroup: featureGroup
46
+ selectedPathOptions: @options.edit.selectedPathOptions
47
+ disabledPathOptions: @options.edit.disabledPathOptions
48
+ poly: @options.poly
49
+
50
+ title: L.drawLocal.edit.toolbar.buttons.edit
51
+ },
52
+ {
53
+ enabled: @options.remove
54
+ handler: new L.EditToolbar.Delete map,
55
+ featureGroup: featureGroup
56
+
57
+ title: L.drawLocal.edit.toolbar.buttons.remove
58
+ }
59
+ ]
60
+
61
+ #Get actions information
62
+ getActions: (handler) ->
63
+ actions = [
64
+ {
65
+ title: L.drawLocal.edit.toolbar.actions.save.title
66
+ text: L.drawLocal.edit.toolbar.actions.save.text
67
+ callback: @_save
68
+ context: @
69
+ }
70
+ {
71
+ title: L.drawLocal.edit.toolbar.actions.cancel.title
72
+ text: L.drawLocal.edit.toolbar.actions.cancel.text
73
+ callback: @disable
74
+ context: @
75
+ }
76
+ ]
77
+
78
+ if handler.removeAllLayers
79
+ actions.push({
80
+ title: L.drawLocal.edit.toolbar.actions.clearAll.title
81
+ text: L.drawLocal.edit.toolbar.actions.clearAll.text
82
+ callback: @_clearAllLayers
83
+ context: @ })
84
+
85
+ actions
86
+
87
+
88
+ class L.LayerSelectionToolbar extends L.Toolbar
89
+ @TYPE: 'layerSelection'
90
+
91
+ options:
92
+ position: 'topleft'
93
+ featureGroup: undefined
94
+ # color: "#A40"
95
+ selectedPathOptions:
96
+ dashArray: '10, 10'
97
+ fill: true
98
+ fillColor: '#fe57a1'
99
+ fillOpacity: 0.1
100
+ maintainColor: false
101
+
102
+ constructor: (options = {}) ->
103
+ C.Util.setOptions @, options
104
+ @type = @constructor.TYPE
105
+
106
+ super @options
107
+ this
108
+
109
+ #Get mode handlers information
110
+ getModeHandlers: (map) ->
111
+ featureGroup = @options.featureGroup
112
+ [
113
+ {
114
+ enabled: true
115
+ handler: new L.LayerSelection map,
116
+ featureGroup: featureGroup
117
+ selectedPathOptions: @options.selectedPathOptions
118
+
119
+ title: L.drawLocal.edit.toolbar.buttons.edit
120
+ }
121
+ ]
122
+
123
+ #Get actions information
124
+ getActions: (handler) ->
125
+ [
126
+ {
127
+ title: L.drawLocal.edit.toolbar.actions.save.title
128
+ text: L.drawLocal.edit.toolbar.actions.save.text
129
+ callback: @_save
130
+ context: @
131
+ },
132
+ {
133
+ title: L.drawLocal.edit.toolbar.actions.cancel.title
134
+ text: L.drawLocal.edit.toolbar.actions.cancel.text
135
+ callback: @disable
136
+ context: @
137
+ }
138
+ ]
139
+
140
+ addToolbar: (map) ->
141
+ container = super map
142
+
143
+ @_checkDisabled()
144
+
145
+ @options.featureGroup.on 'layeradd layerremove', @_checkDisabled, @
146
+
147
+ container
148
+
149
+ removeToolbar: ->
150
+ @options.featureGroup.off 'layeradd layerremove', @_checkDisabled, @
151
+ super
152
+
153
+ disable: ->
154
+ if !@.enabled()
155
+ return
156
+
157
+ super
158
+
159
+ _save: ->
160
+ @_activeMode.handler.save()
161
+
162
+ if @_activeMode
163
+ @_activeMode.handler.disable()
164
+
165
+ _checkDisabled: ->
166
+ featureGroup = @options.featureGroup
167
+ hasLayers = featureGroup.getLayers().length != 0
168
+ button = this._modes[L.LayerSelection.TYPE].button
169
+
170
+ if hasLayers
171
+ L.DomUtil.removeClass button, 'leaflet-disabled'
172
+ else
173
+ L.DomUtil.addClass button, 'leaflet-disabled'
174
+
175
+ title = if hasLayers then L.drawLocal.edit.toolbar.buttons.edit else L.drawLocal.edit.toolbar.buttons.editDisabled
176
+
177
+ button.setAttribute 'title', title
178
+
179
+ class L.HomeToolbar extends L.Toolbar
180
+ @TYPE: 'home'
181
+
182
+ options:
183
+ position: 'topleft'
184
+ featureGroup: null
185
+
186
+ constructor: (options = {}) ->
187
+ C.Util.setOptions @, options
188
+ @type = @constructor.TYPE
189
+ @_toolbarClass = 'leaflet-home'
190
+
191
+ super @options
192
+ this
193
+
194
+ #Get mode handlers information
195
+ getModeHandlers: (map) ->
196
+ [
197
+ {
198
+ enabled: true
199
+ handler: new L.Home map, @options
200
+ title: L.drawLocal.home.toolbar.buttons.home
201
+ }
202
+ ]
203
+
204
+ #Get actions information
205
+ getActions: (handler) ->
206
+ []
207
+
208
+ addToolbar: (map) ->
209
+ container = super map
210
+
211
+ @_checkDisabled()
212
+
213
+ @options.featureGroup.on 'layeradd layerremove', @_checkDisabled, @
214
+
215
+ container
216
+
217
+ removeToolbar: ->
218
+ @options.featureGroup.off 'layeradd layerremove', @_checkDisabled, @
219
+ super
220
+
221
+ _checkDisabled: ->
222
+ featureGroup = @options.featureGroup
223
+ hasLayers = featureGroup.getLayers().length != 0
224
+ button = this._modes[L.Home.TYPE].button
225
+
226
+ if hasLayers
227
+ L.DomUtil.removeClass button, 'leaflet-hidden'
228
+ else
229
+ L.DomUtil.addClass button, 'leaflet-hidden'
230
+
231
+ class L.CutToolbar extends L.Toolbar
232
+ @TYPE: 'cut'
233
+
234
+ options:
235
+ position: 'topleft'
236
+ featureGroup: undefined
237
+ # color: "#A40"
238
+ disabledPathOptions:
239
+ dashArray: null
240
+ fill: true
241
+ color: '#263238'
242
+ fillColor: '#263238'
243
+ opacity: 1
244
+ fillOpacity: 0.4
245
+ maintainColor: false
246
+ selectedPathOptions:
247
+ dashArray: null
248
+ fill: true
249
+ fillColor: '#fe57a1'
250
+ opacity: 1
251
+ fillOpacity: 1
252
+ maintainColor: true
253
+ weight: 3
254
+ cuttingPathOptions:
255
+ color: '#FF6226'
256
+ className: 'leaflet-polygon-splitter'
257
+ #dashArray: '10, 10'
258
+ #fill: true
259
+ # color: '#3f51b5'
260
+ # fillOpacity: 0.9
261
+ #maintainColor: true
262
+ #snap:
263
+ #guideLayers: []
264
+ #snapDistance: 30
265
+ #allowIntersection: false
266
+ #guidelineDistance: 8
267
+ #shapeOptions:
268
+ #dashArray: '8, 8'
269
+ #fill: false
270
+ #color: '#FF5722'
271
+ #opacity: 1
272
+
273
+ constructor: (options = {}) ->
274
+ C.Util.setOptions @, options
275
+ @type = @constructor.TYPE
276
+ @_toolbarClass = 'leaflet-cut-polyline'
277
+
278
+ super @options
279
+ this
280
+
281
+ #Get mode handlers information
282
+ getModeHandlers: (map) ->
283
+ [
284
+ {
285
+ enabled: true
286
+ handler: new L.Cut.Polyline map, @options
287
+
288
+ title: L.drawLocal.split.toolbar.buttons.cutPolyline
289
+ }
290
+ ]
291
+
292
+ #Get actions information
293
+ getActions: (handler) ->
294
+ [
295
+ {
296
+ title: L.drawLocal.split.toolbar.actions.save.title
297
+ text: L.drawLocal.split.toolbar.actions.save.text
298
+ callback: @_save
299
+ context: @
300
+ },
301
+ {
302
+ title: L.drawLocal.split.toolbar.actions.cancel.title
303
+ text: L.drawLocal.split.toolbar.actions.cancel.text
304
+ callback: @disable
305
+ context: @
306
+ }
307
+ ]
308
+
309
+ addToolbar: (map) ->
310
+ container = super map
311
+
312
+ @_checkDisabled()
313
+
314
+ @options.featureGroup.on 'layeradd layerremove', @_checkDisabled, @
315
+
316
+ container
317
+
318
+ removeToolbar: ->
319
+ @options.featureGroup.off 'layeradd layerremove', @_checkDisabled, @
320
+ super
321
+
322
+ disable: ->
323
+ if !@enabled()
324
+ return
325
+
326
+ @_activeMode.handler.disable()
327
+
328
+ _save: ->
329
+ @_activeMode.handler.save()
330
+
331
+ if @_activeMode
332
+ @_activeMode.handler.disable()
333
+
334
+ _checkDisabled: ->
335
+ featureGroup = @options.featureGroup
336
+ hasLayers = featureGroup.getLayers().length != 0
337
+ button = this._modes[L.Cut.Polyline.TYPE].button
338
+
339
+ if hasLayers
340
+ L.DomUtil.removeClass button, 'leaflet-disabled'
341
+ else
342
+ L.DomUtil.addClass button, 'leaflet-disabled'
343
+
344
+ title = if hasLayers then L.drawLocal.split.toolbar.buttons.cutPolyline else L.drawLocal.edit.toolbar.buttons.editDisabled
345
+
346
+ button.setAttribute 'title', title
347
+
348
+
349
+ class L.MergeToolbar extends L.Toolbar
350
+ @TYPE: 'merge'
351
+
352
+ options:
353
+ position: 'topleft'
354
+ featureGroup: undefined
355
+ # color: "#A40"
356
+ disabledPathOptions:
357
+ dashArray: null
358
+ fill: true
359
+ fillColor: '#fe57a1'
360
+ fillOpacity: 0.1
361
+ maintainColor: true
362
+ selectedPathOptions:
363
+ dashArray: null
364
+ fill: true
365
+ fillColor: '#fe57a1'
366
+ fillOpacity: 0.9
367
+ maintainColor: true
368
+ mergingPathOptions:
369
+ dashArray: '10, 10'
370
+ fill: true
371
+ color: '#3f51b5'
372
+ # fillOpacity: 0.9
373
+ maintainColor: false
374
+
375
+ constructor: (options = {}) ->
376
+ C.Util.setOptions @, options
377
+ @type = @constructor.TYPE
378
+ @_toolbarClass = 'leaflet-merge'
379
+
380
+ super @options
381
+ this
382
+
383
+ #Get mode handlers information
384
+ getModeHandlers: (map) ->
385
+ [
386
+ {
387
+ enabled: true
388
+ handler: new L.Merge map, @options
389
+
390
+ title: L.drawLocal.edit.toolbar.buttons.edit
391
+ }
392
+ ]
393
+
394
+ #Get actions information
395
+ getActions: (handler) ->
396
+ [
397
+ {
398
+ title: L.drawLocal.edit.toolbar.actions.save.title
399
+ text: L.drawLocal.edit.toolbar.actions.save.text
400
+ callback: @_save
401
+ context: @
402
+ },
403
+ {
404
+ title: L.drawLocal.edit.toolbar.actions.cancel.title
405
+ text: L.drawLocal.edit.toolbar.actions.cancel.text
406
+ callback: @disable
407
+ context: @
408
+ }
409
+ ]
410
+
411
+ addToolbar: (map) ->
412
+ container = super map
413
+
414
+ @_checkDisabled()
415
+
416
+ @options.featureGroup.on 'layeradd layerremove', @_checkDisabled, @
417
+
418
+ container
419
+
420
+ removeToolbar: ->
421
+ @options.featureGroup.off 'layeradd layerremove', @_checkDisabled, @
422
+ super
423
+
424
+ disable: ->
425
+ if !@.enabled()
426
+ return
427
+
428
+ super
429
+
430
+ _save: ->
431
+ @_activeMode.handler.save()
432
+
433
+ if @_activeMode
434
+ @_activeMode.handler.disable()
435
+
436
+ _checkDisabled: ->
437
+ featureGroup = @options.featureGroup
438
+ hasLayers = featureGroup.getLayers().length != 0
439
+ button = this._modes[L.Merge.TYPE].button
440
+
441
+ if hasLayers
442
+ L.DomUtil.removeClass button, 'leaflet-disabled'
443
+ else
444
+ L.DomUtil.addClass button, 'leaflet-disabled'
445
+
446
+ title = if hasLayers then L.drawLocal.edit.toolbar.buttons.edit else L.drawLocal.edit.toolbar.buttons.editDisabled
447
+
448
+ button.setAttribute 'title', title
449
+
450
+ )(window.Cartography = window.Cartography || {})