adiwg-mdtranslator 2.18.4 → 2.19.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +14 -0
  3. data/Gemfile.lock +11 -9
  4. data/adiwg-mdtranslator.gemspec +3 -3
  5. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +29 -13
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dataQuality.rb +149 -0
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +2 -2
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +10 -6
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_lineage.rb +14 -11
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_methodology.rb +26 -34
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb +13 -1
  12. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +2 -2
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_conformanceResult.rb +1 -1
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageResult.rb +8 -7
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataQuality.rb +4 -4
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataQualityReport.rb +8 -16
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_evaluationMethod.rb +1 -1
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_legalConstraint.rb +8 -8
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_qualityMeasure.rb +34 -0
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_qualityResultFile.rb +72 -0
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_rangeElementDescription.rb +2 -2
  22. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_contact.rb +13 -0
  23. data/lib/adiwg/mdtranslator/version.rb +1 -1
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/{class_quality.rb → class_dataQuality.rb} +14 -10
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_fgdc.rb +3 -3
  26. data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +5 -1
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQuality.rb +39 -18
  28. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQualityReport.rb +385 -0
  29. data/lib/adiwg/mdtranslator/writers/html/sections/html_rangeElementDescription.rb +2 -2
  30. data/lib/adiwg/mdtranslator/writers/html/sections/html_resultFile.rb +60 -0
  31. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataQualityReport.rb +213 -39
  32. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_mdMetadata.rb +1 -1
  33. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_organization.rb +1 -19
  34. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_qualityResultFile.rb +55 -0
  35. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_rangeElementDescription.rb +14 -13
  36. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_sampleDimension.rb +6 -6
  37. data/lib/adiwg/mdtranslator/writers/iso19115_3/iso19115_3_writer.rb +2 -0
  38. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_allocation.rb +1 -1
  39. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageResult.rb +30 -0
  40. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQuality.rb +3 -1
  41. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQualityReport.rb +12 -10
  42. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_descriptiveResult.rb +3 -3
  43. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_funding.rb +2 -2
  44. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_legalConstraint.rb +1 -1
  45. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +1 -1
  46. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_qualityMeasure.rb +4 -3
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_qualityResultFile.rb +23 -0
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_standaloneQualityReport.rb +31 -0
  49. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +10 -0
  50. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_additionalDocumentation.rb +1 -1
  51. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_algorithm.rb +1 -1
  52. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_allocation.rb +1 -1
  53. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_associatedResource.rb +2 -2
  54. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_attribute.rb +2 -2
  55. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_attributeGroup.rb +1 -1
  56. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_body.rb +15 -31
  57. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_citation.rb +5 -5
  58. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_classedData.rb +1 -1
  59. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_constraint.rb +5 -5
  60. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_contact.rb +37 -5
  61. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_coverageInfo.rb +3 -3
  62. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_dataDictionary.rb +5 -5
  63. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_dataQuality.rb +31 -12
  64. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_dataQualityReport.rb +385 -0
  65. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_distribution.rb +1 -1
  66. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_distributor.rb +3 -3
  67. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_domain.rb +3 -3
  68. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_domainItem.rb +1 -1
  69. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_entity.rb +5 -5
  70. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_entityAttribute.rb +3 -3
  71. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_extent.rb +3 -3
  72. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_feature.rb +5 -5
  73. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_featureCollection.rb +4 -4
  74. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_featureProperties.rb +1 -1
  75. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_format.rb +1 -1
  76. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_funding.rb +1 -1
  77. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geodeticParameters.rb +2 -2
  78. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geographicElement.rb +4 -4
  79. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geographicExtent.rb +4 -14
  80. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geologicAge.rb +1 -1
  81. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geometryCollection.rb +4 -4
  82. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_geometryObject.rb +2 -2
  83. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_georectifiedRepresentation.rb +2 -2
  84. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_georeferenceableRepresentation.rb +3 -3
  85. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_graphic.rb +2 -2
  86. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_gridRepresentation.rb +2 -2
  87. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_identifier.rb +1 -1
  88. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_imageInfo.rb +1 -1
  89. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_keyword.rb +14 -16
  90. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_metadataInfo.rb +10 -9
  91. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_metadataRepository.rb +1 -1
  92. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_processStep.rb +1 -1
  93. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_processing.rb +3 -3
  94. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_rangeElementDescription.rb +2 -2
  95. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_resourceInfo.rb +17 -17
  96. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_responsibility.rb +1 -1
  97. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_resultFile.rb +60 -0
  98. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_scope.rb +12 -12
  99. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_source.rb +2 -2
  100. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_taxonomy.rb +1 -1
  101. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_timePeriod.rb +1 -3
  102. metadata +23 -13
  103. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +0 -181
  104. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_bodyScript.js +0 -317
