ekylibre-cartography 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/Rakefile +10 -0
- data/app/assets/javascripts/cartography.coffee +535 -0
- data/app/assets/javascripts/cartography/base.coffee +11 -0
- data/app/assets/javascripts/cartography/controls.coffee +463 -0
- data/app/assets/javascripts/cartography/events.coffee +36 -0
- data/app/assets/javascripts/cartography/layers.coffee +127 -0
- data/app/assets/javascripts/cartography/layers/simple.coffee +37 -0
- data/app/assets/javascripts/cartography/leaflet/controls.coffee +420 -0
- data/app/assets/javascripts/cartography/leaflet/handlers.coffee +461 -0
- data/app/assets/javascripts/cartography/leaflet/i18n.coffee +31 -0
- data/app/assets/javascripts/cartography/leaflet/layers.coffee +60 -0
- data/app/assets/javascripts/cartography/leaflet/toolbars.coffee +450 -0
- data/app/assets/javascripts/cartography/patches.js +8 -0
- data/app/assets/javascripts/cartography/util.coffee +18 -0
- data/app/assets/javascripts/main.js +18 -0
- data/app/assets/stylesheets/cartography.css +86 -0
- data/app/helpers/cartography_helper.rb +55 -0
- data/lib/cartography.rb +1 -0
- data/lib/cartography/engine.rb +11 -0
- data/lib/cartography/version.rb +3 -0
- data/vendor/assets/components/d3-array/dist/d3-array.js +590 -0
- data/vendor/assets/components/d3-array/dist/d3-array.min.js +2 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.js +295 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.js.map +21 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.min.js +1 -0
- data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.css +29 -0
- data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.js +269 -0
- data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.css +1 -0
- data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.js +8 -0
- data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.css +0 -0
- data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.js +48026 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.css +326 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.js +4653 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.map +1 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.css +10 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.js +10 -0
- data/vendor/assets/components/leaflet-geographicutil/dist/leaflet.geographicutil.js +3220 -0
- data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.css +30 -0
- data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.js +3764 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.js +13609 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.js.map +1 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.map +1 -0
- data/vendor/assets/components/leaflet/dist/leaflet.css +632 -0
- data/vendor/assets/components/leaflet/dist/leaflet.js +5 -0
- data/vendor/assets/components/leaflet/dist/leaflet.js.map +1 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.min.js +9 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js +1716 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js.map +1 -0
- data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.js +279 -0
- data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.min.js +1 -0
- data/vendor/assets/components/rtree/dist/rtree.js +911 -0
- data/vendor/assets/components/rtree/dist/rtree.min.js +1 -0
- data/vendor/assets/components/splaytree/dist/splay.es6.js +765 -0
- data/vendor/assets/components/splaytree/dist/splay.es6.js.map +1 -0
- data/vendor/assets/components/splaytree/dist/splay.js +797 -0
- data/vendor/assets/components/splaytree/dist/splay.js.map +1 -0
- metadata +156 -0
@@ -0,0 +1,463 @@
|
|
1
|
+
((C, $) ->
|
2
|
+
"use strict"
|
3
|
+
|
4
|
+
class C.Control extends C.BaseClass
|
5
|
+
constructor: (map) ->
|
6
|
+
super(map)
|
7
|
+
|
8
|
+
class C.Controls extends C.Control
|
9
|
+
constructor: (map) ->
|
10
|
+
@controls = {}
|
11
|
+
@collection = {}
|
12
|
+
|
13
|
+
super(map)
|
14
|
+
|
15
|
+
add: (id) ->
|
16
|
+
return if @get(id)
|
17
|
+
item = @collection[id]
|
18
|
+
control = item.constructor.call()
|
19
|
+
@controls[id] = control
|
20
|
+
@getMap().addControl control.getControl() unless !item.addToMap
|
21
|
+
|
22
|
+
if control.getToolbar()
|
23
|
+
control.getToolbar().on 'enable', (e) =>
|
24
|
+
for toolbar in @getToolbars()
|
25
|
+
continue if toolbar is e.target
|
26
|
+
toolbar.disable()
|
27
|
+
|
28
|
+
if item.callback and item.callback.constructor.name is 'Function'
|
29
|
+
item.callback.call @
|
30
|
+
|
31
|
+
register: (id, addToMap = true, constructor, callback) ->
|
32
|
+
@collection[id] = addToMap: addToMap, constructor: constructor, callback: callback
|
33
|
+
|
34
|
+
unregister: (id) ->
|
35
|
+
@collection[id] = undefined
|
36
|
+
@remove(id)
|
37
|
+
|
38
|
+
remove: (id) ->
|
39
|
+
if control = @get(id)
|
40
|
+
item = @collection[id]
|
41
|
+
@getMap().removeControl control.getControl() unless !item.addToMap
|
42
|
+
|
43
|
+
c = control.getControl()
|
44
|
+
if c and c.disable and c.disable.constructor.name is 'Function'
|
45
|
+
c.disable()
|
46
|
+
|
47
|
+
@controls[id] = undefined
|
48
|
+
|
49
|
+
get: (id) ->
|
50
|
+
@controls[id]
|
51
|
+
|
52
|
+
getToolbar: ->
|
53
|
+
undefined
|
54
|
+
|
55
|
+
getToolbars: ->
|
56
|
+
Object.values(@controls)
|
57
|
+
.filter Boolean
|
58
|
+
.map (c) ->
|
59
|
+
c.getToolbar()
|
60
|
+
.filter Boolean
|
61
|
+
|
62
|
+
|
63
|
+
class C.Controls.Layers extends C.Controls
|
64
|
+
options:
|
65
|
+
position: 'topleft'
|
66
|
+
constructor: ( control, map, options = {} ) ->
|
67
|
+
super(map)
|
68
|
+
|
69
|
+
C.Util.setOptions @, options
|
70
|
+
|
71
|
+
@control = control || new L.Control.Layers(undefined, undefined, @options)
|
72
|
+
|
73
|
+
@layers = {}
|
74
|
+
|
75
|
+
getLayers: ->
|
76
|
+
@references.getLayers()
|
77
|
+
|
78
|
+
getMainLayer: ->
|
79
|
+
@references.getMainLayer()
|
80
|
+
|
81
|
+
getLayer: (name) ->
|
82
|
+
@references.getLayers()[name]
|
83
|
+
|
84
|
+
getControl: ->
|
85
|
+
@control
|
86
|
+
|
87
|
+
class C.Controls.BaseLayers extends C.Controls.Layers
|
88
|
+
options:
|
89
|
+
backgrounds: [
|
90
|
+
'Esri.WorldImagery'
|
91
|
+
'OpenStreetMap.Mapnik',
|
92
|
+
'OpenStreetMap.HOT',
|
93
|
+
'Thunderforest.Landscape',
|
94
|
+
]
|
95
|
+
|
96
|
+
constructor: ( control, map, options = {} )->
|
97
|
+
C.Util.setOptions @, options
|
98
|
+
super(control, map)
|
99
|
+
|
100
|
+
@references = new C.BaseLayers(map, @options)
|
101
|
+
@add(@options.backgrounds)
|
102
|
+
|
103
|
+
@setActive(0)
|
104
|
+
|
105
|
+
add: (layers) ->
|
106
|
+
newLayers = @references.add(layers)
|
107
|
+
|
108
|
+
for name, layer of newLayers
|
109
|
+
@getControl().addBaseLayer(layer, name)
|
110
|
+
|
111
|
+
setActive: (index) ->
|
112
|
+
@getMap().addLayer(@getLayers()[Object.keys(@getLayers())[index]])
|
113
|
+
|
114
|
+
class C.Controls.OverlayLayers extends C.Controls.Layers
|
115
|
+
options:
|
116
|
+
minZoom: 0
|
117
|
+
maxZoom: 25
|
118
|
+
overlays: []
|
119
|
+
series: {}
|
120
|
+
|
121
|
+
constructor: ( control, map, options = {} )->
|
122
|
+
C.Util.setOptions @, options
|
123
|
+
super(control, map)
|
124
|
+
|
125
|
+
@references = new C.OverlayLayers(map, @options)
|
126
|
+
@add(@options.overlays, 'tiles') unless !@options.overlays.length
|
127
|
+
@add([@options.series, @options.layers], 'series') if @options.series?
|
128
|
+
|
129
|
+
#TODO: refactoring
|
130
|
+
add: (layers, type) ->
|
131
|
+
[series, propertiesCollection, ...] = layers
|
132
|
+
|
133
|
+
propertiesCollection ||= []
|
134
|
+
|
135
|
+
if !propertiesCollection.length
|
136
|
+
newLayers = @references.add(layers, type)
|
137
|
+
|
138
|
+
for name, layer of newLayers
|
139
|
+
@getControl().addOverlay(layer, name)
|
140
|
+
|
141
|
+
for properties in propertiesCollection
|
142
|
+
if @references.getLayers()[properties.name] is undefined
|
143
|
+
newLayers = @references.add(layers, type)
|
144
|
+
|
145
|
+
for name, layer of newLayers
|
146
|
+
@getControl().addOverlay(layer, name)
|
147
|
+
else
|
148
|
+
@references.updateSerie(@references.getLayers()[properties.name], series[properties.name])
|
149
|
+
|
150
|
+
remove: (name) ->
|
151
|
+
layer = @getLayer name
|
152
|
+
@getControl().removeLayer layer
|
153
|
+
layer.eachLayer (l) =>
|
154
|
+
@getMap().removeLayer l
|
155
|
+
|
156
|
+
@getMap().removeLayer layer
|
157
|
+
delete @references.layers[name]
|
158
|
+
|
159
|
+
|
160
|
+
class C.Controls.Scale extends C.Controls
|
161
|
+
options:
|
162
|
+
position: "bottomright"
|
163
|
+
imperial: false
|
164
|
+
maxWidth: 200
|
165
|
+
|
166
|
+
constructor: ( map, options = {} ) ->
|
167
|
+
super(map)
|
168
|
+
C.Util.setOptions @, options
|
169
|
+
@control = new L.Control.Scale(@options)
|
170
|
+
|
171
|
+
getControl: ->
|
172
|
+
@control
|
173
|
+
|
174
|
+
class C.Controls.Zoom extends C.Controls
|
175
|
+
options:
|
176
|
+
position: "topleft"
|
177
|
+
|
178
|
+
constructor: ( map, options = {} ) ->
|
179
|
+
super(map)
|
180
|
+
C.Util.setOptions @, options
|
181
|
+
@control = new L.Control.Zoom(@options)
|
182
|
+
|
183
|
+
getControl: ->
|
184
|
+
@control
|
185
|
+
|
186
|
+
class C.Controls.Home extends C.Controls
|
187
|
+
options:
|
188
|
+
position: "topleft"
|
189
|
+
|
190
|
+
constructor: ( map, options = {} ) ->
|
191
|
+
super(map)
|
192
|
+
C.Util.setOptions @, options
|
193
|
+
@control = new L.Control.Home(@options.home)
|
194
|
+
|
195
|
+
getControl: ->
|
196
|
+
@control
|
197
|
+
|
198
|
+
class C.Controls.Draw extends C.Controls
|
199
|
+
options:
|
200
|
+
draw:
|
201
|
+
edit: false
|
202
|
+
draw:
|
203
|
+
marker: false
|
204
|
+
circlemarker: false
|
205
|
+
polyline: false
|
206
|
+
rectangle: false
|
207
|
+
circle: false
|
208
|
+
polygon:
|
209
|
+
allowIntersection: false
|
210
|
+
showArea: false
|
211
|
+
snap:
|
212
|
+
polygon:
|
213
|
+
guideLayers: []
|
214
|
+
snapDistance: 15
|
215
|
+
snapOriginDistance: 30
|
216
|
+
allowIntersection: false
|
217
|
+
guidelineDistance: 8
|
218
|
+
shapeOptions:
|
219
|
+
dashArray: '8, 8'
|
220
|
+
fill: false
|
221
|
+
color: '#FF5722'
|
222
|
+
opacity: 1
|
223
|
+
|
224
|
+
constructor: ( map, options = {} ) ->
|
225
|
+
super(map)
|
226
|
+
C.Util.setOptions @, options
|
227
|
+
|
228
|
+
@control = new L.Control.Draw(@options.draw)
|
229
|
+
@control.setDrawingOptions(@options.snap)
|
230
|
+
|
231
|
+
@toolbar = @control._toolbars['draw']
|
232
|
+
if @options.draw.panel
|
233
|
+
new L.Control.ControlPanel.Draw @toolbar, @options.draw.panel
|
234
|
+
|
235
|
+
@initHooks()
|
236
|
+
|
237
|
+
initHooks: () ->
|
238
|
+
@toolbar.on 'enable', (e) =>
|
239
|
+
@getMap().on L.Draw.Event.DRAWSTART, =>
|
240
|
+
@getMap().fire C.Events.new.start
|
241
|
+
|
242
|
+
@getMap().on L.Draw.Event.DRAWSTOP, =>
|
243
|
+
@getMap().fire C.Events.new.cancel
|
244
|
+
|
245
|
+
getControl: ->
|
246
|
+
@control
|
247
|
+
|
248
|
+
getToolbar: ->
|
249
|
+
@toolbar
|
250
|
+
|
251
|
+
class C.Controls.Edit extends C.Controls
|
252
|
+
options:
|
253
|
+
edit:
|
254
|
+
label: undefined
|
255
|
+
reactiveMeasure: true
|
256
|
+
featureGroup: undefined
|
257
|
+
remove: false
|
258
|
+
shapeOptions:
|
259
|
+
color: "#3498db"
|
260
|
+
fillOpacity: 0.8
|
261
|
+
popup: false
|
262
|
+
snap:
|
263
|
+
polyline:
|
264
|
+
guideLayers: []
|
265
|
+
snapDistance: 5
|
266
|
+
polygon:
|
267
|
+
guideLayers: []
|
268
|
+
snapDistance: 5
|
269
|
+
constructor: (map, options = {}) ->
|
270
|
+
super(map)
|
271
|
+
|
272
|
+
C.Util.setOptions @, options
|
273
|
+
|
274
|
+
@editionLayer = L.geoJson(undefined,
|
275
|
+
style: (feature) =>
|
276
|
+
C.Util.extend @options.edit.shapeOptions, feature.properties)
|
277
|
+
|
278
|
+
@control = new L.Control.SnapEdit(@options)
|
279
|
+
|
280
|
+
@initHooks()
|
281
|
+
|
282
|
+
initHooks: ->
|
283
|
+
@getMap().on "draw:editstart", (e) =>
|
284
|
+
|
285
|
+
getControl: ->
|
286
|
+
@control
|
287
|
+
|
288
|
+
getLayer: ->
|
289
|
+
@editionLayer
|
290
|
+
|
291
|
+
addLayer: (layer) ->
|
292
|
+
@getLayer().addData layer.toGeoJSON()
|
293
|
+
# @getLayer().addLayer layer
|
294
|
+
|
295
|
+
addTo: (control) ->
|
296
|
+
control.addOverlay @getLayer(), @options.label
|
297
|
+
|
298
|
+
|
299
|
+
class C.Controls.Edit.ReactiveMeasure extends C.Controls
|
300
|
+
options:
|
301
|
+
reactiveMeasure:
|
302
|
+
position: 'bottomright'
|
303
|
+
metric: true
|
304
|
+
feet: false
|
305
|
+
tooltip: false
|
306
|
+
|
307
|
+
constructor: (map, control, options = {}) ->
|
308
|
+
super(map)
|
309
|
+
C.Util.setOptions @, options
|
310
|
+
|
311
|
+
@control = new L.ReactiveMeasureControl(control.getLayer(), @options.reactiveMeasure)
|
312
|
+
|
313
|
+
@initHooks()
|
314
|
+
|
315
|
+
initHooks: (->)
|
316
|
+
|
317
|
+
getControl: ->
|
318
|
+
@control
|
319
|
+
|
320
|
+
class C.Controls.LayerSelection extends C.Controls
|
321
|
+
options:
|
322
|
+
layerSelection:
|
323
|
+
featureGroup: undefined
|
324
|
+
|
325
|
+
constructor: (map, options = {}) ->
|
326
|
+
super(map)
|
327
|
+
|
328
|
+
C.Util.setOptions @, options
|
329
|
+
|
330
|
+
@control = new L.Control.LayerSelection(map, @options.layerSelection)
|
331
|
+
|
332
|
+
@initHooks()
|
333
|
+
|
334
|
+
initHooks: ->
|
335
|
+
# @getMap().on "draw:editstart", (e) =>
|
336
|
+
|
337
|
+
getControl: ->
|
338
|
+
@control
|
339
|
+
|
340
|
+
class C.Controls.LayerLocking extends C.Controls
|
341
|
+
options:
|
342
|
+
layerLocking:
|
343
|
+
featureGroup: undefined
|
344
|
+
|
345
|
+
constructor: (map, options = {}) ->
|
346
|
+
super(map)
|
347
|
+
|
348
|
+
C.Util.setOptions @, options
|
349
|
+
|
350
|
+
@control = new L.Control.LayerLocking(map, @options.layerLocking)
|
351
|
+
|
352
|
+
@initHooks()
|
353
|
+
|
354
|
+
initHooks: (->)
|
355
|
+
|
356
|
+
getControl: ->
|
357
|
+
@control
|
358
|
+
|
359
|
+
class C.Controls.Cut extends C.Controls
|
360
|
+
options:
|
361
|
+
cut:
|
362
|
+
featureGroup: undefined
|
363
|
+
|
364
|
+
constructor: (map, options = {}) ->
|
365
|
+
super(map)
|
366
|
+
|
367
|
+
C.Util.setOptions @, options
|
368
|
+
|
369
|
+
@control = new L.Control.Cut(@options.cut)
|
370
|
+
|
371
|
+
@initHooks()
|
372
|
+
|
373
|
+
initHooks: ->
|
374
|
+
# @getMap().on "draw:editstart", (e) =>
|
375
|
+
|
376
|
+
getControl: ->
|
377
|
+
@control
|
378
|
+
|
379
|
+
getToolbar: ->
|
380
|
+
@control._toolbar
|
381
|
+
|
382
|
+
class C.Controls.Merge extends C.Controls
|
383
|
+
options:
|
384
|
+
merge:
|
385
|
+
featureGroup: undefined
|
386
|
+
|
387
|
+
constructor: (map, options = {}) ->
|
388
|
+
super(map)
|
389
|
+
|
390
|
+
C.Util.setOptions @, options
|
391
|
+
|
392
|
+
@control = new L.Control.Merge(@options.merge)
|
393
|
+
|
394
|
+
@initHooks()
|
395
|
+
|
396
|
+
initHooks: (->)
|
397
|
+
|
398
|
+
getControl: ->
|
399
|
+
@control
|
400
|
+
|
401
|
+
class C.Controls.ShapeDraw extends C.Controls
|
402
|
+
options:
|
403
|
+
draw:
|
404
|
+
edit: false
|
405
|
+
draw:
|
406
|
+
marker: false
|
407
|
+
circlemarker: false
|
408
|
+
polyline: false
|
409
|
+
rectangle: false
|
410
|
+
circle: false
|
411
|
+
polygon:
|
412
|
+
allowIntersection: false
|
413
|
+
showArea: false
|
414
|
+
snap:
|
415
|
+
polygon:
|
416
|
+
guideLayers: []
|
417
|
+
snapDistance: 15
|
418
|
+
snapOriginDistance: 30
|
419
|
+
allowIntersection: false
|
420
|
+
guidelineDistance: 8
|
421
|
+
shapeOptions:
|
422
|
+
dashArray: '8, 8'
|
423
|
+
fill: false
|
424
|
+
color: '#FF5722'
|
425
|
+
opacity: 1
|
426
|
+
|
427
|
+
constructor: (map, options = {}) ->
|
428
|
+
super(map)
|
429
|
+
|
430
|
+
C.Util.setOptions @, options
|
431
|
+
|
432
|
+
@options.draw.guideLayers = @options.snap.polygon.guideLayers
|
433
|
+
@control = new L.Control.ShapeDraw(map, @options.draw)
|
434
|
+
|
435
|
+
@initHooks()
|
436
|
+
|
437
|
+
initHooks: ->
|
438
|
+
|
439
|
+
|
440
|
+
getControl: ->
|
441
|
+
@control
|
442
|
+
|
443
|
+
class C.Controls.ShapeCut extends C.Controls
|
444
|
+
options:
|
445
|
+
cut:
|
446
|
+
featureGroup: undefined
|
447
|
+
|
448
|
+
constructor: (map, options = {}) ->
|
449
|
+
super(map)
|
450
|
+
|
451
|
+
C.Util.setOptions @, options
|
452
|
+
|
453
|
+
@control = new L.Control.ShapeCut(map, @options.cut)
|
454
|
+
|
455
|
+
@initHooks()
|
456
|
+
|
457
|
+
initHooks: ->
|
458
|
+
|
459
|
+
|
460
|
+
getControl: ->
|
461
|
+
@control
|
462
|
+
|
463
|
+
)(window.Cartography = window.Cartography || {}, jQuery)
|