react-spatial 1.10.1 → 1.10.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +2 -2
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +2 -2
- package/components/BasicMap/BasicMap.js +7 -19
- package/components/BasicMap/BasicMap.js.map +2 -2
- package/components/Copyright/Copyright.js +15 -26
- package/components/Copyright/Copyright.js.map +2 -2
- package/components/FeatureExportButton/FeatureExportButton.js +2 -2
- package/components/FeatureExportButton/FeatureExportButton.js.map +2 -2
- package/components/LayerTree/LayerTree.js +89 -23
- package/components/LayerTree/LayerTree.js.map +2 -2
- package/components/Permalink/Permalink.js +18 -13
- package/components/Permalink/Permalink.js.map +2 -2
- package/components/StopsFinder/StopsFinder.js +2 -2
- package/components/StopsFinder/StopsFinder.js.map +2 -2
- package/package.json +2 -2
- package/utils/KML.js +1 -1
- package/utils/KML.js.map +2 -2
- package/utils/getLayersAsFlatArray.js +14 -0
- package/utils/getLayersAsFlatArray.js.map +7 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/LayerTree/LayerTree.js"],
|
|
4
|
-
"sourcesContent": ["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Layer, getLayersAsFlatArray } from \"mobility-toolbox-js/ol\";\nimport { unByKey } from \"ol/Observable\";\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Custom function to render the checkbox.\n */\n renderCheckbox: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: \"rs-layer-tree\",\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderCheckbox: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: \"Show layer\",\n layerHide: \"Hide layer\",\n subLayerShow: \"Show sublayer\",\n subLayerHide: \"Hide sublayer\",\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return l.children.filter((c) => {\n return !isItemHidden(c) && c.get(\"isAlwaysExpanded\");\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayers() {\n const { layers, expandChildren } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer();\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\n .filter((c) => {\n return !isItemHidden(c) && !c.get(\"isAlwaysExpanded\");\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer, inputProps) {\n const { titles, isItemHidden, renderCheckbox } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get(\"group\") ? \"radio\" : \"checkbox\";\n return renderCheckbox ? (\n renderCheckbox(layer, this, inputProps)\n ) : (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get(\"isAlwaysExpanded\")\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? \"collapsed\" : \"expanded\"\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? \"rs-visible\" : \"\"}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,
|
|
4
|
+
"sourcesContent": ["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { unByKey } from \"ol/Observable\";\nimport Layer from \"ol/layer/Layer\";\nimport getLayersAsFlatArray from \"../../utils/getLayersAsFlatArray\";\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Custom function to render the checkbox.\n */\n renderCheckbox: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: \"rs-layer-tree\",\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderCheckbox: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: \"Show layer\",\n layerHide: \"Hide layer\",\n subLayerShow: \"Show sublayer\",\n subLayerHide: \"Hide sublayer\",\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n static getChildren = (layer) =>\n layer?.children ||\n layer?.get(\"children\") ||\n // ol.layer.group\n layer?.getLayers?.().getArray() ||\n [];\n\n static getVisible = (layer) =>\n layer.getVisible ? layer.getVisible() : layer.visible;\n\n static setVisible = (layer, visible) => {\n if (layer.setVisible) {\n layer.setVisible(visible);\n return;\n }\n // eslint-disable-next-line no-param-reassign\n layer.visible = visible;\n };\n\n static listenGroups = (layers) => {\n const flat = getLayersAsFlatArray(layers);\n const keys = flat.map((layer) => {\n return layer.on(\"change:visible\", (e) => {\n const { target } = e;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n });\n });\n return keys;\n };\n\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n LayerTree.getChildren(l)\n .filter((child) => {\n return LayerTree.getVisible(child);\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer({}),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else {\n LayerTree.setVisible(layer, !LayerTree.getVisible(layer));\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return LayerTree.getChildren(l).filter((c) => {\n return !isItemHidden(c) && c.get(\"isAlwaysExpanded\");\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayers() {\n const { layers, expandChildren } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer({});\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n const flat = getLayersAsFlatArray(rootLayer);\n flat.forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n\n // Manage group visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n }),\n\n // Manage parent/children visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n const parent = target.get(\"parent\");\n const children = LayerTree.getChildren(target);\n\n if (target.getVisible()) {\n // We make the parent visible\n if (parent) {\n parent.setVisible(true);\n }\n\n // If children doesn't contain any visible layers, we display all children.\n if (children && !children.some((child) => child.getVisible())) {\n children.forEach((child) => {\n child.setVisible(true);\n });\n }\n } else {\n // We hide all the children\n children.forEach((child) => {\n child.setVisible(false);\n });\n\n // If the parent has no more visible child we also hide it.\n if (\n parent?.getVisible() &&\n !parent?.get(\"children\").find((child) => child.getVisible())\n ) {\n parent.setVisible(false);\n }\n }\n }),\n );\n });\n\n // Set parent property.\n flat.forEach((layer) => {\n const children = LayerTree.getChildren(layer);\n children.forEach((child) => {\n child.set(\"parent\", layer);\n });\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n const children = LayerTree.getChildren(rootLayer);\n state.expandedLayers = children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (LayerTree.getVisible(layer) && !isItemHidden(layer)) {\n const children = LayerTree.getChildren(layer)\n .filter((c) => {\n return !isItemHidden(c) && !c.get(\"isAlwaysExpanded\");\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer, inputProps) {\n const { titles, isItemHidden, renderCheckbox } = this.props;\n let tabIndex = 0;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get(\"group\") ? \"radio\" : \"checkbox\";\n return renderCheckbox ? (\n renderCheckbox(layer, this, inputProps)\n ) : (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={\n LayerTree.getVisible(layer) ? titles.layerHide : titles.layerShow\n }\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={LayerTree.getVisible(layer)}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get(\"isAlwaysExpanded\")\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? \"collapsed\" : \"expanded\"\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${LayerTree.getVisible(layer) ? \"rs-visible\" : \"\"}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!LayerTree.getChildren(rootLayer).length) {\n return null;\n }\n\n return (\n <>\n {LayerTree.getChildren(rootLayer)\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,0BAA0B;AAEjC,M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E3B,QAAI,CAAC,UAAU,YAAY,SAAS,EAAE,QAAQ;AAC5C,aAAO;AAAA,IACT;AAEA,WACE,0DACG,UAAU,YAAY,SAAS,EAC7B,OAAO,CAAC,MAAM;AACb,aAAO,CAAC,aAAa,CAAC;AAAA,IACxB,CAAC,EACA,QAAQ,EACR,IAAI,CAAC,MAAM;AACV,aAAO,KAAK,WAAW,GAAG,CAAC;AAAA,IAC7B,CAAC,CACL;AAAA,EAEJ;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,oCAAC,SAAI,aAAuB,KAAK,WAAW,CAAE;AAAA,EACvD;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,8 @@ import { PureComponent } from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import OLMap from "ol/Map";
|
|
4
4
|
import { unByKey } from "ol/Observable";
|
|
5
|
-
import
|
|
5
|
+
import Layer from "ol/layer/Layer";
|
|
6
|
+
import getLayersAsFlatArray from "../../utils/getLayersAsFlatArray";
|
|
6
7
|
const propTypes = {
|
|
7
8
|
/**
|
|
8
9
|
* Either 'react-router' history object:
|
|
@@ -83,14 +84,14 @@ class Permalink extends PureComponent {
|
|
|
83
84
|
if (urlParams.get("layers")) {
|
|
84
85
|
const visibleLayers = urlParams.get("layers").split(",");
|
|
85
86
|
getLayersAsFlatArray(layers).forEach((l) => {
|
|
86
|
-
if (visibleLayers.includes(l.key)) {
|
|
87
|
+
if (visibleLayers.includes(l.key || l.get("key"))) {
|
|
87
88
|
if (l.setVisible) {
|
|
88
89
|
l.setVisible(true);
|
|
89
90
|
} else {
|
|
90
91
|
l.visible = true;
|
|
91
92
|
}
|
|
92
|
-
} else if (!isBaseLayer(l) && !isLayerHidden(l) && !l.children.some((ll) => {
|
|
93
|
-
return ll.visible;
|
|
93
|
+
} else if (!isBaseLayer(l) && !isLayerHidden(l) && !(l.children || l.get("children")).some((ll) => {
|
|
94
|
+
return ll.getVisible ? ll.getVisible() : ll.visible;
|
|
94
95
|
})) {
|
|
95
96
|
if (l.setVisible) {
|
|
96
97
|
l.setVisible(false);
|
|
@@ -105,7 +106,8 @@ class Permalink extends PureComponent {
|
|
|
105
106
|
)[0];
|
|
106
107
|
if (visibleBaseLayer) {
|
|
107
108
|
getLayersAsFlatArray(layers).filter(isBaseLayer).forEach((baseLayer) => {
|
|
108
|
-
const
|
|
109
|
+
const key = baseLayer.key || baseLayer.get("key");
|
|
110
|
+
const visible = key === visibleBaseLayer;
|
|
109
111
|
if (baseLayer.setVisible) {
|
|
110
112
|
baseLayer.setVisible(visible);
|
|
111
113
|
} else {
|
|
@@ -174,32 +176,35 @@ class Permalink extends PureComponent {
|
|
|
174
176
|
return isLayerHidden(child);
|
|
175
177
|
});
|
|
176
178
|
const hasVisibleChildren = children.some((child) => {
|
|
177
|
-
return child.visible;
|
|
179
|
+
return child.getVisible ? child.getVisible() : child.visible;
|
|
178
180
|
});
|
|
179
|
-
|
|
181
|
+
const isVisible = l.getVisible ? l.getVisible() : l.visible;
|
|
182
|
+
return !isBaseLayer(l) && !isLayerHidden(l) && isVisible && (!hasVisibleChildren || allChildrenHidden);
|
|
180
183
|
}).map((l) => {
|
|
181
|
-
return l.key;
|
|
184
|
+
return l.key || l.get("key");
|
|
182
185
|
}).join();
|
|
183
186
|
}
|
|
184
187
|
let baseLayersParam;
|
|
185
188
|
const baseLayers = getLayersAsFlatArray(layers).filter(isBaseLayer);
|
|
186
189
|
if (baseLayers.length) {
|
|
187
190
|
const visibleBaseLayers = (baseLayers.filter((l) => {
|
|
188
|
-
return l.visible;
|
|
191
|
+
return l.getVisible ? l.getVisible() : l.visible;
|
|
189
192
|
}) || []).reverse();
|
|
190
193
|
const nonVisibleBaseLayers = baseLayers.filter((l) => {
|
|
191
|
-
return !l.visible;
|
|
194
|
+
return !(l.getVisible ? l.getVisible() : l.visible);
|
|
192
195
|
}) || [];
|
|
193
196
|
baseLayersParam = [...visibleBaseLayers, ...nonVisibleBaseLayers].sort((a, b) => {
|
|
194
|
-
|
|
197
|
+
const aVisible = a.getVisible ? a.getVisible() : a.visible;
|
|
198
|
+
const bVisible = b.getVisible ? b.getVisible() : b.visible;
|
|
199
|
+
if (aVisible === bVisible) {
|
|
195
200
|
return 0;
|
|
196
201
|
}
|
|
197
|
-
if (
|
|
202
|
+
if (aVisible && !bVisible) {
|
|
198
203
|
return -1;
|
|
199
204
|
}
|
|
200
205
|
return 1;
|
|
201
206
|
}).map((l) => {
|
|
202
|
-
return l.key;
|
|
207
|
+
return l.key || l.get("key");
|
|
203
208
|
}).join();
|
|
204
209
|
}
|
|
205
210
|
this.setState({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Permalink/Permalink.js"],
|
|
4
|
-
"sourcesContent": ["import { PureComponent } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport
|
|
5
|
-
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,
|
|
4
|
+
"sourcesContent": ["import { PureComponent } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport Layer from \"ol/layer/Layer\";\nimport getLayersAsFlatArray from \"../../utils/getLayersAsFlatArray\";\n\nconst propTypes = {\n /**\n * Either 'react-router' history object:\n * https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/history.md<br>\n * or default fallback as HTML5 History:\n * https://developer.mozilla.org/en-US/docs/Web/API/History\n */\n history: PropTypes.shape({\n replace: PropTypes.func,\n }),\n\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Params to be written in url.\n */\n params: PropTypes.object,\n\n /**\n * Maximum number of decimals allowed for coordinates.\n */\n coordinateDecimals: PropTypes.number,\n\n /**\n * Determine if the layer is hidden in the permalink or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the permalink\n */\n isLayerHidden: PropTypes.func,\n\n /**\n * Determine if the layer appears in the baselayers permalink parameter or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the baselayers permalink parameter\n */\n isBaseLayer: PropTypes.func,\n\n /**\n * Custom function to be called when the permalink is updated.\n * This property has priority over the history parameter and window.history.replaceState calls.\n */\n replace: PropTypes.func,\n};\n\nconst defaultProps = {\n history: null,\n replace: null,\n layers: [],\n map: null,\n params: {},\n coordinateDecimals: 2,\n isLayerHidden: () => {\n return false;\n },\n isBaseLayer: (layer) => {\n return layer.get(\"isBaseLayer\");\n },\n};\n\n/**\n * This component handles permalink logic. Injecting an\n * __[ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html)__\n * will add the *map center* (x, y) and the *zoom* (z) parameters to the permalink.\n * Injecting layers will add the *baselayers* and/or *layers* parameters. Further parameters can\n * be added using __params__.\n */\nclass Permalink extends PureComponent {\n constructor(props) {\n super(props);\n this.state = { revision: 0 };\n this.onPropertyChangeKeys = [];\n }\n\n componentDidMount() {\n const { map, layers, isLayerHidden, isBaseLayer } = this.props;\n if (map) {\n this.moveEndRef = map.on(\"moveend\", () => {\n this.onMapMoved();\n });\n }\n\n if (layers) {\n // set layer visibility based on 'layers' parameter.\n const urlParams = new URLSearchParams(window.location.search);\n\n if (urlParams.get(\"layers\")) {\n const visibleLayers = urlParams.get(\"layers\").split(\",\");\n getLayersAsFlatArray(layers).forEach((l) => {\n if (visibleLayers.includes(l.key || l.get(\"key\"))) {\n if (l.setVisible) {\n l.setVisible(true);\n } else {\n // eslint-disable-next-line no-param-reassign\n l.visible = true;\n }\n } else if (\n !isBaseLayer(l) &&\n !isLayerHidden(l) &&\n !(l.children || l.get(\"children\")).some((ll) => {\n return ll.getVisible ? ll.getVisible() : ll.visible;\n })\n ) {\n if (l.setVisible) {\n l.setVisible(false);\n } else {\n // eslint-disable-next-line no-param-reassign\n l.visible = false;\n }\n }\n });\n }\n\n // Set baser layer visibility based on 'baseLayers' parameter.\n // Show the first of the list then hide the others\n const visibleBaseLayer = (urlParams.get(\"baselayers\") || \"\").split(\n \",\",\n )[0];\n if (visibleBaseLayer) {\n getLayersAsFlatArray(layers)\n .filter(isBaseLayer)\n .forEach((baseLayer) => {\n const key = baseLayer.key || baseLayer.get(\"key\");\n const visible = key === visibleBaseLayer;\n if (baseLayer.setVisible) {\n baseLayer.setVisible(visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n baseLayer.visible = visible;\n }\n });\n }\n this.updateLayers();\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n const { map, layers } = this.props;\n const { revision } = this.state;\n\n if (layers !== prevProps.layers || revision !== prevState.revision) {\n this.updateLayers();\n }\n\n if (map !== prevProps.map) {\n unByKey(this.moveEndRef);\n this.moveEndRef = map.on(\"moveend\", () => {\n return this.onMapMoved();\n });\n }\n\n this.updateHistory();\n }\n\n componentWillUnmount() {\n const { map } = this.props;\n\n if (map) {\n unByKey(this.moveEndRef);\n }\n unByKey(this.onPropertyChangeKeys);\n this.onPropertyChangeKeys = [];\n }\n\n onMapMoved() {\n const { map } = this.props;\n const mapView = map.getView();\n const center = mapView.getCenter();\n const params = {};\n\n if (\n center !== undefined &&\n center[0] !== undefined &&\n center[1] !== undefined\n ) {\n params.x = this.roundCoord(center[0]);\n params.y = this.roundCoord(center[1]);\n }\n\n this.setState({\n ...params,\n // rounds zoom to two digits max.\n z: +`${Math.round(`${parseFloat(mapView.getZoom())}e+2`)}e-2`,\n });\n }\n\n roundCoord(val) {\n const { coordinateDecimals } = this.props;\n return parseFloat(val.toFixed(coordinateDecimals));\n }\n\n updateLayers() {\n const { layers, isLayerHidden, isBaseLayer } = this.props;\n const { revision } = this.state;\n\n unByKey(this.onPropertyChangeKeys);\n this.onPropertyChangeKeys = getLayersAsFlatArray(layers).map((layer) => {\n return layer.on(\"change:visible\", () => {\n this.setState({ revision: revision + 1 });\n });\n });\n\n // layers param\n let layersParam;\n if (layers.length) {\n layersParam = getLayersAsFlatArray(layers)\n .filter((l) => {\n const children = l.children || [];\n const allChildrenHidden = children.every((child) => {\n return isLayerHidden(child);\n });\n const hasVisibleChildren = children.some((child) => {\n return child.getVisible ? child.getVisible() : child.visible;\n });\n const isVisible = l.getVisible ? l.getVisible() : l.visible;\n return (\n !isBaseLayer(l) &&\n !isLayerHidden(l) &&\n isVisible &&\n (!hasVisibleChildren || allChildrenHidden)\n );\n })\n .map((l) => {\n return l.key || l.get(\"key\");\n })\n .join();\n }\n\n // baselayers param\n let baseLayersParam;\n const baseLayers = getLayersAsFlatArray(layers).filter(isBaseLayer);\n if (baseLayers.length) {\n // First baselayers in order of visibility, top layer is first\n const visibleBaseLayers = (\n baseLayers.filter((l) => {\n return l.getVisible ? l.getVisible() : l.visible;\n }) || []\n ).reverse();\n const nonVisibleBaseLayers =\n baseLayers.filter((l) => {\n return !(l.getVisible ? l.getVisible() : l.visible);\n }) || [];\n baseLayersParam = [...visibleBaseLayers, ...nonVisibleBaseLayers]\n .sort((a, b) => {\n const aVisible = a.getVisible ? a.getVisible() : a.visible;\n const bVisible = b.getVisible ? b.getVisible() : b.visible;\n if (aVisible === bVisible) {\n return 0;\n }\n if (aVisible && !bVisible) {\n return -1;\n }\n return 1;\n })\n .map((l) => {\n return l.key || l.get(\"key\");\n })\n .join();\n }\n\n // Only add parameters if there is actually some layers added.\n this.setState({\n layers: layersParam,\n baselayers: baseLayersParam,\n });\n }\n\n updateHistory() {\n const { params, history, replace } = this.props;\n const oldParams = new URLSearchParams(window.location.search);\n const parameters = {\n ...Object.fromEntries(oldParams.entries()),\n ...this.state,\n ...params,\n };\n\n delete parameters.revision;\n\n // Remove parameters that are undefined or null\n Object.entries(parameters).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n delete parameters[key];\n }\n });\n\n // We don't encode the , to leave the permalink lisible\n const qStr = new URLSearchParams(parameters)\n .toString()\n .replace(/%2C/g, \",\");\n const search = qStr ? `?${qStr}` : \"\";\n\n if (\n (!qStr && window.location.search) ||\n (qStr && search !== window.location.search)\n ) {\n if (replace) {\n replace({ parameters, search });\n } else if (history) {\n history.replace({ search });\n } else {\n const { hash } = window.location;\n window.history.replaceState(\n undefined,\n undefined,\n `${search}${hash || \"\"}`,\n );\n }\n }\n }\n\n render() {\n return null;\n }\n}\n\nPermalink.propTypes = propTypes;\nPermalink.defaultProps = defaultProps;\n\nexport default Permalink;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,0BAA0B;AAEjC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhB,SAAS,UAAU,MAAM;AAAA,IACvB,SAAS,UAAU;AAAA,EACrB,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,EAKrD,KAAK,UAAU,WAAW,KAAK;AAAA;AAAA;AAAA;AAAA,EAK/B,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA,EAKlB,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS9B,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzB,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,SAAS,UAAU;AACrB;AAEA,MAAM,eAAe;AAAA,EACnB,SAAS;AAAA,EACT,SAAS;AAAA,EACT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G;AAAA,MACvB;AAAA,IACF,CAAC;AAGD,UAAM,OAAO,IAAI,gBAAgB,UAAU,EACxC,SAAS,EACT,QAAQ,QAAQ,GAAG;AACtB,UAAM,SAAS,OAAO,IAAI,IAAI,KAAK;AAEnC,QACG,CAAC,QAAQ,OAAO,SAAS,UACzB,QAAQ,WAAW,OAAO,SAAS,QACpC;AACA,UAAI,SAAS;AACX,gBAAQ,EAAE,YAAY,OAAO,CAAC;AAAA,MAChC,WAAW,SAAS;AAClB,gBAAQ,QAAQ,EAAE,OAAO,CAAC;AAAA,MAC5B,OAAO;AACL,cAAM,EAAE,KAAK,IAAI,OAAO;AACxB,eAAO,QAAQ;AAAA,UACb;AAAA,UACA;AAAA,UACA,GAAG,MAAM,GAAG,QAAQ,EAAE;AAAA,QACxB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,EACT;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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
|
|
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;A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MAAM;AACd,QAAI,CAAC,SAAS;AACZ,aAAO,MAAM;AAAA,MAAC;AAAA,IAChB;AAEA,
|
|
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 map.addControl(control);\n\n return () => {\n map.removeControl(control);\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\nStopsFinder.defaultProps = {\n agencies: null,\n apiKey: null,\n textFieldProps: {},\n bbox: null,\n field: null,\n limit: null,\n mots: null,\n onSelect: null,\n radius: null,\n refLocation: null,\n url: null,\n renderAutocomplete: null,\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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AA,IACV,UAAU,QAAQ,UAAU,MAAM;AAAA,EACpC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK9B,KAAK,UAAU;AACjB;AAEA,YAAY,eAAe;AAAA,EACzB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB,CAAC;AAAA,EACjB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,KAAK;AAAA,EACL,oBAAoB;AACtB;AAEA,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-spatial",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Components to build React map apps.",
|
|
5
|
-
"version": "1.10.
|
|
5
|
+
"version": "1.10.2-beta.0",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@emotion/react": "^11.11.4",
|
|
8
8
|
"@emotion/styled": "^11.11.5",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"lint-staged": "15.2.2",
|
|
66
66
|
"mapbox-gl": "1.13.1",
|
|
67
67
|
"maplibre-gl": "4.2.0",
|
|
68
|
-
"mobility-toolbox-js": "
|
|
68
|
+
"mobility-toolbox-js": "3.0.0-beta.11",
|
|
69
69
|
"ol": "8.2.0",
|
|
70
70
|
"postcss": "^8.4.38",
|
|
71
71
|
"prettier": "3.2.5",
|
package/utils/KML.js
CHANGED
|
@@ -254,7 +254,7 @@ const readFeatures = (kmlString, featureProjection, doNotRevert32pxScaling = fal
|
|
|
254
254
|
};
|
|
255
255
|
const writeFeatures = (layer, featureProjection, mapResolution) => {
|
|
256
256
|
let featString;
|
|
257
|
-
const
|
|
257
|
+
const olLayer = layer.olLayer || layer;
|
|
258
258
|
const exportFeatures = [];
|
|
259
259
|
[...olLayer.getSource().getFeatures()].sort((a, b) => {
|
|
260
260
|
if (getUid(a) <= getUid(b)) {
|
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 line 156\n const tmpStyles = styles(feature);\n const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();\n\n let stroke = style.getStroke();\n if (stroke && feature.get(\"lineDash\")) {\n stroke.setLineDash(\n feature\n .get(\"lineDash\")\n .split(\",\")\n .map((l) => {\n return parseInt(l, 10);\n }),\n );\n }\n\n // The canvas draws a stroke width=1 by default if width=0, so we\n // remove the stroke style in that case.\n if (stroke && stroke.getWidth() === 0) {\n stroke = undefined;\n }\n\n if (feature.get(\"zIndex\")) {\n style.setZIndex(parseInt(feature.get(\"zIndex\"), 10));\n }\n\n // if the feature is a Point and we are offline, we use default vector\n // style.\n // if the feature is a Point and has a name with a text style, we\n // create a correct text style.\n // TODO Handle GeometryCollection displaying name on the first Point\n // geometry.\n if (style && (geom instanceof Point || geom instanceof MultiPoint)) {\n let image = style.getImage();\n let text = null;\n let fill = style.getFill();\n\n // If the feature has name we display it on the map as Google does\n if (\n feature.get(\"name\") &&\n style.getText() &&\n style.getText().getScale() !== 0\n ) {\n if (image && image.getScale() === 0) {\n // transparentCircle is used to allow selection\n image = new Circle({\n radius: 1,\n fill: new Fill({ color: [0, 0, 0, 0] }),\n stroke: new Stroke({ color: [0, 0, 0, 0] }),\n });\n }\n\n // We replace empty white spaces used to keep normal spaces before and after the name.\n let name = feature.get(\"name\");\n if (/\\u200B/g.test(name)) {\n name = name.replace(/\\u200B/g, \"\");\n feature.set(\"name\", name);\n }\n\n text = new Text({\n font: feature.get(\"textFont\") || \"normal 16px Helvetica\",\n text: feature.get(\"name\"),\n fill: style.getText().getFill(),\n // rotation unsupported by KML, taken instead from custom field.\n rotation: feature.get(\"textRotation\") || 0,\n // since ol 6.3.1 : https://github.com/openlayers/openlayers/pull/10613/files#diff-1883da8b57e690db7ea0c35ce53c880aR925\n // a default textstroke is added to mimic google earth.\n // it was not the case before, the stroke was always null. So to keep\n // the same behavior we don't copy the stroke style.\n // TODO : maybe we should use this functionnality in the futur.\n // stroke: style.getText().getStroke(),\n scale: style.getText().getScale(),\n });\n\n if (feature.get(\"textStrokeColor\") && feature.get(\"textStrokeWidth\")) {\n text.setStroke(\n new Stroke({\n color: feature.get(\"textStrokeColor\"),\n width: parseFloat(feature.get(\"textStrokeWidth\")),\n }),\n );\n }\n\n if (feature.get(\"textAlign\")) {\n text.setTextAlign(feature.get(\"textAlign\"));\n }\n\n if (feature.get(\"textOffsetX\")) {\n text.setOffsetX(parseFloat(feature.get(\"textOffsetX\")));\n }\n\n if (feature.get(\"textOffsetY\")) {\n text.setOffsetY(parseFloat(feature.get(\"textOffsetY\")));\n }\n\n if (feature.get(\"textBackgroundFillColor\")) {\n text.setBackgroundFill(\n new Fill({\n color: feature.get(\"textBackgroundFillColor\"),\n }),\n );\n }\n\n if (feature.get(\"textPadding\")) {\n text.setPadding(\n feature\n .get(\"textPadding\")\n .split(\",\")\n .map((n) => {\n return parseFloat(n);\n }),\n );\n }\n if (image instanceof Icon) {\n applyTextStyleForIcon(image, text);\n }\n }\n\n if (image instanceof Icon) {\n /* Apply icon rotation if defined (by default only written as\n * <heading> tag, which is not read as rotation value by the ol KML module)\n */\n image.setRotation(parseFloat(feature.get(\"iconRotation\")) || 0);\n\n if (feature.get(\"iconScale\")) {\n image.setScale(parseFloat(feature.get(\"iconScale\")) || 0);\n\n // We fix the 32px scaling introduced by OL 6.7\n } else if (!doNotRevert32pxScaling) {\n const resizeScale = scaleForSize(image.getSize());\n image.setScale(image.getScaleArray()[0] / resizeScale);\n }\n }\n\n fill = undefined;\n stroke = undefined;\n\n styles = (feat, resolution) => {\n /* Options to be used for picture scaling with map, should have at least\n * a resolution attribute (this is the map resolution at the zoom level when\n * the picture is created), can take an optional constant for further scale\n * adjustment.\n * e.g. { resolution: 0.123, defaultScale: 1 / 6 }\n */\n\n if (feat.get(\"pictureOptions\")) {\n let pictureOptions = feat.get(\"pictureOptions\");\n if (typeof pictureOptions === \"string\") {\n pictureOptions = JSON.parse(pictureOptions);\n }\n feat.set(\"pictureOptions\", pictureOptions);\n if (pictureOptions.resolution) {\n image.setScale(\n (pictureOptions.resolution / resolution) *\n pictureOptions.defaultScale || 1,\n );\n }\n }\n\n return new Style({\n fill,\n stroke,\n image,\n text,\n zIndex: style.getZIndex(),\n });\n };\n }\n\n // Remove image and text styles for polygons and lines\n if (\n !(\n geom instanceof Point ||\n geom instanceof MultiPoint ||\n geom instanceof GeometryCollection\n )\n ) {\n styles = [\n new Style({\n fill: style.getFill(),\n stroke,\n image: null,\n text: null,\n zIndex: style.getZIndex(),\n }),\n ];\n\n // Parse the fillPattern json string and store parsed object\n let fillPattern = feature.get(\"fillPattern\");\n if (fillPattern) {\n fillPattern = JSON.parse(fillPattern);\n feature.set(\"fillPattern\", fillPattern);\n\n /* We set the fill pattern for polygons */\n if (!style.getFill()) {\n styles[0].setFill(new Fill());\n }\n const patternOrColor = fillPattern.empty\n ? [0, 0, 0, 0]\n : getPolygonPattern(fillPattern.id, fillPattern.color);\n styles[0].getFill().setColor(patternOrColor);\n }\n\n // Add line's icons styles\n if (feature.get(\"lineStartIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineStartIcon\")),\n stroke.getColor(),\n ),\n );\n }\n\n if (feature.get(\"lineEndIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineEndIcon\")),\n stroke.getColor(),\n false,\n ),\n );\n }\n }\n feature.setStyle(styles);\n};\n\n/**\n * Read a KML string.\n * @param {String} kmlString A string representing a KML file.\n * @param {<ol.Projection|String>} featureProjection The projection used by the map.\n * @param {<boolean>} doNotRevert32pxScaling Set it to true if you use ol < 6.7 and last version of react-spatial, Fix the 32px scaling, introduced by (ol >= 6.7), see https://github.com/openlayers/openlayers/pull/12695.\n */\nconst readFeatures = (\n kmlString,\n featureProjection,\n doNotRevert32pxScaling = false,\n) => {\n // Since ol 6.7, the KML follows better the spec and GoogleEarth interpretation, see https://github.com/openlayers/openlayers/pull/12695.\n // so the <scale> value is interpreted using an image size of 32px.\n // So when revert32pxScaling is true we fix back the scale, to use only, if you use an OL < 6.7.\n // Now the writeFeatures function use the iconScale extended data to set the image's scale.\n // If the extended data is not found it will look at this boolean to define if we must revert the scale or not.\n const features = new KML().readFeatures(kmlString, {\n featureProjection,\n });\n features.forEach((feature) => {\n // 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,WAAW;AAC/B,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AACzB,OAAO,uBAAuB;AAE9B,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;AAC/B,MAAM,YAAY,IAAI,WAAW;AAIjC,MAAM,eAAe,CAAC,SAAS;AAC7B,SAAO,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AACvC;AAEA,MAAM,wBAAwB,CAAC,QAAQ,WAAW;AAChD,QAAM,OAAO,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE;AACxC,QAAM,QAAQ,OAAO,SAAS,KAAK;AACnC,QAAM,SAAS,OAAO,UAAU,KAAK;AAAA,IAClC,KAAK,CAAC,IAAI,QAAS;AAAA,IACnB,KAAK,CAAC,IAAI,QAAS;AAAA,EACtB;AACA,QAAM,SAAS;AAAA,IACb,SAAS,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK;AAAA,IAChC,SAAS,KAAK,CAAC,IAAI,IAA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G,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 line 156\n const tmpStyles = styles(feature);\n const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();\n\n let stroke = style.getStroke();\n if (stroke && feature.get(\"lineDash\")) {\n stroke.setLineDash(\n feature\n .get(\"lineDash\")\n .split(\",\")\n .map((l) => {\n return parseInt(l, 10);\n }),\n );\n }\n\n // The canvas draws a stroke width=1 by default if width=0, so we\n // remove the stroke style in that case.\n if (stroke && stroke.getWidth() === 0) {\n stroke = undefined;\n }\n\n if (feature.get(\"zIndex\")) {\n style.setZIndex(parseInt(feature.get(\"zIndex\"), 10));\n }\n\n // if the feature is a Point and we are offline, we use default vector\n // style.\n // if the feature is a Point and has a name with a text style, we\n // create a correct text style.\n // TODO Handle GeometryCollection displaying name on the first Point\n // geometry.\n if (style && (geom instanceof Point || geom instanceof MultiPoint)) {\n let image = style.getImage();\n let text = null;\n let fill = style.getFill();\n\n // If the feature has name we display it on the map as Google does\n if (\n feature.get(\"name\") &&\n style.getText() &&\n style.getText().getScale() !== 0\n ) {\n if (image && image.getScale() === 0) {\n // transparentCircle is used to allow selection\n image = new Circle({\n radius: 1,\n fill: new Fill({ color: [0, 0, 0, 0] }),\n stroke: new Stroke({ color: [0, 0, 0, 0] }),\n });\n }\n\n // We replace empty white spaces used to keep normal spaces before and after the name.\n let name = feature.get(\"name\");\n if (/\\u200B/g.test(name)) {\n name = name.replace(/\\u200B/g, \"\");\n feature.set(\"name\", name);\n }\n\n text = new Text({\n font: feature.get(\"textFont\") || \"normal 16px Helvetica\",\n text: feature.get(\"name\"),\n fill: style.getText().getFill(),\n // rotation unsupported by KML, taken instead from custom field.\n rotation: feature.get(\"textRotation\") || 0,\n // since ol 6.3.1 : https://github.com/openlayers/openlayers/pull/10613/files#diff-1883da8b57e690db7ea0c35ce53c880aR925\n // a default textstroke is added to mimic google earth.\n // it was not the case before, the stroke was always null. So to keep\n // the same behavior we don't copy the stroke style.\n // TODO : maybe we should use this functionnality in the futur.\n // stroke: style.getText().getStroke(),\n scale: style.getText().getScale(),\n });\n\n if (feature.get(\"textStrokeColor\") && feature.get(\"textStrokeWidth\")) {\n text.setStroke(\n new Stroke({\n color: feature.get(\"textStrokeColor\"),\n width: parseFloat(feature.get(\"textStrokeWidth\")),\n }),\n );\n }\n\n if (feature.get(\"textAlign\")) {\n text.setTextAlign(feature.get(\"textAlign\"));\n }\n\n if (feature.get(\"textOffsetX\")) {\n text.setOffsetX(parseFloat(feature.get(\"textOffsetX\")));\n }\n\n if (feature.get(\"textOffsetY\")) {\n text.setOffsetY(parseFloat(feature.get(\"textOffsetY\")));\n }\n\n if (feature.get(\"textBackgroundFillColor\")) {\n text.setBackgroundFill(\n new Fill({\n color: feature.get(\"textBackgroundFillColor\"),\n }),\n );\n }\n\n if (feature.get(\"textPadding\")) {\n text.setPadding(\n feature\n .get(\"textPadding\")\n .split(\",\")\n .map((n) => {\n return parseFloat(n);\n }),\n );\n }\n if (image instanceof Icon) {\n applyTextStyleForIcon(image, text);\n }\n }\n\n if (image instanceof Icon) {\n /* Apply icon rotation if defined (by default only written as\n * <heading> tag, which is not read as rotation value by the ol KML module)\n */\n image.setRotation(parseFloat(feature.get(\"iconRotation\")) || 0);\n\n if (feature.get(\"iconScale\")) {\n image.setScale(parseFloat(feature.get(\"iconScale\")) || 0);\n\n // We fix the 32px scaling introduced by OL 6.7\n } else if (!doNotRevert32pxScaling) {\n const resizeScale = scaleForSize(image.getSize());\n image.setScale(image.getScaleArray()[0] / resizeScale);\n }\n }\n\n fill = undefined;\n stroke = undefined;\n\n styles = (feat, resolution) => {\n /* Options to be used for picture scaling with map, should have at least\n * a resolution attribute (this is the map resolution at the zoom level when\n * the picture is created), can take an optional constant for further scale\n * adjustment.\n * e.g. { resolution: 0.123, defaultScale: 1 / 6 }\n */\n\n if (feat.get(\"pictureOptions\")) {\n let pictureOptions = feat.get(\"pictureOptions\");\n if (typeof pictureOptions === \"string\") {\n pictureOptions = JSON.parse(pictureOptions);\n }\n feat.set(\"pictureOptions\", pictureOptions);\n if (pictureOptions.resolution) {\n image.setScale(\n (pictureOptions.resolution / resolution) *\n pictureOptions.defaultScale || 1,\n );\n }\n }\n\n return new Style({\n fill,\n stroke,\n image,\n text,\n zIndex: style.getZIndex(),\n });\n };\n }\n\n // Remove image and text styles for polygons and lines\n if (\n !(\n geom instanceof Point ||\n geom instanceof MultiPoint ||\n geom instanceof GeometryCollection\n )\n ) {\n styles = [\n new Style({\n fill: style.getFill(),\n stroke,\n image: null,\n text: null,\n zIndex: style.getZIndex(),\n }),\n ];\n\n // Parse the fillPattern json string and store parsed object\n let fillPattern = feature.get(\"fillPattern\");\n if (fillPattern) {\n fillPattern = JSON.parse(fillPattern);\n feature.set(\"fillPattern\", fillPattern);\n\n /* We set the fill pattern for polygons */\n if (!style.getFill()) {\n styles[0].setFill(new Fill());\n }\n const patternOrColor = fillPattern.empty\n ? [0, 0, 0, 0]\n : getPolygonPattern(fillPattern.id, fillPattern.color);\n styles[0].getFill().setColor(patternOrColor);\n }\n\n // Add line's icons styles\n if (feature.get(\"lineStartIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineStartIcon\")),\n stroke.getColor(),\n ),\n );\n }\n\n if (feature.get(\"lineEndIcon\")) {\n styles.push(\n getLineIcon(\n feature,\n JSON.parse(feature.get(\"lineEndIcon\")),\n stroke.getColor(),\n false,\n ),\n );\n }\n }\n feature.setStyle(styles);\n};\n\n/**\n * Read a KML string.\n * @param {String} kmlString A string representing a KML file.\n * @param {<ol.Projection|String>} featureProjection The projection used by the map.\n * @param {<boolean>} doNotRevert32pxScaling Set it to true if you use ol < 6.7 and last version of react-spatial, Fix the 32px scaling, introduced by (ol >= 6.7), see https://github.com/openlayers/openlayers/pull/12695.\n */\nconst readFeatures = (\n kmlString,\n featureProjection,\n doNotRevert32pxScaling = false,\n) => {\n // Since ol 6.7, the KML follows better the spec and GoogleEarth interpretation, see https://github.com/openlayers/openlayers/pull/12695.\n // so the <scale> value is interpreted using an image size of 32px.\n // So when revert32pxScaling is true we fix back the scale, to use only, if you use an OL < 6.7.\n // Now the writeFeatures function use the iconScale extended data to set the image's scale.\n // If the extended data is not found it will look at this boolean to define if we must revert the scale or not.\n const features = new KML().readFeatures(kmlString, {\n featureProjection,\n });\n features.forEach((feature) => {\n // 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.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,WAAW;AAC/B,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AACzB,OAAO,uBAAuB;AAE9B,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;AAC/B,MAAM,YAAY,IAAI,WAAW;AAIjC,MAAM,eAAe,CAAC,SAAS;AAC7B,SAAO,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AACvC;AAEA,MAAM,wBAAwB,CAAC,QAAQ,WAAW;AAChD,QAAM,OAAO,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE;AACxC,QAAM,QAAQ,OAAO,SAAS,KAAK;AACnC,QAAM,SAAS,OAAO,UAAU,KAAK;AAAA,IACl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AAM,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const getLayersAsFlatArray = (layersOrLayer = []) => {
|
|
2
|
+
let layers = layersOrLayer;
|
|
3
|
+
if (!Array.isArray(layers)) {
|
|
4
|
+
layers = [layersOrLayer];
|
|
5
|
+
}
|
|
6
|
+
let flatLayers = [];
|
|
7
|
+
layers.forEach((layer) => {
|
|
8
|
+
flatLayers.push(layer);
|
|
9
|
+
const children = layer.children || layer.get("children") || layer.getLayers?.()?.getArray();
|
|
10
|
+
flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
|
|
11
|
+
});
|
|
12
|
+
return flatLayers;
|
|
13
|
+
};
|
|
14
|
+
export default getLayersAsFlatArray;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/getLayersAsFlatArray.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Function that returns an array of OpenLayers layers or groups as a flat array.\n * It also considers the children property for each layer.\n * @param {*} layersOrLayer\n * @returns\n */\nconst getLayersAsFlatArray = (layersOrLayer = []) => {\n let layers = layersOrLayer;\n if (!Array.isArray(layers)) {\n layers = [layersOrLayer];\n }\n let flatLayers = [];\n layers.forEach((layer) => {\n flatLayers.push(layer);\n\n // Handle children property and ol.layer.Group\n const children =\n layer.children ||\n layer.get(\"children\") ||\n layer.getLayers?.()?.getArray();\n flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));\n });\n return flatLayers;\n};\n\nexport default getLayersAsFlatArray;\n"],
|
|
5
|
+
"mappings": "AAMA,MAAM,uBAAuB,CAAC,gBAAgB,CAAC,MAAM;AACnD,MAAI,SAAS;AACb,MAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC1B,aAAS,CAAC,aAAa;AAAA,EACzB;AACA,MAAI,aAAa,CAAC;AAClB,SAAO,QAAQ,CAAC,UAAU;AACxB,eAAW,KAAK,KAAK;AAGrB,UAAM,WACJ,MAAM,YACN,MAAM,IAAI,UAAU,KACpB,MAAM,YAAY,GAAG,SAAS;AAChC,iBAAa,WAAW,OAAO,qBAAqB,YAAY,CAAC,CAAC,CAAC;AAAA,EACrE,CAAC;AACD,SAAO;AACT;AAEA,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|