-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1573 lines (1328 loc) · 67.7 KB
/
index.html
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>EFH Metrics - EIS 2018</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link rel="shortcut icon" href="images/sgfish_icon.png" type="image/png" />
<!--Remote -->
<!--
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet/v1.3.1/leaflet.js"></script>
<script src="https://unpkg.com/@turf/turf@3.5.1/turf.min.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v1.3.1/leaflet.css" />
<script src="https://unpkg.com/esri-leaflet@2.1.2/dist/esri-leaflet.js"></script>
-->
<!--Local -->
<link href='css/normalize.css' rel="stylesheet">
<link href="css/leaflet.css" rel="stylesheet"/>
<link href="css/easy-button.css" rel="stylesheet"/>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/leaflet.js"></script>
<script src="js/esri-leaflet.js"></script>
<script src="js/turf.min.js"></script>
<script src="js/jquery.tabletoCSV.js"></script>
<script src="js/easy-button.js"></script>
<script src="js/typeahead.bundle.min.js"></script>
<!--Measure Tool -->
<!-- Remote
<link rel="stylesheet" href="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.css" />
<script src="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.js"></script>
-->
<!--Local -->
<link href="css/Leaflet.PolylineMeasure.css" rel="stylesheet"/>
<script src="js/Leaflet.PolylineMeasure.js"></script>
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Work+Sans:400,500,600' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<!-- <script src="https://use.fontawesome.com/dbb89f5a68.js"></script>-->
<link rel="stylesheet" href="fonts/font-awesome-4.6.3/css/font-awesome.min.css">
<!-- custom css -->
<link href="css/site.css" rel="stylesheet">
</head>
<body>
<div id='map'></div>
<div id='layer-control-text'></div>
<div id="right-panel">
<!-- HTML form for user to select EFH proposal to draw on map -->
<!-- Note that values for data-nice-name must correspond exactly to attribute names in source GeoJSON data file -->
<!-- Only Collaborative and Oceana proposals initially visible -->
<!-- <h2>EFH Proposals</h2>-->
<div id='poly-search'>
<i class="fa fa-search"></i>
<input class="typeahead" type="text" placeholder="Search by polygon name ...">
</div>
<div id="layer-controls" class="efhalts">
<!-- Current EFH Alternatives. Can be selected for metrics summaries and interacted with by polygon -->
<p class="efh-type">EFHCA Alternatives</p>
<!-- Collaborative -->
<input id="collabLayer" type="checkbox" value="collabLayer" checked>
<label for="collabLayer" style='color:#E5571D' data-nice-name="Collaborative">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-check-square-o layer-selection-icon"></i></span>
1a. Collaborative <span class="layer-counter"><span class="layer-counter-current">0</span>/59</span>
<button class="layer-unselect-all tooltip" data-tooltip="Remove Proposal from Selection">
<i class="fa fa-minus"></i>
</button>
<button class="layer-select-all tooltip" data-tooltip="Add Proposal to Selection">
<i class="fa fa-plus"></i>
</button>
</label>
<!-- Oceana -->
<input id="onoLayer" type="checkbox" value="onoLayer" checked>
<label for="onoLayer" style='color:#6F067B' data-nice-name="Oceana et al.">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-check-square-o layer-selection-icon"></i></span>
1b. Oceana et al. <span class="layer-counter"><span class="layer-counter-current">0</span>/68</span>
<button class="layer-unselect-all tooltip" data-tooltip="Remove Proposal from Selection">
<i class="fa fa-minus"></i>
</button>
<button class="layer-select-all tooltip" data-tooltip="Add Proposal to Selection">
<i class="fa fa-plus"></i>
</button>
</label>
<!-- EFHCA Preferred Alternative -->
<input id="paLayer" type="checkbox" value="paLayer" checked>
<label for="paLayer" style='color:#0F6001' data-nice-name="PFMC FPA">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-check-square-o layer-selection-icon"></i></span>
1h. Preferred <span class="layer-counter"><span class="layer-counter-current">0</span>/70</span>
<button class="layer-unselect-all tooltip" data-tooltip="Remove Proposal from Selection">
<i class="fa fa-minus"></i>
</button>
<button class="layer-select-all tooltip" data-tooltip="Add Proposal to Selection">
<i class="fa fa-plus"></i>
</button>
</label>
</div>
<div id='ui-controls'>
<button value="Zoom" class="layer-ui-button" id="zoom">Zoom to selection <i class="fa fa-arrows-alt"></i></button>
<button value="Clear" class="layer-ui-button" id="clear">Clear selection <i class="fa fa-ban"></i></button>
</div>
<div id="layer-controls" class="rcaalts">
<!-- RCA Alternatives Can only by turned on or off to draw on map -->
<p class="efh-type">Trawl RCA Alternatives</p>
<!-- Remove Trawl RCA -->
<input id="removercaLayer" type="checkbox" value="removercaLayer" unchecked>
<label for="removercaLayer" style='color:#737300' data-nice-name="Remove RCA">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-square-o layer-selection-icon"></i></span>
2c. Remove Trawl RCA
</label>
<!-- Block Area Closures -->
<input id="bacLayer" type="checkbox" value="bacLayer" unchecked>
<label for="bacLayer" style='color:#2e9e82' data-nice-name="Block Area Closures">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-square-o layer-selection-icon"></i></span>
2c. Block Area Closures
</label>
<!-- Remove Trawl RCA (OR/CA), Preferred Alt -->
<input id="removercaORCALayer" type="checkbox" value="removercaORCALayer" unchecked>
<label for="removercaORCALayer" style='color:#737300' data-nice-name="Remove RCA (OR/CA)">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-square-o layer-selection-icon"></i></span>
2d. Preferred - Remove Trawl RCA (OR/CA)
</label>
<!-- Block Area Closures (OR/CA) Preferred Alt -->
<input id="bacORCALayer" type="checkbox" value="bacORCALayer" unchecked>
<label for="bacORCALayer" style='color:#2e9e82' data-nice-name="PFMC FPA Trawl RCA">
<span class="tooltip" data-tooltip="Toggle Visibility"><i class="fa fa-square-o layer-selection-icon"></i></span>
2d. Preferred - Block Area Closures (OR/CA)
</label>
</div>
</div>
<!-- end right-panel -->
<!-- Side panel Div -->
<div id='side-panel'>
<h1>West Coast Groundfish<br> Essential Fish Habitat</h1>
<h2 class='side-panel-header'>Alternatives Analysis Metrics</h2>
<div id='panel-tabs'>
<button class='selected' value='summary-panel'>Summary</button>
<button value='polygons-panel'>Polygons <span id="poly-count">(0)</span></button>
<button value='info-panel'>Info</button>
<button value='help-panel'>How To</button>
</div>
<div class='side-panel' id='summary-panel'>
<!-- <h3 id='poly-count'></h3> -->
<div class="table-wrapper"><table id="summary-metrics"></table></div>
<span class='start-text'>
<p>Click on an EFHCA polygon on the map to add or remove it from the selection.</p>
<p style="text-align:center">OR</p>
<p>Select all or unselect all polygons from an EFHCA alternative using the <i class="fa fa-plus"></i> or <i class="fa fa-minus"></i> icon next to its name.</p>
<br>
<p>A summary of metrics for all selected polygons will display here.</p>
<p>To avoid double-counting in the summary metrics, if you select a polygon that overlaps a current selection, the overlapping polygon will be removed from the selection.</p>
<br>
<p>For the best experience, use the Chrome browser. Other browsers have not been thoroughly tested.</p>
</span>
</div>
<div class='side-panel' id='polygons-panel'>
<div class="table-wrapper"><table id="polygon-metrics" class="data"></table></div>
<button id='download-csv'>Download CSV File</button>
<span class='start-text'>
<p>Click on an EFHCA polygon on the map to add or remove it from the selection.</p>
<p style="text-align:center">OR</p>
<p>Select all or unselect all polygons from an EFHCA alternative using the <i class="fa fa-plus"></i> or <i class="fa fa-minus"></i> icon next to its name.</p>
<br>
<p>A table listing all the selected polygons and their metrics will display here.</p>
<p>To avoid double-counting in the summary metrics, if you select a polygon that overlaps a current selection, the overlapping polygon will be removed from the selection.</p>
<br>
<p>For the best experience, use the Chrome browser. Other browsers have not been thoroughly tested.</p>
</span>
</div>
<div class='side-panel' id='info-panel'>
<h2>Background</h2>
<p>The <a href="http://www.pcouncil.org/" target="_blank">Pacific Fishery Management Council</a> (Council) is developing Amendment 28 to the <a href="https://www.pcouncil.org/groundfish/fishery-management-plan/" target="_blank"> Pacific Coast Groundfish Fishery Management Plan</a>. The Council and <a href="http://www.westcoast.fisheries.noaa.gov/" target="_blank"> NOAA National Marine Fisheries Service</a> (NMFS) are considering proposed changes to <a href="http://www.pcouncil.org/groundfish/groundfish-essential-fish-habitat/" target="_blank">Groundfish Essential Fish Habitat</a> Conservation Areas <a href="http://www.westcoast.fisheries.noaa.gov/fisheries/management/groundfish_closures/essential_fish.html" target="_blank">(EFHCA)</a> and the <a href="http://www.westcoast.fisheries.noaa.gov/fisheries/management/groundfish_closures/rockfish_areas.html" target="_blank">Trawl Rockfish Conservation Area</a> (RCA), as well as prohibiting the use of bottom-contact fishing gear in waters deeper than 3,500 meters off the West Coast of the United States. The range of alternatives include areas to be closed to commercial trawl fishing, as well as currently closed areas to be reopened.</p>
<p>Before identifying a preferred set of alternatives, the Council considered the impacts and benefits of the alternatives to groundfish habitat, biological resources, and socioeconomics related to fishing opportunities and coastal communities.</p>
<p>The primary purpose of this tool is to support Council, stakeholder, and public review of the Draft Environmental Impact Statement. The user can select a custom set of polygons from any EFHCA Alternative and see a summary of the environmental metrics for their set. To provide context, associated data layers, such as existing trawl closures, jurisdictional boundaries, and Trawl RCA Alternatives can be displayed.</p>
<p>The <a href="docs/EFH_RCA_Alternatives_DEIS_2018.pdf" target="_blank">EFHCA Alternatives</a> are:</p>
<!-- <ul style="list-style-type:none">-->
<ul>
<li>1.a. Collaborative</li>
<li>1.b. Oceana et al. </li>
<li>1.h. EFHCA Preferred Alternative </li>
</ul>
<p>The <a href="docs/EFH_RCA_Alternatives_DEIS_2018.pdf" target="_blank">Trawl RCA Alternatives</a> are:</p>
<ul>
<li>2.c. Remove the Trawl RCA and implement Block Area Closures (BAC) outside the tribal U&A fishing area</li>
<li>2.d. RCA Preferred Alternative -- Remove the Trawl RCA and implement Block Area Closures (BAC) in waters off Oregon and California </li>
</ul>
<p> <a href="docs/EFH_RCA_Alternatives_DEIS_2018.pdf" target="_blank">Alternative 3a</a> is to close waters deeper than 3,500 meters to bottom contact gear (display from Reference Layers)</p>
<h2>Credits</h2>
<p>The Council, NOAA, National Marine Fisheries Service (NMFS), scientists, tribes, fishermen, and non-governmental organizations laid the analytical groundwork for this review through a multi-year synthesis of new data sets and analyses. Results of the Groundfish Essential Fish Habitat (EFH) Review are available through the <a href="http://efh-catalog.coas.oregonstate.edu/overview/" target="_blank">EFH Catalog</a> and the <a href="http://efh-viewer.coas.oregonstate.edu/efh/" target="_blank">EFH Viewer</a>. Additional layers and resources are available on the <a href="https://www.nwfsc.noaa.gov/data/map" target="_blank">NWFSC/FRAM Data Warehouse</a>.</p>
<p>The EFH/RCA Project Team produced a Draft Environmental Impact Statement <a href="https://www.westcoast.fisheries.noaa.gov/publications/nepa/groundfish/am28-deis-9-2018.pdf" target="_blank">(DEIS)</a> which is the basis for the metrics in this tool.</p>
<p>Web Development by Allison Bailey, <a href="http://www.soundgis.com" target="_blank">Sound GIS</a></p>
</div>
<div class='side-panel' id='help-panel'>
<h2>How to Use this Tool</h2>
<p>This tool allows a user to select a custom set of EFHCA alternative polygons and see a summary of the metrics for their set. Associated data layers, such as existing trawl closures, jurisdictional boundaries, Trawl RCA Alternatives, other EFHCA proposals can be displayed to provide additional context.</p>
<p>All Alternatives and Proposals:</p>
<ul>
<li>Hover over a polygon to view its metrics</li>
<li>Toggle a checkbox in the right panel to draw or hide an alternative's or proposal's polygons on the map</li>
<li>Zoom to a polygon by entering its name in the search box</li>
</ul>
<p>Reference Layers:</p>
<ul>
<li>Hover over the reference layers icon in the upper right of the map to select a layer's checkbox to draw it on the map</li>
</ul>
<p>EFHCA Alternatives only:</p>
<ul>
<li>Click an EFHCA polygon on the map to add or remove it from the selection</li>
<li>Click the <i class="fa fa-plus"></i> icon next to an EFHCA alternative to select all of its polygons</li>
<li>Click the <i class="fa fa-minus"></i> icon next to an EFHCA alternative to unselect all of its polygons</li>
<li>View the count of selected polygons out of the total polygons for each EFHCA alternative next to its name</li>
<li>View summary metrics for all selected EFHCA polygons in the Summary Tab</li>
<li>View and download a table of individual metrics for selected polygons in the Polygons Tab</li>
<li>'**' indicate confidential economic data</li>
</ul>
<p>To avoid double-counting in the summary metrics, if you select a polygon that overlaps a current selection, the overlapped polygon will be removed from the selection.</p>
<p>For the best experience, use the Chrome browser. Other browsers have not been thoroughly tested.</p>
</div>
</div>
<!-- GeoJSON EFH Alternatives source data (var proposals_metrics) -->
<script src="data/efh_proposals_metrics.js"></script>
<!-- JSON with concat_id and list of unique 1km cells with corspg presence (var corspg1km_proposals) -->
<script src="data/corspg1km_proposals.js"></script>
<!-- Main mapping script -->
<script>
// instantiate the Leaflet map
var options = {
center: [41, -121.2],
zoom: 6,
dragging: true,
zoomControl: true
}
var map = L.map('map', options);
// Base Maps
// ESRI Oceans Base Map
var esri_ocean = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri',
maxZoom: 12
});
// NOAA Nautical Charts - Tile Service
var rnc_image = L.tileLayer('https://tileservice.charts.noaa.gov/tiles/50000_1/{z}/{x}/{y}.png', {
attribution: 'NOAA Office of Coast Survey',
maxZoom: 12
});
// Add base layers to map
// rnc_image.addTo(map);
esri_ocean.addTo(map);
var baseLayers = {
"ESRI Oceans": esri_ocean,
"Nautical Charts": rnc_image
};
L.control.scale().addTo(map); // Add scale bar
// Add home button - zooms to full extent when clicked
var homeBtn = L.easyButton('fa-home', function(btn, map){
// map.setView([41, -121.2]);
// map.setZoom(6);
map.setView([41, -121.2],6,{reset: true})
}).addTo(map);
var mt_options = {
unit: 'nauticalmiles',
showBearings: true,
showUnitControl: true,
measureControlLabel: '↦', // '📏'
};
L.control.polylineMeasure(mt_options).addTo(map);
// Create a geoJSON layer of all polygons for search function
var allpolys = L.geoJson(proposals_metrics);
// Globals to store the polygon names and associate boundaries
var poly_names = [];
var poly_bounds = {};
// Get the polygon names and associated boundaries
allpolys.eachLayer(function(layer){
poly_names.push(layer.feature.properties.SiteName);
poly_bounds[layer.feature.properties.SiteName] = layer.getBounds()
});
// Create Info Box for display of feature data on hover
drawInfo();
// Call function to create user interface for interacting with selected set
buildUI();
// Style info for individual proposal layers
// proposer must match source data from GeoJson file
var layerInfo = {
collabLayer: {
proposer: "Collaborative",
color: "#E5571D",
selectable: 1,
draw:1,
},
onoLayer: {
proposer: "Oceana et al.",
color: "#6F067B",
selectable: 1,
draw:1,
},
paLayer: {
proposer: "PFMC FPA",
color: "#0F6001",
selectable: 1,
draw:1,
},
removercaLayer: {
proposer: "Remove RCA",
color: "#737300",
selectable: 0,
draw:0,
},
bacLayer: {
proposer: "Block Area Closures",
color: "#2e9e82",
selectable: 0,
draw:0,
},
removercaORCALayer: {
proposer: "Remove RCA (OR/CA)",
color: "#737300",
selectable: 0,
draw:0,
},
bacORCALayer: {
proposer: "PFMC FPA Trawl RCA",
color: "#2e9e82",
selectable: 0,
draw:0,
},
};
var selectableAlts = [
"Collaborative",
"Oceana et al.",
"PFMC FPA",
]
var rcaAlts = [
"Remove RCA",
"Block Area Closures",
"Remove RCA (OR/CA)",
"PFMC FPA Trawl RCA",
]
var geoJsonLayers = {}; // global to store all the geoJSON layers
var selectedSet = {}; // global for selected features
// Create individual geoJson Layers for each alternative
for (var lyr in layerInfo) {
var alternative = layerInfo[lyr].proposer;
geoJsonLayers[lyr] = L.geoJson(proposals_metrics, {
filter: function (feature) {
if (feature.properties.Alternative == [layerInfo[lyr].proposer]) {
return feature;
}
},
style: function (feature) {
var opcty;
if (feature.properties.RegAction == "reopen")
opcty = 0.1;
else if (feature.properties.RegAction == "close")
opcty = 0.4;
styles = {
color: layerInfo[lyr].color,
fillColor: layerInfo[lyr].color,
fill: true,
weight: 2,
fillOpacity: opcty
}
return styles
},
onEachFeature: function (feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: function(e){
if (selectableAlts.includes(feature.properties.Alternative)){
toggleSelected(e.target);
}
},
});
}
})//.addTo(map);
geoJsonLayers[lyr].startStyle = styles
geoJsonLayers[lyr].selectable = layerInfo[lyr].selectable
} // end of loop through all geoJSON layers
// // Add only Collaborative and Oceana layers to map to start
// geoJsonLayers["onoLayer"].addTo(map);
// geoJsonLayers["collabLayer"].addTo(map);
// Add most EFH Alts to map to start (if change, also need to update html for TOC)
for (var lyr in geoJsonLayers) {
if (layerInfo[lyr].draw){
geoJsonLayers[lyr].addTo(map);
}
}
// Supplemental Layer styles
var depLineWeight = 2;
var depOpacity = 1;
var eezStyles = {
fillColor: "#7f7f7f",
// stroke: false,
fillOpacity: 0.3,
color: "black",
weight: 1,
opacity: 0.8
}
var eezLnStyles = {
color: "#7f7f7f",
weight: 1,
opacity: 1
}
var stateStyles = {
color: "#7f7f7f",
weight: 1,
opacity: 1
}
var tribalUAStyles = {
color: "#594600",
weight: 2,
opacity: 1
}
var latStyles = {
color: "black",
weight: 1,
opacity: depOpacity
}
var dep30Styles = {
color: "#87bede",
weight: depLineWeight,
opacity: depOpacity
}
var dep100Styles = {
color:"#348ccb",
weight: depLineWeight,
opacity: depOpacity
}
var dep150Styles = {
color: "#08519c",
weight: depLineWeight,
opacity: depOpacity
}
var dep700Styles = {
color: "#000066",
weight: depLineWeight,
opacity: depOpacity
}
var efhcaStyles = {
fillColor: "#7f7f7f",
fillOpacity: 0.3,
color: "black",
weight: 1,
opacity: 1
}
var efh700Styles = {
fillColor: "#7f7f7f",
fillOpacity: 0.3,
color: "black",
weight: 1,
opacity: 1
}
var ccaStyles = {
fillColor: "#ffb366",
fillOpacity: 0.3,
color: "black",
weight: 0.5,
opacity: 1
}
var cbgcaStyles = {
fillColor: "#ff9999",
fillOpacity: 0.3,
color: "black",
weight: 0.5,
opacity: 1
}
var rcaStyles = {
fillColor: "#737300",
fillOpacity: 0.3,
color: "#343434",
weight: 1,
opacity: 1
}
var gt3500Styles = {
fillColor: "#002673",
fillOpacity: 0.3,
color: "#002673",
weight: 1,
opacity: 1
}
sources = {
//"eez": "data/eez_py.geojson",
"eez_ln": "data/eez_ln.geojson",
"state_ln": "data/state_ln.geojson",
"tribalUA_ln": "data/tribalUA_ln.geojson",
"lat": "data/strata_lat.geojson",
"dep30fm": "data/rca_30fm.geojson",
"dep100fm": "data/rca_100fm.geojson",
"dep150fm": "data/rca_150fm.geojson",
"dep700fm": "data/efh_700fm.geojson",
"efhca":"data/efh_consarea_py.geojson",
"efh700":"data/efh_700fm_py.geojson",
"cca":"data/cca_py.geojson",
"cbgca":"data/cbgca_py.geojson",
"rca":"data/RCA_TrawlGF_MarAprSepOct.geojson",
"gt3500m":"data/deeperthan3500m_py.geojson",
}
styles = {
//"eez": eezStyles,
"eez_ln": eezLnStyles,
"state_ln": stateStyles,
"tribalUA_ln": tribalUAStyles,
"lat": latStyles,
"dep30fm": dep30Styles,
"dep100fm": dep100Styles,
"dep150fm": dep150Styles,
"dep700fm": dep700Styles,
"efhca":efhcaStyles,
"efh700":efh700Styles,
"cca":ccaStyles,
"cbgca":cbgcaStyles,
"rca":rcaStyles,
"gt3500m":gt3500Styles,
}
var data = {}; // object to hold JSON data for each layer
var layers = {}; // object to hold Leaflet GeoJSON layers
//
$.when(
$.getJSON(sources["eez_ln"], function(d) {
data["eez_ln"] = d;
}),
$.getJSON(sources["state_ln"], function(d) {
data["state_ln"] = d;
}),
$.getJSON(sources["tribalUA_ln"], function(d) {
data["tribalUA_ln"] = d;
}),
$.getJSON(sources["lat"], function(d) {
data["lat"] = d;
}),
$.getJSON(sources["dep30fm"], function(d) {
data["dep30fm"] = d;
}),
$.getJSON(sources["dep100fm"], function(d) {
data["dep100fm"] = d;
}),
$.getJSON(sources["dep150fm"], function(d) {
data["dep150fm"] = d;
}),
$.getJSON(sources["dep700fm"], function(d) {
data["dep700fm"] = d;
}),
$.getJSON(sources["efhca"], function(d) {
data["efhca"] = d;
}),
$.getJSON(sources["efh700"], function(d) {
data["efh700"] = d;
}),
$.getJSON(sources["cca"], function(d) {
data["cca"] = d;
}),
$.getJSON(sources["cbgca"], function(d) {
data["cbgca"] = d;
}),
$.getJSON(sources["rca"], function(d) {
data["rca"] = d;
}),
$.getJSON(sources["gt3500m"], function(d) {
data["gt3500m"] = d;
}),
).then(function() {
// send complete data object to another function to create layers, etc.
drawMap(data);
// Draw legend with Leaflet GeoJSON layers
drawSwitcher(layers);
});
// Use the GeoJSON input data to create Leaflet GeoJSON layers for map
function drawMap(data){
for (k in data){ // loop through each input source data layer
// Create Leaflet GeoJSON layer with source GeoJSON data
var layer = L.geoJson(data[k], {
style: function (feature) { // style for each GeoJSON feature
return styles[k]
},
onEachFeature: function (feature, layer) {
if (k === "lat") {
var label = feature.properties.Landmark.split(',')[0];
layer.bindTooltip(label,
{permanent: true, direction: 'top', opacity: 1 , offset: [0,12]}
);
}
}
});
// Initial state of all layers is off.
// layer.addTo(map);
layers[k] = layer;
} // end loop for all source data layers
// Add specific layers to draw on initial load here, if desired
layers["tribalUA_ln"].addTo(map);
// Make sure EFH and RCA polygons are always on bottom
// to avoid interference with Proposal selection and hover functions
map.on('overlayadd', function(e){
if (e.name.indexOf('EFH') >= 0 || e.name.indexOf('RCA') >= 0){
e.layer.bringToBack();
}
});
} // end drawMap()
function drawSwitcher(layers){
// Layer Switcher
var layerLabels = {
"<b style='color:#7f7f7f'>EEZ</b>": layers["eez_ln"],
"<b style='color:#7f7f7f'>State Waters</b>": layers["state_ln"],
"<b style='color:#594600'>Tribal U&A, 2106 </b><a style='color:#594600' href='http://www.westcoast.fisheries.noaa.gov/publications/fishery_management/groundfish/public_notices/public_notice_tribal_u_a.pdf' target='_blank'>public notice</a>": layers["tribalUA_ln"],
"<b style='color:black'>Latitude Breaks</b>": layers["lat"],
"<b style='color:#87bede'>30 fathoms</b>": layers["dep30fm"],
"<b style='color:#348ccb'>100 fathoms</b>": layers["dep100fm"],
"<b style='color:#08519c'>150 fathoms</b>": layers["dep150fm"],
"<b style='color:#000066'>700 fathoms</b>": layers["dep700fm"],
"<b style='color:#7f7f7f'>EFH Conservation Areas</b>": layers["efhca"],
"<b style='color:#7f7f7f'>EFH 700-fm Closure</b>": layers["efh700"],
"<b style='color:#ffb366'>Cowcod Conservation Area</b>": layers["cca"],
"<b style='color:#ff9999'>Cordell Bank Groundfish Closed Area</b>": layers["cbgca"],
"<b style='color:#737300'>Trawl RCA, 2015</b>": layers["rca"],
"<b style='color:#002673'>Alt 3a: Waters Deeper than 3500 m</b>": layers["gt3500m"],
}
var switcher = L.control.layers(baseLayers, layerLabels, {
collapsed: true});
switcher.addTo(map);
// Add text label next to layer switcher control
$( "#layer-control-text" ).html( "<p>Reference<br>Layers</p>" );
} // end drawSwitcher()
// Select or unselect feature depending on its current state
function toggleSelected(layer){
var id = layer.feature.properties.concat_id;
if ( selectedSet.hasOwnProperty(id) ){ // in selected set
// Unselect it
unselected(layer);
} else { // If already in selected set
// Select it
selected(layer);
}
} // end toggleSelected()
// Runs when a feature is selected
function selected(layer) {
var data = layer.feature.properties;
var id = layer.feature.properties.concat_id;
var overlapping = [];
// If it isn't already selected, add to set and change style
// otherwise, unselect it
// Change Styles
layer.setStyle({
color: "yellow",
});
layer.bringToFront();
// Test if it overlaps any current selections
for ( var i in selectedSet ){
var feat2compare = selectedSet[i];
if (isOverlapped(layer, feat2compare)) {
// if a current feature is overlapped by selection, add to list
overlapping.push(feat2compare);
}
}
// Add selected feature to the selected set - concat_id is object key
selectedSet[id]= layer;
// Add the feature's stats to the summary statistics
updateSummmary();
// Add the feature's metrics to the polygon table
updatePolyTable(data);
// increase layer control counter by 1 for this proposal
var $layerCounter = $('label[data-nice-name*="'+data.Alternative+'"]').find('.layer-counter-current');
var currentValue = +$layerCounter.html(); // the '+' turns it into a number
$layerCounter.html(currentValue + 1);
// Unselect any overlapping features
overlapping.forEach(function (layer) {
unselected(layer);
});
} // end selected()
// Runs when a feature is removed from selection
function unselected(layer) {
// var layer = e.target;
var data = layer.feature.properties;
var id = layer.feature.properties.concat_id;
var proposer = layer.feature.properties.Alternative;
// If it is selected, remove from selected set object and revert style
if (selectedSet.hasOwnProperty(id)){
// Remove poly from selected set
delete selectedSet[id];
// Get original color of layer based on proposer
for (lyr in layerInfo) {
if (proposer === layerInfo[lyr].proposer) {
var strokeColor = layerInfo[lyr].color
}
}
// Change color back to original
layer.setStyle({
color: strokeColor,
});
// Following causes errors if layer is not currently visible
// layer.bringToFront();
}
// decrease layer control counter by 1 for this proposal
var $layerCounter = $('label[data-nice-name*="'+data.Alternative+'"]').find('.layer-counter-current');
var currentValue = +$layerCounter.html(); // the '+' turns it into a number
$layerCounter.html(currentValue - 1);
// Remove the feature's stats from the summary statistics
updateSummmary();
} // end unselected()
// Determine if two polygons overlap
function isOverlapped(feature1, feature2) {
// Input is two Leaflet layer polygons
// Convert polys GeoJSON
var poly1 = feature1.toGeoJSON();
var poly2 = feature2.toGeoJSON();
// Turf Intersection function
var intersection = turf.intersect(poly1, poly2);
// Only want poly overlaps, not shared boundary intersections
if (intersection) {
if (intersection.geometry.type === "Polygon") {
return feature2;
} else {
return false
}
} else {
return false
}
} // end isOverlapped()
// Create an array of Leaflet Bounds for each feature
function getSelectedBounds() {
var selectedBounds = [];
// Get bounds for selected set of layers
for ( var i in selectedSet ){
selectedBounds.push(selectedSet[i].getBounds())
}
return selectedBounds;
} // end getSelectedBounds()
function zoomToSelected() {
// Get the bounds of currently selected features
var bounds = getSelectedBounds();
// Zooms to currently selected polygons
map.fitBounds(getSelectedBounds());
} // end zoomToSelected()
// Clear all selected polygons
function clearSelected() {
for ( var i in selectedSet ){
var layer = selectedSet[i];
var proposer = layer.feature.properties.Alternative;
// Get original color of layer based on proposer
for (lyr in layerInfo) {
if (proposer === layerInfo[lyr].proposer) {
var strokeColor = layerInfo[lyr].color
}
}
// Change color back to original
layer.setStyle({
color: strokeColor,
});
$('#zoom').removeClass('available');
$('#clear').removeClass('available');
}
$('.layer-counter-current').html(0);
selectedSet = {}; // remove all layers from selected set
buildSummary() // re-create empty summary table
buildPolyTable() // re-create empty polygon table
}
// Runs on mouseover of a feature - updates style and grabs data for info box
function highlightFeature(e) {
var layer = e.target;
// Change Styles to make outline wider
layer.setStyle({
weight: 5,
dashArray: '',
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
// Update the info box
updateInfo(layer)
$(".poly-info").show(); // Show the info box
} // end highlightFeature()
// Runs when mouseout of feature - Returns feature style to original
function resetHighlight(e) {
// Function that when mouseout of feature
var layer = e.target;
layer.setStyle({
weight: 2
})
$(".poly-info").hide(); // Hide the info box
} // end resetHighlight()
function drawInfo() {
// create a new Leaflet control object, and position it lower right
var info = L.control({
position: 'bottomright'
});
info.onAdd = function (map) { // when info control is added to map
// Create a div to hold the info box with a class name of "info"
var div = L.DomUtil.create('div', 'poly-info');
// return empty div to be added to map
return div;
}
// Add empty info div to map
info.addTo(map);
$(".poly-info").hide(); // hide empty info box until populated
} // end drawInfo()
function updateInfo(layer) {
// Info pop-up box when hover over polygon on map
// variable to access layer properties
var data = layer.feature.properties;
var alternative = data.Alternative;
// Years for the Economic data
var RCAeconYr = "1997-2001";
var noRCAeconYr = "2011-2014";
if (data.RegAction === "reopen") {
noRCAeconYr = "1997-2001";
}
if (selectableAlts.includes(alternative) || rcaAlts.includes(alternative)){
var altTitle = "Alternative"
} else {
altTitle = "Proposer"
}
// populate html variable with header - Site name
// and values for the specified attributes using the
// layer (feature) that was passed to this function
var html = "<h3>" + data.SiteName + "</h3>" // +
html += "<br>" + "<b>Action: </b>" + data.RegAction;
html += "<br>" + "<b>" + altTitle + ": </b>" + alternative;
html += "<br>" + "<b>Area (sq mi): </b>" + fmt4table(data.SiteAreaMi2);
if (selectableAlts.includes(alternative) || rcaAlts.includes(alternative)){
html += "<br>" + "<b>Hard Substrate: </b>" + pct(data.hard, data.SiteAreaMi2);
html += "<br>" + "<b>Mixed Substrate: </b>" + pct(data.mixed, data.SiteAreaMi2);
html += "<br>" + "<b>Soft Substrate: </b>" + pct(data.soft, data.SiteAreaMi2);
html += "<br>" + "<b>Unknown Substrate: </b>" + pct(data.unknown, data.SiteAreaMi2);
html += "<br>" + "<b>Canyons & Gullies: </b>" + pct(data.CynAreaMi2, data.SiteAreaMi2);
html += "<br>" + "<b>Overfished Species: </b> " + pct(data.OF80AreaMi2, data.SiteAreaMi2);
html += "<br>" + "<b>Coral Presence</b> (1 km cells): " + data.coral_cnt;
html += "<br>" + "<b>Sponge Presence</b> (1 km cells): " + data.sponge_cnt;
html += "<br>" + "<b>Sea Pen Presence</b> (1 km cells): " + data.penn_cnt;
html += "<br>" + "<b>Coral Bycatch</b> (.5 km cells): " + data.coralthreshold_count;
html += "<br>" + "<b>Sponge Bycatch</b> (.5 km cells): " + data.spongethreshold_count;
html += "<br>" + "<b>Sea Pen Bycatch</b> (.5 km cells): " + data.pennthreshold_count;
}
if (selectableAlts.includes(alternative)) {
html += "<br>" + "<b>Outside RCA</b> (" + noRCAeconYr + "):";
html += "<br>" + " <b>Landings</b> (lbs): " + cfd4table(data.LWlb_outRCA, 'landings');
html += "<br>" + " <b>Ex-Vessel Revenue: </b>: " + cfd4table(data.Rev_outRCA, 'dollars');
html += "<br>" + "<b>Inside RCA</b> (" + RCAeconYr + "):";
html += "<br>" + " <b>Landings</b> (lbs): " + cfd4table(data.LWlb_inRCA, 'landings');
html += "<br>" + " <b>Ex-Vessel Revenue</b>: " + cfd4table(data.Rev_inRCA, 'dollars');
html += "<br>" + "** indicates confidential data";
// html += "<br>" + "<b>Conserv. Value Mean: </b> " + rnd(data.consval_mean, 2);
// html += "<br>" + "<b>Conserv. Value Variance: </b> " + rnd(data.consval_var, 2);
}
// Assign the html content to the info box using JQuery selector
$(".poly-info").html(html);
} // end updateInfo()
function buildUI() {