react-spatial 1.7.2-beta.0 → 1.8.0-beta.0
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/MousePosition/MousePosition.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { createStringXY } from \"ol/coordinate\";\nimport OLMousePosition from \"ol/control/MousePosition\";\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: \"EPSG:4326\",\n value: \"EPSG:4326\",\n },\n {\n label: \"EPSG:3857\",\n value: \"EPSG:3857\",\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,UAAU,QAAQ,WAAW,mBAAmB;AAChE,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAC/B,OAAO,qBAAqB;AAE5B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,aAAa,UAAU;AAAA,IACrB,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA,MAId,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,MAMxB,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA,MAKxB,QAAQ,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA,IAI/B,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAMxB,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA,IAKxB,QAAQ,UAAU;AAAA,EACpB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOD,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,aAAa;AAAA,IACX;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,iBAAiB;AACnB;AAMA,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,CAAC,YAAY,aAAa,IAAI;AAAA,IAClC,gBACI,mBACA,YAAY,KAAK,CAAC,MAAM;AACtB,aAAO,EAAE,UAAU,gBAAgB;AAAA,IACrC,CAAC,KACD,YAAY,CAAC;AAAA,EACnB;AACA,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS;AACvC,QAAM,MAAM,OAAO;AAEnB,YAAU,MAAM;AACd,UAAM,gBAAgB,IAAI,gBAAgB;AAAA,MACxC,QAAQ,IAAI;AAAA,MACZ,
|
|
4
|
+
"sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { createStringXY } from \"ol/coordinate\";\nimport OLMousePosition from \"ol/control/MousePosition\";\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: \"EPSG:4326\",\n value: \"EPSG:4326\",\n },\n {\n label: \"EPSG:3857\",\n value: \"EPSG:3857\",\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n placeholder: \" \",\n className: \"\",\n });\n map.addControl(mousePosition);\n setControl(mousePosition);\n\n return () => {\n map.removeControl(mousePosition);\n };\n }, [map]);\n\n useEffect(() => {\n if (!projection || !control) {\n return;\n }\n control.setProjection(projection.value);\n control.setCoordinateFormat(projection.format || createStringXY(4));\n }, [projection, control]);\n\n useEffect(() => {\n if (projections) {\n const proj =\n (projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0];\n setProjection(proj);\n }\n }, [projections, projectionValue]);\n\n const onChangeCb = useCallback(\n (evt) => {\n const newProj = projections.find((opt) => {\n return evt.target.value === opt.value;\n });\n setProjection(newProj);\n onChange(evt, newProj);\n },\n [onChange, projections],\n );\n\n if (!projection || !projections || !projections.length) {\n return null;\n }\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-mouse-position\" {...other}>\n <select\n className=\"rs-select\"\n value={projection.value}\n onChange={onChangeCb}\n >\n {projections.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </select>\n <span ref={ref} className=\"rs-coordinates\" />\n </div>\n );\n}\n\nMousePosition.propTypes = propTypes;\nMousePosition.defaultProps = defaultProps;\n\nexport default React.memo(MousePosition);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,UAAU,QAAQ,WAAW,mBAAmB;AAChE,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAC/B,OAAO,qBAAqB;AAE5B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,aAAa,UAAU;AAAA,IACrB,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA,MAId,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,MAMxB,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA,MAKxB,QAAQ,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA,IAI/B,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAMxB,OAAO,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA,IAKxB,QAAQ,UAAU;AAAA,EACpB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOD,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,aAAa;AAAA,IACX;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,iBAAiB;AACnB;AAMA,SAAS,cAAc;AAAA,EAC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Ae,CAAC,YAAY,QAAQ;AACtD,WAAO;AAAA,EACT;AAEA;AAAA;AAAA,IAEE,oCAAC,SAAI,WAAU,qBAAqB,GAAG,SACrC;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,WAAW;AAAA,QAClB,UAAU;AAAA;AAAA,MAET,YAAY,IAAI,CAAC,WAAW;AAC3B,eACE,oCAAC,YAAO,KAAK,OAAO,OAAO,OAAO,OAAO,SACtC,OAAO,KACV;AAAA,MAEJ,CAAC;AAAA,IACH,GACA,oCAAC,UAAK,KAAU,WAAU,kBAAiB,CAC7C;AAAA;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-spatial",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Components to build React map apps.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.8.0-beta.0",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@geops/geops-ui": "0.1.18",
|
|
8
8
|
"@material-ui/core": "4.12.4",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@commitlint/config-conventional": "18.4.3",
|
|
29
29
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
30
30
|
"@svgr/webpack": "8.1.0",
|
|
31
|
-
"@testing-library/jest-dom": "6.1.
|
|
31
|
+
"@testing-library/jest-dom": "6.1.5",
|
|
32
32
|
"@testing-library/react": "14.1.2",
|
|
33
33
|
"@testing-library/user-event": "14.5.1",
|
|
34
34
|
"babel-jest": "29.7.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"enzyme": "3.11.0",
|
|
39
39
|
"esbuild": "^0.19.8",
|
|
40
40
|
"esbuild-loader": "^4.0.2",
|
|
41
|
-
"eslint": "8.
|
|
41
|
+
"eslint": "8.55.0",
|
|
42
42
|
"eslint-config-airbnb": "19.0.4",
|
|
43
|
-
"eslint-config-prettier": "9.
|
|
43
|
+
"eslint-config-prettier": "9.1.0",
|
|
44
44
|
"eslint-plugin-import": "2.29.0",
|
|
45
45
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
46
46
|
"eslint-plugin-prettier": "5.0.1",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"jest-transform-file": "1.1.1",
|
|
62
62
|
"jest-transformer-svg": "^2.0.1",
|
|
63
63
|
"jsts": "2.11.0",
|
|
64
|
-
"lint-staged": "15.
|
|
64
|
+
"lint-staged": "15.2.0",
|
|
65
65
|
"mapbox-gl": "1.13.1",
|
|
66
66
|
"maplibre-gl": "3.6.2",
|
|
67
|
-
"mobility-toolbox-js": "2.3.
|
|
67
|
+
"mobility-toolbox-js": "2.3.7",
|
|
68
68
|
"ol": "8.2.0",
|
|
69
|
-
"postcss": "^8.4.
|
|
69
|
+
"postcss": "^8.4.32",
|
|
70
70
|
"prettier": "3.1.0",
|
|
71
71
|
"proj4": "2.9.2",
|
|
72
72
|
"prop-types": "15.8.1",
|
package/utils/KML.js
CHANGED
|
@@ -57,7 +57,7 @@ const getLineIcon = (feature, icon, color, start = true) => {
|
|
|
57
57
|
zIndex: icon.zIndex
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
|
-
const sanitizeFeature = (feature,
|
|
60
|
+
const sanitizeFeature = (feature, doNotRevert32pxScaling = false) => {
|
|
61
61
|
const geom = feature.getGeometry();
|
|
62
62
|
let styles = feature.getStyleFunction();
|
|
63
63
|
if (feature.get("maxZoom")) {
|
|
@@ -150,7 +150,9 @@ const sanitizeFeature = (feature, fixGxwAndGxh) => {
|
|
|
150
150
|
}
|
|
151
151
|
if (image instanceof Icon) {
|
|
152
152
|
image.setRotation(parseFloat(feature.get("iconRotation")) || 0);
|
|
153
|
-
if (
|
|
153
|
+
if (feature.get("iconScale")) {
|
|
154
|
+
image.setScale(parseFloat(feature.get("iconScale")) || 0);
|
|
155
|
+
} else if (!doNotRevert32pxScaling) {
|
|
154
156
|
const resizeScale = scaleForSize(image.getSize());
|
|
155
157
|
image.setScale(image.getScaleArray()[0] / resizeScale);
|
|
156
158
|
}
|
|
@@ -221,17 +223,16 @@ const sanitizeFeature = (feature, fixGxwAndGxh) => {
|
|
|
221
223
|
}
|
|
222
224
|
feature.setStyle(styles);
|
|
223
225
|
};
|
|
224
|
-
const readFeatures = (kmlString, featureProjection,
|
|
225
|
-
const containsGxwAndGxh = /(gx:h|gx:w)/.test(kmlString);
|
|
226
|
+
const readFeatures = (kmlString, featureProjection, doNotRevert32pxScaling = false) => {
|
|
226
227
|
const features = new KML().readFeatures(kmlString, {
|
|
227
228
|
featureProjection
|
|
228
229
|
});
|
|
229
230
|
features.forEach((feature) => {
|
|
230
|
-
sanitizeFeature(feature,
|
|
231
|
+
sanitizeFeature(feature, doNotRevert32pxScaling);
|
|
231
232
|
});
|
|
232
233
|
return features;
|
|
233
234
|
};
|
|
234
|
-
const writeFeatures = (layer, featureProjection, mapResolution
|
|
235
|
+
const writeFeatures = (layer, featureProjection, mapResolution) => {
|
|
235
236
|
let featString;
|
|
236
237
|
const { olLayer } = layer;
|
|
237
238
|
const exportFeatures = [];
|
|
@@ -319,11 +320,8 @@ const writeFeatures = (layer, featureProjection, mapResolution, fixGxwAndGxh) =>
|
|
|
319
320
|
if (newStyle.image.getRotation()) {
|
|
320
321
|
clone.set("iconRotation", newStyle.image.getRotation());
|
|
321
322
|
}
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
newStyle.image.setScale(
|
|
325
|
-
newStyle.image.getScaleArray()[0] * resizeScale
|
|
326
|
-
);
|
|
323
|
+
if (newStyle.image.getScale()) {
|
|
324
|
+
clone.set("iconScale", newStyle.image.getScale());
|
|
327
325
|
}
|
|
328
326
|
if (feature.get("pictureOptions")) {
|
|
329
327
|
clone.set(
|
package/utils/KML.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/KML.js"],
|
|
4
|
-
"sourcesContent": ["import KML from \"ol/format/KML\";\nimport { Feature } from \"ol\";\nimport Point from \"ol/geom/Point\";\nimport MultiPoint from \"ol/geom/MultiPoint\";\nimport GeometryCollection from \"ol/geom/GeometryCollection\";\nimport { Style, Text, Icon, Circle, Fill, Stroke } from \"ol/style\";\nimport { asString } from \"ol/color\";\nimport { parse } from \"ol/xml\";\nimport VectorSource from \"ol/source/Vector\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport { kmlStyle } from \"./Styles\";\nimport getPolygonPattern from \"./getPolygonPattern\";\n\n// Comes from ol >= 6.7,\n// https://github.com/openlayers/openlayers/blob/main/src/ol/format/KML.js#L320\nconst scaleForSize = (size) => {\n return 32 / Math.min(size[0], size[1]);\n};\n\nconst applyTextStyleForIcon = (olIcon, olText) => {\n const size = olIcon.getSize() || [48, 48];\n const scale = olIcon.getScale() || 1;\n const anchor = olIcon.getAnchor() || [\n (size[0] * scale) / 2,\n (size[1] * scale) / 2,\n ];\n const offset = [\n scale * (size[0] - anchor[0]) + 5,\n scale * (size[1] / 2 - anchor[1]),\n ];\n olText.setOffsetX(offset[0]);\n olText.setOffsetY(offset[1]);\n olText.setTextAlign(\"left\");\n};\n\nconst getVertexCoord = (geom, start = true, index = 0) => {\n const coords = geom.getCoordinates();\n const len = coords.length - 1;\n return start ? coords[index] : coords[len - index];\n};\n\nconst getLineIcon = (feature, icon, color, start = true) => {\n const geom = feature.getGeometry();\n const coordA = getVertexCoord(geom, start, 1);\n const coordB = getVertexCoord(geom, start);\n const dx = start ? coordA[0] - coordB[0] : coordB[0] - coordA[0];\n const dy = start ? coordA[1] - coordB[1] : coordB[1] - coordA[1];\n const rotation = Math.atan2(dy, dx);\n\n return new Style({\n geometry: (feat) => {\n const ge = feat.getGeometry();\n return new Point(getVertexCoord(ge, start));\n },\n image: new Icon({\n src: icon.url,\n color,\n rotation: -rotation,\n rotateWithView: true,\n scale: icon.scale,\n size: icon.size, // ie 11\n }),\n zIndex: icon.zIndex,\n });\n};\n\n// Clean the unneeded feature's style and properties created by the KML parser.\nconst sanitizeFeature = (feature, fixGxwAndGxh) => {\n const geom = feature.getGeometry();\n let styles = feature.getStyleFunction();\n\n // Store maxZoom in properties\n if (feature.get(\"maxZoom\")) {\n feature.set(\"maxZoom\", parseFloat(feature.get(\"maxZoom\"), 10));\n }\n\n // Store minZoom in properties\n if (feature.get(\"minZoom\")) {\n feature.set(\"minZoom\", parseFloat(feature.get(\"minZoom\"), 10));\n }\n\n // The use of clone is part of the scale fix line 156\n const tmpStyles = styles(feature);\n const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();\n\n let stroke = style.getStroke();\n if (stroke && feature.get(\"lineDash\")) {\n stroke.setLineDash(\n feature\n .get(\"lineDash\")\n .split(\",\")\n .map((l) => {\n return parseInt(l, 10);\n }),\n );\n }\n\n // The canvas draws a stroke width=1 by default if width=0, so we\n // remove the stroke style in that case.\n if (stroke && stroke.getWidth() === 0) {\n stroke = undefined;\n }\n\n if (feature.get(\"zIndex\")) {\n style.setZIndex(parseInt(feature.get(\"zIndex\"), 10));\n }\n\n // if the feature is a Point and we are offline, we use default vector\n // style.\n // if the feature is a Point and has a name with a text style, we\n // create a correct text style.\n // TODO Handle GeometryCollection displaying name on the first Point\n // geometry.\n if (style && (geom instanceof Point || geom instanceof MultiPoint)) {\n let image = style.getImage();\n let text = null;\n let fill = style.getFill();\n\n // If the feature has name we display it on the map as Google does\n if (\n feature.get(\"name\") &&\n style.getText() &&\n style.getText().getScale() !== 0\n ) {\n if (image && image.getScale() === 0) {\n // transparentCircle is used to allow selection\n image = new Circle({\n radius: 1,\n fill: new Fill({ color: [0, 0, 0, 0] }),\n stroke: new Stroke({ color: [0, 0, 0, 0] }),\n });\n }\n\n // We replace empty white spaces used to keep normal spaces before and after the name.\n let name = feature.get(\"name\");\n if (/\\u200B/g.test(name)) {\n name = name.replace(/\\u200B/g, \"\");\n feature.set(\"name\", name);\n }\n\n text = new Text({\n font: feature.get(\"textFont\") || \"normal 16px Helvetica\",\n text: feature.get(\"name\"),\n fill: style.getText().getFill(),\n // rotation unsupported by KML, taken instead from custom field.\n rotation: feature.get(\"textRotation\") || 0,\n // since ol 6.3.1 : https://github.com/openlayers/openlayers/pull/10613/files#diff-1883da8b57e690db7ea0c35ce53c880aR925\n // a default textstroke is added to mimic google earth.\n // it was not the case before, the stroke was always null. So to keep\n // the same behavior we don't copy the stroke style.\n // TODO : maybe we should use this functionnality in the futur.\n // stroke: style.getText().getStroke(),\n scale: style.getText().getScale(),\n });\n\n if (feature.get(\"textStrokeColor\") && feature.get(\"textStrokeWidth\")) {\n text.setStroke(\n new Stroke({\n color: feature.get(\"textStrokeColor\"),\n width: parseFloat(feature.get(\"textStrokeWidth\")),\n }),\n );\n }\n\n if (feature.get(\"textAlign\")) {\n text.setTextAlign(feature.get(\"textAlign\"));\n }\n\n if (feature.get(\"textOffsetX\")) {\n text.setOffsetX(parseFloat(feature.get(\"textOffsetX\")));\n }\n\n if (feature.get(\"textOffsetY\")) {\n text.setOffsetY(parseFloat(feature.get(\"textOffsetY\")));\n }\n\n if (feature.get(\"textBackgroundFillColor\")) {\n text.setBackgroundFill(\n new Fill({\n color: feature.get(\"textBackgroundFillColor\"),\n }),\n );\n }\n\n if (feature.get(\"textPadding\")) {\n text.setPadding(\n feature\n .get(\"textPadding\")\n .split(\",\")\n .map((n) => {\n return parseFloat(n);\n }),\n );\n }\n if (image instanceof Icon) {\n applyTextStyleForIcon(image, text);\n }\n }\n\n if (image instanceof Icon) {\n /* Apply icon rotation if defined (by default only written as\n * <heading> tag, which is not read as rotation value by the ol KML module)\n */\n image.setRotation(parseFloat(feature.get(\"iconRotation\")) || 0);\n\n // Fix scale when gx:h and gx:w are used, this is for Mapset KMLs\n if (fixGxwAndGxh) {\n const resizeScale = scaleForSize(image.getSize());\n image.setScale(image.getScaleArray()[0] / resizeScale);\n }\n }\n\n fill = undefined;\n stroke = undefined;\n\n styles = (feat, resolution) => {\n /* Options to be used for picture scaling with map, should have at least\n * a resolution attribute (this is the map resolution at the zoom level when\n * the picture is created), can take an optional constant for further scale\n * adjustment.\n * e.g. { resolution: 0.123, defaultScale: 1 / 6 }\n */\n\n if (feat.get(\"pictureOptions\")) {\n let pictureOptions = feat.get(\"pictureOptions\");\n if (typeof pictureOptions === \"string\") {\n pictureOptions = JSON.parse(pictureOptions);\n }\n feat.set(\"pictureOptions\", pictureOptions);\n if (pictureOptions.resolution) {\n image.setScale(\n (pictureOptions.resolution / resolution) *\n pictureOptions.defaultScale || 1,\n );\n }\n }\n\n return new Style({\n fill,\n stroke,\n image,\n text,\n zIndex: style.getZIndex(),\n });\n };\n }\n\n // Remove image and text styles for polygons and lines\n if (\n !(\n geom instanceof Point ||\n geom instanceof MultiPoint ||\n geom instanceof GeometryCollection\n )\n ) {\n styles = [\n new Style({\n fill: style.getFill(),\n stroke,\n image: null,\n text: null,\n zIndex: style.getZIndex(),\n }),\n ];\n\n // Parse the fillPattern json string and store parsed object\n let fillPattern = feature.get(\"fillPattern\");\n if (fillPattern) {\n fillPattern = JSON.parse(fillPattern);\n feature.set(\"fillPattern\", fillPattern);\n\n /* We set the fill pattern for polygons */\n if (!style.getFill()) {\n styles[0].setFill(new Fill());\n }\n const patternOrColor = fillPattern.empty\n ? [0, 0, 0, 0]\n : getPolygonPattern(fillPattern.id, fillPattern.color);\n styles[0].getFill().setColor(patternOrColor);\n }\n\n // Add line's icons styles\n if (feature.get(\"lineStartIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineStartIcon\")),\n stroke.getColor(),\n ),\n );\n }\n\n if (feature.get(\"lineEndIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineEndIcon\")),\n stroke.getColor(),\n false,\n ),\n );\n }\n }\n feature.setStyle(styles);\n};\n\n/**\n * Read a KML string.\n * @param {String} kmlString A string representing a KML file.\n * @param {<ol.Projection|String>} featureProjection The projection used by the map.\n * @param {<boolean>} fixGxyAndGxh If the KML contains gx:w and gx:h, (ol >= 6.7), it will fix the bug introduced by https://github.com/openlayers/openlayers/pull/12695.\n */\nconst readFeatures = (kmlString, featureProjection, fixGxwAndGxh) => {\n // Mapset used gx:w and gx:h to specify the width height of an icon,\n // unfortunately since ol 6.7, the KML follows better the KML spec and GoogleEarth interpretation, see https://github.com/openlayers/openlayers/pull/12695.\n // and gx:w are gx:h are simply ignored.\n // So when fixGxwAndGxh is true we fix back the scale.\n // This has to be fixed in Mapset removing the use of gx:w and gx:h and adapt the scale accordingly like the formula in ol.\n const containsGxwAndGxh = /(gx:h|gx:w)/.test(kmlString);\n const features = new KML().readFeatures(kmlString, {\n featureProjection,\n });\n features.forEach((feature) => {\n sanitizeFeature(feature, containsGxwAndGxh && fixGxwAndGxh);\n });\n return features;\n};\n\n/**\n * Create a KML string.\n * @param {VectorLayer} layer A react-spatial VectorLayer.\n * @param {<ol.Projection|String>} featureProjection The current projection used by the features.\n * @param {<boolean>} fixGxyAndGxh If the KML contains gx:w and gx:h, (ol >= 6.7), it will fix the bug introduced by https://github.com/openlayers/openlayers/pull/12695.\n */\nconst writeFeatures = (\n layer,\n featureProjection,\n mapResolution,\n fixGxwAndGxh,\n) => {\n let featString;\n const { olLayer } = layer;\n const exportFeatures = [];\n\n olLayer.getSource().forEachFeature((feature) => {\n // We silently ignore Circle elements as they are\n // not supported in kml.\n if (feature.getGeometry().getType() === \"Circle\") {\n return;\n }\n\n const clone = feature.clone();\n clone.setId(feature.getId());\n clone.getGeometry().setProperties(feature.getGeometry().getProperties());\n clone.getGeometry().transform(featureProjection, \"EPSG:4326\");\n\n // We remove all ExtendedData not related to style.\n Object.keys(feature.getProperties()).forEach((key) => {\n if (!/^(geometry|name|description)$/.test(key)) {\n clone.unset(key, true);\n }\n });\n\n let styles;\n\n if (feature.getStyleFunction()) {\n styles = feature.getStyleFunction()(feature, mapResolution);\n } else if (olLayer && olLayer.getStyleFunction()) {\n styles = olLayer.getStyleFunction()(feature, mapResolution);\n }\n\n const mainStyle = styles[0] || styles;\n\n const newStyle = {\n fill: mainStyle.getFill(),\n stroke: mainStyle.getStroke(),\n text: mainStyle.getText(),\n image: mainStyle.getImage(),\n zIndex: mainStyle.getZIndex(),\n };\n\n if (newStyle.zIndex) {\n clone.set(\"zIndex\", newStyle.zIndex);\n }\n\n // If we see spaces at the beginning or at the end we add a empty\n // white space at the beginning and at the end.\n if (newStyle.text && /^\\s|\\s$/g.test(newStyle.text.getText())) {\n newStyle.text.setText(`\\u200B${newStyle.text.getText()}\\u200B`);\n }\n\n // Set custom properties to be converted in extendedData in KML.\n if (newStyle.text && newStyle.text.getRotation()) {\n clone.set(\"textRotation\", newStyle.text.getRotation());\n }\n\n if (newStyle.text && newStyle.text.getFont()) {\n clone.set(\"textFont\", newStyle.text.getFont());\n }\n\n if (newStyle.text && newStyle.text.getTextAlign()) {\n clone.set(\"textAlign\", newStyle.text.getTextAlign());\n }\n\n if (newStyle.text && newStyle.text.getOffsetX()) {\n clone.set(\"textOffsetX\", newStyle.text.getOffsetX());\n }\n\n if (newStyle.text && newStyle.text.getOffsetY()) {\n clone.set(\"textOffsetY\", newStyle.text.getOffsetY());\n }\n\n if (newStyle.text && newStyle.text.getStroke()) {\n if (newStyle.text.getStroke().getColor()) {\n clone.set(\n \"textStrokeColor\",\n asString(newStyle.text.getStroke().getColor()),\n );\n }\n\n if (newStyle.text.getStroke().getWidth()) {\n clone.set(\"textStrokeWidth\", newStyle.text.getStroke().getWidth());\n }\n }\n\n if (newStyle.text && newStyle.text.getBackgroundFill()) {\n clone.set(\n \"textBackgroundFillColor\",\n asString(newStyle.text.getBackgroundFill().getColor()),\n );\n }\n\n if (newStyle.text && newStyle.text.getPadding()) {\n clone.set(\"textPadding\", newStyle.text.getPadding().join());\n }\n\n if (newStyle.stroke && newStyle.stroke.getLineDash()) {\n clone.set(\"lineDash\", newStyle.stroke.getLineDash().join(\",\"));\n }\n\n if (newStyle.image instanceof Circle) {\n newStyle.image = null;\n }\n\n if (newStyle.image) {\n const imgSource = newStyle.image.getSrc();\n if (!/(http(s?)):\\/\\//gi.test(imgSource)) {\n // eslint-disable-next-line no-console\n console.log(\n \"Local image source not supported for KML export.\" +\n \"Should use remote web server\",\n );\n }\n\n if (newStyle.image.getRotation()) {\n // We set the icon rotation as extended data\n clone.set(\"iconRotation\", newStyle.image.getRotation());\n }\n\n // Fix scale when gx:h and gx:w are used, this is for Mapset KMLs\n if (fixGxwAndGxh) {\n const resizeScale = scaleForSize(newStyle.image.getSize());\n newStyle.image.setScale(\n newStyle.image.getScaleArray()[0] * resizeScale,\n );\n }\n\n // Set map resolution to use for icon-to-map proportional scaling\n if (feature.get(\"pictureOptions\")) {\n clone.set(\n \"pictureOptions\",\n JSON.stringify(feature.get(\"pictureOptions\")),\n );\n }\n }\n\n // In case a fill pattern should be applied (use fillPattern attribute to store pattern id, color etc)\n if (feature.get(\"fillPattern\")) {\n clone.set(\"fillPattern\", JSON.stringify(feature.get(\"fillPattern\")));\n newStyle.fill = null;\n }\n\n // maxZoom: maximum zoom level at which the feature is displayed\n if (feature.get(\"maxZoom\")) {\n clone.set(\"maxZoom\", parseFloat(feature.get(\"maxZoom\"), 10));\n }\n\n // minZoom: minimum zoom level at which the feature is displayed\n if (feature.get(\"minZoom\")) {\n clone.set(\"minZoom\", parseFloat(feature.get(\"minZoom\"), 10));\n }\n\n // If only text is displayed we must specify an\n // image style with scale=0\n if (newStyle.text && !newStyle.image) {\n newStyle.image = new Icon({\n src: \"noimage\",\n scale: 0,\n });\n }\n\n // In case we use line's icon .\n const extraLineStyles = (Array.isArray(styles) && styles.slice(1)) || [];\n extraLineStyles.forEach((extraLineStyle) => {\n if (\n extraLineStyle &&\n extraLineStyle.getImage() instanceof Icon &&\n extraLineStyle.getGeometry()\n ) {\n const coord = extraLineStyle.getGeometry()(feature).getCoordinates();\n const startCoord = feature.getGeometry().getFirstCoordinate();\n if (coord[0] === startCoord[0] && coord[1] === startCoord[1]) {\n clone.set(\n \"lineStartIcon\",\n JSON.stringify({\n url: extraLineStyle.getImage().getSrc(),\n scale: extraLineStyle.getImage().getScale(),\n size: extraLineStyle.getImage().getSize(),\n zIndex: extraLineStyle.getZIndex(),\n }),\n );\n } else {\n clone.set(\n \"lineEndIcon\",\n JSON.stringify({\n url: extraLineStyle.getImage().getSrc(),\n scale: extraLineStyle.getImage().getScale(),\n size: extraLineStyle.getImage().getSize(),\n zIndex: extraLineStyle.getZIndex(),\n }),\n );\n }\n }\n });\n\n const olStyle = new Style(newStyle);\n clone.setStyle(olStyle);\n\n if (\n !(\n clone.getGeometry() instanceof Point &&\n olStyle.getText() &&\n !olStyle.getText().getText()\n )\n ) {\n exportFeatures.push(clone);\n }\n });\n\n if (exportFeatures.length > 0) {\n if (exportFeatures.length === 1) {\n // force the add of a <Document> node\n exportFeatures.push(new Feature());\n }\n\n featString = new KML({\n extractStyles: true,\n defaultStyle: [kmlStyle],\n }).writeFeatures(exportFeatures);\n\n // Remove no image hack\n featString = featString.replace(\n /<Icon>\\s*<href>noimage<\\/href>\\s*<\\/Icon>/g,\n \"\",\n );\n\n // Remove empty placemark added to have\n // <Document> tag\n featString = featString.replace(/<Placemark\\/>/g, \"\");\n\n // Add KML document name\n if (layer.name) {\n featString = featString.replace(\n /<Document>/,\n `<Document><name>${layer.name}</name>`,\n );\n }\n }\n\n return featString;\n};\n\n/**\n * Removes the <Camera> tag from a KML string. Returns the KML string with removed <Camera> tag.\n * @param {String} kmlString A string representing a KML file.\n */\nconst removeDocumentCamera = (kmlString) => {\n const kmlDoc = parse(kmlString);\n // Remove old Camera node\n const oldCameraNode = kmlDoc.getElementsByTagName(\"Camera\")[0];\n if (oldCameraNode) {\n oldCameraNode.remove();\n }\n return new XMLSerializer().serializeToString(kmlDoc);\n};\n\n/**\n * Write the <Camera> tag into a KML string. Returns the KML string with added <Camera> tag.\n * @param {String} kmlString A string representing a KML file.\n * @param {Object} cameraAttributes Object containing the camera tags (longitude, latitude, altitude, heading, tilt, altitudeMode, roll)\n * as keys with corresponding values. See https://developers.google.com/kml/documentation/kmlreference#camera\n */\nconst writeDocumentCamera = (kmlString, cameraAttributes) => {\n const kmlDoc = parse(removeDocumentCamera(kmlString));\n\n if (cameraAttributes) {\n // Create Camera node with child attributes if the cameraAttributes object is defined\n const cameraNode = kmlDoc.createElement(\"Camera\");\n Object.keys(cameraAttributes).forEach((key) => {\n const cameraAttribute = kmlDoc.createElement(\n `${key.charAt(0).toUpperCase() + key.slice(1)}`,\n );\n cameraAttribute.innerHTML = cameraAttributes[key];\n cameraNode.appendChild(cameraAttribute);\n });\n const documentNode = kmlDoc.getElementsByTagName(\"Document\")[0];\n documentNode.appendChild(cameraNode);\n }\n\n return new XMLSerializer().serializeToString(kmlDoc);\n};\n\nwindow.VectorLayer = VectorLayer;\nwindow.VectorSource = VectorSource;\n\nwindow.writeFeatures = writeFeatures;\nwindow.readFeatures = readFeatures;\n\nexport default {\n readFeatures,\n writeFeatures,\n writeDocumentCamera,\n removeDocumentCamera,\n};\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS;AAChB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAC/B,SAAS,OAAO,MAAM,MAAM,QAAQ,MAAM,cAAc;AACxD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,OAAO,kBAAkB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,OAAO,uBAAuB;AAI9B,MAAM,eAAe,CAAC,SAAS;AAC7B,SAAO,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AACvC;AAEA,MAAM,wBAAwB,CAAC,QAAQ,WAAW;AAChD,QAAM,OAAO,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE;AACxC,QAAM,QAAQ,OAAO,SAAS,KAAK;AACnC,QAAM,SAAS,OAAO,UAAU,KAAK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,WAAW,QAAQ,kBAAkB,EAAE;AAGpD,QAAI,MAAM,MAAM;AACd,mBAAa,WAAW;AAAA,QACtB;AAAA,QACA,mBAAmB,MAAM,IAAI;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAMA,MAAM,uBAAuB,CAAC,cAAc;AAC1C,QAAM,SAAS,MAAM,SAAS;AAE9B,QAAM,gBAAgB,OAAO,qBAAqB,QAAQ,EAAE,CAAC;AAC7D,MAAI,eAAe;AACjB,kBAAc,OAAO;AAAA,EACvB;AACA,SAAO,IAAI,cAAc,EAAE,kBAAkB,MAAM;AACrD;AAQA,MAAM,sBAAsB,CAAC,WAAW,qBAAqB;AAC3D,QAAM,SAAS,MAAM,qBAAqB,SAAS,CAAC;AAEpD,MAAI,kBAAkB;AAEpB,UAAM,aAAa,OAAO,cAAc,QAAQ;AAChD,WAAO,KAAK,gBAAgB,EAAE,QAAQ,CAAC,QAAQ;AAC7C,YAAM,kBAAkB,OAAO;AAAA,QAC7B,GAAG,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,CAAC;AAAA,MAC/C;AACA,sBAAgB,YAAY,iBAAiB,GAAG;AAChD,iBAAW,YAAY,eAAe;AAAA,IACxC,CAAC;AACD,UAAM,eAAe,OAAO,qBAAqB,UAAU,EAAE,CAAC;AAC9D,iBAAa,YAAY,UAAU;AAAA,EACrC;AAEA,SAAO,IAAI,cAAc,EAAE,kBAAkB,MAAM;AACrD;AAEA,OAAO,cAAc;AACrB,OAAO,eAAe;AAEtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AAEtB,eAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
4
|
+
"sourcesContent": ["import KML from \"ol/format/KML\";\nimport { Feature } from \"ol\";\nimport Point from \"ol/geom/Point\";\nimport MultiPoint from \"ol/geom/MultiPoint\";\nimport GeometryCollection from \"ol/geom/GeometryCollection\";\nimport { Style, Text, Icon, Circle, Fill, Stroke } from \"ol/style\";\nimport { asString } from \"ol/color\";\nimport { parse } from \"ol/xml\";\nimport VectorSource from \"ol/source/Vector\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport { kmlStyle } from \"./Styles\";\nimport getPolygonPattern from \"./getPolygonPattern\";\n\n// Comes from ol >= 6.7,\n// https://github.com/openlayers/openlayers/blob/main/src/ol/format/KML.js#L320\nconst scaleForSize = (size) => {\n return 32 / Math.min(size[0], size[1]);\n};\n\nconst applyTextStyleForIcon = (olIcon, olText) => {\n const size = olIcon.getSize() || [48, 48];\n const scale = olIcon.getScale() || 1;\n const anchor = olIcon.getAnchor() || [\n (size[0] * scale) / 2,\n (size[1] * scale) / 2,\n ];\n const offset = [\n scale * (size[0] - anchor[0]) + 5,\n scale * (size[1] / 2 - anchor[1]),\n ];\n olText.setOffsetX(offset[0]);\n olText.setOffsetY(offset[1]);\n olText.setTextAlign(\"left\");\n};\n\nconst getVertexCoord = (geom, start = true, index = 0) => {\n const coords = geom.getCoordinates();\n const len = coords.length - 1;\n return start ? coords[index] : coords[len - index];\n};\n\nconst getLineIcon = (feature, icon, color, start = true) => {\n const geom = feature.getGeometry();\n const coordA = getVertexCoord(geom, start, 1);\n const coordB = getVertexCoord(geom, start);\n const dx = start ? coordA[0] - coordB[0] : coordB[0] - coordA[0];\n const dy = start ? coordA[1] - coordB[1] : coordB[1] - coordA[1];\n const rotation = Math.atan2(dy, dx);\n\n return new Style({\n geometry: (feat) => {\n const ge = feat.getGeometry();\n return new Point(getVertexCoord(ge, start));\n },\n image: new Icon({\n src: icon.url,\n color,\n rotation: -rotation,\n rotateWithView: true,\n scale: icon.scale,\n size: icon.size, // ie 11\n }),\n zIndex: icon.zIndex,\n });\n};\n\n// Clean the unneeded feature's style and properties created by the KML parser.\nconst sanitizeFeature = (feature, doNotRevert32pxScaling = false) => {\n const geom = feature.getGeometry();\n let styles = feature.getStyleFunction();\n\n // Store maxZoom in properties\n if (feature.get(\"maxZoom\")) {\n feature.set(\"maxZoom\", parseFloat(feature.get(\"maxZoom\"), 10));\n }\n\n // Store minZoom in properties\n if (feature.get(\"minZoom\")) {\n feature.set(\"minZoom\", parseFloat(feature.get(\"minZoom\"), 10));\n }\n\n // The use of clone is part of the scale fix line 156\n const tmpStyles = styles(feature);\n const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();\n\n let stroke = style.getStroke();\n if (stroke && feature.get(\"lineDash\")) {\n stroke.setLineDash(\n feature\n .get(\"lineDash\")\n .split(\",\")\n .map((l) => {\n return parseInt(l, 10);\n }),\n );\n }\n\n // The canvas draws a stroke width=1 by default if width=0, so we\n // remove the stroke style in that case.\n if (stroke && stroke.getWidth() === 0) {\n stroke = undefined;\n }\n\n if (feature.get(\"zIndex\")) {\n style.setZIndex(parseInt(feature.get(\"zIndex\"), 10));\n }\n\n // if the feature is a Point and we are offline, we use default vector\n // style.\n // if the feature is a Point and has a name with a text style, we\n // create a correct text style.\n // TODO Handle GeometryCollection displaying name on the first Point\n // geometry.\n if (style && (geom instanceof Point || geom instanceof MultiPoint)) {\n let image = style.getImage();\n let text = null;\n let fill = style.getFill();\n\n // If the feature has name we display it on the map as Google does\n if (\n feature.get(\"name\") &&\n style.getText() &&\n style.getText().getScale() !== 0\n ) {\n if (image && image.getScale() === 0) {\n // transparentCircle is used to allow selection\n image = new Circle({\n radius: 1,\n fill: new Fill({ color: [0, 0, 0, 0] }),\n stroke: new Stroke({ color: [0, 0, 0, 0] }),\n });\n }\n\n // We replace empty white spaces used to keep normal spaces before and after the name.\n let name = feature.get(\"name\");\n if (/\\u200B/g.test(name)) {\n name = name.replace(/\\u200B/g, \"\");\n feature.set(\"name\", name);\n }\n\n text = new Text({\n font: feature.get(\"textFont\") || \"normal 16px Helvetica\",\n text: feature.get(\"name\"),\n fill: style.getText().getFill(),\n // rotation unsupported by KML, taken instead from custom field.\n rotation: feature.get(\"textRotation\") || 0,\n // since ol 6.3.1 : https://github.com/openlayers/openlayers/pull/10613/files#diff-1883da8b57e690db7ea0c35ce53c880aR925\n // a default textstroke is added to mimic google earth.\n // it was not the case before, the stroke was always null. So to keep\n // the same behavior we don't copy the stroke style.\n // TODO : maybe we should use this functionnality in the futur.\n // stroke: style.getText().getStroke(),\n scale: style.getText().getScale(),\n });\n\n if (feature.get(\"textStrokeColor\") && feature.get(\"textStrokeWidth\")) {\n text.setStroke(\n new Stroke({\n color: feature.get(\"textStrokeColor\"),\n width: parseFloat(feature.get(\"textStrokeWidth\")),\n }),\n );\n }\n\n if (feature.get(\"textAlign\")) {\n text.setTextAlign(feature.get(\"textAlign\"));\n }\n\n if (feature.get(\"textOffsetX\")) {\n text.setOffsetX(parseFloat(feature.get(\"textOffsetX\")));\n }\n\n if (feature.get(\"textOffsetY\")) {\n text.setOffsetY(parseFloat(feature.get(\"textOffsetY\")));\n }\n\n if (feature.get(\"textBackgroundFillColor\")) {\n text.setBackgroundFill(\n new Fill({\n color: feature.get(\"textBackgroundFillColor\"),\n }),\n );\n }\n\n if (feature.get(\"textPadding\")) {\n text.setPadding(\n feature\n .get(\"textPadding\")\n .split(\",\")\n .map((n) => {\n return parseFloat(n);\n }),\n );\n }\n if (image instanceof Icon) {\n applyTextStyleForIcon(image, text);\n }\n }\n\n if (image instanceof Icon) {\n /* Apply icon rotation if defined (by default only written as\n * <heading> tag, which is not read as rotation value by the ol KML module)\n */\n image.setRotation(parseFloat(feature.get(\"iconRotation\")) || 0);\n\n if (feature.get(\"iconScale\")) {\n image.setScale(parseFloat(feature.get(\"iconScale\")) || 0);\n\n // We fix the 32px scaling introduced by OL 6.7\n } else if (!doNotRevert32pxScaling) {\n const resizeScale = scaleForSize(image.getSize());\n image.setScale(image.getScaleArray()[0] / resizeScale);\n }\n }\n\n fill = undefined;\n stroke = undefined;\n\n styles = (feat, resolution) => {\n /* Options to be used for picture scaling with map, should have at least\n * a resolution attribute (this is the map resolution at the zoom level when\n * the picture is created), can take an optional constant for further scale\n * adjustment.\n * e.g. { resolution: 0.123, defaultScale: 1 / 6 }\n */\n\n if (feat.get(\"pictureOptions\")) {\n let pictureOptions = feat.get(\"pictureOptions\");\n if (typeof pictureOptions === \"string\") {\n pictureOptions = JSON.parse(pictureOptions);\n }\n feat.set(\"pictureOptions\", pictureOptions);\n if (pictureOptions.resolution) {\n image.setScale(\n (pictureOptions.resolution / resolution) *\n pictureOptions.defaultScale || 1,\n );\n }\n }\n\n return new Style({\n fill,\n stroke,\n image,\n text,\n zIndex: style.getZIndex(),\n });\n };\n }\n\n // Remove image and text styles for polygons and lines\n if (\n !(\n geom instanceof Point ||\n geom instanceof MultiPoint ||\n geom instanceof GeometryCollection\n )\n ) {\n styles = [\n new Style({\n fill: style.getFill(),\n stroke,\n image: null,\n text: null,\n zIndex: style.getZIndex(),\n }),\n ];\n\n // Parse the fillPattern json string and store parsed object\n let fillPattern = feature.get(\"fillPattern\");\n if (fillPattern) {\n fillPattern = JSON.parse(fillPattern);\n feature.set(\"fillPattern\", fillPattern);\n\n /* We set the fill pattern for polygons */\n if (!style.getFill()) {\n styles[0].setFill(new Fill());\n }\n const patternOrColor = fillPattern.empty\n ? [0, 0, 0, 0]\n : getPolygonPattern(fillPattern.id, fillPattern.color);\n styles[0].getFill().setColor(patternOrColor);\n }\n\n // Add line's icons styles\n if (feature.get(\"lineStartIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineStartIcon\")),\n stroke.getColor(),\n ),\n );\n }\n\n if (feature.get(\"lineEndIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineEndIcon\")),\n stroke.getColor(),\n false,\n ),\n );\n }\n }\n feature.setStyle(styles);\n};\n\n/**\n * Read a KML string.\n * @param {String} kmlString A string representing a KML file.\n * @param {<ol.Projection|String>} featureProjection The projection used by the map.\n * @param {<boolean>} doNotRevert32pxScaling Set it to true if you use ol < 6.7 and last version of react-spatial, Fix the 32px scaling, introduced by (ol >= 6.7), see https://github.com/openlayers/openlayers/pull/12695.\n */\nconst readFeatures = (\n kmlString,\n featureProjection,\n doNotRevert32pxScaling = false,\n) => {\n // Since ol 6.7, the KML follows better the spec and GoogleEarth interpretation, see https://github.com/openlayers/openlayers/pull/12695.\n // so the <scale> value is interpreted using an image size of 32px.\n // So when revert32pxScaling is true we fix back the scale, to use only, if you use an OL < 6.7.\n // Now the writeFeatures function use the iconScale extended data to set the image's scale.\n // If the extended data is not found it will look at this boolean to define if we must revert the scale or not.\n const features = new KML().readFeatures(kmlString, {\n featureProjection,\n });\n features.forEach((feature) => {\n sanitizeFeature(feature, doNotRevert32pxScaling);\n });\n return features;\n};\n\n/**\n * Create a KML string.\n * @param {VectorLayer} layer A react-spatial VectorLayer.\n * @param {<ol.Projection|String>} featureProjection The current projection used by the features.\n * @param {<boolean>} fixGxyAndGxh If the KML contains gx:w and gx:h, (ol >= 6.7), it will fix the bug introduced by https://github.com/openlayers/openlayers/pull/12695.\n */\nconst writeFeatures = (layer, featureProjection, mapResolution) => {\n let featString;\n const { olLayer } = layer;\n const exportFeatures = [];\n\n olLayer.getSource().forEachFeature((feature) => {\n // We silently ignore Circle elements as they are\n // not supported in kml.\n if (feature.getGeometry().getType() === \"Circle\") {\n return;\n }\n\n const clone = feature.clone();\n clone.setId(feature.getId());\n clone.getGeometry().setProperties(feature.getGeometry().getProperties());\n clone.getGeometry().transform(featureProjection, \"EPSG:4326\");\n\n // We remove all ExtendedData not related to style.\n Object.keys(feature.getProperties()).forEach((key) => {\n if (!/^(geometry|name|description)$/.test(key)) {\n clone.unset(key, true);\n }\n });\n\n let styles;\n\n if (feature.getStyleFunction()) {\n styles = feature.getStyleFunction()(feature, mapResolution);\n } else if (olLayer && olLayer.getStyleFunction()) {\n styles = olLayer.getStyleFunction()(feature, mapResolution);\n }\n\n const mainStyle = styles[0] || styles;\n\n const newStyle = {\n fill: mainStyle.getFill(),\n stroke: mainStyle.getStroke(),\n text: mainStyle.getText(),\n image: mainStyle.getImage(),\n zIndex: mainStyle.getZIndex(),\n };\n\n if (newStyle.zIndex) {\n clone.set(\"zIndex\", newStyle.zIndex);\n }\n\n // If we see spaces at the beginning or at the end we add a empty\n // white space at the beginning and at the end.\n if (newStyle.text && /^\\s|\\s$/g.test(newStyle.text.getText())) {\n newStyle.text.setText(`\\u200B${newStyle.text.getText()}\\u200B`);\n }\n\n // Set custom properties to be converted in extendedData in KML.\n if (newStyle.text && newStyle.text.getRotation()) {\n clone.set(\"textRotation\", newStyle.text.getRotation());\n }\n\n if (newStyle.text && newStyle.text.getFont()) {\n clone.set(\"textFont\", newStyle.text.getFont());\n }\n\n if (newStyle.text && newStyle.text.getTextAlign()) {\n clone.set(\"textAlign\", newStyle.text.getTextAlign());\n }\n\n if (newStyle.text && newStyle.text.getOffsetX()) {\n clone.set(\"textOffsetX\", newStyle.text.getOffsetX());\n }\n\n if (newStyle.text && newStyle.text.getOffsetY()) {\n clone.set(\"textOffsetY\", newStyle.text.getOffsetY());\n }\n\n if (newStyle.text && newStyle.text.getStroke()) {\n if (newStyle.text.getStroke().getColor()) {\n clone.set(\n \"textStrokeColor\",\n asString(newStyle.text.getStroke().getColor()),\n );\n }\n\n if (newStyle.text.getStroke().getWidth()) {\n clone.set(\"textStrokeWidth\", newStyle.text.getStroke().getWidth());\n }\n }\n\n if (newStyle.text && newStyle.text.getBackgroundFill()) {\n clone.set(\n \"textBackgroundFillColor\",\n asString(newStyle.text.getBackgroundFill().getColor()),\n );\n }\n\n if (newStyle.text && newStyle.text.getPadding()) {\n clone.set(\"textPadding\", newStyle.text.getPadding().join());\n }\n\n if (newStyle.stroke && newStyle.stroke.getLineDash()) {\n clone.set(\"lineDash\", newStyle.stroke.getLineDash().join(\",\"));\n }\n\n if (newStyle.image instanceof Circle) {\n newStyle.image = null;\n }\n\n if (newStyle.image) {\n const imgSource = newStyle.image.getSrc();\n if (!/(http(s?)):\\/\\//gi.test(imgSource)) {\n // eslint-disable-next-line no-console\n console.log(\n \"Local image source not supported for KML export.\" +\n \"Should use remote web server\",\n );\n }\n\n if (newStyle.image.getRotation()) {\n // We set the icon rotation as extended data\n clone.set(\"iconRotation\", newStyle.image.getRotation());\n }\n\n if (newStyle.image.getScale()) {\n // We set the scale as extended metadata because the <scale> in the KML is related to a 32px img, since ol >= 6.10.\n clone.set(\"iconScale\", newStyle.image.getScale());\n }\n\n // Set map resolution to use for icon-to-map proportional scaling\n if (feature.get(\"pictureOptions\")) {\n clone.set(\n \"pictureOptions\",\n JSON.stringify(feature.get(\"pictureOptions\")),\n );\n }\n }\n\n // In case a fill pattern should be applied (use fillPattern attribute to store pattern id, color etc)\n if (feature.get(\"fillPattern\")) {\n clone.set(\"fillPattern\", JSON.stringify(feature.get(\"fillPattern\")));\n newStyle.fill = null;\n }\n\n // maxZoom: maximum zoom level at which the feature is displayed\n if (feature.get(\"maxZoom\")) {\n clone.set(\"maxZoom\", parseFloat(feature.get(\"maxZoom\"), 10));\n }\n\n // minZoom: minimum zoom level at which the feature is displayed\n if (feature.get(\"minZoom\")) {\n clone.set(\"minZoom\", parseFloat(feature.get(\"minZoom\"), 10));\n }\n\n // If only text is displayed we must specify an\n // image style with scale=0\n if (newStyle.text && !newStyle.image) {\n newStyle.image = new Icon({\n src: \"noimage\",\n scale: 0,\n });\n }\n\n // In case we use line's icon .\n const extraLineStyles = (Array.isArray(styles) && styles.slice(1)) || [];\n extraLineStyles.forEach((extraLineStyle) => {\n if (\n extraLineStyle &&\n extraLineStyle.getImage() instanceof Icon &&\n extraLineStyle.getGeometry()\n ) {\n const coord = extraLineStyle.getGeometry()(feature).getCoordinates();\n const startCoord = feature.getGeometry().getFirstCoordinate();\n if (coord[0] === startCoord[0] && coord[1] === startCoord[1]) {\n clone.set(\n \"lineStartIcon\",\n JSON.stringify({\n url: extraLineStyle.getImage().getSrc(),\n scale: extraLineStyle.getImage().getScale(),\n size: extraLineStyle.getImage().getSize(),\n zIndex: extraLineStyle.getZIndex(),\n }),\n );\n } else {\n clone.set(\n \"lineEndIcon\",\n JSON.stringify({\n url: extraLineStyle.getImage().getSrc(),\n scale: extraLineStyle.getImage().getScale(),\n size: extraLineStyle.getImage().getSize(),\n zIndex: extraLineStyle.getZIndex(),\n }),\n );\n }\n }\n });\n\n const olStyle = new Style(newStyle);\n clone.setStyle(olStyle);\n\n if (\n !(\n clone.getGeometry() instanceof Point &&\n olStyle.getText() &&\n !olStyle.getText().getText()\n )\n ) {\n exportFeatures.push(clone);\n }\n });\n\n if (exportFeatures.length > 0) {\n if (exportFeatures.length === 1) {\n // force the add of a <Document> node\n exportFeatures.push(new Feature());\n }\n\n featString = new KML({\n extractStyles: true,\n defaultStyle: [kmlStyle],\n }).writeFeatures(exportFeatures);\n\n // Remove no image hack\n featString = featString.replace(\n /<Icon>\\s*<href>noimage<\\/href>\\s*<\\/Icon>/g,\n \"\",\n );\n\n // Remove empty placemark added to have\n // <Document> tag\n featString = featString.replace(/<Placemark\\/>/g, \"\");\n\n // Add KML document name\n if (layer.name) {\n featString = featString.replace(\n /<Document>/,\n `<Document><name>${layer.name}</name>`,\n );\n }\n }\n\n return featString;\n};\n\n/**\n * Removes the <Camera> tag from a KML string. Returns the KML string with removed <Camera> tag.\n * @param {String} kmlString A string representing a KML file.\n */\nconst removeDocumentCamera = (kmlString) => {\n const kmlDoc = parse(kmlString);\n // Remove old Camera node\n const oldCameraNode = kmlDoc.getElementsByTagName(\"Camera\")[0];\n if (oldCameraNode) {\n oldCameraNode.remove();\n }\n return new XMLSerializer().serializeToString(kmlDoc);\n};\n\n/**\n * Write the <Camera> tag into a KML string. Returns the KML string with added <Camera> tag.\n * @param {String} kmlString A string representing a KML file.\n * @param {Object} cameraAttributes Object containing the camera tags (longitude, latitude, altitude, heading, tilt, altitudeMode, roll)\n * as keys with corresponding values. See https://developers.google.com/kml/documentation/kmlreference#camera\n */\nconst writeDocumentCamera = (kmlString, cameraAttributes) => {\n const kmlDoc = parse(removeDocumentCamera(kmlString));\n\n if (cameraAttributes) {\n // Create Camera node with child attributes if the cameraAttributes object is defined\n const cameraNode = kmlDoc.createElement(\"Camera\");\n Object.keys(cameraAttributes).forEach((key) => {\n const cameraAttribute = kmlDoc.createElement(\n `${key.charAt(0).toUpperCase() + key.slice(1)}`,\n );\n cameraAttribute.innerHTML = cameraAttributes[key];\n cameraNode.appendChild(cameraAttribute);\n });\n const documentNode = kmlDoc.getElementsByTagName(\"Document\")[0];\n documentNode.appendChild(cameraNode);\n }\n\n return new XMLSerializer().serializeToString(kmlDoc);\n};\n\nwindow.VectorLayer = VectorLayer;\nwindow.VectorSource = VectorSource;\n\nwindow.writeFeatures = writeFeatures;\nwindow.readFeatures = readFeatures;\n\nexport default {\n readFeatures,\n writeFeatures,\n writeDocumentCamera,\n removeDocumentCamera,\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS;AAChB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAC/B,SAAS,OAAO,MAAM,MAAM,QAAQ,MAAM,cAAc;AACxD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,OAAO,kBAAkB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,OAAO,uBAAuB;AAI9B,MAAM,eAAe,CAAC,SAAS;AAC7B,SAAO,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AACvC;AAEA,MAAM,wBAAwB,CAAC,QAAQ,WAAW;AAChD,QAAM,OAAO,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE;AACxC,QAAM,QAAQ,OAAO,SAAS,KAAK;AACnC,QAAM,SAAS,OAAO,UAAU,KAAK;AAAA,IAClC,KAAK,CAAC,IAAI,QAAS;AAAA,IACnB,KAAK,CAAC,IAAI,QAAS;AAAA,EACtB;AACA,QAAM,SAAS;AAAA,IACb,SAAS,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK;AAAA,IAChC,SAAS,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC;AAAA,EACjC;AACA,SAAO,WAAW,OAAO,C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