@@ -1,181 +0,0 @@
1
- # Reader - fgdc to internal data structure
2
- # unpack fgdc data quality
3
-
4
- # History:
5
- # Stan Smith 2017-08-15 original script
6
-
7
- require 'nokogiri'
8
- require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
- require_relative 'module_lineage'
10
-
11
- module ADIWG
12
- module Mdtranslator
13
- module Readers
14
- module Fgdc
15
-
16
- module Quality
17
-
18
- def self.unpack(xDataQual, hMetadata, hDataQuality, hResponseObj)
19
-
20
- hDataQuality[:scope] = {scopeCode: 'tabularDataset'}
21
- hDataQuality[:systemIdentifier] = {
22
- uid: UUIDTools::UUID.random_create.to_s,
23
- label: "CSDGM Data Quality"
24
- }
25
-
26
-
27
- # data quality 2.1 (attracc) - attribute accuracy
28
- xAccuracy = xDataQual.xpath('./attracc')
29
- accuracyReport = xAccuracy.xpath('./attraccr').text
30
- hDataQuality[:report] << {
31
- type: 'DQ_NonQuantitativeAttributeCompleteness',
32
- descriptiveResult: [ {statement: accuracyReport} ]
33
- }
34
-
35
- # data quality 2.1 (qattracc) - Quantitative Attribute Accuracy Assessment
36
-
37
- xQuantitativeAccuracy = xDataQual.xpath('./qattracc')
38
- unless xQuantitativeAccuracy.xpath('./attraccv').empty?
39
- hDataQuality[:report] << {
40
- type: 'DQ_QuantitativeAttributeAccuracy',
41
- quantitativeResult: [{
42
- value: xQuantitativeAccuracy.xpath('./attraccv').text
43
- }]
44
- }
45
- end
46
-
47
- # data quality 2.2 (logic) - logical consistency (required) (not implemented)
48
- xLogic = xDataQual.xpath('./logic')
49
- if xLogic.empty?
50
- hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: data quality logical consistency section is missing'
51
- else
52
- logic = xLogic.text
53
- hDataQuality[:report] << {
54
- type: 'DQ_ConceptualConsistency',
55
- qualityMeasure: {
56
- description: logic
57
- }
58
- }
59
- end
60
-
61
- # data quality 2.3 (complete) - completion report (required)
62
- xComplete = xDataQual.xpath('./complete')
63
- if xComplete.empty?
64
- hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: data quality completion report section is missing'
65
- else
66
- complete = xComplete.text
67
- hDataQuality[:report] << {
68
- type: 'DQ_CompletenessOmission',
69
- descriptiveResult: [{
70
- statement: complete
71
- }]
72
- }
73
- end
74
-
75
- # data quality 2.4 (position) - positional accuracy
76
- xPositionalAccuracy = xDataQual.xpath('./posacc')
77
- unless xPositionalAccuracy.empty?
78
-
79
- # horizontal positional accuracy
80
- xHorizontal = xPositionalAccuracy.xpath('./horizpa')
81
- unless xHorizontal.empty?
82
-
83
- report = {}
84
-
85
- unless xHorizontal.xpath('horizpar').empty?
86
- report[:evaluationMethod] = {
87
- methodDescription: xHorizontal.xpath('horizpar').text
88
- }
89
- end
90
-
91
- unless xHorizontal.xpath('qhorizpa/horizpae').empty?
92
- report[:qualityMeasure] = {
93
- description: xHorizontal.xpath('qhorizpa/horizpae').text
94
- }
95
- end
96
-
97
- unless xHorizontal.xpath('qhorizpa/horizpav').empty?
98
- report[:quantitativeResult] = [{
99
- value: [ xHorizontal.xpath('qhorizpa/horizpav').text ]
100
- }]
101
- end
102
-
103
- unless report.empty?
104
- if report[:qualityMeasure].nil?
105
- report[:qualityMeasure] = {
106
- name: ['Horizontal Positional Accuracy Report']
107
- }
108
- else
109
- report[:qualityMeasure][:name] = ['Horizontal Positional Accuracy Report']
110
- end
111
-
112
- report[:type] = 'DQ_AbsoluteExternalPositionalAccuracy'
113
-
114
- hDataQuality[:report] << report
115
- end
116
- end
117
-
118
- # vertical positional accuracy
119
- xVertical = xPositionalAccuracy.xpath('./vertacc')
120
- unless xVertical.empty?
121
-
122
- report = {}
123
-
124
- unless xVertical.xpath('vertaccr').empty?
125
- report[:evaluationMethod] = {
126
- methodDescription: xVertical.xpath('vertaccr').text
127
- }
128
- end
129
-
130
- unless xVertical.xpath('qvertpa/vertacce').empty?
131
- report[:qualityMeasure] = {
132
- description: xVertical.xpath('qvertpa/vertacce').text
133
- }
134
- end
135
-
136
- unless xVertical.xpath('qvertpa/vertaccv').empty?
137
- report[:quantitativeResult] = [{
138
- value: [ xVertical.xpath('qvertpa/vertaccv').text ]
139
- }]
140
- end
141
-
142
- unless report.empty?
143
- if report[:qualityMeasure].nil?
144
- report[:qualityMeasure] = {
145
- name: ['Vertical Positional Accuracy Report']
146
- }
147
- else
148
- report[:qualityMeasure][:name] = ['Vertical Positional Accuracy Report']
149
- end
150
-
151
- report[:type] = 'DQ_AbsoluteExternalPositionalAccuracy'
152
-
153
- hDataQuality[:report] << report
154
- end
155
- end
156
- end
157
-
158
- # data quality 2.5 (lineage) - lineage (required)
159
- xLineage = xDataQual.xpath('./lineage')
160
- unless xLineage.empty?
161
- hLineage = Lineage.unpack(xLineage, hResponseObj)
162
- unless hLineage.nil?
163
- hMetadata[:lineageInfo] << hLineage
164
- end
165
- end
166
- if xLineage.nil?
167
- hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: data quality lineage section is missing'
168
- end
169
-
170
- # data quality 2.6 (cloud) - cloud cover (not implemented)
171
-
172
- return hDataQuality
173
-
174
- end
175
-
176
- end
177
-
178
- end
179
- end
180
- end
181
- end
@@ -1,317 +0,0 @@
1
-
2
- //forEach Polyfill, Reference: https://goo.gl/hFIfSd
3
- if (!Array.prototype.forEach) {
4
- Array.prototype.forEach = function(callback, thisArg) {
5
- var T, k;
6
- if (this === null || this === undefined) {
7
- throw new TypeError(' this is null or not defined');
8
- }
9
- var O = Object(this);
10
- var len = O.length >>> 0;
11
- if ( typeof callback !== "function") {
12
- throw new TypeError(callback + ' is not a function');
13
- }
14
- if (arguments.length > 1) {
15
- T = thisArg;
16
- }
17
- k = 0;
18
- while (k < len) {
19
- var kValue;
20
- if ( k in O) {
21
- kValue = O[k];
22
- callback.call(T, kValue, k, O);
23
- }
24
- k++;
25
- }
26
- };
27
- }
28
-
29
- // open detail panel in the document
30
- function openDetail(evt) {
31
- var href = evt.target.getAttribute("href");
32
- href = href.slice(1);
33
-
34
- if(window.location !== window.parent.location){
35
- evt.preventDefault();
36
- var el = document.getElementById(href);
37
- window.scrollTo(0, el.offsetTop);
38
- }
39
- var parentNode = document.getElementById(href).parentNode;
40
- parentNode.open = true;
41
- }
42
-
43
- // open all detail panels in the document
44
- function openAllDetails(evt) {
45
- if(window.location !== window.parent.location){
46
- evt.preventDefault();
47
- }
48
- var arr = document.getElementsByTagName("details");
49
- var len = arr.length;
50
-
51
- for (var i = 0; i < len; i++) {
52
- arr[i].open = true;
53
- }
54
- }
55
-
56
- // close all detail panels in the document
57
- function closeAllDetails(evt) {
58
- if(window.location !== window.parent.location){
59
- evt.preventDefault();
60
- }
61
- var arr = document.getElementsByTagName("details");
62
- var len = arr.length;
63
-
64
- for (var i = 0; i < len; i++) {
65
- arr[i].open = false;
66
- }
67
- }
68
-
69
- // add event listeners to all anchor buttons in the sideNav
70
- var navBtnList = document.querySelectorAll('a.navBtn');
71
- var navBtnArray = Array.prototype.slice.call(navBtnList);
72
- navBtnArray.forEach(function(btn, btnIdx, btnArr) {
73
- var href = btn.getAttribute("href").slice(1);
74
- var target = document.getElementById(href);
75
- //hide button if target is not present
76
- if(target) {
77
- btn.addEventListener("click", openDetail, false);
78
- } else {
79
- btn.style.display = 'none';
80
- }
81
- });
82
-
83
- // add event listener to openAllButton
84
- var elOpen = document.getElementById("openAllButton");
85
- elOpen.addEventListener("click", openAllDetails, false);
86
-
87
- // add event listener to closeAllButton
88
- var elClose = document.getElementById("closeAllButton");
89
- elClose.addEventListener("click", closeAllDetails, false);
90
-
91
- //replace top links in inframes
92
- if(window.location !== window.parent.location){
93
- // add event listeners to all "top" links
94
- var topList = document.querySelectorAll("a[href='#']");
95
- var topArray = Array.prototype.slice.call(topList);
96
- topArray.forEach(function(a) {
97
- a.addEventListener("click", function(evt) {
98
- evt.preventDefault();
99
- window.scrollTo(0,0);
100
- }, false);
101
- });
102
- }
103
-
104
- if ( typeof L === "object") {
105
- (function() {
106
-
107
- var westBound;
108
- var eastBound;
109
-
110
- var coordsToLatLng = function(coords) {
111
- // if computed bounding box spans the antimeridian
112
- // add 360 to negative longitudes
113
- var longitude = coords[0];
114
- if (westBound >= 0 && eastBound < 0) {
115
- if (longitude < 0) {
116
- longitude += 360;
117
- }
118
- }
119
- var latitude = coords[1];
120
- return L.latLng(latitude, longitude);
121
- };
122
-
123
- var bbox2Poly = function(bbox) {
124
- var bboxJson = JSON.parse(bbox.textContent || bbox.innerText);
125
- var sw = [ bboxJson.westLongitude, bboxJson.southLatitude ];
126
- var nw = [ bboxJson.westLongitude, bboxJson.northLatitude ];
127
- var ne = [ bboxJson.eastLongitude, bboxJson.northLatitude ];
128
- var se = [ bboxJson.eastLongitude, bboxJson.southLatitude ];
129
- var coords = [];
130
- coords.push(sw);
131
- coords.push(nw);
132
- coords.push(ne);
133
- coords.push(se);
134
- var bboxCoods = [];
135
- bboxCoods.push(coords);
136
- return bboxCoods;
137
- };
138
-
139
- // collect all geographicExtents sections in document
140
- var geoExtentNodeList = document.querySelectorAll('section.extent-geographic');
141
- var geoExtents = Array.prototype.slice.call(geoExtentNodeList);
142
-
143
- var check = function(i, me, bnds) {
144
- if (i < 3) {
145
- var resize = me.getSize().x === 0 && me.getContainer().offsetWidth > 0;
146
-
147
- me.invalidateSize();
148
- if (resize) {
149
- me.fitBounds(bnds);
150
- } else {
151
- i++;
152
- setTimeout(function() {
153
- check(i, me, bnds);
154
- }, 100);
155
- }
156
- }
157
- };
158
-
159
- geoExtents.forEach(function(geoExtent, idx, arr) {
160
- // instantiate a leaflet map in the map div
161
- var map = L.map(geoExtent.querySelector('div.map'), {noWrap: true});
162
- // get a pointer to the map header switch
163
- var header = geoExtent.querySelector('summary.map-summary');
164
- // get the GeoJSON from the geojson div
165
- var geoJsonDiv = geoExtent.querySelector('div.geojson');
166
- if (geoJsonDiv) {
167
- var geojson = JSON.parse(geoJsonDiv.textContent || geoJsonDiv.innerText);
168
- }
169
- else {
170
- var geojson = [];
171
- }
172
- // get the user provided bounding box for the extent - if any
173
- var userBBox = geoExtent.querySelector('div.userBBox');
174
- if (userBBox) {
175
- var userCoords = bbox2Poly(userBBox);
176
- var newUserBBox = {
177
- "type": "Feature",
178
- "geometry": {
179
- "type": "Polygon",
180
- "coordinates": userCoords
181
- },
182
- "properties": {
183
- "style": {
184
- "color": '#f00',
185
- "fill": false
186
- },
187
- "featureName": [
188
- "User BBOX"
189
- ]
190
- }
191
- };
192
- geojson.push(newUserBBox);
193
- }
194
-
195
- // get the computed bounding box for the extent - always one
196
- var computedBBox = geoExtent.querySelector('div.computedBBox');
197
- if (computedBBox) {
198
- var compCoords = bbox2Poly(computedBBox);
199
- var newCompBBox = {
200
- "type": "Feature",
201
- "geometry": {
202
- "type": "Polygon",
203
- "coordinates": compCoords
204
- },
205
- "properties": {
206
- "style": {
207
- "color": '#0f0',
208
- "fill": false
209
- },
210
- "featureName": [
211
- "Computed BBOX"
212
- ]
213
- }
214
- };
215
- geojson.push(newCompBBox);
216
- westBound = compCoords[0][0][0];
217
- eastBound = compCoords[0][2][0];
218
- }
219
-
220
- var pointCnt = 0;
221
- var lineStringCnt = 0;
222
- var polygonCnt = 0;
223
- var geoCollectCnt = 0;
224
- var featureCnt = 0;
225
-
226
- geojson.forEach(function(geo, geoIdx, geoArr) {
227
-
228
- // make sure each geo has a properties object
229
- if (!geo.properties) {
230
- geo.properties = {};
231
- }
232
-
233
- // add popup information
234
- if (geo.type === "Point") {
235
- pointCnt += 1;
236
- geo.properties.popup = "Point " + pointCnt;
237
- }
238
- if (geo.type === 'LineString') {
239
- lineStringCnt += 1;
240
- geo.properties.popup = "LineString " + lineStringCnt;
241
- }
242
- if (geo.type === 'Polygon') {
243
- polygonCnt += 1;
244
- geo.properties.popup = "Polygon " + polygonCnt;
245
- }
246
- if (geo.type === 'GeometryCollection') {
247
- geoCollectCnt += 1;
248
- geo.properties.popup = "Geometry Collection " + geoCollectCnt;
249
- // popup can't find properties on collection objects
250
- // placed popup on geometry collection instead
251
- // geo.geometries.forEach(function (geoG, geoGIdx, geoGArr) {
252
- // geoG.properties = {};
253
- // geoG.properties.popup = "Geometry Collection " + geoCollectCnt + " " + geoG.type;
254
- // });
255
- }
256
- if (geo.type === 'Feature') {
257
- featureCnt += 1;
258
- var featureName;
259
- if (geo.properties.featureName !== undefined) {
260
- featureName = geo.properties.featureName[0] || geo.id || geo.geometry.type;
261
- } else featureName = geo.id || "Feature " + featureCnt + " " + geo.geometry.type;
262
- geo.properties.popup = featureName;
263
- }
264
- if (geo.type === 'FeatureCollection') {
265
- geo.features.forEach(function (geoF, geoFIdx, geoFArr) {
266
- featureCnt += 1;
267
- var featureName;
268
- if (geoF.properties.featureName !== undefined) {
269
- featureName = geoF.properties.featureName[0] || geoF.id || geoF.geometry.type;
270
- } else featureName = geoF.id || "Feature " + featureCnt + " " + geoF.geometry.type;
271
- geoF.properties.popup = featureName;
272
- });
273
- }
274
-
275
- });
276
-
277
- var geoLayer = L.geoJSON(geojson, {
278
- style: function(feature) {
279
- return feature.properties.style || {};
280
- },
281
- coordsToLatLng: coordsToLatLng,
282
- onEachFeature: function (feature, layer) {
283
- layer.bindPopup(feature.properties.popup,{
284
- closeButton: true
285
- });
286
- }
287
- }).addTo(map);
288
-
289
- var bnds = geoLayer.getBounds();
290
- map.fitBounds(bnds);
291
-
292
- L.DomEvent.addListener(header, 'click', function() {
293
- var me = this;
294
- var i = 0;
295
-
296
- setTimeout(function() {
297
- check(i, me, bnds);
298
- }, 100);
299
-
300
- }, map);
301
-
302
- L.DomEvent.addListener(L.DomUtil.get('openAllButton'), 'click', function() {
303
- var me = this;
304
- var i = 0;
305
-
306
- setTimeout(function() {
307
- check(i, me, bnds);
308
- }, 100);
309
-
310
- }, map);
311
-
312
- // map.addLayer(new L.TileLayer.OSM());
313
- var stamen = new L.StamenTileLayer("terrain");
314
- map.addLayer(stamen);
315
- });
316
- })();
317
- }