react-spatial 1.11.1 → 1.11.3
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/components/Copyright/Copyright.js +7 -2
- package/components/Copyright/Copyright.js.map +2 -2
- package/components/FitExtent/FitExtent.js +7 -5
- package/components/FitExtent/FitExtent.js.map +2 -2
- package/components/MousePosition/MousePosition.js +3 -4
- package/components/MousePosition/MousePosition.js.map +2 -2
- package/components/NorthArrow/NorthArrow.js +7 -7
- package/components/NorthArrow/NorthArrow.js.map +2 -2
- package/components/Overlay/Overlay.js +9 -20
- package/components/Overlay/Overlay.js.map +2 -2
- package/components/ResizeHandler/ResizeHandler.js +6 -3
- package/components/ResizeHandler/ResizeHandler.js.map +2 -2
- package/components/RouteSchedule/RouteSchedule.js +25 -31
- package/components/RouteSchedule/RouteSchedule.js.map +2 -2
- package/components/ScaleLine/ScaleLine.js +1 -2
- package/components/ScaleLine/ScaleLine.js.map +2 -2
- package/components/StopsFinder/StopsFinder.js +4 -15
- package/components/StopsFinder/StopsFinder.js.map +2 -2
- package/package.json +23 -22
- package/utils/KML.js +59 -13
- package/utils/KML.js.map +2 -2
|
@@ -23,7 +23,12 @@ const defaultProps = {
|
|
|
23
23
|
},
|
|
24
24
|
className: "rs-copyright"
|
|
25
25
|
};
|
|
26
|
-
function Copyright({
|
|
26
|
+
function Copyright({
|
|
27
|
+
map,
|
|
28
|
+
className = defaultProps.className,
|
|
29
|
+
format = defaultProps.format,
|
|
30
|
+
...other
|
|
31
|
+
}) {
|
|
27
32
|
const [copyrights, setCopyrights] = useState([]);
|
|
28
33
|
const control = useMemo(
|
|
29
34
|
() => {
|
|
@@ -57,6 +62,7 @@ function Copyright({ map, format, ...other }) {
|
|
|
57
62
|
return /* @__PURE__ */ React.createElement(
|
|
58
63
|
"div",
|
|
59
64
|
{
|
|
65
|
+
className,
|
|
60
66
|
...other,
|
|
61
67
|
dangerouslySetInnerHTML: {
|
|
62
68
|
__html: format(copyrights) || ""
|
|
@@ -65,5 +71,4 @@ function Copyright({ map, format, ...other }) {
|
|
|
65
71
|
);
|
|
66
72
|
}
|
|
67
73
|
Copyright.propTypes = propTypes;
|
|
68
|
-
Copyright.defaultProps = defaultProps;
|
|
69
74
|
export default React.memo(Copyright);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Copyright/Copyright.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo, useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Map } from \"ol\";\nimport { CopyrightControl } from \"mobility-toolbox-js/ol\";\n\nconst propTypes = {\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Format function. Called with an array of copyrights from visible layers\n * and returns the copyright.\n */\n format: PropTypes.func,\n\n /**\n * CSS class of th root element\n */\n className: PropTypes.string,\n};\n\nconst defaultProps = {\n format: (copyrights) => {\n return copyrights.join(\" | \");\n },\n className: \"rs-copyright\",\n};\n\n/**\n * The Copyright component uses the\n * [mobility-toolbox-js CopyrightControl](https://mobility-toolbox-js.geops.io/api/class/src/mapbox/controls/CopyrightControl%20js~CopyrightControl%20html-offset-anchor)\n * to render the layer copyrights.\n */\nfunction Copyright({
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,SAAS,WAAW,gBAAgB;AACpD,OAAO,eAAe;AACtB,SAAS,WAAW;AACpB,SAAS,wBAAwB;AAEjC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,GAAG,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA,EAKlB,WAAW,UAAU;AACvB;AAEA,MAAM,eAAe;AAAA,EACnB,QAAQ,CAAC,eAAe;AACtB,WAAO,WAAW,KAAK,KAAK;AAAA,EAC9B;AAAA,EACA,WAAW;AACb;AAOA,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import React, { useMemo, useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Map } from \"ol\";\nimport { CopyrightControl } from \"mobility-toolbox-js/ol\";\n\nconst propTypes = {\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Format function. Called with an array of copyrights from visible layers\n * and returns the copyright.\n */\n format: PropTypes.func,\n\n /**\n * CSS class of th root element\n */\n className: PropTypes.string,\n};\n\nconst defaultProps = {\n format: (copyrights) => {\n return copyrights.join(\" | \");\n },\n className: \"rs-copyright\",\n};\n\n/**\n * The Copyright component uses the\n * [mobility-toolbox-js CopyrightControl](https://mobility-toolbox-js.geops.io/api/class/src/mapbox/controls/CopyrightControl%20js~CopyrightControl%20html-offset-anchor)\n * to render the layer copyrights.\n */\nfunction Copyright({\n map,\n className = defaultProps.className,\n format = defaultProps.format,\n ...other\n}) {\n const [copyrights, setCopyrights] = useState([]);\n\n const control = useMemo(\n () => {\n return new CopyrightControl({\n target: document.createElement(\"div\"),\n element: document.createElement(\"div\"),\n render() {\n // eslint-disable-next-line react/no-this-in-sfc\n const newCopyrights = this.getCopyrights();\n if (copyrights.toString() !== newCopyrights.toString()) {\n setCopyrights(newCopyrights);\n }\n },\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n // Ensure the control is not associated to the wrong map\n useEffect(() => {\n if (!control) {\n return () => {};\n }\n\n control.map = map;\n\n return () => {\n control.map = null;\n };\n }, [map, control]);\n\n if (!control || !control.getCopyrights().length) {\n return null;\n }\n\n return (\n <div\n className={className}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{\n __html: format(copyrights) || \"\",\n }}\n />\n );\n}\n\nCopyright.propTypes = propTypes;\n\nexport default React.memo(Copyright);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,SAAS,WAAW,gBAAgB;AACpD,OAAO,eAA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,MAChC;AAAA;AAAA,EACF;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe,MAAM,KAAK,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,10 +19,13 @@ const propTypes = {
|
|
|
19
19
|
*/
|
|
20
20
|
children: PropTypes.node.isRequired
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
function FitExtent({
|
|
23
|
+
map,
|
|
24
|
+
extent,
|
|
25
|
+
className = "rs-fit-extent",
|
|
26
|
+
children,
|
|
27
|
+
...other
|
|
28
|
+
}) {
|
|
26
29
|
const fit = (evt) => {
|
|
27
30
|
if (evt.which && evt.which !== 13) {
|
|
28
31
|
return;
|
|
@@ -44,5 +47,4 @@ function FitExtent({ map, extent, className, children, ...other }) {
|
|
|
44
47
|
);
|
|
45
48
|
}
|
|
46
49
|
FitExtent.propTypes = propTypes;
|
|
47
|
-
FitExtent.defaultProps = defaultProps;
|
|
48
50
|
export default FitExtent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/FitExtent/FitExtent.js"],
|
|
4
|
-
"sourcesContent": ["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\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 * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n};\n\
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,UAAU,UAAU,KAAK;AAC3B;
|
|
4
|
+
"sourcesContent": ["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\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 * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n};\n\n/**\n * The FitExtent component creates a button that updates the current extent of\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction FitExtent({\n map,\n extent,\n className = \"rs-fit-extent\",\n children,\n ...other\n}) {\n const fit = (evt) => {\n if (evt.which && evt.which !== 13) {\n return;\n }\n map.getView().cancelAnimations();\n map.getView().fit(extent, map.getSize());\n };\n\n return (\n <div\n className={className}\n role=\"button\"\n tabIndex=\"0\"\n onClick={fit}\n onKeyPress={fit}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\n\nexport default FitExtent;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,UAAU,UAAU,KAAK;AAC3B;AAMA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,MAAM,CAAC,QAAQ;AACnB,QAAI,IAAI,SAAS,IAAI,UAAU,IAAI;AACjC;AAAA,IACF;AACA,QAAI,QAAQ,EAAE,iBAAiB;AAC/B,QAAI,QAAQ,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,UAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MAEX,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -70,9 +70,9 @@ const defaultProps = {
|
|
|
70
70
|
};
|
|
71
71
|
function MousePosition({
|
|
72
72
|
map,
|
|
73
|
-
projections,
|
|
74
|
-
projectionValue,
|
|
75
|
-
onChange,
|
|
73
|
+
projections = defaultProps.projections,
|
|
74
|
+
projectionValue = defaultProps.projectionValue,
|
|
75
|
+
onChange = defaultProps.onChange,
|
|
76
76
|
...other
|
|
77
77
|
}) {
|
|
78
78
|
const [projection, setProjection] = useState(
|
|
@@ -138,5 +138,4 @@ function MousePosition({
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
MousePosition.propTypes = propTypes;
|
|
141
|
-
MousePosition.defaultProps = defaultProps;
|
|
142
141
|
export default React.memo(MousePosition);
|
|
@@ -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 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;\
|
|
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,
|
|
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 = defaultProps.projections,\n projectionValue = defaultProps.projectionValue,\n onChange = defaultProps.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;\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;AAM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IACA,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,MAAI,CAAC,cAAc,CAAC,eAAe,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;AAE1B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,15 +23,16 @@ const propTypes = {
|
|
|
23
23
|
*/
|
|
24
24
|
children: PropTypes.node
|
|
25
25
|
};
|
|
26
|
-
const defaultProps = {
|
|
27
|
-
rotationOffset: 0,
|
|
28
|
-
circled: false,
|
|
29
|
-
children: null
|
|
30
|
-
};
|
|
31
26
|
const getRotation = (map, rotationOffset) => {
|
|
32
27
|
return toDegrees(map.getView().getRotation()) + rotationOffset;
|
|
33
28
|
};
|
|
34
|
-
function NorthArrow({
|
|
29
|
+
function NorthArrow({
|
|
30
|
+
map,
|
|
31
|
+
rotationOffset = 0,
|
|
32
|
+
circled = false,
|
|
33
|
+
children = null,
|
|
34
|
+
...other
|
|
35
|
+
}) {
|
|
35
36
|
const [rotation, setRotation] = useState(rotationOffset);
|
|
36
37
|
useEffect(() => {
|
|
37
38
|
if (!map) {
|
|
@@ -55,5 +56,4 @@ function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
|
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
NorthArrow.propTypes = propTypes;
|
|
58
|
-
NorthArrow.defaultProps = defaultProps;
|
|
59
59
|
export default React.memo(NorthArrow);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { toDegrees } from \"ol/math\";\nimport NorthArrowSimple from \"../../images/northArrow.svg\";\nimport NorthArrowCircle from \"../../images/northArrowCircle.svg\";\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 * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK1B,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { toDegrees } from \"ol/math\";\nimport NorthArrowSimple from \"../../images/northArrow.svg\";\nimport NorthArrowCircle from \"../../images/northArrowCircle.svg\";\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 * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return toDegrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({\n map,\n rotationOffset = 0,\n circled = false,\n children = null,\n ...other\n}) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on(\"postrender\", () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\n\nexport default React.memo(NorthArrow);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK1B,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,UAAU,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAClD;AAMA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,GAAG;AACL,GAAG;AACD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MAET,GAAG;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,QAAQ,OAAO;AAAA;AAAA,IAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB;AAAA,EACnE;AAEJ;AAEA,WAAW,YAAY;AAEvB,eAAe,MAAM,KAAK,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -71,27 +71,17 @@ const defaultMobileSize = {
|
|
|
71
71
|
maximalHeight: "100%",
|
|
72
72
|
minimalHeight: "25%"
|
|
73
73
|
};
|
|
74
|
-
const
|
|
75
|
-
className: null,
|
|
76
|
-
children: null,
|
|
77
|
-
observe: null,
|
|
78
|
-
isMobileResizable: true,
|
|
79
|
-
mobileSize: defaultMobileSize,
|
|
80
|
-
thresholdWidthForMobile: 768,
|
|
81
|
-
onResizeStop: () => {
|
|
82
|
-
},
|
|
83
|
-
onResizeStart: () => {
|
|
84
|
-
}
|
|
74
|
+
const emptyFunc = () => {
|
|
85
75
|
};
|
|
86
76
|
function Overlay({
|
|
87
|
-
observe,
|
|
88
|
-
className,
|
|
89
|
-
children,
|
|
90
|
-
isMobileResizable,
|
|
91
|
-
mobileSize,
|
|
92
|
-
onResizeStop,
|
|
93
|
-
onResizeStart,
|
|
94
|
-
thresholdWidthForMobile
|
|
77
|
+
observe = null,
|
|
78
|
+
className = null,
|
|
79
|
+
children = null,
|
|
80
|
+
isMobileResizable = true,
|
|
81
|
+
mobileSize = defaultMobileSize,
|
|
82
|
+
onResizeStop = emptyFunc,
|
|
83
|
+
onResizeStart = emptyFunc,
|
|
84
|
+
thresholdWidthForMobile = 768
|
|
95
85
|
}) {
|
|
96
86
|
const [isMobile, setIsMobile] = useState();
|
|
97
87
|
const onResize = (entries) => {
|
|
@@ -146,5 +136,4 @@ function Overlay({
|
|
|
146
136
|
) : /* @__PURE__ */ React.createElement("div", { className: `tm-overlay${className ? ` ${className}` : ""}` }, children));
|
|
147
137
|
}
|
|
148
138
|
Overlay.propTypes = propTypes;
|
|
149
|
-
Overlay.defaultProps = defaultProps;
|
|
150
139
|
export default Overlay;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Overlay/Overlay.js"],
|
|
4
|
-
"sourcesContent": ["import React, { Component, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Resizable } from \"re-resizable\";\nimport ResizeHandler from \"../ResizeHandler\";\n\nconst propTypes = {\n /**\n * CSS class added to container.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the overlay.\n */\n children: PropTypes.node,\n\n /**\n * Observed element to define screen size.\n */\n observe: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.node,\n PropTypes.instanceOf(Component),\n PropTypes.shape({ current: PropTypes.node }),\n PropTypes.shape({ current: PropTypes.instanceOf(Component) }),\n ]),\n\n /**\n * Deactivate the ability to resize the overlay on mobile.\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n isMobileResizable: PropTypes.bool,\n\n /**\n * Size parameters to the Resizable component on mobile.\n * Pass following prop to re-resizable component: 'size', 'defaultSize', 'minHeight' & 'maxHeight'\n * (https://github.com/bokuweb/re-resizable)\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n mobileSize: PropTypes.shape({\n minimalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n defaultSize: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n size: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n }),\n\n /**\n * Minimal width to consider the observed as mobile.\n * Default is 768px.\n */\n thresholdWidthForMobile: PropTypes.number,\n\n /**\n * Callback when stop resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStop: PropTypes.func,\n\n /**\n * Callback when start resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStart: PropTypes.func,\n};\n\nconst defaultMobileSize = {\n defaultSize: {\n width: \"100%\",\n height: \"25%\",\n },\n size: undefined,\n maximalHeight: \"100%\",\n minimalHeight: \"25%\",\n};\n\nconst
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,SAAS,iBAAiB;AAC1B,OAAO,mBAAmB;AAE1B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,SAAS,UAAU,UAAU;AAAA,IAC3B,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU,WAAW,SAAS;AAAA,IAC9B,UAAU,MAAM,EAAE,SAAS,UAAU,KAAK,CAAC;AAAA,IAC3C,UAAU,MAAM,EAAE,SAAS,UAAU,WAAW,SAAS,EAAE,CAAC;AAAA,EAC9D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,YAAY,UAAU,MAAM;AAAA,IAC1B,eAAe,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACvE,eAAe,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACvE,aAAa,UAAU,MAAM;AAAA,MAC3B,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,MAChE,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACjE,CAAC;AAAA,IACD,MAAM,UAAU,MAAM;AAAA,MACpB,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,MAChE,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACjE,CAAC;AAAA,EACH,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,yBAAyB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,eAAe,UAAU;AAC3B;AAEA,MAAM,oBAAoB;AAAA,EACxB,aAAa;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,MAAM;AAAA,EACN,eAAe;AAAA,EACf,eAAe;AACjB;AAEA,MAAM,
|
|
4
|
+
"sourcesContent": ["import React, { Component, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Resizable } from \"re-resizable\";\nimport ResizeHandler from \"../ResizeHandler\";\n\nconst propTypes = {\n /**\n * CSS class added to container.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the overlay.\n */\n children: PropTypes.node,\n\n /**\n * Observed element to define screen size.\n */\n observe: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.node,\n PropTypes.instanceOf(Component),\n PropTypes.shape({ current: PropTypes.node }),\n PropTypes.shape({ current: PropTypes.instanceOf(Component) }),\n ]),\n\n /**\n * Deactivate the ability to resize the overlay on mobile.\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n isMobileResizable: PropTypes.bool,\n\n /**\n * Size parameters to the Resizable component on mobile.\n * Pass following prop to re-resizable component: 'size', 'defaultSize', 'minHeight' & 'maxHeight'\n * (https://github.com/bokuweb/re-resizable)\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n mobileSize: PropTypes.shape({\n minimalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n defaultSize: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n size: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n }),\n\n /**\n * Minimal width to consider the observed as mobile.\n * Default is 768px.\n */\n thresholdWidthForMobile: PropTypes.number,\n\n /**\n * Callback when stop resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStop: PropTypes.func,\n\n /**\n * Callback when start resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStart: PropTypes.func,\n};\n\nconst defaultMobileSize = {\n defaultSize: {\n width: \"100%\",\n height: \"25%\",\n },\n size: undefined,\n maximalHeight: \"100%\",\n minimalHeight: \"25%\",\n};\n\nconst emptyFunc = () => {};\n/**\n * The Overlay component creates a resizable, swipable overlay <div\\>\n */\nfunction Overlay({\n observe = null,\n className = null,\n children = null,\n isMobileResizable = true,\n mobileSize = defaultMobileSize,\n onResizeStop = emptyFunc,\n onResizeStart = emptyFunc,\n thresholdWidthForMobile = 768,\n}) {\n const [isMobile, setIsMobile] = useState();\n\n const onResize = (entries) => {\n for (let i = 0; i < entries.length; i += 1) {\n const { width } = entries[i].contentRect;\n setIsMobile(width <= thresholdWidthForMobile);\n }\n };\n\n let resizableMobileSize;\n if (mobileSize) {\n resizableMobileSize = { ...defaultMobileSize, ...mobileSize };\n }\n\n return (\n <>\n {observe ? <ResizeHandler observe={observe} onResize={onResize} /> : null}\n {isMobile ? (\n <Resizable\n style={{\n position: \"absolute\",\n }}\n enable={{\n top: isMobileResizable,\n right: false,\n bottom: false,\n left: false,\n topRight: false,\n bottomRight: false,\n bottomLeft: false,\n topLeft: false,\n }}\n maxHeight={mobileSize && resizableMobileSize.maximalHeight}\n minHeight={mobileSize && resizableMobileSize.minimalHeight}\n handleComponent={{\n top: <div className=\"tm-overlay-handler\">—</div>,\n }}\n onResizeStart={onResizeStart}\n onResizeStop={onResizeStop}\n handleStyles={{\n top: {\n top: \"-20px\",\n height: \"20px\",\n padding: \"20px 0\",\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n }}\n size={resizableMobileSize.size}\n defaultSize={mobileSize && resizableMobileSize.defaultSize}\n className={`tm-overlay-mobile${className ? ` ${className}` : \"\"}`}\n >\n <div className=\"tm-overlay-mobile-content\">{children}</div>\n </Resizable>\n ) : (\n <div className={`tm-overlay${className ? ` ${className}` : \"\"}`}>\n {children}\n </div>\n )}\n </>\n );\n}\n\nOverlay.propTypes = propTypes;\n\nexport default Overlay;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,SAAS,iBAAiB;AAC1B,OAAO,mBAAmB;AAE1B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,SAAS,UAAU,UAAU;AAAA,IA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,oCAAC,SAAI,WAAU,+BAA6B,QAAS;AAAA,EACvD,IAEA,oCAAC,SAAI,WAAW,aAAa,YAAY,IAAI,SAAS,KAAK,EAAE,MAC1D,QACH,CAEJ;AAEJ;AAEA,QAAQ,YAAY;AAEpB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ReactDOM from "react-dom";
|
|
2
1
|
import { PureComponent, Component } from "react";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
import ResizeObserver from "resize-observer-polyfill";
|
|
@@ -121,13 +120,17 @@ class ResizeHandler extends PureComponent {
|
|
|
121
120
|
if (typeof observe === "string" || observe instanceof String) {
|
|
122
121
|
this.nodes = document.querySelectorAll(observe);
|
|
123
122
|
} else if (observe instanceof Component) {
|
|
124
|
-
|
|
123
|
+
console.warn(
|
|
124
|
+
"observe attribute as a Component is deprecated: Please use React.createRef() or React.useRef() instead of a React component."
|
|
125
|
+
);
|
|
125
126
|
} else if (observe instanceof Element) {
|
|
126
127
|
this.nodes.push(observe);
|
|
127
128
|
} else if (observe.current instanceof Element) {
|
|
128
129
|
this.nodes.push(observe.current);
|
|
129
130
|
} else if (observe.current instanceof Component) {
|
|
130
|
-
|
|
131
|
+
console.warn(
|
|
132
|
+
"observe attribute as a ref to Component is deprecated: Please use React.createRef() or React.useRef() instead of a React component."
|
|
133
|
+
);
|
|
131
134
|
}
|
|
132
135
|
if (this.nodes.length) {
|
|
133
136
|
this.nodes.forEach((node) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ResizeHandler/ResizeHandler.js"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import { PureComponent, Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\nconst propTypes = {\n observe: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.node,\n PropTypes.instanceOf(Component),\n PropTypes.shape({ current: PropTypes.node }),\n PropTypes.shape({ current: PropTypes.instanceOf(Component) }),\n ]),\n maxHeightBrkpts: PropTypes.objectOf(PropTypes.number),\n maxWidthBrkpts: PropTypes.objectOf(PropTypes.number),\n stylePropHeight: PropTypes.string,\n onResize: PropTypes.func,\n\n // This property is used to re-apply the classes, for example when the className of the observed node changes.\n forceUpdate: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.number,\n PropTypes.bool,\n ]),\n};\n\n// Same as bootstrap\nconst defaultProps = {\n observe: null,\n maxHeightBrkpts: {\n xs: 576,\n s: 768,\n m: 992,\n l: 1200,\n xl: Infinity,\n },\n maxWidthBrkpts: {\n xs: 576,\n s: 768,\n m: 992,\n l: 1200,\n xl: Infinity,\n },\n stylePropHeight: null,\n onResize: null,\n forceUpdate: null,\n};\n/**\n * This component adds css class to an element depending on his size.\n */\nclass ResizeHandler extends PureComponent {\n static applyBreakpoints(entry, breakpoints, size, direction) {\n let found = false;\n let screenSize;\n Object.entries(breakpoints).forEach((brkpt) => {\n const cssClass = `rs-${direction}-${brkpt[0]}`;\n entry.target.classList.remove(cssClass);\n if (!found && size <= brkpt[1]) {\n found = true;\n [screenSize] = brkpt;\n entry.target.classList.add(cssClass);\n }\n });\n return screenSize;\n }\n\n constructor(props) {\n super(props);\n this.observer = new ResizeObserver((entries) => {\n return this.onResize(entries);\n });\n this.nodes = [];\n }\n\n componentDidMount() {\n this.observe();\n }\n\n componentDidUpdate(prevProps) {\n const { observe, forceUpdate } = this.props;\n\n if (\n observe !== prevProps.observe ||\n forceUpdate !== prevProps.forceUpdate\n ) {\n this.observe();\n }\n }\n\n componentWillUnmount() {\n this.observer.disconnect();\n }\n\n onResize(entries) {\n const { maxHeightBrkpts, maxWidthBrkpts, stylePropHeight, onResize } =\n this.props;\n\n if (stylePropHeight) {\n const vh = window.innerHeight * 0.01;\n document.documentElement.style.setProperty(stylePropHeight, `${vh}px`);\n }\n\n if (!maxWidthBrkpts && !maxHeightBrkpts) {\n onResize(entries);\n return;\n }\n\n let newScreenWidth;\n let newScreenHeight;\n\n for (let i = 0; i < entries.length; i += 1) {\n const entry = entries[i];\n const rect = entry.contentRect;\n const { height, width } = rect;\n\n if (maxWidthBrkpts) {\n newScreenWidth = ResizeHandler.applyBreakpoints(\n entry,\n maxWidthBrkpts,\n width,\n \"w\",\n );\n }\n if (maxHeightBrkpts) {\n newScreenHeight = ResizeHandler.applyBreakpoints(\n entry,\n maxHeightBrkpts,\n height,\n \"h\",\n );\n }\n }\n\n if (onResize) {\n onResize(entries, newScreenWidth, newScreenHeight);\n }\n }\n\n observe() {\n this.observer.disconnect();\n const { observe } = this.props;\n\n if (!observe) {\n return;\n }\n\n if (typeof observe === \"string\" || observe instanceof String) {\n this.nodes = document.querySelectorAll(observe);\n } else if (observe instanceof Component) {\n // eslint-disable-next-line no-console\n console.warn(\n \"observe attribute as a Component is deprecated: Please use React.createRef() or React.useRef() instead of a React component.\",\n );\n // eslint-disable-next-line react/no-find-dom-node\n // this.nodes.push(ReactDOM.findDOMNode(observe));\n } else if (observe instanceof Element) {\n this.nodes.push(observe);\n } else if (observe.current instanceof Element) {\n // observe value created with React.createRef() on a html node.\n this.nodes.push(observe.current);\n } else if (observe.current instanceof Component) {\n // eslint-disable-next-line no-console\n console.warn(\n \"observe attribute as a ref to Component is deprecated: Please use React.createRef() or React.useRef() instead of a React component.\",\n );\n // observe value created with React.createRef() on a React component.\n // eslint-disable-next-line react/no-find-dom-node\n // this.nodes.push(ReactDOM.findDOMNode(observe.current));\n }\n\n if (this.nodes.length) {\n this.nodes.forEach((node) => {\n return this.observer.observe(node);\n });\n }\n }\n\n render() {\n return null;\n }\n}\n\nResizeHandler.propTypes = propTypes;\nResizeHandler.defaultProps = defaultProps;\n\nexport default ResizeHandler;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe,iBAAiB;AACzC,OAAO,eAAe;A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,IACnD;AAAA,EACF;AAAA,EAEA,UAAU;AACR,SAAK,SAAS,WAAW;AACzB,UAAM,EAAE,QAAQ,IAAI,KAAK;AAEzB,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,QAAI,OAAO,YAAY,YAAY,mBAAmB,QAAQ;AAC5D,WAAK,QAAQ,SAAS,iBAAiB,OAAO;AAAA,IAChD,WAAW,mBAAmB,WAAW;AAEvC,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IAGF,WAAW,mBAAmB,SAAS;AACrC,WAAK,MAAM,KAAK,OAAO;AAAA,IACzB,WAAW,QAAQ,mBAAmB,SAAS;AAE7C,WAAK,MAAM,KAAK,QAAQ,OAAO;AAAA,IACjC,WAAW,QAAQ,mBAAmB,WAAW;AAE/C,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IAIF;AAEA,QAAI,KAAK,MAAM,QAAQ;AACrB,WAAK,MAAM,QAAQ,CAAC,SAAS;AAC3B,eAAO,KAAK,SAAS,QAAQ,IAAI;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,EACT;AACF;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -60,12 +60,14 @@ const defaultRenderStationName = (stations, index, cancelled) => {
|
|
|
60
60
|
const { stationName } = stations[index];
|
|
61
61
|
return /* @__PURE__ */ React.createElement("div", { className: cancelled ? "rt-route-cancelled" : "" }, stationName);
|
|
62
62
|
};
|
|
63
|
+
const emptyFunc = () => {
|
|
64
|
+
};
|
|
63
65
|
function RouteStop({
|
|
64
66
|
lineInfos,
|
|
65
|
-
onStationClick,
|
|
67
|
+
onStationClick = emptyFunc,
|
|
66
68
|
trackerLayer,
|
|
67
|
-
renderStationImg,
|
|
68
|
-
renderStationName,
|
|
69
|
+
renderStationImg = defaultRenderStationImg,
|
|
70
|
+
renderStationName = defaultRenderStationName,
|
|
69
71
|
stop,
|
|
70
72
|
idx
|
|
71
73
|
}) {
|
|
@@ -165,10 +167,13 @@ const defaultRenderRouteIdentifier = ({ routeIdentifier, longName }) => {
|
|
|
165
167
|
}
|
|
166
168
|
return null;
|
|
167
169
|
};
|
|
170
|
+
const defaultRenderHeaderButtons = () => {
|
|
171
|
+
return null;
|
|
172
|
+
};
|
|
168
173
|
const defaultRenderHeader = ({
|
|
169
174
|
lineInfos,
|
|
170
|
-
renderHeaderButtons,
|
|
171
|
-
renderRouteIdentifier
|
|
175
|
+
renderHeaderButtons = defaultRenderHeaderButtons,
|
|
176
|
+
renderRouteIdentifier = defaultRenderRouteIdentifier
|
|
172
177
|
}) => {
|
|
173
178
|
const {
|
|
174
179
|
type,
|
|
@@ -193,19 +198,19 @@ const defaultRenderHeader = ({
|
|
|
193
198
|
shortName
|
|
194
199
|
), /* @__PURE__ */ React.createElement("div", { className: "rt-route-title" }, /* @__PURE__ */ React.createElement("span", { className: "rt-route-name" }, destination), /* @__PURE__ */ React.createElement("span", null, longName, renderRouteIdentifier(lineInfos))), /* @__PURE__ */ React.createElement("div", { className: "rt-route-buttons" }, renderHeaderButtons(routeIdentifier)));
|
|
195
200
|
};
|
|
196
|
-
const defaultRenderFooter = (props) => {
|
|
197
|
-
const { lineInfos, renderCopyright } = props;
|
|
198
|
-
if (!lineInfos.operator && !lineInfos.publisher) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
return /* @__PURE__ */ React.createElement("div", { className: "rt-route-footer" }, renderCopyright({ ...props }));
|
|
202
|
-
};
|
|
203
201
|
const defaultRenderLink = (text, url) => {
|
|
204
202
|
return /* @__PURE__ */ React.createElement("div", { className: "rt-route-copyright-link" }, url ? /* @__PURE__ */ React.createElement("a", { href: url, target: "_blank", rel: "noreferrer" }, text) : text);
|
|
205
203
|
};
|
|
206
204
|
const defaultRenderCopyright = ({ lineInfos }) => {
|
|
207
205
|
return /* @__PURE__ */ React.createElement("span", { className: "rt-route-copyright" }, lineInfos.operator && defaultRenderLink(lineInfos.operator, lineInfos.operatorUrl), lineInfos.operator && lineInfos.publisher && /* @__PURE__ */ React.createElement("span", null, "\xA0-\xA0"), lineInfos.publisher && defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl), lineInfos.license && /* @__PURE__ */ React.createElement("span", null, "\xA0("), lineInfos.license && defaultRenderLink(lineInfos.license, lineInfos.licenseUrl), lineInfos.license && ")");
|
|
208
206
|
};
|
|
207
|
+
const defaultRenderFooter = (props) => {
|
|
208
|
+
const { lineInfos, renderCopyright = defaultRenderCopyright } = props;
|
|
209
|
+
if (!lineInfos.operator && !lineInfos.publisher) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
return /* @__PURE__ */ React.createElement("div", { className: "rt-route-footer" }, renderCopyright({ ...props }));
|
|
213
|
+
};
|
|
209
214
|
const propTypes = {
|
|
210
215
|
/**
|
|
211
216
|
* CSS class of the route schedule wrapper.
|
|
@@ -256,24 +261,14 @@ const propTypes = {
|
|
|
256
261
|
*/
|
|
257
262
|
renderHeaderButtons: PropTypes.func
|
|
258
263
|
};
|
|
259
|
-
|
|
260
|
-
className
|
|
261
|
-
|
|
262
|
-
renderHeader
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
renderFooter: defaultRenderFooter,
|
|
268
|
-
renderRouteIdentifier: defaultRenderRouteIdentifier,
|
|
269
|
-
renderHeaderButtons: () => {
|
|
270
|
-
return null;
|
|
271
|
-
},
|
|
272
|
-
onStationClick: () => {
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
function RouteSchedule(props) {
|
|
276
|
-
const { lineInfos, className, renderStation, renderHeader, renderFooter } = props;
|
|
264
|
+
function RouteSchedule({
|
|
265
|
+
className = "rt-route-schedule",
|
|
266
|
+
renderStation = defaultRenderStation,
|
|
267
|
+
renderHeader = defaultRenderHeader,
|
|
268
|
+
renderFooter = defaultRenderFooter,
|
|
269
|
+
...props
|
|
270
|
+
}) {
|
|
271
|
+
const { lineInfos } = props;
|
|
277
272
|
if (!lineInfos) {
|
|
278
273
|
return null;
|
|
279
274
|
}
|
|
@@ -282,5 +277,4 @@ function RouteSchedule(props) {
|
|
|
282
277
|
})), renderFooter({ ...props }));
|
|
283
278
|
}
|
|
284
279
|
RouteSchedule.propTypes = propTypes;
|
|
285
|
-
RouteSchedule.defaultProps = defaultProps;
|
|
286
280
|
export default React.memo(RouteSchedule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/RouteSchedule/RouteSchedule.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\n/* eslint-disable react/prop-types */\nimport React, { useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport {\n RealtimeLayer as TrackerLayer,\n realtimeConfig,\n} from \"mobility-toolbox-js/ol\";\nimport { getHoursAndMinutes, getDelayString } from \"../../utils/timeUtils\";\nimport ReactTransitPropTypes from \"../../propTypes\";\nimport firstStation from \"../../images/RouteSchedule/firstStation.png\";\nimport station from \"../../images/RouteSchedule/station.png\";\nimport lastStation from \"../../images/RouteSchedule/lastStation.png\";\nimport line from \"../../images/RouteSchedule/line.png\";\n\nconst { getBgColor } = realtimeConfig;\n\n/**\n * Returns a color class to display the delay.\n * @param {Number} time Delay time in milliseconds.\n */\nconst getDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return \"dark-red\";\n }\n if (secs >= 500) {\n return \"middle-red\";\n }\n if (secs >= 300) {\n return \"light-red\";\n }\n if (secs >= 180) {\n return \"orange\";\n }\n return \"green\";\n};\n\n/**\n * Returns true if the train doesn't stop to the station.\n * @param {Object} stop Station information.\n */\nconst isNotStop = (stop) => {\n return !stop.arrivalTime && !stop.departureTime;\n};\n\n/**\n * Returns if the station has already been passed by the vehicule.\n * @param {Object} stop Station information.\n * @param {number} time The current time to test in ms.\n * @param {Array<Object>} stops the list of all stops of the train.\n * @param {idx} idx The index of the stop object in the stops array.\n */\nconst isPassed = (stop, time, stops, idx) => {\n // If the train doesn't stop to the stop object, we test if the stop just before has been passed or not.\n // if yes the current stop is considered as passed.\n if (isNotStop(stop)) {\n if (stops[idx - 1] && idx > 0) {\n return isPassed(stops[idx - 1], time, stops, idx);\n }\n return true;\n }\n\n // Sometimes stop.departureDelay is undefined.\n const timeToCompare = stop.aimedDepartureTime || stop.aimedArrivalTime || 0;\n let delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;\n\n // It could happens that the delay is negative we simply ignores it.\n if (delayToCompare < 0) {\n delayToCompare = 0;\n }\n\n return timeToCompare + delayToCompare <= time;\n};\n\n/**\n * Returns an image for first, middle or last stations.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} isStationPassed If the train is already passed at this station.\n * @param {Boolean} isNotStation If the train doesn't stop to this station.\n */\nconst defaultRenderStationImg = (\n stations,\n index,\n isStationPassed,\n isNotStation,\n) => {\n const { length } = stations;\n let src = station.src || station;\n if (index === 0) {\n src = firstStation.src || firstStation;\n } else if (index === length - 1) {\n src = lastStation.src || lastStation;\n } else if (isNotStation) {\n src = line.src || line;\n }\n return <img src={src} alt=\"routeScheduleLine\" className=\"rt-route-icon\" />;\n};\n\n/**\n * Returns an text.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} cancelled If the station is cancelled\n */\nconst defaultRenderStationName = (stations, index, cancelled) => {\n const { stationName } = stations[index];\n return (\n <div className={cancelled ? \"rt-route-cancelled\" : \"\"}>{stationName}</div>\n );\n};\n\nfunction RouteStop({\n lineInfos,\n onStationClick,\n trackerLayer,\n renderStationImg,\n renderStationName,\n stop,\n idx,\n}) {\n const {\n arrivalDelay,\n departureDelay,\n state,\n aimedArrivalTime,\n aimedDepartureTime,\n } = stop;\n const cancelled = state === \"JOURNEY_CANCELLED\" || state === \"STOP_CANCELLED\";\n const { stations } = lineInfos;\n const isFirstStation = idx === 0;\n const isLastStation = idx === stations.length - 1;\n const isNotStation = isNotStop(stop);\n const [isStationPassed, setIsStationPassed] = useState(false);\n\n useEffect(() => {\n let timeout = null;\n\n const isStopPassed = isPassed(stop, trackerLayer.time, stations, idx);\n setIsStationPassed(isStopPassed);\n\n // We have to refresh the stop when the state it's time_based\n if (stop.state === \"TIME_BASED\" && !isStopPassed) {\n timeout = setInterval(() => {\n setIsStationPassed(isPassed(stop, trackerLayer.time, stations, idx));\n }, 20000);\n }\n return () => {\n clearInterval(timeout);\n };\n }, [stop, trackerLayer, stations, idx]);\n\n return (\n <div\n role=\"button\"\n className={[\n \"rt-route-station\",\n isStationPassed ? \" rt-passed\" : \"\",\n isNotStation ? \" rt-no-stop\" : \"\",\n ].join(\"\")}\n onClick={(e) => {\n return onStationClick(stop, e);\n }}\n tabIndex={0}\n onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n >\n <div className=\"rt-route-delay\">\n {arrivalDelay === undefined ||\n arrivalDelay === null ||\n isFirstStation ||\n cancelled ? (\n \"\"\n ) : (\n <span\n className={`rt-route-delay-arrival${` ${getDelayColor(\n arrivalDelay,\n )}`}`}\n >\n {`+${getDelayString(arrivalDelay)}`}\n </span>\n )}\n {departureDelay === undefined ||\n departureDelay === null ||\n isLastStation ||\n cancelled ? (\n \"\"\n ) : (\n <span\n className={`rt-route-delay-departure${` ${getDelayColor(\n departureDelay,\n )}`}`}\n >\n {`+${getDelayString(departureDelay)}`}\n </span>\n )}\n </div>\n <div className=\"rt-route-times\">\n <span\n className={`rt-route-time-arrival ${\n cancelled ? \"rt-route-cancelled\" : \"\"\n }`}\n >\n {getHoursAndMinutes(aimedArrivalTime)}\n </span>\n <span\n className={`rt-route-time-departure ${\n cancelled ? \"rt-route-cancelled\" : \"\"\n }`}\n >\n {getHoursAndMinutes(aimedDepartureTime)}\n </span>\n </div>\n {renderStationImg(stations, idx, isStationPassed, isNotStation)}\n {renderStationName(stations, idx, cancelled)}\n </div>\n );\n}\n\nconst defaultRenderStation = (props) => {\n const { stationId, arrivalTime, departureTime, stationName } = props.stop;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return (\n <RouteStop\n // Train line can go in circle so begin and end have the same id,\n // using the time in the key should fix the issue.\n key={(stationId || stationName) + arrivalTime + departureTime}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n />\n );\n};\n\nconst defaultRenderRouteIdentifier = ({ routeIdentifier, longName }) => {\n if (routeIdentifier) {\n // first part of the id, without leading zeros.\n const id = parseInt(routeIdentifier.split(\".\")[0], 10);\n if (!longName.includes(id) && !Number.isNaN(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\n\nconst defaultRenderHeader = ({\n lineInfos,\n renderHeaderButtons,\n renderRouteIdentifier,\n}) => {\n const {\n type,\n vehicleType,\n shortName,\n longName,\n stroke,\n destination,\n routeIdentifier,\n text_color: textColor,\n } = lineInfos;\n return (\n <div className=\"rt-route-header\">\n <span\n className=\"rt-route-icon\"\n style={{\n /* stylelint-disable-next-line value-keyword-case */\n backgroundColor: stroke || getBgColor(type || vehicleType),\n color: textColor || \"black\",\n }}\n >\n {shortName}\n </span>\n <div className=\"rt-route-title\">\n <span className=\"rt-route-name\">{destination}</span>\n <span>\n {longName}\n {renderRouteIdentifier(lineInfos)}\n </span>\n </div>\n <div className=\"rt-route-buttons\">\n {renderHeaderButtons(routeIdentifier)}\n </div>\n </div>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} target=\"_blank\" rel=\"noreferrer\">\n {text}\n </a>\n ) : (\n text\n )}\n </div>\n );\n};\n\nconst defaultRenderCopyright = ({ lineInfos }) => {\n return (\n <span className=\"rt-route-copyright\">\n {lineInfos.operator &&\n defaultRenderLink(lineInfos.operator, lineInfos.operatorUrl)}\n {lineInfos.operator && lineInfos.publisher && <span> - </span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span> (</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && \")\"}\n </span>\n );\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render the route identifier in the header\n */\n renderRouteIdentifier: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Render a station name.\n */\n renderStationName: PropTypes.func,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n};\n\nconst defaultProps = {\n className: \"rt-route-schedule\",\n lineInfos: null,\n renderHeader: defaultRenderHeader,\n renderStation: defaultRenderStation,\n renderStationImg: defaultRenderStationImg,\n renderStationName: defaultRenderStationName,\n renderCopyright: defaultRenderCopyright,\n renderFooter: defaultRenderFooter,\n renderRouteIdentifier: defaultRenderRouteIdentifier,\n renderHeaderButtons: () => {\n return null;\n },\n onStationClick: () => {},\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule(props) {\n const { lineInfos, className, renderStation, renderHeader, renderFooter } =\n props;\n\n if (!lineInfos) {\n return null;\n }\n\n return (\n <div className={className}>\n {renderHeader({ ...props })}\n <div className=\"rt-route-body\">\n {lineInfos.stations.map((stop, idx) => {\n return renderStation({ ...props, stop, idx });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\nRouteSchedule.defaultProps = defaultProps;\n\nexport default React.memo(RouteSchedule);\n"],
|
|
5
|
-
"mappings": "AAEA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB;AAAA,EACE,iBAAiB;AAAA,EACjB;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,OAAO,2BAA2B;AAClC,OAAO,kBAAkB;AACzB,OAAO,aAAa;AACpB,OAAO,iBAAiB;AACxB,OAAO,UAAU;AAEjB,MAAM,EAAE,WAAW,IAAI;AAMvB,MAAM,gBAAgB,CAAC,SAAS;AAC9B,QAAM,OAAO,KAAK,MAAQ,OAAO,OAAO,IAAK,OAAQ,GAAI;AACzD,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAMA,MAAM,YAAY,CAAC,SAAS;AAC1B,SAAO,CAAC,KAAK,eAAe,CAAC,KAAK;AACpC;AASA,MAAM,WAAW,CAAC,MAAM,MAAM,OAAO,QAAQ;AAG3C,MAAI,UAAU,IAAI,GAAG;AACnB,QAAI,MAAM,MAAM,CAAC,KAAK,MAAM,GAAG;AAC7B,aAAO,SAAS,MAAM,MAAM,CAAC,GAAG,MAAM,OAAO,GAAG;AAAA,IAClD;AACA,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,KAAK,sBAAsB,KAAK,oBAAoB;AAC1E,MAAI,iBAAiB,KAAK,kBAAkB,KAAK,gBAAgB;AAGjE,MAAI,iBAAiB,GAAG;AACtB,qBAAiB;AAAA,EACnB;AAEA,SAAO,gBAAgB,kBAAkB;AAC3C;AASA,MAAM,0BAA0B,CAC9B,UACA,OACA,iBACA,iBACG;AACH,QAAM,EAAE,OAAO,IAAI;AACnB,MAAI,MAAM,QAAQ,OAAO;AACzB,MAAI,UAAU,GAAG;AACf,UAAM,aAAa,OAAO;AAAA,EAC5B,WAAW,UAAU,SAAS,GAAG;AAC/B,UAAM,YAAY,OAAO;AAAA,EAC3B,WAAW,cAAc;AACvB,UAAM,KAAK,OAAO;AAAA,EACpB;AACA,SAAO,oCAAC,SAAI,KAAU,KAAI,qBAAoB,WAAU,iBAAgB;AAC1E;AAQA,MAAM,2BAA2B,CAAC,UAAU,OAAO,cAAc;AAC/D,QAAM,EAAE,YAAY,IAAI,SAAS,KAAK;AACtC,SACE,oCAAC,SAAI,WAAW,YAAY,uBAAuB,MAAK,WAAY;AAExE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\n/* eslint-disable react/prop-types */\nimport React, { useEffect, useState } from \"react\";\nimport PropTypes from \"prop-types\";\nimport {\n RealtimeLayer as TrackerLayer,\n realtimeConfig,\n} from \"mobility-toolbox-js/ol\";\nimport { getHoursAndMinutes, getDelayString } from \"../../utils/timeUtils\";\nimport ReactTransitPropTypes from \"../../propTypes\";\nimport firstStation from \"../../images/RouteSchedule/firstStation.png\";\nimport station from \"../../images/RouteSchedule/station.png\";\nimport lastStation from \"../../images/RouteSchedule/lastStation.png\";\nimport line from \"../../images/RouteSchedule/line.png\";\n\nconst { getBgColor } = realtimeConfig;\n\n/**\n * Returns a color class to display the delay.\n * @param {Number} time Delay time in milliseconds.\n */\nconst getDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return \"dark-red\";\n }\n if (secs >= 500) {\n return \"middle-red\";\n }\n if (secs >= 300) {\n return \"light-red\";\n }\n if (secs >= 180) {\n return \"orange\";\n }\n return \"green\";\n};\n\n/**\n * Returns true if the train doesn't stop to the station.\n * @param {Object} stop Station information.\n */\nconst isNotStop = (stop) => {\n return !stop.arrivalTime && !stop.departureTime;\n};\n\n/**\n * Returns if the station has already been passed by the vehicule.\n * @param {Object} stop Station information.\n * @param {number} time The current time to test in ms.\n * @param {Array<Object>} stops the list of all stops of the train.\n * @param {idx} idx The index of the stop object in the stops array.\n */\nconst isPassed = (stop, time, stops, idx) => {\n // If the train doesn't stop to the stop object, we test if the stop just before has been passed or not.\n // if yes the current stop is considered as passed.\n if (isNotStop(stop)) {\n if (stops[idx - 1] && idx > 0) {\n return isPassed(stops[idx - 1], time, stops, idx);\n }\n return true;\n }\n\n // Sometimes stop.departureDelay is undefined.\n const timeToCompare = stop.aimedDepartureTime || stop.aimedArrivalTime || 0;\n let delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;\n\n // It could happens that the delay is negative we simply ignores it.\n if (delayToCompare < 0) {\n delayToCompare = 0;\n }\n\n return timeToCompare + delayToCompare <= time;\n};\n\n/**\n * Returns an image for first, middle or last stations.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} isStationPassed If the train is already passed at this station.\n * @param {Boolean} isNotStation If the train doesn't stop to this station.\n */\nconst defaultRenderStationImg = (\n stations,\n index,\n isStationPassed,\n isNotStation,\n) => {\n const { length } = stations;\n let src = station.src || station;\n if (index === 0) {\n src = firstStation.src || firstStation;\n } else if (index === length - 1) {\n src = lastStation.src || lastStation;\n } else if (isNotStation) {\n src = line.src || line;\n }\n return <img src={src} alt=\"routeScheduleLine\" className=\"rt-route-icon\" />;\n};\n\n/**\n * Returns an text.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} cancelled If the station is cancelled\n */\nconst defaultRenderStationName = (stations, index, cancelled) => {\n const { stationName } = stations[index];\n return (\n <div className={cancelled ? \"rt-route-cancelled\" : \"\"}>{stationName}</div>\n );\n};\nconst emptyFunc = () => {};\n\nfunction RouteStop({\n lineInfos,\n onStationClick = emptyFunc,\n trackerLayer,\n renderStationImg = defaultRenderStationImg,\n renderStationName = defaultRenderStationName,\n stop,\n idx,\n}) {\n const {\n arrivalDelay,\n departureDelay,\n state,\n aimedArrivalTime,\n aimedDepartureTime,\n } = stop;\n const cancelled = state === \"JOURNEY_CANCELLED\" || state === \"STOP_CANCELLED\";\n const { stations } = lineInfos;\n const isFirstStation = idx === 0;\n const isLastStation = idx === stations.length - 1;\n const isNotStation = isNotStop(stop);\n const [isStationPassed, setIsStationPassed] = useState(false);\n\n useEffect(() => {\n let timeout = null;\n\n const isStopPassed = isPassed(stop, trackerLayer.time, stations, idx);\n setIsStationPassed(isStopPassed);\n\n // We have to refresh the stop when the state it's time_based\n if (stop.state === \"TIME_BASED\" && !isStopPassed) {\n timeout = setInterval(() => {\n setIsStationPassed(isPassed(stop, trackerLayer.time, stations, idx));\n }, 20000);\n }\n return () => {\n clearInterval(timeout);\n };\n }, [stop, trackerLayer, stations, idx]);\n\n return (\n <div\n role=\"button\"\n className={[\n \"rt-route-station\",\n isStationPassed ? \" rt-passed\" : \"\",\n isNotStation ? \" rt-no-stop\" : \"\",\n ].join(\"\")}\n onClick={(e) => {\n return onStationClick(stop, e);\n }}\n tabIndex={0}\n onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n >\n <div className=\"rt-route-delay\">\n {arrivalDelay === undefined ||\n arrivalDelay === null ||\n isFirstStation ||\n cancelled ? (\n \"\"\n ) : (\n <span\n className={`rt-route-delay-arrival${` ${getDelayColor(\n arrivalDelay,\n )}`}`}\n >\n {`+${getDelayString(arrivalDelay)}`}\n </span>\n )}\n {departureDelay === undefined ||\n departureDelay === null ||\n isLastStation ||\n cancelled ? (\n \"\"\n ) : (\n <span\n className={`rt-route-delay-departure${` ${getDelayColor(\n departureDelay,\n )}`}`}\n >\n {`+${getDelayString(departureDelay)}`}\n </span>\n )}\n </div>\n <div className=\"rt-route-times\">\n <span\n className={`rt-route-time-arrival ${\n cancelled ? \"rt-route-cancelled\" : \"\"\n }`}\n >\n {getHoursAndMinutes(aimedArrivalTime)}\n </span>\n <span\n className={`rt-route-time-departure ${\n cancelled ? \"rt-route-cancelled\" : \"\"\n }`}\n >\n {getHoursAndMinutes(aimedDepartureTime)}\n </span>\n </div>\n {renderStationImg(stations, idx, isStationPassed, isNotStation)}\n {renderStationName(stations, idx, cancelled)}\n </div>\n );\n}\n\nconst defaultRenderStation = (props) => {\n const { stationId, arrivalTime, departureTime, stationName } = props.stop;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return (\n <RouteStop\n // Train line can go in circle so begin and end have the same id,\n // using the time in the key should fix the issue.\n key={(stationId || stationName) + arrivalTime + departureTime}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n />\n );\n};\n\nconst defaultRenderRouteIdentifier = ({ routeIdentifier, longName }) => {\n if (routeIdentifier) {\n // first part of the id, without leading zeros.\n const id = parseInt(routeIdentifier.split(\".\")[0], 10);\n if (!longName.includes(id) && !Number.isNaN(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\nconst defaultRenderHeaderButtons = () => {\n return null;\n};\n\nconst defaultRenderHeader = ({\n lineInfos,\n renderHeaderButtons = defaultRenderHeaderButtons,\n renderRouteIdentifier = defaultRenderRouteIdentifier,\n}) => {\n const {\n type,\n vehicleType,\n shortName,\n longName,\n stroke,\n destination,\n routeIdentifier,\n text_color: textColor,\n } = lineInfos;\n return (\n <div className=\"rt-route-header\">\n <span\n className=\"rt-route-icon\"\n style={{\n /* stylelint-disable-next-line value-keyword-case */\n backgroundColor: stroke || getBgColor(type || vehicleType),\n color: textColor || \"black\",\n }}\n >\n {shortName}\n </span>\n <div className=\"rt-route-title\">\n <span className=\"rt-route-name\">{destination}</span>\n <span>\n {longName}\n {renderRouteIdentifier(lineInfos)}\n </span>\n </div>\n <div className=\"rt-route-buttons\">\n {renderHeaderButtons(routeIdentifier)}\n </div>\n </div>\n );\n};\n\nconst defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} target=\"_blank\" rel=\"noreferrer\">\n {text}\n </a>\n ) : (\n text\n )}\n </div>\n );\n};\n\nconst defaultRenderCopyright = ({ lineInfos }) => {\n return (\n <span className=\"rt-route-copyright\">\n {lineInfos.operator &&\n defaultRenderLink(lineInfos.operator, lineInfos.operatorUrl)}\n {lineInfos.operator && lineInfos.publisher && <span> - </span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span> (</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && \")\"}\n </span>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright = defaultRenderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render the route identifier in the header\n */\n renderRouteIdentifier: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Render a station name.\n */\n renderStationName: PropTypes.func,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule({\n className = \"rt-route-schedule\",\n renderStation = defaultRenderStation,\n renderHeader = defaultRenderHeader,\n renderFooter = defaultRenderFooter,\n ...props\n}) {\n const { lineInfos } = props;\n\n if (!lineInfos) {\n return null;\n }\n\n return (\n <div className={className}>\n {renderHeader({ ...props })}\n <div className=\"rt-route-body\">\n {lineInfos.stations.map((stop, idx) => {\n return renderStation({ ...props, stop, idx });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\n\nexport default React.memo(RouteSchedule);\n"],
|
|
5
|
+
"mappings": "AAEA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB;AAAA,EACE,iBAAiB;AAAA,EACjB;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,OAAO,2BAA2B;AAClC,OAAO,kBAAkB;AACzB,OAAO,aAAa;AACpB,OAAO,iBAAiB;AACxB,OAAO,UAAU;AAEjB,MAAM,EAAE,WAAW,IAAI;AAMvB,MAAM,gBAAgB,CAAC,SAAS;AAC9B,QAAM,OAAO,KAAK,MAAQ,OAAO,OAAO,IAAK,OAAQ,GAAI;AACzD,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAMA,MAAM,YAAY,CAAC,SAAS;AAC1B,SAAO,CAAC,KAAK,eAAe,CAAC,KAAK;AACpC;AASA,MAAM,WAAW,CAAC,MAAM,MAAM,OAAO,QAAQ;AAG3C,MAAI,UAAU,IAAI,GAAG;AACnB,QAAI,MAAM,MAAM,CAAC,KAAK,MAAM,GAAG;AAC7B,aAAO,SAAS,MAAM,MAAM,CAAC,GAAG,MAAM,O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kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK5B,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAKzB,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK7B,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK1B,qBAAqB,UAAU;AACjC;AAKA,SAAS,cAAc;AAAA,EACrB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,GAAG;AACL,GAAG;AACD,QAAM,EAAE,UAAU,IAAI;AAEtB,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,SACE,oCAAC,SAAI,aACF,aAAa,EAAE,GAAG,MAAM,CAAC,GAC1B,oCAAC,SAAI,WAAU,mBACZ,UAAU,SAAS,IAAI,CAAC,MAAM,QAAQ;AACrC,WAAO,cAAc,EAAE,GAAG,OAAO,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC,CACH,GACC,aAAa,EAAE,GAAG,MAAM,CAAC,CAC5B;AAEJ;AAEA,cAAc,YAAY;AAE1B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ const propTypes = {
|
|
|
16
16
|
const defaultProps = {
|
|
17
17
|
options: {}
|
|
18
18
|
};
|
|
19
|
-
function ScaleLine({ map, options, ...other }) {
|
|
19
|
+
function ScaleLine({ map, options = defaultProps.options, ...other }) {
|
|
20
20
|
const ref = useRef();
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
const control = new OLScaleLine({
|
|
@@ -31,5 +31,4 @@ function ScaleLine({ map, options, ...other }) {
|
|
|
31
31
|
return /* @__PURE__ */ React.createElement("div", { className: "rs-scale-line", ref, ...other });
|
|
32
32
|
}
|
|
33
33
|
ScaleLine.propTypes = propTypes;
|
|
34
|
-
ScaleLine.defaultProps = defaultProps;
|
|
35
34
|
export default React.memo(ScaleLine);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ScaleLine/ScaleLine.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useRef, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLScaleLine from \"ol/control/ScaleLine\";\nimport OLMap from \"ol/Map\";\n\nconst propTypes = {\n /**\n * ol/map.\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Options for ol/control/ScaleLine.\n * See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html\n */\n options: PropTypes.object,\n};\n\nconst defaultProps = {\n options: {},\n};\n\n/**\n * The ScaleLine component creates an\n * [ol/control/ScaleLine](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html)\n * for an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction ScaleLine({ map, options, ...other }) {\n const ref = useRef();\n\n useEffect(() => {\n const control = new OLScaleLine({\n ...options,\n ...{ target: ref.current },\n });\n\n map.addControl(control);\n return () => {\n map.removeControl(control);\n };\n }, [map, options]);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <div className=\"rs-scale-line\" ref={ref} {...other} />;\n}\n\nScaleLine.propTypes = propTypes;\
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,QAAQ,iBAAiB;AACzC,OAAO,eAAe;AACtB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,SAAS,UAAU;AACrB;AAEA,MAAM,eAAe;AAAA,EACnB,SAAS,CAAC;AACZ;AAOA,SAAS,UAAU,EAAE,KAAK,SAAS,GAAG,MAAM,GAAG;
|
|
4
|
+
"sourcesContent": ["import React, { useRef, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLScaleLine from \"ol/control/ScaleLine\";\nimport OLMap from \"ol/Map\";\n\nconst propTypes = {\n /**\n * ol/map.\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Options for ol/control/ScaleLine.\n * See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html\n */\n options: PropTypes.object,\n};\n\nconst defaultProps = {\n options: {},\n};\n\n/**\n * The ScaleLine component creates an\n * [ol/control/ScaleLine](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html)\n * for an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction ScaleLine({ map, options = defaultProps.options, ...other }) {\n const ref = useRef();\n\n useEffect(() => {\n const control = new OLScaleLine({\n ...options,\n ...{ target: ref.current },\n });\n\n map.addControl(control);\n return () => {\n map.removeControl(control);\n };\n }, [map, options]);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <div className=\"rs-scale-line\" ref={ref} {...other} />;\n}\n\nScaleLine.propTypes = propTypes;\n\nexport default React.memo(ScaleLine);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,QAAQ,iBAAiB;AACzC,OAAO,eAAe;AACtB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,SAAS,UAAU;AACrB;AAEA,MAAM,eAAe;AAAA,EACnB,SAAS,CAAC;AACZ;AAOA,SAAS,UAAU,EAAE,KAAK,UAAU,aAAa,SAAS,GAAG,MAAM,GAAG;AACpE,QAAM,MAAM,OAAO;AAEnB,YAAU,MAAM;AACd,UAAM,UAAU,IAAI,YAAY;AAAA,MAC9B,GAAG;AAAA,MACH,GAAG,EAAE,QAAQ,IAAI,QAAQ;AAAA,IAC3B,CAAC;AAED,QAAI,WAAW,OAAO;AACtB,WAAO,MAAM;AACX,UAAI,cAAc,OAAO;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,KAAK,OAAO,CAAC;AAGjB,SAAO,oCAAC,SAAI,WAAU,iBAAgB,KAAW,GAAG,OAAO;AAC7D;AAEA,UAAU,YAAY;AAEtB,eAAe,MAAM,KAAK,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,6 +12,9 @@ const StyledAutocomplete = styled(Autocomplete)(() => ({
|
|
|
12
12
|
transform: "rotate(0)"
|
|
13
13
|
}
|
|
14
14
|
}));
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
textFieldProps: {}
|
|
17
|
+
};
|
|
15
18
|
function StopsFinder({
|
|
16
19
|
agencies,
|
|
17
20
|
apiKey,
|
|
@@ -25,7 +28,7 @@ function StopsFinder({
|
|
|
25
28
|
refLocation,
|
|
26
29
|
renderAutocomplete,
|
|
27
30
|
url,
|
|
28
|
-
textFieldProps,
|
|
31
|
+
textFieldProps = defaultProps.textFieldProps,
|
|
29
32
|
...props
|
|
30
33
|
}) {
|
|
31
34
|
const [inputValue, setInputValue] = useState("");
|
|
@@ -233,18 +236,4 @@ StopsFinder.propTypes = {
|
|
|
233
236
|
*/
|
|
234
237
|
url: PropTypes.string
|
|
235
238
|
};
|
|
236
|
-
StopsFinder.defaultProps = {
|
|
237
|
-
agencies: null,
|
|
238
|
-
apiKey: null,
|
|
239
|
-
textFieldProps: {},
|
|
240
|
-
bbox: null,
|
|
241
|
-
field: null,
|
|
242
|
-
limit: null,
|
|
243
|
-
mots: null,
|
|
244
|
-
onSelect: null,
|
|
245
|
-
radius: null,
|
|
246
|
-
refLocation: null,
|
|
247
|
-
url: null,
|
|
248
|
-
renderAutocomplete: null
|
|
249
|
-
};
|
|
250
239
|
export default StopsFinder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/StopsFinder/StopsFinder.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/jsx-props-no-spreading */\nimport React, { useMemo, useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Autocomplete, autocompleteClasses, styled } from \"@mui/material\";\nimport { FaSearch } from \"react-icons/fa\";\nimport TextField from \"@mui/material/TextField\";\nimport CircularProgress from \"@mui/material/CircularProgress\";\nimport { StopFinderControl } from \"mobility-toolbox-js/ol\";\nimport { Map } from \"ol\";\nimport StopsFinderOption from \"./StopsFinderOption\";\n\nconst StyledAutocomplete = styled(Autocomplete)(() => ({\n [`& .${autocompleteClasses.popupIndicatorOpen}`]: {\n transform: \"rotate(0)\",\n },\n}));\n\nfunction StopsFinder({\n agencies,\n apiKey,\n bbox,\n field,\n limit,\n map,\n mots,\n onSelect,\n radius,\n refLocation,\n renderAutocomplete,\n url,\n textFieldProps,\n ...props\n}) {\n const [inputValue, setInputValue] = useState(\"\");\n const [suggestions, setSuggestions] = useState([]);\n const [isLoading, setLoading] = useState(false);\n const [isOpen, setOpen] = useState(false);\n\n const control = useMemo(() => {\n return new StopFinderControl({\n url,\n apiKey,\n target: document.createElement(\"div\"),\n element: document.createElement(\"div\"),\n render(newSuggestions = { features: [] }) {\n setSuggestions(newSuggestions.features);\n setLoading(false);\n },\n });\n }, [apiKey, url]);\n\n useEffect(() => {\n if (!inputValue) {\n setSuggestions([]);\n setLoading(false);\n return () => {};\n }\n const abortController = new AbortController();\n setLoading(true);\n control.apiParams = {\n prefAgencies: agencies && agencies.toString(),\n bbox: bbox && bbox.toString(),\n field: field && field.toString(),\n limit,\n mots: mots && mots.toString(),\n radius,\n ref_location: refLocation && refLocation.toString(),\n };\n control.search(inputValue, abortController);\n return () => {\n abortController.abort();\n };\n }, [\n agencies,\n bbox,\n control,\n field,\n inputValue,\n limit,\n mots,\n radius,\n refLocation,\n ]);\n\n // Ensure the control is not associated to the wrong map\n useEffect(() => {\n if (!control) {\n return () => {};\n }\n\n control.map = map;\n\n return () => {\n control.map = null;\n };\n }, [map, control]);\n\n if (!control) {\n return null;\n }\n\n if (renderAutocomplete) {\n return renderAutocomplete(\n suggestions,\n inputValue,\n setInputValue,\n isOpen,\n setOpen,\n isLoading,\n setLoading,\n );\n }\n return (\n <StyledAutocomplete\n fullWidth\n autoComplete\n autoHighlight\n selectOnFocus\n getOptionLabel={(option) => {\n return option.properties.name;\n }}\n onChange={(evt, value, reason) => {\n if (onSelect && reason === \"selectOption\") {\n onSelect(value, evt);\n }\n }}\n popupIcon={<FaSearch focusable={false} size={15} />}\n renderInput={(params) => {\n return (\n <TextField\n label=\"Search stops\"\n {...params}\n {...textFieldProps}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {isLoading && <CircularProgress size={20} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n );\n }}\n renderOption={(liProps, option) => {\n return (\n <StopsFinderOption\n key={option.properties?.name}\n option={option}\n {...liProps}\n />\n );\n }}\n {...props}\n inputValue={inputValue}\n open={isOpen}\n options={suggestions}\n loading={isLoading}\n onOpen={() => {\n setOpen(true);\n }}\n onClose={() => {\n setOpen(false);\n }}\n onInputChange={(evt, val) => {\n setInputValue(val);\n }}\n />\n );\n}\n\nStopsFinder.propTypes = {\n /**\n * Array or a comma separated list of agencies which should be available.\n * Order of these agencies chooses which agency will be preferred.\n * Available values : sbb, db\n */\n agencies: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * geOps api key to access the StopsFinder service.\n */\n apiKey: PropTypes.string,\n\n /**\n * Properties apply to the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.\n */\n textFieldProps: PropTypes.object,\n\n /**\n * minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.\n */\n bbox: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Array or a comma separated list of fields which should be used for look up.\n * Available values : id, name, coords\n */\n field: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Control how many matches will be returned.\n */\n limit: PropTypes.number,\n\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Array or a comma separated list of mode of transpaorts which should be available.\n * Available values : bus, ferry, gondola, tram, rail, funicular, cable_car, subway\n */\n mots: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Function called when a suggestion is selected.\n */\n onSelect: PropTypes.func,\n\n /**\n * Radius around refLocation in meters that is most relevant.\n * Used as granularity for location rank.\n */\n radius: PropTypes.number,\n\n /**\n * Coordinates in WGS84 (in lat,lon order) used to rank stops close to this position higher.\n * Available values : id, name, coords\n */\n refLocation: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Function to render a different autocomplete input than the default one.\n */\n renderAutocomplete: PropTypes.func,\n\n /**\n * Url of the geOps StopsFinder service.\n */\n url: PropTypes.string,\n};\n\
|
|
5
|
-
"mappings": "AACA,OAAO,SAAS,SAAS,UAAU,iBAAiB;AACpD,OAAO,eAAe;AACtB,SAAS,cAAc,qBAAqB,cAAc;AAC1D,SAAS,gBAAgB;AACzB,OAAO,eAAe;AACtB,OAAO,sBAAsB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,WAAW;AACpB,OAAO,uBAAuB;AAE9B,MAAM,qBAAqB,OAAO,YAAY,EAAE,OAAO;AAAA,EACrD,CAAC,MAAM,oBAAoB,kBAAkB,EAAE,GAAG;AAAA,IAChD,WAAW;AAAA,EACb;AACF,EAAE;AAEF,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/jsx-props-no-spreading */\nimport React, { useMemo, useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Autocomplete, autocompleteClasses, styled } from \"@mui/material\";\nimport { FaSearch } from \"react-icons/fa\";\nimport TextField from \"@mui/material/TextField\";\nimport CircularProgress from \"@mui/material/CircularProgress\";\nimport { StopFinderControl } from \"mobility-toolbox-js/ol\";\nimport { Map } from \"ol\";\nimport StopsFinderOption from \"./StopsFinderOption\";\n\nconst StyledAutocomplete = styled(Autocomplete)(() => ({\n [`& .${autocompleteClasses.popupIndicatorOpen}`]: {\n transform: \"rotate(0)\",\n },\n}));\n\nconst defaultProps = {\n textFieldProps: {},\n};\n\nfunction StopsFinder({\n agencies,\n apiKey,\n bbox,\n field,\n limit,\n map,\n mots,\n onSelect,\n radius,\n refLocation,\n renderAutocomplete,\n url,\n textFieldProps = defaultProps.textFieldProps,\n ...props\n}) {\n const [inputValue, setInputValue] = useState(\"\");\n const [suggestions, setSuggestions] = useState([]);\n const [isLoading, setLoading] = useState(false);\n const [isOpen, setOpen] = useState(false);\n\n const control = useMemo(() => {\n return new StopFinderControl({\n url,\n apiKey,\n target: document.createElement(\"div\"),\n element: document.createElement(\"div\"),\n render(newSuggestions = { features: [] }) {\n setSuggestions(newSuggestions.features);\n setLoading(false);\n },\n });\n }, [apiKey, url]);\n\n useEffect(() => {\n if (!inputValue) {\n setSuggestions([]);\n setLoading(false);\n return () => {};\n }\n const abortController = new AbortController();\n setLoading(true);\n control.apiParams = {\n prefAgencies: agencies && agencies.toString(),\n bbox: bbox && bbox.toString(),\n field: field && field.toString(),\n limit,\n mots: mots && mots.toString(),\n radius,\n ref_location: refLocation && refLocation.toString(),\n };\n control.search(inputValue, abortController);\n return () => {\n abortController.abort();\n };\n }, [\n agencies,\n bbox,\n control,\n field,\n inputValue,\n limit,\n mots,\n radius,\n refLocation,\n ]);\n\n // Ensure the control is not associated to the wrong map\n useEffect(() => {\n if (!control) {\n return () => {};\n }\n\n control.map = map;\n\n return () => {\n control.map = null;\n };\n }, [map, control]);\n\n if (!control) {\n return null;\n }\n\n if (renderAutocomplete) {\n return renderAutocomplete(\n suggestions,\n inputValue,\n setInputValue,\n isOpen,\n setOpen,\n isLoading,\n setLoading,\n );\n }\n return (\n <StyledAutocomplete\n fullWidth\n autoComplete\n autoHighlight\n selectOnFocus\n getOptionLabel={(option) => {\n return option.properties.name;\n }}\n onChange={(evt, value, reason) => {\n if (onSelect && reason === \"selectOption\") {\n onSelect(value, evt);\n }\n }}\n popupIcon={<FaSearch focusable={false} size={15} />}\n renderInput={(params) => {\n return (\n <TextField\n label=\"Search stops\"\n {...params}\n {...textFieldProps}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {isLoading && <CircularProgress size={20} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n );\n }}\n renderOption={(liProps, option) => {\n return (\n <StopsFinderOption\n key={option.properties?.name}\n option={option}\n {...liProps}\n />\n );\n }}\n {...props}\n inputValue={inputValue}\n open={isOpen}\n options={suggestions}\n loading={isLoading}\n onOpen={() => {\n setOpen(true);\n }}\n onClose={() => {\n setOpen(false);\n }}\n onInputChange={(evt, val) => {\n setInputValue(val);\n }}\n />\n );\n}\n\nStopsFinder.propTypes = {\n /**\n * Array or a comma separated list of agencies which should be available.\n * Order of these agencies chooses which agency will be preferred.\n * Available values : sbb, db\n */\n agencies: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * geOps api key to access the StopsFinder service.\n */\n apiKey: PropTypes.string,\n\n /**\n * Properties apply to the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.\n */\n textFieldProps: PropTypes.object,\n\n /**\n * minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.\n */\n bbox: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Array or a comma separated list of fields which should be used for look up.\n * Available values : id, name, coords\n */\n field: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Control how many matches will be returned.\n */\n limit: PropTypes.number,\n\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Array or a comma separated list of mode of transpaorts which should be available.\n * Available values : bus, ferry, gondola, tram, rail, funicular, cable_car, subway\n */\n mots: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Function called when a suggestion is selected.\n */\n onSelect: PropTypes.func,\n\n /**\n * Radius around refLocation in meters that is most relevant.\n * Used as granularity for location rank.\n */\n radius: PropTypes.number,\n\n /**\n * Coordinates in WGS84 (in lat,lon order) used to rank stops close to this position higher.\n * Available values : id, name, coords\n */\n refLocation: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Function to render a different autocomplete input than the default one.\n */\n renderAutocomplete: PropTypes.func,\n\n /**\n * Url of the geOps StopsFinder service.\n */\n url: PropTypes.string,\n};\n\nexport default StopsFinder;\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,SAAS,SAAS,UAAU,iBAAiB;AACpD,OAAO,eAAe;AACtB,SAAS,cAAc,qBAAqB,cAAc;AAC1D,SAAS,gBAAgB;AACzB,OAAO,eAAe;AACtB,OAAO,sBAAsB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,WAAW;AACpB,OAAO,uBAAuB;AAE9B,MAAM,qBAAqB,OAAO,YAAY,EAAE,OAAO;AAAA,EACrD,CAAC,MAAM,oBAAoB,kBAAkB,EAAE,GAAG;AAAA,IAChD,WAAW;AAAA,EACb;AACF,EAAE;AAEF,MAAM,eAAe;AAAA,EACnB,gBAAgB,CAAC;AACnB;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB,aAAa;AAAA,EA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ED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"name": "react-spatial",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Components to build React map apps.",
|
|
5
|
-
"version": "1.11.
|
|
5
|
+
"version": "1.11.3",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@emotion/react": "^11.11.4",
|
|
8
8
|
"@emotion/styled": "^11.11.5",
|
|
9
9
|
"@geops/geops-ui": "0.3.2",
|
|
10
|
-
"@mui/icons-material": "^5.15.
|
|
11
|
-
"@mui/material": "^5.15.
|
|
12
|
-
"re-resizable": "6.9.
|
|
10
|
+
"@mui/icons-material": "^5.15.20",
|
|
11
|
+
"@mui/material": "^5.15.20",
|
|
12
|
+
"re-resizable": "6.9.17",
|
|
13
13
|
"react-icons": "5.2.1",
|
|
14
14
|
"resize-observer-polyfill": "1.5.1"
|
|
15
15
|
},
|
|
@@ -22,30 +22,31 @@
|
|
|
22
22
|
"react-dom": "^18"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/preset-env": "7.24.
|
|
26
|
-
"@babel/preset-react": "7.24.
|
|
25
|
+
"@babel/preset-env": "7.24.7",
|
|
26
|
+
"@babel/preset-react": "7.24.7",
|
|
27
27
|
"@cfaester/enzyme-adapter-react-18": "0.8.0",
|
|
28
28
|
"@commitlint/cli": "19.3.0",
|
|
29
29
|
"@commitlint/config-conventional": "19.2.2",
|
|
30
30
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
31
31
|
"@svgr/webpack": "8.1.0",
|
|
32
|
-
"@testing-library/
|
|
33
|
-
"@testing-library/
|
|
32
|
+
"@testing-library/dom": "^10.1.0",
|
|
33
|
+
"@testing-library/jest-dom": "6.4.6",
|
|
34
|
+
"@testing-library/react": "16.0.0",
|
|
34
35
|
"@testing-library/user-event": "14.5.2",
|
|
35
36
|
"babel-jest": "29.7.0",
|
|
36
37
|
"babel-loader": "9.1.3",
|
|
37
38
|
"canvas": "2.11.2",
|
|
38
|
-
"css-loader": "7.1.
|
|
39
|
+
"css-loader": "7.1.2",
|
|
39
40
|
"enzyme": "3.11.0",
|
|
40
|
-
"esbuild": "^0.21.
|
|
41
|
-
"esbuild-loader": "^4.
|
|
41
|
+
"esbuild": "^0.21.5",
|
|
42
|
+
"esbuild-loader": "^4.2.0",
|
|
42
43
|
"eslint": "8",
|
|
43
44
|
"eslint-config-airbnb": "19.0.4",
|
|
44
45
|
"eslint-config-prettier": "9.1.0",
|
|
45
46
|
"eslint-plugin-import": "2.29.1",
|
|
46
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
47
|
+
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
47
48
|
"eslint-plugin-prettier": "5.1.3",
|
|
48
|
-
"eslint-plugin-react": "7.34.
|
|
49
|
+
"eslint-plugin-react": "7.34.3",
|
|
49
50
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
50
51
|
"file-loader": "6.2.0",
|
|
51
52
|
"fixpack": "4.0.0",
|
|
@@ -62,13 +63,13 @@
|
|
|
62
63
|
"jest-transform-file": "1.1.1",
|
|
63
64
|
"jest-transformer-svg": "^2.0.2",
|
|
64
65
|
"jsts": "2.11.3",
|
|
65
|
-
"lint-staged": "15.2.
|
|
66
|
+
"lint-staged": "15.2.7",
|
|
66
67
|
"mapbox-gl": "1.13.1",
|
|
67
|
-
"maplibre-gl": "4.
|
|
68
|
-
"mobility-toolbox-js": "2.4.
|
|
69
|
-
"ol": "
|
|
68
|
+
"maplibre-gl": "4.4.1",
|
|
69
|
+
"mobility-toolbox-js": "2.4.2",
|
|
70
|
+
"ol": "9.2.4",
|
|
70
71
|
"postcss": "^8.4.38",
|
|
71
|
-
"prettier": "3.2
|
|
72
|
+
"prettier": "3.3.2",
|
|
72
73
|
"proj4": "2.11.0",
|
|
73
74
|
"prop-types": "15.8.1",
|
|
74
75
|
"react": "18.3.1",
|
|
@@ -76,19 +77,19 @@
|
|
|
76
77
|
"react-styleguidist": "13.1.2",
|
|
77
78
|
"react-svg-loader": "3.0.3",
|
|
78
79
|
"react-test-renderer": "18.3.1",
|
|
79
|
-
"sass": "1.77.
|
|
80
|
+
"sass": "1.77.6",
|
|
80
81
|
"sass-loader": "14.2.1",
|
|
81
82
|
"standard-version": "9.5.0",
|
|
82
83
|
"stream-array": "1.1.2",
|
|
83
84
|
"style-loader": "4.0.0",
|
|
84
|
-
"stylelint": "16.
|
|
85
|
+
"stylelint": "16.6.1",
|
|
85
86
|
"stylelint-config-recommended-scss": "14.0.0",
|
|
86
87
|
"stylelint-config-standard": "36.0.0",
|
|
87
|
-
"stylelint-scss": "6.3.
|
|
88
|
+
"stylelint-scss": "6.3.2",
|
|
88
89
|
"terser-webpack-plugin": "^5.3.10",
|
|
89
90
|
"url-loader": "4.1.1",
|
|
90
91
|
"vinyl-fs": "4.0.0",
|
|
91
|
-
"webpack": "^5.
|
|
92
|
+
"webpack": "^5.92.1",
|
|
92
93
|
"xml-beautifier": "0.5.0"
|
|
93
94
|
},
|
|
94
95
|
"scripts": {
|
package/utils/KML.js
CHANGED
|
@@ -73,13 +73,25 @@ const sanitizeFeature = (feature, doNotRevert32pxScaling = false) => {
|
|
|
73
73
|
const tmpStyles = styles(feature);
|
|
74
74
|
const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();
|
|
75
75
|
let stroke = style.getStroke();
|
|
76
|
-
if (
|
|
77
|
-
stroke.
|
|
76
|
+
if (feature.get("lineCap")) {
|
|
77
|
+
stroke?.setLineCap(feature.get("lineCap"));
|
|
78
|
+
}
|
|
79
|
+
if (feature.get("lineJoin")) {
|
|
80
|
+
stroke?.setLineJoin(feature.get("lineJoin"));
|
|
81
|
+
}
|
|
82
|
+
if (feature.get("lineDash")) {
|
|
83
|
+
stroke?.setLineDash(
|
|
78
84
|
feature.get("lineDash").split(",").map((l) => {
|
|
79
85
|
return parseInt(l, 10);
|
|
80
86
|
})
|
|
81
87
|
);
|
|
82
88
|
}
|
|
89
|
+
if (feature.get("lineDashOffset")) {
|
|
90
|
+
stroke?.setLineDashOffset(parseInt(feature.get("lineDashOffset"), 10));
|
|
91
|
+
}
|
|
92
|
+
if (feature.get("miterLimit")) {
|
|
93
|
+
stroke?.setMiterLimit(parseInt(feature.get("miterLimit"), 10));
|
|
94
|
+
}
|
|
83
95
|
if (stroke && stroke.getWidth() === 0) {
|
|
84
96
|
stroke = void 0;
|
|
85
97
|
}
|
|
@@ -117,6 +129,18 @@ const sanitizeFeature = (feature, doNotRevert32pxScaling = false) => {
|
|
|
117
129
|
// stroke: style.getText().getStroke(),
|
|
118
130
|
scale: style.getText().getScale()
|
|
119
131
|
});
|
|
132
|
+
if (feature.get("textArray")) {
|
|
133
|
+
try {
|
|
134
|
+
const textArray = JSON.parse(feature.get("textArray"));
|
|
135
|
+
text.setText(textArray);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error(
|
|
138
|
+
"Error parsing textArray",
|
|
139
|
+
feature.get("textArray"),
|
|
140
|
+
err
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
120
144
|
if (feature.get("textStrokeColor") && feature.get("textStrokeWidth")) {
|
|
121
145
|
text.setStroke(
|
|
122
146
|
new Stroke({
|
|
@@ -304,25 +328,35 @@ const writeFeatures = (layer, featureProjection, mapResolution) => {
|
|
|
304
328
|
if (newStyle.zIndex) {
|
|
305
329
|
clone.set("zIndex", newStyle.zIndex);
|
|
306
330
|
}
|
|
307
|
-
|
|
308
|
-
|
|
331
|
+
const text = newStyle.text?.getText();
|
|
332
|
+
if (text) {
|
|
333
|
+
let kmlText = text;
|
|
334
|
+
if (Array.isArray(text)) {
|
|
335
|
+
clone.set("textArray", JSON.stringify(text));
|
|
336
|
+
kmlText = text.map((t, idx) => {
|
|
337
|
+
return idx % 2 === 0 ? t : "";
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (/^\s|\s$/g.test(kmlText)) {
|
|
341
|
+
newStyle.text.setText(`\u200B${kmlText}\u200B`);
|
|
342
|
+
}
|
|
309
343
|
}
|
|
310
|
-
if (newStyle.text
|
|
344
|
+
if (newStyle.text?.getRotation()) {
|
|
311
345
|
clone.set("textRotation", newStyle.text.getRotation());
|
|
312
346
|
}
|
|
313
|
-
if (newStyle.text
|
|
347
|
+
if (newStyle.text?.getFont()) {
|
|
314
348
|
clone.set("textFont", newStyle.text.getFont());
|
|
315
349
|
}
|
|
316
|
-
if (newStyle.text
|
|
350
|
+
if (newStyle.text?.getTextAlign()) {
|
|
317
351
|
clone.set("textAlign", newStyle.text.getTextAlign());
|
|
318
352
|
}
|
|
319
|
-
if (newStyle.text
|
|
353
|
+
if (newStyle.text?.getOffsetX()) {
|
|
320
354
|
clone.set("textOffsetX", newStyle.text.getOffsetX());
|
|
321
355
|
}
|
|
322
|
-
if (newStyle.text
|
|
356
|
+
if (newStyle.text?.getOffsetY()) {
|
|
323
357
|
clone.set("textOffsetY", newStyle.text.getOffsetY());
|
|
324
358
|
}
|
|
325
|
-
if (newStyle.text
|
|
359
|
+
if (newStyle.text?.getStroke()) {
|
|
326
360
|
if (newStyle.text.getStroke().getColor()) {
|
|
327
361
|
clone.set(
|
|
328
362
|
"textStrokeColor",
|
|
@@ -333,18 +367,30 @@ const writeFeatures = (layer, featureProjection, mapResolution) => {
|
|
|
333
367
|
clone.set("textStrokeWidth", newStyle.text.getStroke().getWidth());
|
|
334
368
|
}
|
|
335
369
|
}
|
|
336
|
-
if (newStyle.text
|
|
370
|
+
if (newStyle.text?.getBackgroundFill()) {
|
|
337
371
|
clone.set(
|
|
338
372
|
"textBackgroundFillColor",
|
|
339
373
|
asString(newStyle.text.getBackgroundFill().getColor())
|
|
340
374
|
);
|
|
341
375
|
}
|
|
342
|
-
if (newStyle.text
|
|
376
|
+
if (newStyle.text?.getPadding()) {
|
|
343
377
|
clone.set("textPadding", newStyle.text.getPadding().join());
|
|
344
378
|
}
|
|
345
|
-
if (newStyle.stroke
|
|
379
|
+
if (newStyle.stroke?.getLineCap()) {
|
|
380
|
+
clone.set("lineCap", newStyle.stroke.getLineCap());
|
|
381
|
+
}
|
|
382
|
+
if (newStyle.stroke?.getLineJoin()) {
|
|
383
|
+
clone.set("lineJoin", newStyle.stroke.getLineJoin());
|
|
384
|
+
}
|
|
385
|
+
if (newStyle.stroke?.getLineDash()) {
|
|
346
386
|
clone.set("lineDash", newStyle.stroke.getLineDash().join(","));
|
|
347
387
|
}
|
|
388
|
+
if (newStyle.stroke?.getLineDashOffset()) {
|
|
389
|
+
clone.set("lineDashOffset", newStyle.stroke.getLineDashOffset());
|
|
390
|
+
}
|
|
391
|
+
if (newStyle.stroke?.getMiterLimit()) {
|
|
392
|
+
clone.set("miterLimit", newStyle.stroke.getMiterLimit());
|
|
393
|
+
}
|
|
348
394
|
if (newStyle.image instanceof Circle) {
|
|
349
395
|
newStyle.image = null;
|
|
350
396
|
}
|
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, getUid } 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 { fromCircle } from \"ol/geom/Polygon\";\nimport { transform, get } from \"ol/proj\";\nimport CircleGeom from \"ol/geom/Circle\";\nimport { kmlStyle } from \"./Styles\";\nimport getPolygonPattern from \"./getPolygonPattern\";\n\nconst CIRCLE_GEOMETRY_CENTER = \"circleGeometryCenter\";\nconst CIRCLE_GEOMETRY_RADIUS = \"circleGeometryRadius\";\nconst EPSG_4326 = get(\"EPSG:4326\");\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 for OL > 6.7\n // If an IconStyle has no gx:w and gx:h defined, a scale factor is applied\n // after the image is loaded. To avoided having the scale factor applied we\n // clone the style and keep the scale as it is.\n // Having gx:w and gx:h not defined should not happen, using the last version of the parser/reader.\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 only if the image has a size defined.\n } else if (!doNotRevert32pxScaling && image.getSize()) {\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 // Transform back polygon to circle geometry\n const {\n [CIRCLE_GEOMETRY_CENTER]: circleGeometryCenter,\n [CIRCLE_GEOMETRY_RADIUS]: circleGeometryRadius,\n } = feature?.getProperties() || {};\n if (circleGeometryCenter && circleGeometryRadius) {\n const circle = new CircleGeom(\n transform(\n JSON.parse(circleGeometryCenter),\n EPSG_4326,\n featureProjection || EPSG_4326,\n ),\n parseFloat(circleGeometryRadius, 10),\n );\n circle.setProperties(feature.getGeometry().getProperties());\n feature.setGeometry(circle);\n }\n\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().getFeatures()]\n .sort((a, b) => {\n // The order of features must be kept.\n // We could use the useSpatialIndex = false property on the layer\n // but we prefer to sort feature by ol uid because ol uid is an integer\n // increased on each creation of a feature.\n // So we will keep the order of creation made by the the KML parser.\n // Ideally we should order by the zIndex of the style only.\n if (getUid(a) <= getUid(b)) {\n return -1;\n }\n return 1;\n })\n .forEach((feature) => {\n const clone = feature.clone();\n if (clone.getGeometry().getType() === \"Circle\") {\n // We transform circle elements into polygons\n // because circle not supported in KML spec and in ol KML parser\n const circleGeom = feature.getGeometry();\n clone.setGeometry(fromCircle(circleGeom, 100));\n clone.set(\n CIRCLE_GEOMETRY_CENTER,\n JSON.stringify(\n transform(circleGeom.getCenter(), featureProjection, EPSG_4326),\n ),\n );\n clone.set(CIRCLE_GEOMETRY_RADIUS, circleGeom.getRadius());\n }\n clone.setId(feature.getId());\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 (\n ![\n \"geometry\",\n \"name\",\n \"description\",\n CIRCLE_GEOMETRY_CENTER,\n CIRCLE_GEOMETRY_RADIUS,\n ].includes(key)\n ) {\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\nexport default {\n readFeatures,\n writeFeatures,\n writeDocumentCamera,\n removeDocumentCamera,\n};\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS;AAChB,SAAS,SAAS,cAAc;AAChC,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAC/B,SAAS,OAAO,MAAM,MAAM,QAAQ,MAAM,cAAc;AACxD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,WAAW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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,eAAe;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
4
|
+
"sourcesContent": ["import KML from \"ol/format/KML\";\nimport { Feature, getUid } 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 { fromCircle } from \"ol/geom/Polygon\";\nimport { transform, get } from \"ol/proj\";\nimport CircleGeom from \"ol/geom/Circle\";\nimport { kmlStyle } from \"./Styles\";\nimport getPolygonPattern from \"./getPolygonPattern\";\n\nconst CIRCLE_GEOMETRY_CENTER = \"circleGeometryCenter\";\nconst CIRCLE_GEOMETRY_RADIUS = \"circleGeometryRadius\";\nconst EPSG_4326 = get(\"EPSG:4326\");\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 for OL > 6.7\n // If an IconStyle has no gx:w and gx:h defined, a scale factor is applied\n // after the image is loaded. To avoided having the scale factor applied we\n // clone the style and keep the scale as it is.\n // Having gx:w and gx:h not defined should not happen, using the last version of the parser/reader.\n const tmpStyles = styles(feature);\n const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();\n\n let stroke = style.getStroke();\n\n if (feature.get(\"lineCap\")) {\n stroke?.setLineCap(feature.get(\"lineCap\"));\n }\n\n if (feature.get(\"lineJoin\")) {\n stroke?.setLineJoin(feature.get(\"lineJoin\"));\n }\n\n if (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 if (feature.get(\"lineDashOffset\")) {\n stroke?.setLineDashOffset(parseInt(feature.get(\"lineDashOffset\"), 10));\n }\n\n if (feature.get(\"miterLimit\")) {\n stroke?.setMiterLimit(parseInt(feature.get(\"miterLimit\"), 10));\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(\"textArray\")) {\n try {\n const textArray = JSON.parse(feature.get(\"textArray\"));\n text.setText(textArray);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n \"Error parsing textArray\",\n feature.get(\"textArray\"),\n err,\n );\n }\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 only if the image has a size defined.\n } else if (!doNotRevert32pxScaling && image.getSize()) {\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 // Transform back polygon to circle geometry\n const {\n [CIRCLE_GEOMETRY_CENTER]: circleGeometryCenter,\n [CIRCLE_GEOMETRY_RADIUS]: circleGeometryRadius,\n } = feature?.getProperties() || {};\n if (circleGeometryCenter && circleGeometryRadius) {\n const circle = new CircleGeom(\n transform(\n JSON.parse(circleGeometryCenter),\n EPSG_4326,\n featureProjection || EPSG_4326,\n ),\n parseFloat(circleGeometryRadius, 10),\n );\n circle.setProperties(feature.getGeometry().getProperties());\n feature.setGeometry(circle);\n }\n\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().getFeatures()]\n .sort((a, b) => {\n // The order of features must be kept.\n // We could use the useSpatialIndex = false property on the layer\n // but we prefer to sort feature by ol uid because ol uid is an integer\n // increased on each creation of a feature.\n // So we will keep the order of creation made by the the KML parser.\n // Ideally we should order by the zIndex of the style only.\n if (getUid(a) <= getUid(b)) {\n return -1;\n }\n return 1;\n })\n .forEach((feature) => {\n const clone = feature.clone();\n if (clone.getGeometry().getType() === \"Circle\") {\n // We transform circle elements into polygons\n // because circle not supported in KML spec and in ol KML parser\n const circleGeom = feature.getGeometry();\n clone.setGeometry(fromCircle(circleGeom, 100));\n clone.set(\n CIRCLE_GEOMETRY_CENTER,\n JSON.stringify(\n transform(circleGeom.getCenter(), featureProjection, EPSG_4326),\n ),\n );\n clone.set(CIRCLE_GEOMETRY_RADIUS, circleGeom.getRadius());\n }\n clone.setId(feature.getId());\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 (\n ![\n \"geometry\",\n \"name\",\n \"description\",\n CIRCLE_GEOMETRY_CENTER,\n CIRCLE_GEOMETRY_RADIUS,\n ].includes(key)\n ) {\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 const text = newStyle.text?.getText();\n if (text) {\n let kmlText = text;\n\n if (Array.isArray(text)) {\n // text can be a string or an array of strings\n clone.set(\"textArray\", JSON.stringify(text));\n\n // in the KML we just add the text without the bold or italic information\n kmlText = text.map((t, idx) => {\n return idx % 2 === 0 ? t : \"\";\n });\n }\n\n if (/^\\s|\\s$/g.test(kmlText)) {\n newStyle.text.setText(`\\u200B${kmlText}\\u200B`);\n }\n }\n\n // Set custom properties to be converted in extendedData in KML.\n if (newStyle.text?.getRotation()) {\n clone.set(\"textRotation\", newStyle.text.getRotation());\n }\n\n if (newStyle.text?.getFont()) {\n clone.set(\"textFont\", newStyle.text.getFont());\n }\n\n if (newStyle.text?.getTextAlign()) {\n clone.set(\"textAlign\", newStyle.text.getTextAlign());\n }\n\n if (newStyle.text?.getOffsetX()) {\n clone.set(\"textOffsetX\", newStyle.text.getOffsetX());\n }\n\n if (newStyle.text?.getOffsetY()) {\n clone.set(\"textOffsetY\", newStyle.text.getOffsetY());\n }\n\n if (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?.getBackgroundFill()) {\n clone.set(\n \"textBackgroundFillColor\",\n asString(newStyle.text.getBackgroundFill().getColor()),\n );\n }\n\n if (newStyle.text?.getPadding()) {\n clone.set(\"textPadding\", newStyle.text.getPadding().join());\n }\n\n if (newStyle.stroke?.getLineCap()) {\n clone.set(\"lineCap\", newStyle.stroke.getLineCap());\n }\n\n if (newStyle.stroke?.getLineJoin()) {\n clone.set(\"lineJoin\", newStyle.stroke.getLineJoin());\n }\n\n if (newStyle.stroke?.getLineDash()) {\n clone.set(\"lineDash\", newStyle.stroke.getLineDash().join(\",\"));\n }\n\n if (newStyle.stroke?.getLineDashOffset()) {\n clone.set(\"lineDashOffset\", newStyle.stroke.getLineDashOffset());\n }\n\n if (newStyle.stroke?.getMiterLimit()) {\n clone.set(\"miterLimit\", newStyle.stroke.getMiterLimit());\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\nexport default {\n readFeatures,\n writeFeatures,\n writeDocumentCamera,\n removeDocumentCamera,\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS;AAChB,SAAS,SAAS,cAAc;AAChC,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAC/B,SAAS,OAAO,MAAM,MAAM,QAAQ,MAAM,cAAc;AACxD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,WAAW,WAAW;AAC/B,OAAO,gBAAgB;AACvB,S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