@mapcomponents/react-maplibre 0.1.57 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +11 -0
- package/.eslintrc.js +20 -0
- package/.github/workflows/check-formatting.yml +46 -0
- package/.prettierignore +11 -0
- package/.prettierrc.json +6 -0
- package/CHANGELOG.md +18 -0
- package/coverage/clover.xml +229 -77
- package/coverage/coverage-final.json +43 -37
- package/coverage/lcov-report/index.html +65 -20
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +83 -83
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +66 -66
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +30 -30
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +202 -0
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +116 -0
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +99 -99
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +66 -66
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +221 -221
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +308 -308
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +497 -497
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +85 -85
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +469 -0
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +116 -0
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +140 -140
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +37 -37
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +179 -179
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +113 -113
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +181 -181
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +58 -58
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +108 -108
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +39 -39
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +183 -183
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +163 -163
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +50 -50
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +30 -30
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +83 -83
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +204 -204
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +180 -180
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +163 -163
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +136 -136
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +53 -53
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +123 -123
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +35 -35
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +155 -155
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +255 -255
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +66 -66
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +48 -48
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/exportMap/index.html +131 -0
- package/coverage/lcov-report/src/hooks/exportMap/index.ts.html +175 -0
- package/coverage/lcov-report/src/hooks/exportMap/lib.ts.html +646 -0
- package/coverage/lcov-report/src/hooks/index.html +48 -18
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +230 -188
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +232 -0
- package/coverage/lcov-report/src/hooks/useMap.ts.html +72 -69
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +145 -145
- package/coverage/lcov-report/src/hooks/useSource.ts.html +337 -0
- package/coverage/lcov-report/src/hooks/useWms.js.html +72 -72
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +11 -2
- package/coverage/lcov.info +448 -151
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +24 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +13 -0
- package/dist/components/MlCreatePdfForm/lib/PdfContext.d.ts +21 -0
- package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +10 -0
- package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +13 -0
- package/dist/components/MlCreatePdfForm/lib/pdf.templates.d.ts +11 -0
- package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +22 -0
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +10 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +1 -1
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +2 -2
- package/dist/decorators/MapContextDecoratorHooks.d.ts +2 -0
- package/dist/hooks/exportMap/index.d.ts +11 -0
- package/dist/hooks/exportMap/lib.d.ts +36 -0
- package/dist/hooks/useLayer.d.ts +6 -5
- package/dist/hooks/useLayerEvent.d.ts +2 -0
- package/dist/hooks/useMap.d.ts +1 -1
- package/dist/hooks/useMapState.stories.d.ts +2 -2
- package/dist/hooks/useSource.d.ts +17 -0
- package/dist/hooks/useSources.stories.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +1055 -315
- package/dist/index.esm.js.map +1 -1
- package/eslintErrorTest.js +10 -0
- package/package.json +7 -1
- package/public/thumbnails/MlCreatePdfForm.png +0 -0
- package/src/components/MapLibreMap/MapLibreMap.stories.js +72 -72
- package/src/components/MapLibreMap/MapLibreMap.test.js +60 -60
- package/src/components/MapLibreMap/MapLibreMap.tsx +82 -82
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +343 -343
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +619 -619
- package/src/components/MlBasicComponent.js +25 -25
- package/src/components/MlCenterPosition/MlCenterPosition.stories.js +6 -6
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +65 -65
- package/src/components/MlComponentTemplate/MlComponentTemplate.stories.js +5 -5
- package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +23 -23
- package/src/components/MlCreatePdfButton/{MlCreatePdfButton.meta.json → MlCreatePdfButton.meta_.json} +0 -0
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.stories.js +16 -16
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +29 -29
- package/src/components/MlCreatePdfButton/lib/createPdf.ts +175 -175
- package/src/components/MlCreatePdfButton/lib/nominatimMap.ts +51 -51
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.doc.de.md +3 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +15 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +152 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx +39 -0
- package/src/components/MlCreatePdfForm/lib/PdfContext.tsx +53 -0
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +161 -0
- package/src/components/MlCreatePdfForm/lib/PdfPreview.tsx +399 -0
- package/src/components/MlCreatePdfForm/lib/pdf.templates.ts +82 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +55 -55
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +105 -105
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +119 -119
- package/src/components/MlFeatureEditor/custom-direct-select-mode.js +208 -208
- package/src/components/MlFeatureEditor/custom-polygon-mode.js +148 -148
- package/src/components/MlFeatureEditor/custom-select-mode.js +314 -314
- package/src/components/MlFeatureEditor/lib/common_selectors.js +34 -34
- package/src/components/MlFeatureEditor/lib/constants.js +61 -61
- package/src/components/MlFeatureEditor/lib/constrain_feature_movement.js +51 -51
- package/src/components/MlFeatureEditor/lib/create_midpoint.js +30 -30
- package/src/components/MlFeatureEditor/lib/create_supplementary_points.js +82 -82
- package/src/components/MlFeatureEditor/lib/create_vertex.js +16 -16
- package/src/components/MlFeatureEditor/lib/double_click_zoom.js +23 -23
- package/src/components/MlFeatureEditor/lib/euclidean_distance.js +3 -3
- package/src/components/MlFeatureEditor/lib/features_at.js +23 -23
- package/src/components/MlFeatureEditor/lib/get_features_and_set_cursor.js +15 -15
- package/src/components/MlFeatureEditor/lib/is_click.js +8 -8
- package/src/components/MlFeatureEditor/lib/is_event_at_coordinates.js +2 -2
- package/src/components/MlFeatureEditor/lib/is_tap.js +6 -6
- package/src/components/MlFeatureEditor/lib/map_event_to_bounding_box.js +4 -4
- package/src/components/MlFeatureEditor/lib/mode_handler.js +105 -105
- package/src/components/MlFeatureEditor/lib/mouse_event_point.js +5 -5
- package/src/components/MlFeatureEditor/lib/move_features.js +33 -33
- package/src/components/MlFeatureEditor/lib/sort_features.js +25 -25
- package/src/components/MlFeatureEditor/lib/string_set.js +36 -36
- package/src/components/MlFeatureEditor/lib/string_sets_are_equal.js +2 -2
- package/src/components/MlFeatureEditor/lib/theme.js +230 -230
- package/src/components/MlFeatureEditor/lib/to_dense_array.js +1 -1
- package/src/components/MlFeatureEditor/lib/utils.js +40 -40
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.js +9 -9
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.test.js +4 -4
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx +65 -65
- package/src/components/MlFollowGps/MlFollowGps.stories.js +6 -6
- package/src/components/MlFollowGps/MlFollowGps.test.js +44 -44
- package/src/components/MlFollowGps/MlFollowGps.tsx +220 -220
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +15 -15
- package/src/components/MlGPXViewer/MlGPXViewer.test.js +12 -12
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +345 -345
- package/src/components/MlGPXViewer/gpxConverter.js +496 -496
- package/src/components/MlGPXViewer/util/GeoJsonContext.ts +4 -4
- package/src/components/MlGPXViewer/util/GeoJsonProvider.tsx +16 -16
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +34 -34
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.test.js +8 -8
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +84 -84
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +21 -21
- package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +27 -27
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.doc.de.md +3 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +15 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.js +19 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +128 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +28 -28
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +8 -8
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +162 -162
- package/src/components/MlLayer/MlLayer.stories.js +5 -5
- package/src/components/MlLayer/MlLayer.test.js +86 -86
- package/src/components/MlLayer/MlLayer.tsx +36 -36
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +21 -21
- package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +54 -54
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +201 -201
- package/src/components/MlLayerSwipe/MlLayerSwipe.stories.js +20 -20
- package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +54 -54
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +130 -130
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +194 -194
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +85 -85
- package/src/components/MlLayerSwitcher/components/LayerBox.js +57 -57
- package/src/components/MlMarker/MlMarker.stories.js +7 -7
- package/src/components/MlMarker/MlMarker.tsx +119 -119
- package/src/components/MlMeasureTool/MlMeasureTool.stories.js +64 -64
- package/src/components/MlMeasureTool/MlMeasureTool.tsx +38 -38
- package/src/components/MlNavigationCompass/MlNavigationCompass.stories.js +45 -45
- package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +40 -40
- package/src/components/MlNavigationCompass/MlNavigationCompass.tsx +192 -192
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +18 -18
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +173 -173
- package/src/components/MlOsmLayer/MlOsmLayer.js +49 -49
- package/src/components/MlOsmLayer/MlOsmLayer.stories_.js +29 -29
- package/src/components/MlOsmLayer/MlOsmLayer.test.js +8 -8
- package/src/components/MlScaleReference/MlScaleReference.js +82 -82
- package/src/components/MlScaleReference/MlScaleReference.stories.js +27 -27
- package/src/components/MlShareMapState/MlShareMapState.js +203 -203
- package/src/components/MlShareMapState/MlShareMapState.stories.js +68 -68
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +201 -201
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +35 -35
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +8 -8
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +186 -186
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.js +21 -21
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.test.js +24 -24
- package/src/components/MlThreeJsLayer/lib/GLTFLoader.js +3327 -3327
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +31 -30
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.test.js +8 -8
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +146 -146
- package/src/components/MlTransitionGeoJsonLayer/util/transitionFunctions.js +207 -207
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +52 -52
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.stories.js +13 -13
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.stories.js +27 -27
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.test.js +27 -27
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +137 -137
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +34 -34
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.js +7 -7
- package/src/components/MlWmsLayer/MlWmsLayer.stories.js +26 -26
- package/src/components/MlWmsLayer/MlWmsLayer.test.js +8 -8
- package/src/components/MlWmsLayer/MlWmsLayer.tsx +167 -167
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +27 -27
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +254 -254
- package/src/contexts/MapComponentsProvider.test.js +229 -229
- package/src/contexts/MapContext.tsx +65 -65
- package/src/contexts/SimpleDataProvider.js +47 -47
- package/src/contexts/SimpleDataProvider.test.js +29 -29
- package/src/custom.d.tsx +14 -14
- package/src/decorators/MapContextDecorator.js +22 -22
- package/src/decorators/MapContextDecoratorHooks.js +34 -0
- package/src/decorators/MultiMapContextDecorator.js +63 -63
- package/src/decorators/NoNavToolsDecorator.js +17 -17
- package/src/decorators/ThemeWrapper.jsx +1 -1
- package/src/hooks/assets/pointWG.json +13 -0
- package/src/hooks/exportMap/index.ts +30 -0
- package/src/hooks/exportMap/lib.ts +187 -0
- package/src/hooks/useLayer.test.js +188 -188
- package/src/hooks/useLayer.ts +194 -180
- package/src/hooks/useLayerEvent.js +49 -0
- package/src/hooks/useMap.ts +67 -66
- package/src/hooks/useMapState.stories.js +78 -78
- package/src/hooks/useMapState.ts +161 -161
- package/src/hooks/useSource.ts +84 -0
- package/src/hooks/useSources.stories.js +232 -0
- package/src/hooks/useWms.js +71 -71
- package/src/index.ts +3 -0
- package/src/setupTests.js +86 -86
- package/src/ui_components/ImageLoader.js +62 -62
- package/src/ui_components/Legend.js +34 -34
- package/src/ui_components/LoadingOverlay.js +29 -29
- package/src/ui_components/LoadingOverlayContext.js +68 -68
- package/src/ui_components/Sidebar.js +80 -80
- package/src/ui_components/Tooltip.js +9 -9
- package/src/ui_components/TopToolbar.js +23 -23
- package/src/util/layerRemovalTest.js +111 -111
- package/src/util/sourceRemovalTest.js +103 -103
|
@@ -1117,509 +1117,509 @@
|
|
|
1117
1117
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1118
1118
|
*/
|
|
1119
1119
|
var toGeoJSON = (function () {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1126
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1127
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1128
|
-
|
|
1129
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1149
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1150
|
-
|
|
1151
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1156
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1157
|
-
|
|
1158
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1163
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1164
|
-
|
|
1165
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1173
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1174
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1175
|
-
|
|
1176
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1191
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1192
|
-
|
|
1193
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1203
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1204
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1205
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1120
|
+
var removeSpace = /\s*/g,
|
|
1121
|
+
trimSpace = /^\s*|\s*$/g,
|
|
1122
|
+
splitSpace = /\s+/;
|
|
1123
|
+
// generate a short, numeric hash of a string
|
|
1124
|
+
function <span class="fstat-no" title="function not covered" >okhash(</span>x) {
|
|
1125
|
+
<span class="cstat-no" title="statement not covered" > if (!x || !x.length) <span class="cstat-no" title="statement not covered" >return 0;</span></span>
|
|
1126
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0,</span> h = <span class="cstat-no" title="statement not covered" >0;</span> i < x.length; i++) {</span>
|
|
1127
|
+
<span class="cstat-no" title="statement not covered" > h = ((h << 5) - h + x.charCodeAt(i)) | 0;</span>
|
|
1128
|
+
}
|
|
1129
|
+
<span class="cstat-no" title="statement not covered" > return h;</span>
|
|
1130
|
+
}
|
|
1131
|
+
// all Y children of X
|
|
1132
|
+
function <span class="fstat-no" title="function not covered" >get(</span>x, y) {
|
|
1133
|
+
<span class="cstat-no" title="statement not covered" > return x.getElementsByTagName(y);</span>
|
|
1134
|
+
}
|
|
1135
|
+
function <span class="fstat-no" title="function not covered" >attr(</span>x, y) {
|
|
1136
|
+
<span class="cstat-no" title="statement not covered" > return x.getAttribute(y);</span>
|
|
1137
|
+
}
|
|
1138
|
+
function <span class="fstat-no" title="function not covered" >attrf(</span>x, y) {
|
|
1139
|
+
<span class="cstat-no" title="statement not covered" > return parseFloat(attr(x, y));</span>
|
|
1140
|
+
}
|
|
1141
|
+
// one Y child of X, if any, otherwise null
|
|
1142
|
+
function <span class="fstat-no" title="function not covered" >get1(</span>x, y) {
|
|
1143
|
+
var n = <span class="cstat-no" title="statement not covered" >get(x, y);</span>
|
|
1144
|
+
<span class="cstat-no" title="statement not covered" > return n.length ? n[0] : null;</span>
|
|
1145
|
+
}
|
|
1146
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize
|
|
1147
|
+
function <span class="fstat-no" title="function not covered" >norm(</span>el) {
|
|
1148
|
+
<span class="cstat-no" title="statement not covered" > if (el.normalize) {</span>
|
|
1149
|
+
<span class="cstat-no" title="statement not covered" > el.normalize();</span>
|
|
1150
|
+
}
|
|
1151
|
+
<span class="cstat-no" title="statement not covered" > return el;</span>
|
|
1152
|
+
}
|
|
1153
|
+
// cast array x into numbers
|
|
1154
|
+
function <span class="fstat-no" title="function not covered" >numarray(</span>x) {
|
|
1155
|
+
<span class="cstat-no" title="statement not covered" > for (var j = <span class="cstat-no" title="statement not covered" >0,</span> o = <span class="cstat-no" title="statement not covered" >[];</span> j < x.length; j++) {</span>
|
|
1156
|
+
<span class="cstat-no" title="statement not covered" > o[j] = parseFloat(x[j]);</span>
|
|
1157
|
+
}
|
|
1158
|
+
<span class="cstat-no" title="statement not covered" > return o;</span>
|
|
1159
|
+
}
|
|
1160
|
+
// get the content of a text node, if any
|
|
1161
|
+
function <span class="fstat-no" title="function not covered" >nodeVal(</span>x) {
|
|
1162
|
+
<span class="cstat-no" title="statement not covered" > if (x) {</span>
|
|
1163
|
+
<span class="cstat-no" title="statement not covered" > norm(x);</span>
|
|
1164
|
+
}
|
|
1165
|
+
<span class="cstat-no" title="statement not covered" > return (x && x.textContent) || "";</span>
|
|
1166
|
+
}
|
|
1167
|
+
// get the contents of multiple text nodes, if present
|
|
1168
|
+
function <span class="fstat-no" title="function not covered" >getMulti(</span>x, ys) {
|
|
1169
|
+
var o = <span class="cstat-no" title="statement not covered" >{},</span>
|
|
1170
|
+
n,
|
|
1171
|
+
k;
|
|
1172
|
+
<span class="cstat-no" title="statement not covered" > for (k = 0; k < ys.length; k++) {</span>
|
|
1173
|
+
<span class="cstat-no" title="statement not covered" > n = get1(x, ys[k]);</span>
|
|
1174
|
+
<span class="cstat-no" title="statement not covered" > if (n) <span class="cstat-no" title="statement not covered" >o[ys[k]] = nodeVal(n);</span></span>
|
|
1175
|
+
}
|
|
1176
|
+
<span class="cstat-no" title="statement not covered" > return o;</span>
|
|
1177
|
+
}
|
|
1178
|
+
// add properties of Y to X, overwriting if present in both
|
|
1179
|
+
function <span class="fstat-no" title="function not covered" >extend(</span>x, y) {
|
|
1180
|
+
<span class="cstat-no" title="statement not covered" > for (var k in y) <span class="cstat-no" title="statement not covered" >x[k] = y[k];</span></span>
|
|
1181
|
+
}
|
|
1182
|
+
// get one coordinate from a coordinate array, if any
|
|
1183
|
+
function <span class="fstat-no" title="function not covered" >coord1(</span>v) {
|
|
1184
|
+
<span class="cstat-no" title="statement not covered" > return numarray(v.replace(removeSpace, "").split(","));</span>
|
|
1185
|
+
}
|
|
1186
|
+
// get all coordinates from a coordinate array as [[],[]]
|
|
1187
|
+
function <span class="fstat-no" title="function not covered" >coord(</span>v) {
|
|
1188
|
+
var coords = <span class="cstat-no" title="statement not covered" >v.replace(trimSpace, "").split(splitSpace),</span>
|
|
1189
|
+
o = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
1190
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0;</span> i < coords.length; i++) {</span>
|
|
1191
|
+
<span class="cstat-no" title="statement not covered" > o.push(coord1(coords[i]));</span>
|
|
1192
|
+
}
|
|
1193
|
+
<span class="cstat-no" title="statement not covered" > return o;</span>
|
|
1194
|
+
}
|
|
1195
|
+
function <span class="fstat-no" title="function not covered" >coordPair(</span>x) {
|
|
1196
|
+
var ll = <span class="cstat-no" title="statement not covered" >[attrf(x, "lon"), attrf(x, "lat")],</span>
|
|
1197
|
+
ele = <span class="cstat-no" title="statement not covered" >get1(x, "ele"),</span>
|
|
1198
|
+
// handle namespaced attribute in browser
|
|
1199
|
+
heartRate = <span class="cstat-no" title="statement not covered" >get1(x, "gpxtpx:hr") || get1(x, "hr"),</span>
|
|
1200
|
+
time = <span class="cstat-no" title="statement not covered" >get1(x, "time"),</span>
|
|
1201
|
+
e;
|
|
1202
|
+
<span class="cstat-no" title="statement not covered" > if (ele) {</span>
|
|
1203
|
+
<span class="cstat-no" title="statement not covered" > e = parseFloat(nodeVal(ele));</span>
|
|
1204
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(e)) {</span>
|
|
1205
|
+
<span class="cstat-no" title="statement not covered" > ll.push(e);</span>
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1209
|
+
coordinates: ll,
|
|
1210
|
+
time: time ? nodeVal(time) : null,
|
|
1211
|
+
heartRate: heartRate ? parseFloat(nodeVal(heartRate)) : null,
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
1214
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1215
|
+
// create a new feature collection parent object
|
|
1216
|
+
function <span class="fstat-no" title="function not covered" >fc(</span>) {
|
|
1217
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1218
|
+
type: "FeatureCollection",
|
|
1219
|
+
features: [],
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
1222
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1231
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1232
|
-
|
|
1233
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1242
|
-
|
|
1223
|
+
var serializer;
|
|
1224
|
+
if (typeof XMLSerializer !== "undefined") {
|
|
1225
|
+
/* istanbul ignore next */
|
|
1226
|
+
serializer = new XMLSerializer();
|
|
1227
|
+
} else <span class="missing-if-branch" title="else path not taken" >E</span>{
|
|
1228
|
+
var isNodeEnv = <span class="cstat-no" title="statement not covered" >typeof process === "object" && !process.browser;</span>
|
|
1229
|
+
var isTitaniumEnv = <span class="cstat-no" title="statement not covered" >typeof Titanium === "object";</span>
|
|
1230
|
+
<span class="cstat-no" title="statement not covered" > if (typeof exports === "object" && (isNodeEnv || isTitaniumEnv)) {</span>
|
|
1231
|
+
<span class="cstat-no" title="statement not covered" > serializer = new (require("xmldom").XMLSerializer)();</span>
|
|
1232
|
+
} else {
|
|
1233
|
+
<span class="cstat-no" title="statement not covered" > throw new Error("Unable to initialize serializer");</span>
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function <span class="fstat-no" title="function not covered" >xml2str(</span>str) {
|
|
1237
|
+
// IE9 will create a new XMLSerializer but it'll crash immediately.
|
|
1238
|
+
// This line is ignored because we don't run coverage tests in IE9
|
|
1239
|
+
/* istanbul ignore next */
|
|
1240
|
+
if (str.xml !== undefined) return str.xml;
|
|
1241
|
+
<span class="cstat-no" title="statement not covered" > return serializer.serializeToString(str);</span>
|
|
1242
|
+
}
|
|
1243
1243
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1244
|
+
var t = {
|
|
1245
|
+
kml: <span class="fstat-no" title="function not covered" >fu</span>nction (doc) {
|
|
1246
|
+
var gj = <span class="cstat-no" title="statement not covered" >fc(),</span>
|
|
1247
|
+
// styleindex keeps track of hashed styles in order to match features
|
|
1248
|
+
styleIndex = <span class="cstat-no" title="statement not covered" >{},</span>
|
|
1249
|
+
styleByHash = <span class="cstat-no" title="statement not covered" >{},</span>
|
|
1250
|
+
// stylemapindex keeps track of style maps to expose in properties
|
|
1251
|
+
styleMapIndex = <span class="cstat-no" title="statement not covered" >{},</span>
|
|
1252
|
+
// atomic geospatial types supported by KML - MultiGeometry is
|
|
1253
|
+
// handled separately
|
|
1254
|
+
geotypes = <span class="cstat-no" title="statement not covered" >["Polygon", "LineString", "Point", "Track", "gx:Track"],</span>
|
|
1255
|
+
// all root placemarks in the file
|
|
1256
|
+
placemarks = <span class="cstat-no" title="statement not covered" >get(doc, "Placemark"),</span>
|
|
1257
|
+
styles = <span class="cstat-no" title="statement not covered" >get(doc, "Style"),</span>
|
|
1258
|
+
styleMaps = <span class="cstat-no" title="statement not covered" >get(doc, "StyleMap");</span>
|
|
1259
1259
|
|
|
1260
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1261
|
-
|
|
1262
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1263
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1264
|
-
|
|
1265
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1266
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1270
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1271
|
-
|
|
1272
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1273
|
-
|
|
1274
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1275
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1280
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1281
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1282
|
-
|
|
1283
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1284
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1285
|
-
|
|
1286
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1287
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1288
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1289
|
-
|
|
1290
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1300
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1301
|
-
|
|
1302
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1303
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1317
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1318
|
-
|
|
1319
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1320
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1321
|
-
|
|
1322
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1323
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1324
|
-
|
|
1325
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1326
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1327
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1328
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1329
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1330
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1331
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1344
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1345
|
-
|
|
1346
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1260
|
+
<span class="cstat-no" title="statement not covered" > for (var k = <span class="cstat-no" title="statement not covered" >0;</span> k < styles.length; k++) {</span>
|
|
1261
|
+
var hash = <span class="cstat-no" title="statement not covered" >okhash(xml2str(styles[k])).toString(16);</span>
|
|
1262
|
+
<span class="cstat-no" title="statement not covered" > styleIndex["#" + attr(styles[k], "id")] = hash;</span>
|
|
1263
|
+
<span class="cstat-no" title="statement not covered" > styleByHash[hash] = styles[k];</span>
|
|
1264
|
+
}
|
|
1265
|
+
<span class="cstat-no" title="statement not covered" > for (var l = <span class="cstat-no" title="statement not covered" >0;</span> l < styleMaps.length; l++) {</span>
|
|
1266
|
+
<span class="cstat-no" title="statement not covered" > styleIndex["#" + attr(styleMaps[l], "id")] = okhash(xml2str(styleMaps[l])).toString(16);</span>
|
|
1267
|
+
var pairs = <span class="cstat-no" title="statement not covered" >get(styleMaps[l], "Pair");</span>
|
|
1268
|
+
var pairsMap = <span class="cstat-no" title="statement not covered" >{};</span>
|
|
1269
|
+
<span class="cstat-no" title="statement not covered" > for (var m = <span class="cstat-no" title="statement not covered" >0;</span> m < pairs.length; m++) {</span>
|
|
1270
|
+
<span class="cstat-no" title="statement not covered" > pairsMap[nodeVal(get1(pairs[m], "key"))] = nodeVal(get1(pairs[m], "styleUrl"));</span>
|
|
1271
|
+
}
|
|
1272
|
+
<span class="cstat-no" title="statement not covered" > styleMapIndex["#" + attr(styleMaps[l], "id")] = pairsMap;</span>
|
|
1273
|
+
}
|
|
1274
|
+
<span class="cstat-no" title="statement not covered" > for (var j = <span class="cstat-no" title="statement not covered" >0;</span> j < placemarks.length; j++) {</span>
|
|
1275
|
+
<span class="cstat-no" title="statement not covered" > gj.features = gj.features.concat(getPlacemark(placemarks[j]));</span>
|
|
1276
|
+
}
|
|
1277
|
+
function <span class="fstat-no" title="function not covered" >kmlColor(</span>v) {
|
|
1278
|
+
var color, opacity;
|
|
1279
|
+
<span class="cstat-no" title="statement not covered" > v = v || "";</span>
|
|
1280
|
+
<span class="cstat-no" title="statement not covered" > if (v.substr(0, 1) === "#") {</span>
|
|
1281
|
+
<span class="cstat-no" title="statement not covered" > v = v.substr(1);</span>
|
|
1282
|
+
}
|
|
1283
|
+
<span class="cstat-no" title="statement not covered" > if (v.length === 6 || v.length === 3) {</span>
|
|
1284
|
+
<span class="cstat-no" title="statement not covered" > color = v;</span>
|
|
1285
|
+
}
|
|
1286
|
+
<span class="cstat-no" title="statement not covered" > if (v.length === 8) {</span>
|
|
1287
|
+
<span class="cstat-no" title="statement not covered" > opacity = parseInt(v.substr(0, 2), 16) / 255;</span>
|
|
1288
|
+
<span class="cstat-no" title="statement not covered" > color = "#" + v.substr(6, 2) + v.substr(4, 2) + v.substr(2, 2);</span>
|
|
1289
|
+
}
|
|
1290
|
+
<span class="cstat-no" title="statement not covered" > return [color, isNaN(opacity) ? undefined : opacity];</span>
|
|
1291
|
+
}
|
|
1292
|
+
function <span class="fstat-no" title="function not covered" >gxCoord(</span>v) {
|
|
1293
|
+
<span class="cstat-no" title="statement not covered" > return numarray(v.split(" "));</span>
|
|
1294
|
+
}
|
|
1295
|
+
function <span class="fstat-no" title="function not covered" >gxCoords(</span>root) {
|
|
1296
|
+
var elems = <span class="cstat-no" title="statement not covered" >get(root, "coord", "gx"),</span>
|
|
1297
|
+
coords = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1298
|
+
times = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
1299
|
+
<span class="cstat-no" title="statement not covered" > if (elems.length === 0) <span class="cstat-no" title="statement not covered" >elems = get(root, "gx:coord");</span></span>
|
|
1300
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0;</span> i < elems.length; i++) <span class="cstat-no" title="statement not covered" >coords.push(gxCoord(nodeVal(elems[i])));</span></span>
|
|
1301
|
+
var timeElems = <span class="cstat-no" title="statement not covered" >get(root, "when");</span>
|
|
1302
|
+
<span class="cstat-no" title="statement not covered" > for (var j = <span class="cstat-no" title="statement not covered" >0;</span> j < timeElems.length; j++) <span class="cstat-no" title="statement not covered" >times.push(nodeVal(timeElems[j]));</span></span>
|
|
1303
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1304
|
+
coords: coords,
|
|
1305
|
+
times: times,
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
function <span class="fstat-no" title="function not covered" >getGeometry(</span>root) {
|
|
1309
|
+
var geomNode,
|
|
1310
|
+
geomNodes,
|
|
1311
|
+
i,
|
|
1312
|
+
j,
|
|
1313
|
+
k,
|
|
1314
|
+
geoms = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1315
|
+
coordTimes = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
1316
|
+
<span class="cstat-no" title="statement not covered" > if (get1(root, "MultiGeometry")) {</span>
|
|
1317
|
+
<span class="cstat-no" title="statement not covered" > return getGeometry(get1(root, "MultiGeometry"));</span>
|
|
1318
|
+
}
|
|
1319
|
+
<span class="cstat-no" title="statement not covered" > if (get1(root, "MultiTrack")) {</span>
|
|
1320
|
+
<span class="cstat-no" title="statement not covered" > return getGeometry(get1(root, "MultiTrack"));</span>
|
|
1321
|
+
}
|
|
1322
|
+
<span class="cstat-no" title="statement not covered" > if (get1(root, "gx:MultiTrack")) {</span>
|
|
1323
|
+
<span class="cstat-no" title="statement not covered" > return getGeometry(get1(root, "gx:MultiTrack"));</span>
|
|
1324
|
+
}
|
|
1325
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < geotypes.length; i++) {</span>
|
|
1326
|
+
<span class="cstat-no" title="statement not covered" > geomNodes = get(root, geotypes[i]);</span>
|
|
1327
|
+
<span class="cstat-no" title="statement not covered" > if (geomNodes) {</span>
|
|
1328
|
+
<span class="cstat-no" title="statement not covered" > for (j = 0; j < geomNodes.length; j++) {</span>
|
|
1329
|
+
<span class="cstat-no" title="statement not covered" > geomNode = geomNodes[j];</span>
|
|
1330
|
+
<span class="cstat-no" title="statement not covered" > if (geotypes[i] === "Point") {</span>
|
|
1331
|
+
<span class="cstat-no" title="statement not covered" > geoms.push({</span>
|
|
1332
|
+
type: "Point",
|
|
1333
|
+
coordinates: coord1(nodeVal(get1(geomNode, "coordinates"))),
|
|
1334
|
+
});
|
|
1335
|
+
} else <span class="cstat-no" title="statement not covered" >if (geotypes[i] === "LineString") {</span>
|
|
1336
|
+
<span class="cstat-no" title="statement not covered" > geoms.push({</span>
|
|
1337
|
+
type: "LineString",
|
|
1338
|
+
coordinates: coord(nodeVal(get1(geomNode, "coordinates"))),
|
|
1339
|
+
});
|
|
1340
|
+
} else <span class="cstat-no" title="statement not covered" >if (geotypes[i] === "Polygon") {</span>
|
|
1341
|
+
var rings = <span class="cstat-no" title="statement not covered" >get(geomNode, "LinearRing"),</span>
|
|
1342
|
+
coords = <span class="cstat-no" title="statement not covered" >[];</span>
|
|
1343
|
+
<span class="cstat-no" title="statement not covered" > for (k = 0; k < rings.length; k++) {</span>
|
|
1344
|
+
<span class="cstat-no" title="statement not covered" > coords.push(coord(nodeVal(get1(rings[k], "coordinates"))));</span>
|
|
1345
|
+
}
|
|
1346
|
+
<span class="cstat-no" title="statement not covered" > geoms.push({</span>
|
|
1347
|
+
type: "Polygon",
|
|
1348
|
+
coordinates: coords,
|
|
1349
|
+
});
|
|
1350
|
+
} else <span class="cstat-no" title="statement not covered" >if (geotypes[i] === "Track" || geotypes[i] === "gx:Track") {</span>
|
|
1351
|
+
var track = <span class="cstat-no" title="statement not covered" >gxCoords(geomNode);</span>
|
|
1352
|
+
<span class="cstat-no" title="statement not covered" > geoms.push({</span>
|
|
1353
|
+
type: "LineString",
|
|
1354
|
+
coordinates: track.coords,
|
|
1355
|
+
});
|
|
1356
|
+
<span class="cstat-no" title="statement not covered" > if (track.times.length) <span class="cstat-no" title="statement not covered" >coordTimes.push(track.times);</span></span>
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1362
|
+
geoms: geoms,
|
|
1363
|
+
coordTimes: coordTimes,
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
function <span class="fstat-no" title="function not covered" >getPlacemark(</span>root) {
|
|
1367
|
+
var geomsAndTimes = <span class="cstat-no" title="statement not covered" >getGeometry(root),</span>
|
|
1368
|
+
i,
|
|
1369
|
+
properties = <span class="cstat-no" title="statement not covered" >{},</span>
|
|
1370
|
+
name = <span class="cstat-no" title="statement not covered" >nodeVal(get1(root, "name")),</span>
|
|
1371
|
+
address = <span class="cstat-no" title="statement not covered" >nodeVal(get1(root, "address")),</span>
|
|
1372
|
+
styleUrl = <span class="cstat-no" title="statement not covered" >nodeVal(get1(root, "styleUrl")),</span>
|
|
1373
|
+
description = <span class="cstat-no" title="statement not covered" >nodeVal(get1(root, "description")),</span>
|
|
1374
|
+
timeSpan = <span class="cstat-no" title="statement not covered" >get1(root, "TimeSpan"),</span>
|
|
1375
|
+
timeStamp = <span class="cstat-no" title="statement not covered" >get1(root, "TimeStamp"),</span>
|
|
1376
|
+
extendedData = <span class="cstat-no" title="statement not covered" >get1(root, "ExtendedData"),</span>
|
|
1377
|
+
lineStyle = <span class="cstat-no" title="statement not covered" >get1(root, "LineStyle"),</span>
|
|
1378
|
+
polyStyle = <span class="cstat-no" title="statement not covered" >get1(root, "PolyStyle"),</span>
|
|
1379
|
+
visibility = <span class="cstat-no" title="statement not covered" >get1(root, "visibility");</span>
|
|
1380
1380
|
|
|
1381
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1382
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1383
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1384
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1385
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1386
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1387
|
-
|
|
1381
|
+
<span class="cstat-no" title="statement not covered" > if (!geomsAndTimes.geoms.length) <span class="cstat-no" title="statement not covered" >return [];</span></span>
|
|
1382
|
+
<span class="cstat-no" title="statement not covered" > if (name) <span class="cstat-no" title="statement not covered" >properties.name = name;</span></span>
|
|
1383
|
+
<span class="cstat-no" title="statement not covered" > if (address) <span class="cstat-no" title="statement not covered" >properties.address = address;</span></span>
|
|
1384
|
+
<span class="cstat-no" title="statement not covered" > if (styleUrl) {</span>
|
|
1385
|
+
<span class="cstat-no" title="statement not covered" > if (styleUrl[0] !== "#") {</span>
|
|
1386
|
+
<span class="cstat-no" title="statement not covered" > styleUrl = "#" + styleUrl;</span>
|
|
1387
|
+
}
|
|
1388
1388
|
|
|
1389
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1390
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1391
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1392
|
-
|
|
1393
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1394
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1395
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1400
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1401
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1402
|
-
|
|
1403
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1404
|
-
|
|
1405
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1406
|
-
|
|
1407
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1413
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1417
|
-
|
|
1418
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1419
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1420
|
-
|
|
1421
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1427
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1428
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1429
|
-
|
|
1430
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1437
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1438
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1439
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1440
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1441
|
-
|
|
1442
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1443
|
-
|
|
1444
|
-
|
|
1389
|
+
<span class="cstat-no" title="statement not covered" > properties.styleUrl = styleUrl;</span>
|
|
1390
|
+
<span class="cstat-no" title="statement not covered" > if (styleIndex[styleUrl]) {</span>
|
|
1391
|
+
<span class="cstat-no" title="statement not covered" > properties.styleHash = styleIndex[styleUrl];</span>
|
|
1392
|
+
}
|
|
1393
|
+
<span class="cstat-no" title="statement not covered" > if (styleMapIndex[styleUrl]) {</span>
|
|
1394
|
+
<span class="cstat-no" title="statement not covered" > properties.styleMapHash = styleMapIndex[styleUrl];</span>
|
|
1395
|
+
<span class="cstat-no" title="statement not covered" > properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal];</span>
|
|
1396
|
+
}
|
|
1397
|
+
// Try to populate the lineStyle or polyStyle since we got the style hash
|
|
1398
|
+
var style = <span class="cstat-no" title="statement not covered" >styleByHash[properties.styleHash];</span>
|
|
1399
|
+
<span class="cstat-no" title="statement not covered" > if (style) {</span>
|
|
1400
|
+
<span class="cstat-no" title="statement not covered" > if (!lineStyle) <span class="cstat-no" title="statement not covered" >lineStyle = get1(style, "LineStyle");</span></span>
|
|
1401
|
+
<span class="cstat-no" title="statement not covered" > if (!polyStyle) <span class="cstat-no" title="statement not covered" >polyStyle = get1(style, "PolyStyle");</span></span>
|
|
1402
|
+
var iconStyle = <span class="cstat-no" title="statement not covered" >get1(style, "IconStyle");</span>
|
|
1403
|
+
<span class="cstat-no" title="statement not covered" > if (iconStyle) {</span>
|
|
1404
|
+
var icon = <span class="cstat-no" title="statement not covered" >get1(iconStyle, "Icon");</span>
|
|
1405
|
+
<span class="cstat-no" title="statement not covered" > if (icon) {</span>
|
|
1406
|
+
var href = <span class="cstat-no" title="statement not covered" >nodeVal(get1(icon, "href"));</span>
|
|
1407
|
+
<span class="cstat-no" title="statement not covered" > if (href) <span class="cstat-no" title="statement not covered" >properties.icon = href;</span></span>
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
<span class="cstat-no" title="statement not covered" > if (description) <span class="cstat-no" title="statement not covered" >properties.description = description;</span></span>
|
|
1413
|
+
<span class="cstat-no" title="statement not covered" > if (timeSpan) {</span>
|
|
1414
|
+
var begin = <span class="cstat-no" title="statement not covered" >nodeVal(get1(timeSpan, "begin"));</span>
|
|
1415
|
+
var end = <span class="cstat-no" title="statement not covered" >nodeVal(get1(timeSpan, "end"));</span>
|
|
1416
|
+
<span class="cstat-no" title="statement not covered" > properties.timespan = { begin: begin, end: end };</span>
|
|
1417
|
+
}
|
|
1418
|
+
<span class="cstat-no" title="statement not covered" > if (timeStamp) {</span>
|
|
1419
|
+
<span class="cstat-no" title="statement not covered" > properties.timestamp = nodeVal(get1(timeStamp, "when"));</span>
|
|
1420
|
+
}
|
|
1421
|
+
<span class="cstat-no" title="statement not covered" > if (lineStyle) {</span>
|
|
1422
|
+
var linestyles = <span class="cstat-no" title="statement not covered" >kmlColor(nodeVal(get1(lineStyle, "color"))),</span>
|
|
1423
|
+
color = <span class="cstat-no" title="statement not covered" >linestyles[0],</span>
|
|
1424
|
+
opacity = <span class="cstat-no" title="statement not covered" >linestyles[1],</span>
|
|
1425
|
+
width = <span class="cstat-no" title="statement not covered" >parseFloat(nodeVal(get1(lineStyle, "width")));</span>
|
|
1426
|
+
<span class="cstat-no" title="statement not covered" > if (color) <span class="cstat-no" title="statement not covered" >properties.stroke = color;</span></span>
|
|
1427
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(opacity)) <span class="cstat-no" title="statement not covered" >properties["stroke-opacity"] = opacity;</span></span>
|
|
1428
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(width)) <span class="cstat-no" title="statement not covered" >properties["stroke-width"] = width;</span></span>
|
|
1429
|
+
}
|
|
1430
|
+
<span class="cstat-no" title="statement not covered" > if (polyStyle) {</span>
|
|
1431
|
+
var polystyles = <span class="cstat-no" title="statement not covered" >kmlColor(nodeVal(get1(polyStyle, "color"))),</span>
|
|
1432
|
+
pcolor = <span class="cstat-no" title="statement not covered" >polystyles[0],</span>
|
|
1433
|
+
popacity = <span class="cstat-no" title="statement not covered" >polystyles[1],</span>
|
|
1434
|
+
fill = <span class="cstat-no" title="statement not covered" >nodeVal(get1(polyStyle, "fill")),</span>
|
|
1435
|
+
outline = <span class="cstat-no" title="statement not covered" >nodeVal(get1(polyStyle, "outline"));</span>
|
|
1436
|
+
<span class="cstat-no" title="statement not covered" > if (pcolor) <span class="cstat-no" title="statement not covered" >properties.fill = pcolor;</span></span>
|
|
1437
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(popacity)) <span class="cstat-no" title="statement not covered" >properties["fill-opacity"] = popacity;</span></span>
|
|
1438
|
+
<span class="cstat-no" title="statement not covered" > if (fill) <span class="cstat-no" title="statement not covered" >properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;</span></span>
|
|
1439
|
+
<span class="cstat-no" title="statement not covered" > if (outline)</span>
|
|
1440
|
+
<span class="cstat-no" title="statement not covered" > properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;</span>
|
|
1441
|
+
}
|
|
1442
|
+
<span class="cstat-no" title="statement not covered" > if (extendedData) {</span>
|
|
1443
|
+
var datas = <span class="cstat-no" title="statement not covered" >get(extendedData, "Data"),</span>
|
|
1444
|
+
simpleDatas = <span class="cstat-no" title="statement not covered" >get(extendedData, "SimpleData");</span>
|
|
1445
1445
|
|
|
1446
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1447
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1448
|
-
|
|
1449
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1450
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1454
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1455
|
-
|
|
1456
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1457
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1474
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1475
|
-
|
|
1476
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1487
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1488
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1489
|
-
|
|
1490
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1491
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1492
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1493
|
-
|
|
1494
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1495
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1499
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1500
|
-
|
|
1501
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1510
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1511
|
-
|
|
1512
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1513
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1514
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1515
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1516
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1532
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1533
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1534
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1535
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1536
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1537
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1538
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1539
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1543
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1544
|
-
|
|
1545
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1551
|
-
|
|
1552
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1553
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1554
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1555
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1556
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1568
|
-
|
|
1569
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1583
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1595
|
-
|
|
1596
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1601
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1602
|
-
|
|
1603
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1612
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1613
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1614
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1615
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1616
|
-
|
|
1617
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1618
|
-
|
|
1619
|
-
<span class="cstat-no" title="statement not covered" >
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1446
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < datas.length; i++) {</span>
|
|
1447
|
+
<span class="cstat-no" title="statement not covered" > properties[datas[i].getAttribute("name")] = nodeVal(get1(datas[i], "value"));</span>
|
|
1448
|
+
}
|
|
1449
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < simpleDatas.length; i++) {</span>
|
|
1450
|
+
<span class="cstat-no" title="statement not covered" > properties[simpleDatas[i].getAttribute("name")] = nodeVal(simpleDatas[i]);</span>
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
<span class="cstat-no" title="statement not covered" > if (visibility) {</span>
|
|
1454
|
+
<span class="cstat-no" title="statement not covered" > properties.visibility = nodeVal(visibility);</span>
|
|
1455
|
+
}
|
|
1456
|
+
<span class="cstat-no" title="statement not covered" > if (geomsAndTimes.coordTimes.length) {</span>
|
|
1457
|
+
<span class="cstat-no" title="statement not covered" > properties.coordTimes =</span>
|
|
1458
|
+
geomsAndTimes.coordTimes.length === 1
|
|
1459
|
+
? geomsAndTimes.coordTimes[0]
|
|
1460
|
+
: geomsAndTimes.coordTimes;
|
|
1461
|
+
}
|
|
1462
|
+
var feature = <span class="cstat-no" title="statement not covered" >{</span>
|
|
1463
|
+
type: "Feature",
|
|
1464
|
+
geometry:
|
|
1465
|
+
geomsAndTimes.geoms.length === 1
|
|
1466
|
+
? geomsAndTimes.geoms[0]
|
|
1467
|
+
: {
|
|
1468
|
+
type: "GeometryCollection",
|
|
1469
|
+
geometries: geomsAndTimes.geoms,
|
|
1470
|
+
},
|
|
1471
|
+
properties: properties,
|
|
1472
|
+
};
|
|
1473
|
+
<span class="cstat-no" title="statement not covered" > if (attr(root, "id")) <span class="cstat-no" title="statement not covered" >feature.id = attr(root, "id");</span></span>
|
|
1474
|
+
<span class="cstat-no" title="statement not covered" > return [feature];</span>
|
|
1475
|
+
}
|
|
1476
|
+
<span class="cstat-no" title="statement not covered" > return gj;</span>
|
|
1477
|
+
},
|
|
1478
|
+
gpx: <span class="fstat-no" title="function not covered" >fu</span>nction (doc) {
|
|
1479
|
+
var i,
|
|
1480
|
+
tracks = <span class="cstat-no" title="statement not covered" >get(doc, "trk"),</span>
|
|
1481
|
+
routes = <span class="cstat-no" title="statement not covered" >get(doc, "rte"),</span>
|
|
1482
|
+
waypoints = <span class="cstat-no" title="statement not covered" >get(doc, "wpt"),</span>
|
|
1483
|
+
// a feature collection
|
|
1484
|
+
gj = <span class="cstat-no" title="statement not covered" >fc(),</span>
|
|
1485
|
+
feature;
|
|
1486
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < tracks.length; i++) {</span>
|
|
1487
|
+
<span class="cstat-no" title="statement not covered" > feature = getTrack(tracks[i]);</span>
|
|
1488
|
+
<span class="cstat-no" title="statement not covered" > if (feature) <span class="cstat-no" title="statement not covered" >gj.features.push(feature);</span></span>
|
|
1489
|
+
}
|
|
1490
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < routes.length; i++) {</span>
|
|
1491
|
+
<span class="cstat-no" title="statement not covered" > feature = getRoute(routes[i]);</span>
|
|
1492
|
+
<span class="cstat-no" title="statement not covered" > if (feature) <span class="cstat-no" title="statement not covered" >gj.features.push(feature);</span></span>
|
|
1493
|
+
}
|
|
1494
|
+
<span class="cstat-no" title="statement not covered" > for (i = 0; i < waypoints.length; i++) {</span>
|
|
1495
|
+
<span class="cstat-no" title="statement not covered" > gj.features.push(getPoint(waypoints[i]));</span>
|
|
1496
|
+
}
|
|
1497
|
+
function <span class="fstat-no" title="function not covered" >initializeArray(</span>arr, size) {
|
|
1498
|
+
<span class="cstat-no" title="statement not covered" > for (var h = <span class="cstat-no" title="statement not covered" >0;</span> h < size; h++) {</span>
|
|
1499
|
+
<span class="cstat-no" title="statement not covered" > arr.push(null);</span>
|
|
1500
|
+
}
|
|
1501
|
+
<span class="cstat-no" title="statement not covered" > return arr;</span>
|
|
1502
|
+
}
|
|
1503
|
+
function <span class="fstat-no" title="function not covered" >getPoints(</span>node, pointname) {
|
|
1504
|
+
var pts = <span class="cstat-no" title="statement not covered" >get(node, pointname),</span>
|
|
1505
|
+
line = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1506
|
+
times = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1507
|
+
heartRates = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1508
|
+
l = <span class="cstat-no" title="statement not covered" >pts.length;</span>
|
|
1509
|
+
<span class="cstat-no" title="statement not covered" > if (l < 2) <span class="cstat-no" title="statement not covered" >return {}; </span></span>// Invalid line in GeoJSON
|
|
1510
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0;</span> i < l; i++) {</span>
|
|
1511
|
+
var c = <span class="cstat-no" title="statement not covered" >coordPair(pts[i]);</span>
|
|
1512
|
+
<span class="cstat-no" title="statement not covered" > line.push(c.coordinates);</span>
|
|
1513
|
+
<span class="cstat-no" title="statement not covered" > if (c.time) <span class="cstat-no" title="statement not covered" >times.push(c.time);</span></span>
|
|
1514
|
+
<span class="cstat-no" title="statement not covered" > if (c.heartRate || heartRates.length) {</span>
|
|
1515
|
+
<span class="cstat-no" title="statement not covered" > if (!heartRates.length) <span class="cstat-no" title="statement not covered" >initializeArray(heartRates, i);</span></span>
|
|
1516
|
+
<span class="cstat-no" title="statement not covered" > heartRates.push(c.heartRate || null);</span>
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1520
|
+
line: line,
|
|
1521
|
+
times: times,
|
|
1522
|
+
heartRates: heartRates,
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
function <span class="fstat-no" title="function not covered" >getTrack(</span>node) {
|
|
1526
|
+
var segments = <span class="cstat-no" title="statement not covered" >get(node, "trkseg"),</span>
|
|
1527
|
+
track = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1528
|
+
times = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1529
|
+
heartRates = <span class="cstat-no" title="statement not covered" >[],</span>
|
|
1530
|
+
line;
|
|
1531
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0;</span> i < segments.length; i++) {</span>
|
|
1532
|
+
<span class="cstat-no" title="statement not covered" > line = getPoints(segments[i], "trkpt");</span>
|
|
1533
|
+
<span class="cstat-no" title="statement not covered" > if (line) {</span>
|
|
1534
|
+
<span class="cstat-no" title="statement not covered" > if (line.line) <span class="cstat-no" title="statement not covered" >track.push(line.line);</span></span>
|
|
1535
|
+
<span class="cstat-no" title="statement not covered" > if (line.times && line.times.length) <span class="cstat-no" title="statement not covered" >times.push(line.times);</span></span>
|
|
1536
|
+
<span class="cstat-no" title="statement not covered" > if (heartRates.length || (line.heartRates && line.heartRates.length)) {</span>
|
|
1537
|
+
<span class="cstat-no" title="statement not covered" > if (!heartRates.length) {</span>
|
|
1538
|
+
<span class="cstat-no" title="statement not covered" > for (var s = <span class="cstat-no" title="statement not covered" >0;</span> s < i; s++) {</span>
|
|
1539
|
+
<span class="cstat-no" title="statement not covered" > heartRates.push(initializeArray([], track[s].length));</span>
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
<span class="cstat-no" title="statement not covered" > if (line.heartRates && line.heartRates.length) {</span>
|
|
1543
|
+
<span class="cstat-no" title="statement not covered" > heartRates.push(line.heartRates);</span>
|
|
1544
|
+
} else {
|
|
1545
|
+
<span class="cstat-no" title="statement not covered" > heartRates.push(initializeArray([], line.line.length || 0));</span>
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
<span class="cstat-no" title="statement not covered" > if (track.length === 0) <span class="cstat-no" title="statement not covered" >return;</span></span>
|
|
1551
|
+
var properties = <span class="cstat-no" title="statement not covered" >getProperties(node);</span>
|
|
1552
|
+
<span class="cstat-no" title="statement not covered" > extend(properties, getLineStyle(get1(node, "extensions")));</span>
|
|
1553
|
+
<span class="cstat-no" title="statement not covered" > if (times.length) <span class="cstat-no" title="statement not covered" >properties.coordTimes = track.length === 1 ? times[0] : times;</span></span>
|
|
1554
|
+
<span class="cstat-no" title="statement not covered" > if (heartRates.length)</span>
|
|
1555
|
+
<span class="cstat-no" title="statement not covered" > properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;</span>
|
|
1556
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1557
|
+
type: "Feature",
|
|
1558
|
+
properties: properties,
|
|
1559
|
+
geometry: {
|
|
1560
|
+
type: track.length === 1 ? "LineString" : "MultiLineString",
|
|
1561
|
+
coordinates: track.length === 1 ? track[0] : track,
|
|
1562
|
+
},
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
function <span class="fstat-no" title="function not covered" >getRoute(</span>node) {
|
|
1566
|
+
var line = <span class="cstat-no" title="statement not covered" >getPoints(node, "rtept");</span>
|
|
1567
|
+
<span class="cstat-no" title="statement not covered" > if (!line.line) <span class="cstat-no" title="statement not covered" >return;</span></span>
|
|
1568
|
+
var prop = <span class="cstat-no" title="statement not covered" >getProperties(node);</span>
|
|
1569
|
+
<span class="cstat-no" title="statement not covered" > extend(prop, getLineStyle(get1(node, "extensions")));</span>
|
|
1570
|
+
var routeObj = <span class="cstat-no" title="statement not covered" >{</span>
|
|
1571
|
+
type: "Feature",
|
|
1572
|
+
properties: prop,
|
|
1573
|
+
geometry: {
|
|
1574
|
+
type: "LineString",
|
|
1575
|
+
coordinates: line.line,
|
|
1576
|
+
},
|
|
1577
|
+
};
|
|
1578
|
+
<span class="cstat-no" title="statement not covered" > return routeObj;</span>
|
|
1579
|
+
}
|
|
1580
|
+
function <span class="fstat-no" title="function not covered" >getPoint(</span>node) {
|
|
1581
|
+
var prop = <span class="cstat-no" title="statement not covered" >getProperties(node);</span>
|
|
1582
|
+
<span class="cstat-no" title="statement not covered" > extend(prop, getMulti(node, ["sym"]));</span>
|
|
1583
|
+
<span class="cstat-no" title="statement not covered" > return {</span>
|
|
1584
|
+
type: "Feature",
|
|
1585
|
+
properties: prop,
|
|
1586
|
+
geometry: {
|
|
1587
|
+
type: "Point",
|
|
1588
|
+
coordinates: coordPair(node).coordinates,
|
|
1589
|
+
},
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
function <span class="fstat-no" title="function not covered" >getLineStyle(</span>extensions) {
|
|
1593
|
+
var style = <span class="cstat-no" title="statement not covered" >{};</span>
|
|
1594
|
+
<span class="cstat-no" title="statement not covered" > if (extensions) {</span>
|
|
1595
|
+
var lineStyle = <span class="cstat-no" title="statement not covered" >get1(extensions, "line");</span>
|
|
1596
|
+
<span class="cstat-no" title="statement not covered" > if (lineStyle) {</span>
|
|
1597
|
+
var color = <span class="cstat-no" title="statement not covered" >nodeVal(get1(lineStyle, "color")),</span>
|
|
1598
|
+
opacity = <span class="cstat-no" title="statement not covered" >parseFloat(nodeVal(get1(lineStyle, "opacity"))),</span>
|
|
1599
|
+
width = <span class="cstat-no" title="statement not covered" >parseFloat(nodeVal(get1(lineStyle, "width")));</span>
|
|
1600
|
+
<span class="cstat-no" title="statement not covered" > if (color) <span class="cstat-no" title="statement not covered" >style.stroke = color;</span></span>
|
|
1601
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(opacity)) <span class="cstat-no" title="statement not covered" >style["stroke-opacity"] = opacity;</span></span>
|
|
1602
|
+
// GPX width is in mm, convert to px with 96 px per inch
|
|
1603
|
+
<span class="cstat-no" title="statement not covered" > if (!isNaN(width)) <span class="cstat-no" title="statement not covered" >style["stroke-width"] = (width * 96) / 25.4;</span></span>
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
<span class="cstat-no" title="statement not covered" > return style;</span>
|
|
1607
|
+
}
|
|
1608
|
+
function <span class="fstat-no" title="function not covered" >getProperties(</span>node) {
|
|
1609
|
+
var prop = <span class="cstat-no" title="statement not covered" >getMulti(node, ["name", "cmt", "desc", "type", "time", "keywords"]),</span>
|
|
1610
|
+
links = <span class="cstat-no" title="statement not covered" >get(node, "link");</span>
|
|
1611
|
+
<span class="cstat-no" title="statement not covered" > if (links.length) <span class="cstat-no" title="statement not covered" >prop.links = [];</span></span>
|
|
1612
|
+
<span class="cstat-no" title="statement not covered" > for (var i = <span class="cstat-no" title="statement not covered" >0,</span> link; i < links.length; i++) {</span>
|
|
1613
|
+
<span class="cstat-no" title="statement not covered" > link = { href: attr(links[i], "href") };</span>
|
|
1614
|
+
<span class="cstat-no" title="statement not covered" > extend(link, getMulti(links[i], ["text", "type"]));</span>
|
|
1615
|
+
<span class="cstat-no" title="statement not covered" > prop.links.push(link);</span>
|
|
1616
|
+
}
|
|
1617
|
+
<span class="cstat-no" title="statement not covered" > return prop;</span>
|
|
1618
|
+
}
|
|
1619
|
+
<span class="cstat-no" title="statement not covered" > return gj;</span>
|
|
1620
|
+
},
|
|
1621
|
+
};
|
|
1622
|
+
return t;
|
|
1623
1623
|
})();
|
|
1624
1624
|
|
|
1625
1625
|
export default toGeoJSON;
|
|
@@ -1630,7 +1630,7 @@ export default toGeoJSON;
|
|
|
1630
1630
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
1631
1631
|
Code coverage generated by
|
|
1632
1632
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
1633
|
-
at Tue
|
|
1633
|
+
at Tue Oct 04 2022 12:11:13 GMT+0000 (Coordinated Universal Time)
|
|
1634
1634
|
</div>
|
|
1635
1635
|
<script src="../../../prettify.js"></script>
|
|
1636
1636
|
<script>
|