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,36 @@
1
+ ((C) ->
2
+ "use strict"
3
+
4
+ C.Events = {}
5
+ C.Events.new = {}
6
+ C.Events.new.start = "cartography:events:new:start"
7
+ C.Events.new.complete = "cartography:events:new:complete"
8
+ C.Events.new.cancel = "cartography:events:new:cancel"
9
+ C.Events.new.change = "cartography:events:new:change"
10
+ C.Events.shapeDraw = {}
11
+ C.Events.shapeDraw.start = "cartography:events:shapeDraw:start"
12
+ C.Events.shapeDraw.draw = "cartography:events:shapeDraw:draw"
13
+ C.Events.shapeDraw.edit = "cartography:events:shapeDraw:edit"
14
+ C.Events.shapeDraw.warn = "cartography:events:shapeDraw:warn"
15
+ C.Events.split = {}
16
+ C.Events.split.start = "cartography:events:split:start"
17
+ C.Events.split.complete = "cartography:events:split:complete"
18
+ C.Events.split.cancel = "cartography:events:split:cancel"
19
+ C.Events.split.change = "cartography:events:split:change"
20
+ C.Events.split.select = "cartography:events:split:select"
21
+ C.Events.split.cutting = "cartography:events:split:cutting"
22
+ C.Events.edit = {}
23
+ C.Events.edit.start = "cartography:events:edit:start"
24
+ C.Events.edit.complete = "cartography:events:edit:complete"
25
+ C.Events.edit.cancel = "cartography:events:edit:cancel"
26
+ C.Events.edit.change = "cartography:events:edit:change"
27
+ C.Events.select = {}
28
+ C.Events.select.select = "cartography:events:select:select"
29
+ C.Events.select.unselect = "cartography:events:select:unselect"
30
+ C.Events.select.selected = "cartography:events:select:selected"
31
+ C.Events.select.start = "cartography:events:select:start"
32
+ C.Events.select.stop = "cartography:events:select:stop"
33
+
34
+ L.Draw.Event.INVALIDATED = 'draw:invalidated'
35
+
36
+ )(window.Cartography = window.Cartography || {})
@@ -0,0 +1,127 @@
1
+ ((C, $) ->
2
+ "use strict"
3
+
4
+ class C.Layer extends C.BaseClass
5
+ @LAYER_TYPES : {}
6
+ constructor: (map, layer = undefined, data = undefined, options = {}) ->
7
+ super(map)
8
+
9
+ if layer and data and type = @constructor.LAYER_TYPES[layer.type]
10
+ return new type(map, layer, data, options)
11
+
12
+ @registerLayerType: (name, klass) ->
13
+ @LAYER_TYPES[name] = klass
14
+
15
+ class C.Layers extends C.Layer
16
+ constructor: (map) ->
17
+ super(map)
18
+ @layers = {}
19
+
20
+ getLayers: ->
21
+ @layers
22
+
23
+ getMainLayer: ->
24
+ Object.values(@layers).filter((l) ->
25
+ l.renderedLayer.layer.serie == "main")[0]
26
+
27
+ class C.BaseLayers extends C.Layers
28
+ options:
29
+ backgrounds: []
30
+
31
+ constructor: ( map, options = {} ) ->
32
+ C.Util.setOptions @, options
33
+ super(map)
34
+
35
+ add: (layers) ->
36
+ layers = [layers] unless layers.constructor.name is "Array"
37
+
38
+ newLayers = {}
39
+
40
+ for layer in layers
41
+ if layer.constructor.name is "Array"
42
+ newLayers[layer] = L.tileLayer.provider(layer[0], layer[1])
43
+ else
44
+ newLayers[layer] = L.tileLayer.provider(layer)
45
+
46
+ L.Util.extend(@layers, newLayers)
47
+ newLayers
48
+
49
+ class C.OverlayLayers extends C.Layers
50
+ options:
51
+ overlays: []
52
+ series: {}
53
+ properties:
54
+ color: "#FAEBD7"
55
+ fillOpacity: 0.35
56
+
57
+ constructor: ( map, options = {} ) ->
58
+ C.Util.setOptions @, options
59
+
60
+ super(map)
61
+
62
+ add: (layers, type) ->
63
+ @["add#{type}"](layers)
64
+
65
+ addtiles: (layers) ->
66
+ layers = [layers] unless layers.constructor.name is "Array"
67
+
68
+ newLayers = {}
69
+
70
+ for layer in layers
71
+ opts = {}
72
+ opts.attribution = layer.attribution if layer.attribution?
73
+ opts.minZoom = layer.minZoom || @options.minZoom
74
+ opts.maxZoom = layer.maxZoom || @options.maxZoom
75
+ opts.subdomains = layer.subdomains if layer.subdomains?
76
+ opts.opacity = (layer.opacity / 100).toFixed(1) if layer.opacity? and !isNaN(layer.opacity)
77
+ opts.tms = true if layer.tms
78
+ newLayers[layer.name] = L.tileLayer(layer.url, opts)
79
+ newLayers[layer.name].addTo(@getMap())
80
+
81
+ L.Util.extend(@layers, newLayers)
82
+ newLayers
83
+
84
+ addseries: (data) ->
85
+ series = data[0]
86
+ layers = data[1]
87
+
88
+ newLayers = {}
89
+
90
+ for layer in layers
91
+ serie = series[layer.serie]
92
+ renderedLayer = new C.Layer(@getMap(), layer, serie)
93
+
94
+ if renderedLayer and renderedLayer.valid()
95
+ layerGroup = renderedLayer.buildLayerGroup(@options.properties)
96
+ layerGroup.name = layer.name
97
+ layerGroup.renderedLayer = renderedLayer
98
+
99
+ newLayers[layer.name] = layerGroup
100
+ newLayers[layer.name].addTo(@getMap())
101
+
102
+ L.Util.extend(@layers, newLayers)
103
+ newLayers
104
+
105
+ updateSerie: (layerGroup, serie) ->
106
+
107
+ newLayers = new L.GeoJSON(serie)
108
+
109
+ if layerGroup.getLayers().length
110
+ removeList = layerGroup.getLayers().filter (layer) ->
111
+ !newLayers.hasIDLayer layer
112
+
113
+ if removeList.length
114
+ for l in removeList
115
+ layerGroup.removeLayer l
116
+
117
+ updateList = newLayers.getLayers().filter (layer) ->
118
+ !layerGroup.hasIDLayer layer
119
+
120
+ else
121
+ updateList = newLayers.getLayers()
122
+
123
+ for layer in updateList
124
+ layerGroup.addData(layer.toGeoJSON())
125
+
126
+
127
+ )(window.Cartography = window.Cartography || {}, jQuery)
@@ -0,0 +1,37 @@
1
+ #= require cartography/layers
2
+
3
+ ((C, $) ->
4
+ "use strict"
5
+
6
+ class C.Layer.Simple extends C.Layer
7
+ constructor: (map, @layer, @data, @options = {}) ->
8
+ super(map)
9
+
10
+ buildLayerGroup: (style = {}) ->
11
+ klass = if @layer.index then L.IndexedGeoJSON else L.GeoJSON
12
+
13
+ new klass @data,
14
+ style: (feature) =>
15
+ if @layer.style
16
+ @layer.style.apply @, arguments
17
+ else
18
+ C.Util.extend style, feature.properties
19
+
20
+ onEachFeature: (feature, layer) =>
21
+ feature.properties ||= {}
22
+
23
+ feature.properties.uuid ||= new UUID(4).format()
24
+
25
+ layer.feature.properties = feature.properties
26
+
27
+ if @layer.onEachFeature
28
+ @layer.onEachFeature.apply @, arguments
29
+
30
+
31
+
32
+ valid: () -> true
33
+
34
+ C.Layer.registerLayerType("simple", C.Layer.Simple)
35
+
36
+
37
+ )(window.Cartography = window.Cartography || {}, jQuery)
@@ -0,0 +1,420 @@
1
+ ((C) ->
2
+ "use strict"
3
+
4
+ class L.Control.Home extends L.Control
5
+ options:
6
+ position: 'topleft'
7
+ featureGroup: null
8
+
9
+ constructor: (options) ->
10
+ C.Util.setOptions @, options
11
+ super options
12
+
13
+ if L.HomeToolbar && !@_toolbar
14
+ @_toolbar = new L.HomeToolbar @options
15
+
16
+ onAdd: (map) ->
17
+ container = L.DomUtil.create('div', 'leaflet-draw leaflet-control-cut')
18
+ topClassName = 'leaflet-draw-toolbar-top'
19
+ toolbarContainer = @_toolbar.addToolbar(map)
20
+ if toolbarContainer
21
+ L.DomUtil.addClass toolbarContainer.childNodes[0], topClassName
22
+ container.appendChild toolbarContainer
23
+ container
24
+
25
+ onRemove: ->
26
+ @_toolbar.removeToolbar()
27
+
28
+ class L.Control.SnapEdit extends L.Control
29
+ options:
30
+ position: 'topleft'
31
+ draw: {}
32
+ edit:
33
+ panel:
34
+ position: 'bottomleft'
35
+
36
+ constructor: (options) ->
37
+ C.Util.setOptions @, options
38
+ super options
39
+ toolbar = undefined
40
+ @_toolbar = {}
41
+ if L.SnapEditToolbar
42
+ @options.snap.guideLayers = @options.snap.polygon.guideLayers
43
+
44
+ @_toolbar = new L.SnapEditToolbar @options
45
+
46
+ if @options.edit.panel
47
+ new L.Control.ControlPanel.SnapEdit @_toolbar, @options.edit.panel
48
+
49
+ L.toolbar = this
50
+ return
51
+
52
+ onAdd: (map) ->
53
+ container = L.DomUtil.create('div', 'leaflet-draw')
54
+ topClassName = 'leaflet-draw-toolbar-top'
55
+ toolbarContainer = @_toolbar.addToolbar(map)
56
+ if toolbarContainer
57
+ L.DomUtil.addClass toolbarContainer.childNodes[0], topClassName
58
+ container.appendChild toolbarContainer
59
+ container
60
+
61
+ onRemove: ->
62
+ @_toolbar.removeToolbar()
63
+
64
+ class L.Control.ControlPanel.SnapEdit extends L.Control.ControlPanel
65
+ constructor: (options) ->
66
+ C.Util.setOptions @, options
67
+ super
68
+
69
+ onAdd: (map) ->
70
+ super map
71
+
72
+ @_container
73
+
74
+ addProperties: ->
75
+ super
76
+ @_addEditPolygon()
77
+
78
+ _addEditPolygon: ->
79
+ container = L.DomUtil.create 'div', 'property', @_propertiesContainer
80
+
81
+ containerTitle = L.DomUtil.create 'div', 'property-title', container
82
+ containerTitle.innerHTML = @options.surfaceProperty
83
+
84
+ @_areaContainer = L.DomUtil.create 'div', 'property-content', container
85
+
86
+ @_onEditingPolygon()
87
+ @_map.on L.ReactiveMeasure.Edit.Event.MOVE, @_onEditingPolygon, @
88
+
89
+ _onEditingPolygon: (e) ->
90
+ area = if e and e.measure then e.measure.area else 0
91
+
92
+ L.DomUtil.empty(@_areaContainer)
93
+
94
+ surface = L.DomUtil.create 'div', 'surface-row', @_areaContainer
95
+ surface.innerHTML = L.GeometryUtil.readableArea(area, true)
96
+
97
+ class L.Control.LayerSelection extends L.Control
98
+ @_toolbar: {}
99
+
100
+ options:
101
+ position: 'topleft'
102
+ featureGroup: undefined
103
+
104
+ constructor: (map, options) ->
105
+ C.Util.setOptions @, options
106
+ super options
107
+
108
+ @_handler = new L.LayerSelection map, featureGroup: @options.featureGroup
109
+
110
+ return
111
+
112
+ enable: ->
113
+ @_handler.enable()
114
+
115
+ class L.Control.LayerLocking extends L.Control
116
+ @_toolbar: {}
117
+
118
+ options:
119
+ position: 'topleft'
120
+ featureGroup: undefined
121
+
122
+ constructor: (map, options) ->
123
+ C.Util.setOptions @, options
124
+ super options
125
+
126
+ @_handler = new L.LayerLocking map, featureGroup: @options.featureGroup
127
+
128
+ return
129
+
130
+ enable: ->
131
+ @_handler.enable()
132
+
133
+ class L.Control.Cut extends L.Control
134
+ @_toolbar: {}
135
+
136
+ options:
137
+ position: 'topleft'
138
+ featureGroup: undefined
139
+ panel:
140
+ position: 'bottomleft'
141
+
142
+ constructor: (options) ->
143
+ C.Util.setOptions @, options
144
+ super options
145
+
146
+ if L.CutToolbar && !@_toolbar
147
+ @_toolbar = new L.CutToolbar @options
148
+
149
+ if @options.panel
150
+ new L.Control.ControlPanel.Cut @_toolbar, @options.panel
151
+
152
+ onAdd: (map) ->
153
+ container = L.DomUtil.create('div', 'leaflet-draw leaflet-control-cut')
154
+ topClassName = 'leaflet-draw-toolbar-top'
155
+ toolbarContainer = @_toolbar.addToolbar(map)
156
+ if toolbarContainer
157
+ L.DomUtil.addClass toolbarContainer.childNodes[0], topClassName
158
+ container.appendChild toolbarContainer
159
+ container
160
+
161
+ onRemove: ->
162
+ @_toolbar.removeToolbar()
163
+
164
+ class L.Control.ControlPanel.Cut extends L.Control.ControlPanel
165
+ constructor: (options) ->
166
+ C.Util.setOptions @, options
167
+ super
168
+
169
+ onAdd: (map) ->
170
+ super map
171
+ @_container
172
+
173
+ addProperties: ->
174
+ @_addSubtitle() if @options.subtitleProperty
175
+ super
176
+ @_map.on L.Cutting.Polyline.Event.CREATED, @_addCreatedPolygons, @
177
+
178
+ _addSubtitle: ->
179
+ container = L.DomUtil.create 'div', 'property', @_propertiesContainer
180
+ containerTitle = L.DomUtil.create 'div', 'property-title', container
181
+ containerTitle.innerHTML = @options.subtitleProperty
182
+
183
+ _addCreatedPolygons: (e) ->
184
+
185
+ container = L.DomUtil.create 'div', 'property', @_propertiesContainer
186
+
187
+ containerTitle = L.DomUtil.create 'div', 'property-title', container
188
+ containerTitle.innerHTML = @options.surfacesProperty
189
+
190
+ @_areaContainer = L.DomUtil.create 'div', 'property-content', container
191
+
192
+ @_onUpdateArea(e)
193
+
194
+ @_map.on L.Cutting.Polyline.Event.UPDATED, @_onUpdateArea, @
195
+
196
+ _onUpdateArea: (e) ->
197
+ layers = e.layers
198
+
199
+ L.DomUtil.empty(@_areaContainer)
200
+
201
+ for layer in layers
202
+ if layer
203
+ legendRow = L.DomUtil.create 'div', 'legend-row', @_areaContainer
204
+ legend = L.DomUtil.create 'div', 'legend', legendRow
205
+ area = L.DomUtil.create("div", 'legend-area', legendRow)
206
+ # layer.options.fillColor
207
+
208
+ if typeof layer.getLatLngs is 'function'
209
+ legend.style.backgroundColor = layer.options.fillColor
210
+ latlngs = layer.getLatLngs()
211
+ else
212
+ legend.style.backgroundColor = layer.getLayers()[0].options.fillColor
213
+ latlngs = layer.getLayers()[0].getLatLngs()
214
+
215
+ area.innerHTML = L.GeometryUtil.readableArea(L.GeometryUtil.geodesicArea(latlngs[0]), true)
216
+
217
+
218
+ class L.Control.ControlPanel.Draw extends L.Control.ControlPanel
219
+ constructor: (options) ->
220
+ C.Util.setOptions @, options
221
+ super
222
+
223
+ onAdd: (map) ->
224
+ super map
225
+ @_container
226
+
227
+ addProperties: ->
228
+ super
229
+ @_addDrawingPolygon()
230
+
231
+ _addDrawingPolygon: ->
232
+
233
+ container = L.DomUtil.create 'div', 'property', @_propertiesContainer
234
+
235
+ containerTitle = L.DomUtil.create 'div', 'property-title', container
236
+ containerTitle.innerHTML = "Surface"
237
+
238
+ @_areaContainer = L.DomUtil.create 'div', 'property-content', container
239
+
240
+ @_onDrawingPolygon()
241
+ @_map.on L.ReactiveMeasure.Draw.Event.MOVE, @_onDrawingPolygon, @
242
+
243
+ _onDrawingPolygon: (e) ->
244
+ area = if e and e.measure then e.measure.area else 0
245
+
246
+ L.DomUtil.empty(@_areaContainer)
247
+
248
+ surface = L.DomUtil.create 'div', 'surface-row', @_areaContainer
249
+ surface.innerHTML = L.GeometryUtil.readableArea(area, true)
250
+
251
+ class L.Control.Merge extends L.Control
252
+ @_toolbar: {}
253
+
254
+ options:
255
+ position: 'topleft'
256
+ featureGroup: undefined
257
+ panel:
258
+ position: 'bottomleft'
259
+
260
+ constructor: (options) ->
261
+ C.Util.setOptions @, options
262
+ super options
263
+
264
+ if L.MergeToolbar && !@_toolbar
265
+ @_toolbar = new L.MergeToolbar @options
266
+
267
+ if @options.panel
268
+ new L.Control.ControlPanel.Merge @_toolbar, @options.panel
269
+
270
+ onAdd: (map) ->
271
+ container = L.DomUtil.create('div', 'leaflet-draw leaflet-control-merge')
272
+ topClassName = 'leaflet-draw-toolbar-top'
273
+ toolbarContainer = @_toolbar.addToolbar(map)
274
+ if toolbarContainer
275
+ L.DomUtil.addClass toolbarContainer.childNodes[0], topClassName
276
+ container.appendChild toolbarContainer
277
+ container
278
+
279
+ onRemove: ->
280
+ @_toolbar.removeToolbar()
281
+
282
+
283
+ class L.Control.ControlPanel.Merge extends L.Control.ControlPanel
284
+ constructor: (options) ->
285
+ C.Util.setOptions @, options
286
+ super
287
+
288
+ onAdd: (map) ->
289
+ super map
290
+ @_container
291
+
292
+ addProperties: ->
293
+ super
294
+ # @_map.on L.Cutting.Polyline.Event.CREATED, @_addCreatedPolygons, @
295
+
296
+ _addCreatedPolygons: (e) ->
297
+
298
+ container = L.DomUtil.create 'div', 'property', @_propertiesContainer
299
+
300
+ containerTitle = L.DomUtil.create 'div', 'property-title', container
301
+ containerTitle.innerHTML = "Surfaces"
302
+
303
+ @_areaContainer = L.DomUtil.create 'div', 'property-content', container
304
+
305
+ @_onUpdateArea(e)
306
+
307
+ @_map.on L.Cutting.Polyline.Event.UPDATED, @_onUpdateArea, @
308
+
309
+ _onUpdateArea: (e) ->
310
+ layers = e.layers
311
+
312
+ L.DomUtil.empty(@_areaContainer)
313
+
314
+ for layer in layers
315
+ legendRow = L.DomUtil.create 'div', 'legend-row', @_areaContainer
316
+ legend = L.DomUtil.create 'div', 'legend', legendRow
317
+ area = L.DomUtil.create("div", 'legend-area', legendRow)
318
+ # layer.options.fillColor
319
+
320
+ if typeof layer.getLatLngs is 'function'
321
+ legend.style.backgroundColor = layer.options.fillColor
322
+ latlngs = layer.getLatLngs()
323
+ else
324
+ legend.style.backgroundColor = layer.getLayers()[0].options.fillColor
325
+ latlngs = layer.getLayers()[0].getLatLngs()
326
+
327
+ area.innerHTML = L.GeometryUtil.readableArea(L.GeometryUtil.geodesicArea(latlngs[0]), true)
328
+
329
+
330
+ class L.Control.ShapeDraw extends L.Control
331
+ options:
332
+ featureGroup: undefined
333
+ snapDistance: 15
334
+ shapeOptions:
335
+ color: '#FF6226'
336
+ className: 'leaflet-polygon-drawer'
337
+
338
+ constructor: (map, options) ->
339
+ C.Util.setOptions @, options
340
+ super options
341
+
342
+ @_handler = new L.Draw.Polygon map, @options
343
+
344
+ @_map = map
345
+ return
346
+
347
+ _onDrawVertex: (e) ->
348
+ @_map.fire C.Events.shapeDraw.start
349
+ @_map.off "draw:drawvertex", @_onDrawVertex, @
350
+
351
+ _onDrawingPolygon: (e) ->
352
+ measure = {
353
+ area: e.measure.extrapolatedArea,
354
+ perimeter: if @_handler._poly.getLatLngs().length == 1 then e.measure.perimeter else e.measure.extrapolatedPerimeter
355
+ }
356
+ @_map.fire C.Events.shapeDraw.draw, data: { measure: measure }
357
+
358
+ _onInvalidDrawingPolygon: (e) ->
359
+ @_map.fire C.Events.shapeDraw.warn, data: { message: e.error }
360
+
361
+ enable: ->
362
+ @_map.on "draw:drawvertex", @_onDrawVertex, @
363
+ @_map.on L.ReactiveMeasure.Draw.Event.MOVE, @_onDrawingPolygon, @
364
+ @_map.on L.Draw.Event.INVALIDATED, @_onInvalidDrawingPolygon, @
365
+ @_handler.enable()
366
+
367
+ disable: ->
368
+ @_map.off "draw:drawvertex", @_onDrawVertex, @
369
+ @_map.off L.ReactiveMeasure.Draw.Event.MOVE, @_onDrawingPolygon, @
370
+ @_map.off L.Draw.Event.INVALIDATED, @_onInvalidDrawingPolygon, @
371
+ @_handler.disable()
372
+
373
+ class L.Control.ShapeCut extends L.Control
374
+ options:
375
+ featureGroup: undefined
376
+ disabledPathOptions:
377
+ dashArray: null
378
+ fill: true
379
+ color: '#263238'
380
+ fillColor: '#263238'
381
+ opacity: 1
382
+ fillOpacity: 0.4
383
+ maintainColor: false
384
+ editablePathOptions:
385
+ dashArray: null
386
+ fill: true
387
+ color: '#1195F5'
388
+ fillColor: '#1195F5'
389
+ opacity: 1
390
+ fillOpacity: 0.35
391
+ maintainColor: false
392
+ selectedPathOptions:
393
+ dashArray: null
394
+ fill: true
395
+ fillColor: '#fe57a1'
396
+ opacity: 1
397
+ fillOpacity: 1
398
+ maintainColor: true
399
+ weight: 3
400
+ cuttingPathOptions:
401
+ color: '#FF6226'
402
+ className: 'leaflet-polygon-splitter'
403
+ cycling: 2
404
+
405
+ constructor: (map, options) ->
406
+ C.Util.setOptions @, options
407
+ super options
408
+
409
+ @_handler = new L.Cut.Polyline map, @options
410
+
411
+ @_map = map
412
+ return
413
+
414
+ enable: ->
415
+ @_handler.enable()
416
+
417
+ disable: ->
418
+ @_handler.disable()
419
+
420
+ )(window.Cartography = window.Cartography || {})