qwc2 2025.9.23 → 2025.10.2

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.
Files changed (66) hide show
  1. package/components/AttributeForm.js +3 -3
  2. package/components/AttributeTableWidget.js +1 -1
  3. package/components/EditUploadField.js +1 -1
  4. package/components/IdentifyViewer.js +5 -5
  5. package/components/PickFeature.js +1 -1
  6. package/components/QtDesignerForm.js +2 -2
  7. package/components/ResizeableWindow.js +2 -2
  8. package/components/SearchBox.js +2 -2
  9. package/components/StandardApp.js +2 -2
  10. package/components/map3d/ImportObjects3D.js +1 -1
  11. package/components/widgets/EditableSelect.js +1 -1
  12. package/components/widgets/SearchWidget.js +1 -1
  13. package/components/widgets/SuggestionInput.js +1 -1
  14. package/package.json +2 -1
  15. package/plugins/AttributeTable.js +1 -1
  16. package/plugins/Editing.js +2 -2
  17. package/plugins/FeatureSearch.js +2 -2
  18. package/plugins/GeometryDigitizer.js +1 -1
  19. package/plugins/HeightProfile.js +2 -2
  20. package/plugins/LayerTree.js +1 -1
  21. package/plugins/Map.js +1 -1
  22. package/plugins/MapFilter.js +3 -3
  23. package/plugins/MapTip.js +2 -2
  24. package/plugins/OverviewMap.js +2 -2
  25. package/plugins/Routing.js +4 -4
  26. package/plugins/ScratchDrawing.js +2 -2
  27. package/plugins/TimeManager.js +2 -2
  28. package/plugins/TopBar.js +1 -1
  29. package/plugins/ValueTool.js +2 -2
  30. package/plugins/View3D.js +2 -2
  31. package/plugins/map/SnappingSupport.js +2 -2
  32. package/resources/arrow.glb +0 -0
  33. package/resources/person.png +0 -0
  34. package/resources/person.svg +45 -0
  35. package/resources/pin.glb +0 -0
  36. package/resources/viewcone.svg +124 -0
  37. package/scripts/dist.sh +2 -0
  38. package/scripts/themesConfig.js +1 -1
  39. package/static/translations/bg-BG.json +2 -0
  40. package/static/translations/ca-ES.json +2 -0
  41. package/static/translations/cs-CZ.json +2 -0
  42. package/static/translations/de-CH.json +2 -0
  43. package/static/translations/de-DE.json +2 -0
  44. package/static/translations/en-US.json +2 -0
  45. package/static/translations/es-ES.json +2 -0
  46. package/static/translations/fi-FI.json +2 -0
  47. package/static/translations/fr-FR.json +2 -0
  48. package/static/translations/hu-HU.json +2 -0
  49. package/static/translations/it-IT.json +2 -0
  50. package/static/translations/ja-JP.json +2 -0
  51. package/static/translations/nl-NL.json +2 -0
  52. package/static/translations/no-NO.json +2 -0
  53. package/static/translations/pl-PL.json +2 -0
  54. package/static/translations/pt-BR.json +2 -0
  55. package/static/translations/pt-PT.json +2 -0
  56. package/static/translations/ro-RO.json +2 -0
  57. package/static/translations/ru-RU.json +2 -0
  58. package/static/translations/sv-SE.json +2 -0
  59. package/static/translations/tr-TR.json +2 -0
  60. package/static/translations/tsconfig.json +2 -0
  61. package/static/translations/uk-UA.json +2 -0
  62. package/utils/CoordinatesUtils.js +2 -2
  63. package/utils/IdentifyUtils.js +2 -2
  64. package/utils/LayerUtils.js +1 -1
  65. package/utils/RoutingInterface.js +2 -2
  66. package/utils/VectorLayerUtils.js +3 -3
@@ -4,14 +4,14 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import Sortable from"react-sortablejs";import FileSaver from"file-saver";import PropTypes from"prop-types";import{createSelector}from"reselect";import{LayerRole,addLayerFeatures,removeLayer}from"../actions/layers";import{zoomToExtent}from"../actions/map";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import ButtonBar from"../components/widgets/ButtonBar";import DateTimeInput from"../components/widgets/DateTimeInput";import NumberInput from"../components/widgets/NumberInput";import SearchWidget from"../components/widgets/SearchWidget";import Spinner from"../components/widgets/Spinner";import ToggleSwitch from"../components/widgets/ToggleSwitch";import VectorLayerPicker from"../components/widgets/VectorLayerPicker";import searchProvidersSelector from"../selectors/searchproviders";import ConfigUtils from"../utils/ConfigUtils";import CoordinatesUtils from"../utils/CoordinatesUtils";import LocaleUtils from"../utils/LocaleUtils";import MeasureUtils from"../utils/MeasureUtils";import RoutingInterface from"../utils/RoutingInterface";import VectorLayerUtils from"../utils/VectorLayerUtils";import"./style/Routing.css";/**
7
+ */import React from"react";import{connect}from"react-redux";import Sortable from"react-sortablejs";import FileSaver from"file-saver";import PropTypes from"prop-types";import{createSelector}from"reselect";import{v4 as uuidv4}from"uuid";import{LayerRole,addLayerFeatures,removeLayer}from"../actions/layers";import{zoomToExtent}from"../actions/map";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import ButtonBar from"../components/widgets/ButtonBar";import DateTimeInput from"../components/widgets/DateTimeInput";import NumberInput from"../components/widgets/NumberInput";import SearchWidget from"../components/widgets/SearchWidget";import Spinner from"../components/widgets/Spinner";import ToggleSwitch from"../components/widgets/ToggleSwitch";import VectorLayerPicker from"../components/widgets/VectorLayerPicker";import searchProvidersSelector from"../selectors/searchproviders";import ConfigUtils from"../utils/ConfigUtils";import CoordinatesUtils from"../utils/CoordinatesUtils";import LocaleUtils from"../utils/LocaleUtils";import MeasureUtils from"../utils/MeasureUtils";import RoutingInterface from"../utils/RoutingInterface";import VectorLayerUtils from"../utils/VectorLayerUtils";import"./style/Routing.css";/**
8
8
  * Compute routes and isochrones.
9
9
  *
10
10
  * Requires `routingServiceUrl` in `config.json` pointing to a Valhalla routing service.
11
- */var Routing=/*#__PURE__*/function(_React$Component){function Routing(props){var _this;_classCallCheck(this,Routing);_this=_callSuper(this,Routing,[props]);_defineProperty(_this,"state",{visible:false,currentTab:"Route",mode:"auto",settings:{auto:{method:"fastest",maxSpeed:130,useFerries:true,useHighways:true,useTollways:true},heavyvehicle:{method:"fastest",maxSpeed:100,useFerries:true,useHighways:true,useTollways:true},transit:{timepoint:"now",time:""},bicycle:{method:"fastest",maxSpeed:25,useFerries:true},pedestrian:{method:"fastest",maxSpeed:4,useFerries:true}},settingsPopup:false,routeConfig:{points:[{text:"",pos:null,crs:null},{text:"",pos:null,crs:null}],result:null,roundtrip:false,optimized_route:false,excludeLayer:null},isoConfig:{points:[{text:"",pos:null,crs:null}],mode:"time",units:{time:"min",distance:"km"},intervals:"5, 10",result:null},searchProviders:[],searchParams:{},highlightId:null});_defineProperty(_this,"renderSettings",function(){var settings=_this.state.settings[_this.state.mode];return/*#__PURE__*/React.createElement("div",{className:"routing-settings-menu"},/*#__PURE__*/React.createElement("table",{className:"routing-settings-menu-entries"},/*#__PURE__*/React.createElement("tbody",null,settings.method!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.method"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateSetting(_this.state.mode,{method:ev.target.value})},value:settings.method},/*#__PURE__*/React.createElement("option",{value:"fastest"},LocaleUtils.tr("routing.fastest")),/*#__PURE__*/React.createElement("option",{value:"shortest"},LocaleUtils.tr("routing.shortest"))))):null,settings.maxSpeed!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.maxspeed"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{max:350,min:1,mobile:true,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{maxSpeed:value})},suffix:" km/h",value:settings.maxSpeed}))):null,settings.useFerries!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.useferries"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useFerries,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useFerries:value})}}))):null,settings.useHighways!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.usehighways"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useHighways,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useHighways:value})}}))):null,settings.useTollways!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.usetollways"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useTollways,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useTollways:value})}}))):null)))});_defineProperty(_this,"renderRouteWidget",function(){var routeConfig=_this.state.routeConfig;var vectorLayers=_this.props.layers.filter(function(layer){return layer.type==="vector"&&layer.role===LayerRole.USERLAYER&&!layer.readonly});var numpoints=routeConfig.points.length;return/*#__PURE__*/React.createElement("div",{className:"routing-tab-widget"},/*#__PURE__*/React.createElement("div",{className:"routing-input"},/*#__PURE__*/React.createElement("div",{className:"routing-points"},/*#__PURE__*/React.createElement(Sortable,{onChange:_this.onSortChange,options:{ghostClass:"drop-ghost",delay:200}},routeConfig.points.map(function(entry,idx){var placeholder=LocaleUtils.tr("routing.addviapoint");if(idx===0){placeholder=LocaleUtils.tr("routing.fromhere")}else if(idx===routeConfig.points.length-1){placeholder=LocaleUtils.tr("routing.tohere")}return _this.renderSearchField(entry,idx,"routeConfig",idx>0&&idx<numpoints-1,placeholder)})),/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Icon,{icon:"up-down-arrow",onClick:_this.reverseRoutePts}))),/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.addPoint("routeConfig",-1)}},/*#__PURE__*/React.createElement(Icon,{icon:"plus"})," ",LocaleUtils.tr("routing.add")),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),_this.renderImportButton("routeConfig"),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.clearConfig("routeConfig")}},/*#__PURE__*/React.createElement(Icon,{icon:"clear"})," ",LocaleUtils.tr("routing.clear"))),_this.state.mode==="transit"?/*#__PURE__*/React.createElement("div",{className:"routing-time-settings"},/*#__PURE__*/React.createElement("select",{onChange:_this.updateTransitTimepoint,value:_this.state.settings.transit.timepoint},/*#__PURE__*/React.createElement("option",{value:"now"},LocaleUtils.tr("routing.leavenow")),/*#__PURE__*/React.createElement("option",{value:"leaveat"},LocaleUtils.tr("routing.leaveat")),/*#__PURE__*/React.createElement("option",{value:"arriveat"},LocaleUtils.tr("routing.arriveat"))),_this.state.settings.transit.timepoint!=="now"?/*#__PURE__*/React.createElement(DateTimeInput,{onChange:function onChange(value){return _this.updateSetting("transit",{time:value})},value:_this.state.settings.transit.time}):null):null,/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("label",null,/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.updateRouteConfig({roundtrip:ev.target.checked})},type:"checkbox",value:routeConfig.roundtrip})," ",LocaleUtils.tr("routing.roundtrip"))),_this.state.mode!=="transit"?/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("label",null,/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.updateRouteConfig({optimized_route:ev.target.checked})},type:"checkbox",value:routeConfig.optimized_route})," ",LocaleUtils.tr("routing.optimized_route"))):null,ConfigUtils.havePlugin("Redlining")?/*#__PURE__*/React.createElement("div",{className:"routing-points-commands controlgroup"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("routing.excludepolygons"),":\xA0"),/*#__PURE__*/React.createElement(VectorLayerPicker,{layers:vectorLayers,onChange:function onChange(layer){return _this.updateRouteConfig({excludeLayer:(layer||{}).id})},showNone:true,value:routeConfig.excludeLayer||""}),/*#__PURE__*/React.createElement("button",{className:"button",onClick:_this.setRedliningTool},/*#__PURE__*/React.createElement(Icon,{icon:"draw"}))):null),routeConfig.busy?/*#__PURE__*/React.createElement("div",{className:"routing-busy"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("routing.computing")):null,routeConfig.result?_this.renderRouteResult(routeConfig):null)});_defineProperty(_this,"updateTransitTimepoint",function(ev){var diff={timepoint:ev.target.value};if(ev.target.value!=="now"&&_this.state.settings.transit.timepoint==="now"){var tzoffset=new Date().getTimezoneOffset()*60000;diff.time=new Date(Date.now()-tzoffset).toISOString().slice(0,-1)}_this.updateSetting("transit",diff)});_defineProperty(_this,"setRedliningTool",function(){_this.props.setCurrentTask("Redlining",null,null,{layerId:_this.state.routeConfig.excludeLayer})});_defineProperty(_this,"renderRouteResult",function(routeConfig){if(routeConfig.result.success===false){return/*#__PURE__*/React.createElement("div",{className:"routing-status-failure"},routeConfig.result.data.errorMsgId?LocaleUtils.tr(routeConfig.result.data.errorMsgId):routeConfig.result.data.error)}else{return/*#__PURE__*/React.createElement("div",{className:"routing-result"},/*#__PURE__*/React.createElement("div",{className:"routing-result-summary"},/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"clock"})," ",MeasureUtils.formatDuration(routeConfig.result.data.summary.time)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"measure"})," ",MeasureUtils.formatMeasurement(routeConfig.result.data.summary.length,false)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"export"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.exportRoute},LocaleUtils.tr("routing.export")))),/*#__PURE__*/React.createElement("div",{className:"routing-result-instructions"},routeConfig.result.data.legs.map(function(leg,lidx){return leg.maneuvers.map(function(entry,eidx){return/*#__PURE__*/React.createElement("div",{className:"routing-result-instruction",key:"instr"+lidx+":"+eidx,onMouseEnter:function onMouseEnter(){return _this.highlightRouteSection(lidx+":"+eidx,entry,leg)},onMouseLeave:function onMouseLeave(){return _this.clearRouteSectionHighlight(lidx+":"+eidx)}},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Icon,{icon:entry.icon}),/*#__PURE__*/React.createElement("b",null,entry.instruction)),/*#__PURE__*/React.createElement("div",{className:"routing-result-instruction-summary"},/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"clock"})," ",MeasureUtils.formatDuration(entry.time)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"measure"})," ",MeasureUtils.formatMeasurement(entry.length,false))))})})))}});_defineProperty(_this,"highlightRouteSection",function(id,entry,leg){_this.setState({highlightId:id});var feature={type:"Feature",crs:"EPSG:4326",geometry:{type:"LineString",coordinates:leg.coordinates.slice(entry.geom_indices[0],entry.geom_indices[1]+1)}};var sellayer={id:"routingselection",role:LayerRole.SELECTION,styleOptions:{strokeWidth:3,strokeColor:[255,255,0,1],strokeDash:[]}};_this.props.addLayerFeatures(sellayer,[feature],true)});_defineProperty(_this,"clearRouteSectionHighlight",function(id){if(_this.state.highlightId===id){_this.setState({highlightId:null});_this.props.removeLayer("routingselection")}});_defineProperty(_this,"renderIsochroneWidget",function(){var isoConfig=_this.state.isoConfig;var intervalValid=!!isoConfig.intervals.match(/^\d+(,\s*\d+)*$/);return/*#__PURE__*/React.createElement("div",{className:"routing-tab-widget"},/*#__PURE__*/React.createElement("div",{className:"routing-input"},/*#__PURE__*/React.createElement("div",null,isoConfig.points.map(function(entry,idx){return _this.renderSearchField(entry,idx,"isoConfig",idx>0)})),/*#__PURE__*/React.createElement("table",{className:"routing-iso-settings"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.iso_mode"),": "),/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateIsoConfig({mode:ev.target.value})},value:isoConfig.mode},/*#__PURE__*/React.createElement("option",{value:"time"},LocaleUtils.tr("routing.iso_mode_time")),/*#__PURE__*/React.createElement("option",{value:"distance"},LocaleUtils.tr("routing.iso_mode_distance"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.iso_intervals"),": "),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("input",{className:isoConfig.intervals&&!intervalValid?"routing-input-invalid":"",onChange:function onChange(ev){return _this.updateIsoConfig({intervals:ev.target.value})},placeholder:"5, 10, 15",type:"text",value:isoConfig.intervals})),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){_this.setState(function(state){return{isoConfig:_objectSpread(_objectSpread({},state.isoConfig),{},{units:_objectSpread(_objectSpread({},state.isoConfig.units),{},_defineProperty({},state.isoConfig.mode,ev.target.value))})}});_this.recomputeIfNeeded()},value:isoConfig.units[isoConfig.mode]},Object.keys(_this.props.units[isoConfig.mode]).map(function(unit){return/*#__PURE__*/React.createElement("option",{key:unit,value:unit},unit)})))))),/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.addPoint("isoConfig",isoConfig.points.length)}},/*#__PURE__*/React.createElement(Icon,{icon:"plus"})," ",LocaleUtils.tr("routing.add")),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),_this.renderImportButton("isoConfig"),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.clearConfig("isoConfig")}},/*#__PURE__*/React.createElement(Icon,{icon:"clear"})," ",LocaleUtils.tr("routing.clear")))),isoConfig.busy?/*#__PURE__*/React.createElement("div",{className:"routing-busy"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("routing.computing")):null,isoConfig.result?_this.renderIsochroneResult(isoConfig):null)});_defineProperty(_this,"renderIsochroneResult",function(isoConfig){if(isoConfig.result.success===false){return/*#__PURE__*/React.createElement("div",{className:"routing-status-failure"},isoConfig.result.data.errorMsgId?LocaleUtils.tr(isoConfig.result.data.errorMsgId):isoConfig.result.data.error)}else{return/*#__PURE__*/React.createElement("div",{className:"routing-result"},/*#__PURE__*/React.createElement("div",{className:"routing-result-summary"},/*#__PURE__*/React.createElement(Icon,{icon:"export"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.exportIsochrone},LocaleUtils.tr("routing.export"))))}});_defineProperty(_this,"renderSearchField",function(entry,idx,config,removeable){var placeholder=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;return/*#__PURE__*/React.createElement("div",{className:"routing-search-field controlgroup",key:"field"+idx},/*#__PURE__*/React.createElement(SearchWidget,{placeholder:placeholder,resultSelected:function resultSelected(result){return _this.searchResultSelected(config,idx,result)},role:"input",searchParams:_this.state.searchParams,searchProviders:_this.state.searchProviders,value:entry.text}),idx===0?/*#__PURE__*/React.createElement("button",{className:"button",disabled:!_this.props.locatePos,onClick:function onClick(){return _this.updatePoint(config,0,_this.locatePos())},role:"suffix"},/*#__PURE__*/React.createElement(Icon,{icon:"screenshot"})):null,removeable?/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this.removePoint(config,idx)},role:"suffix"},/*#__PURE__*/React.createElement(Icon,{icon:"remove"})):null)});_defineProperty(_this,"renderImportButton",function(config){return/*#__PURE__*/React.createElement("label",{className:"routing-import-button",title:LocaleUtils.tr("routing.importhint")},/*#__PURE__*/React.createElement(Icon,{icon:"import"})," ",LocaleUtils.tr("routing.importpoints"),/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.importPoints(ev,config)},type:"file"}))});_defineProperty(_this,"locatePos",function(){return{pos:_toConsumableArray(_this.props.locatePos),text:_this.props.locatePos.map(function(x){return x.toFixed(4)}).join(", "),crs:"EPSG:4326"}});_defineProperty(_this,"updateSetting",function(mode,diff){_this.setState(function(state){return{settings:_objectSpread(_objectSpread({},state.settings),{},_defineProperty({},mode,_objectSpread(_objectSpread({},state.settings[mode]),diff)))}});_this.recomputeIfNeeded()});_defineProperty(_this,"addPoint",function(config){var index=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1;var entry=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{text:"",pos:null};_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:[].concat(_toConsumableArray(state[config].points.slice(0,index)),[entry],_toConsumableArray(state[config].points.slice(index)))}))});if(entry.pos){_this.recomputeIfNeeded()}});_defineProperty(_this,"updatePoint",function(config,idx,diff){_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:[].concat(_toConsumableArray(state[config].points.slice(0,idx)),[_objectSpread(_objectSpread({},state[config].points[idx]),diff)],_toConsumableArray(state[config].points.slice(idx+1)))}))});_this.recomputeIfNeeded()});_defineProperty(_this,"importPoints",function(ev,config){var reader=new FileReader;reader.onload=function(loadev){try{var obj=JSON.parse(loadev.target.result);var crs="EPSG:4326";if(obj.crs&&obj.crs.properties){crs=CoordinatesUtils.fromOgcUrnCrs(obj.crs.properties.name)}var prec=CoordinatesUtils.getPrecision(crs);_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:obj.features.map(function(feature){var coordinates=feature.geometry.coordinates;return{text:coordinates.map(function(x){return x.toFixed(prec)}).join(", ")+" ("+crs+")",pos:coordinates,crs:crs}})}))});_this.recomputeIfNeeded()}catch(e){// eslint-disable-next-line
11
+ */var Routing=/*#__PURE__*/function(_React$Component){function Routing(props){var _this;_classCallCheck(this,Routing);_this=_callSuper(this,Routing,[props]);_defineProperty(_this,"state",{visible:false,currentTab:"Route",mode:"auto",settings:{auto:{method:"fastest",maxSpeed:130,useFerries:true,useHighways:true,useTollways:true},heavyvehicle:{method:"fastest",maxSpeed:100,useFerries:true,useHighways:true,useTollways:true},transit:{timepoint:"now",time:""},bicycle:{method:"fastest",maxSpeed:25,useFerries:true},pedestrian:{method:"fastest",maxSpeed:4,useFerries:true}},settingsPopup:false,routeConfig:{points:[{text:"",pos:null,crs:null},{text:"",pos:null,crs:null}],result:null,roundtrip:false,optimized_route:false,excludeLayer:null},isoConfig:{points:[{text:"",pos:null,crs:null}],mode:"time",units:{time:"min",distance:"km"},intervals:"5, 10",result:null},searchProviders:[],searchParams:{},highlightId:null});_defineProperty(_this,"renderSettings",function(){var settings=_this.state.settings[_this.state.mode];return/*#__PURE__*/React.createElement("div",{className:"routing-settings-menu"},/*#__PURE__*/React.createElement("table",{className:"routing-settings-menu-entries"},/*#__PURE__*/React.createElement("tbody",null,settings.method!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.method"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateSetting(_this.state.mode,{method:ev.target.value})},value:settings.method},/*#__PURE__*/React.createElement("option",{value:"fastest"},LocaleUtils.tr("routing.fastest")),/*#__PURE__*/React.createElement("option",{value:"shortest"},LocaleUtils.tr("routing.shortest"))))):null,settings.maxSpeed!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.maxspeed"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{max:350,min:1,mobile:true,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{maxSpeed:value})},suffix:" km/h",value:settings.maxSpeed}))):null,settings.useFerries!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.useferries"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useFerries,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useFerries:value})}}))):null,settings.useHighways!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.usehighways"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useHighways,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useHighways:value})}}))):null,settings.useTollways!==undefined?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.usetollways"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:settings.useTollways,onChange:function onChange(value){return _this.updateSetting(_this.state.mode,{useTollways:value})}}))):null)))});_defineProperty(_this,"renderRouteWidget",function(){var routeConfig=_this.state.routeConfig;var vectorLayers=_this.props.layers.filter(function(layer){return layer.type==="vector"&&layer.role===LayerRole.USERLAYER&&!layer.readonly});var numpoints=routeConfig.points.length;return/*#__PURE__*/React.createElement("div",{className:"routing-tab-widget"},/*#__PURE__*/React.createElement("div",{className:"routing-input"},/*#__PURE__*/React.createElement("div",{className:"routing-points"},/*#__PURE__*/React.createElement(Sortable,{onChange:_this.onSortChange,options:{ghostClass:"drop-ghost",delay:200}},routeConfig.points.map(function(entry,idx){var placeholder=LocaleUtils.tr("routing.addviapoint");if(idx===0){placeholder=LocaleUtils.tr("routing.fromhere")}else if(idx===routeConfig.points.length-1){placeholder=LocaleUtils.tr("routing.tohere")}return _this.renderSearchField(entry,idx,"routeConfig",idx>0&&idx<numpoints-1,placeholder)})),/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Icon,{icon:"up-down-arrow",onClick:_this.reverseRoutePts}))),/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.addPoint("routeConfig",-1)}},/*#__PURE__*/React.createElement(Icon,{icon:"plus"})," ",LocaleUtils.tr("routing.add")),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),_this.renderImportButton("routeConfig"),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.clearConfig("routeConfig")}},/*#__PURE__*/React.createElement(Icon,{icon:"clear"})," ",LocaleUtils.tr("routing.clear"))),_this.state.mode==="transit"?/*#__PURE__*/React.createElement("div",{className:"routing-time-settings"},/*#__PURE__*/React.createElement("select",{onChange:_this.updateTransitTimepoint,value:_this.state.settings.transit.timepoint},/*#__PURE__*/React.createElement("option",{value:"now"},LocaleUtils.tr("routing.leavenow")),/*#__PURE__*/React.createElement("option",{value:"leaveat"},LocaleUtils.tr("routing.leaveat")),/*#__PURE__*/React.createElement("option",{value:"arriveat"},LocaleUtils.tr("routing.arriveat"))),_this.state.settings.transit.timepoint!=="now"?/*#__PURE__*/React.createElement(DateTimeInput,{onChange:function onChange(value){return _this.updateSetting("transit",{time:value})},value:_this.state.settings.transit.time}):null):null,/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("label",null,/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.updateRouteConfig({roundtrip:ev.target.checked})},type:"checkbox",value:routeConfig.roundtrip})," ",LocaleUtils.tr("routing.roundtrip"))),_this.state.mode!=="transit"?/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("label",null,/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.updateRouteConfig({optimized_route:ev.target.checked})},type:"checkbox",value:routeConfig.optimized_route})," ",LocaleUtils.tr("routing.optimized_route"))):null,ConfigUtils.havePlugin("Redlining")?/*#__PURE__*/React.createElement("div",{className:"routing-points-commands controlgroup"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("routing.excludepolygons"),":\xA0"),/*#__PURE__*/React.createElement(VectorLayerPicker,{layers:vectorLayers,onChange:function onChange(layer){return _this.updateRouteConfig({excludeLayer:(layer||{}).id})},showNone:true,value:routeConfig.excludeLayer||""}),/*#__PURE__*/React.createElement("button",{className:"button",onClick:_this.setRedliningTool},/*#__PURE__*/React.createElement(Icon,{icon:"draw"}))):null),routeConfig.busy?/*#__PURE__*/React.createElement("div",{className:"routing-busy"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("routing.computing")):null,routeConfig.result?_this.renderRouteResult(routeConfig):null)});_defineProperty(_this,"updateTransitTimepoint",function(ev){var diff={timepoint:ev.target.value};if(ev.target.value!=="now"&&_this.state.settings.transit.timepoint==="now"){var tzoffset=new Date().getTimezoneOffset()*60000;diff.time=new Date(Date.now()-tzoffset).toISOString().slice(0,-1)}_this.updateSetting("transit",diff)});_defineProperty(_this,"setRedliningTool",function(){_this.props.setCurrentTask("Redlining",null,null,{layerId:_this.state.routeConfig.excludeLayer})});_defineProperty(_this,"renderRouteResult",function(routeConfig){if(routeConfig.result.success===false){return/*#__PURE__*/React.createElement("div",{className:"routing-status-failure"},routeConfig.result.data.errorMsgId?LocaleUtils.tr(routeConfig.result.data.errorMsgId):routeConfig.result.data.error)}else{return/*#__PURE__*/React.createElement("div",{className:"routing-result"},/*#__PURE__*/React.createElement("div",{className:"routing-result-summary"},/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"clock"})," ",MeasureUtils.formatDuration(routeConfig.result.data.summary.time)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"measure"})," ",MeasureUtils.formatMeasurement(routeConfig.result.data.summary.length,false)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"export"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.exportRoute},LocaleUtils.tr("routing.export"))),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"layers"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.addRouteLayer},LocaleUtils.tr("routing.addlayer")))),/*#__PURE__*/React.createElement("div",{className:"routing-result-instructions"},routeConfig.result.data.legs.map(function(leg,lidx){return leg.maneuvers.map(function(entry,eidx){return/*#__PURE__*/React.createElement("div",{className:"routing-result-instruction",key:"instr"+lidx+":"+eidx,onMouseEnter:function onMouseEnter(){return _this.highlightRouteSection(lidx+":"+eidx,entry,leg)},onMouseLeave:function onMouseLeave(){return _this.clearRouteSectionHighlight(lidx+":"+eidx)}},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Icon,{icon:entry.icon}),/*#__PURE__*/React.createElement("b",null,entry.instruction)),/*#__PURE__*/React.createElement("div",{className:"routing-result-instruction-summary"},/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"clock"})," ",MeasureUtils.formatDuration(entry.time)),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"measure"})," ",MeasureUtils.formatMeasurement(entry.length,false))))})})))}});_defineProperty(_this,"highlightRouteSection",function(id,entry,leg){_this.setState({highlightId:id});var feature={type:"Feature",crs:"EPSG:4326",geometry:{type:"LineString",coordinates:leg.coordinates.slice(entry.geom_indices[0],entry.geom_indices[1]+1)}};var sellayer={id:"routingselection",role:LayerRole.SELECTION,styleOptions:{strokeWidth:3,strokeColor:[255,255,0,1],strokeDash:[]}};_this.props.addLayerFeatures(sellayer,[feature],true)});_defineProperty(_this,"clearRouteSectionHighlight",function(id){if(_this.state.highlightId===id){_this.setState({highlightId:null});_this.props.removeLayer("routingselection")}});_defineProperty(_this,"renderIsochroneWidget",function(){var isoConfig=_this.state.isoConfig;var intervalValid=!!isoConfig.intervals.match(/^\d+(,\s*\d+)*$/);return/*#__PURE__*/React.createElement("div",{className:"routing-tab-widget"},/*#__PURE__*/React.createElement("div",{className:"routing-input"},/*#__PURE__*/React.createElement("div",null,isoConfig.points.map(function(entry,idx){return _this.renderSearchField(entry,idx,"isoConfig",idx>0)})),/*#__PURE__*/React.createElement("table",{className:"routing-iso-settings"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.iso_mode"),": "),/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateIsoConfig({mode:ev.target.value})},value:isoConfig.mode},/*#__PURE__*/React.createElement("option",{value:"time"},LocaleUtils.tr("routing.iso_mode_time")),/*#__PURE__*/React.createElement("option",{value:"distance"},LocaleUtils.tr("routing.iso_mode_distance"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("routing.iso_intervals"),": "),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("input",{className:isoConfig.intervals&&!intervalValid?"routing-input-invalid":"",onChange:function onChange(ev){return _this.updateIsoConfig({intervals:ev.target.value})},placeholder:"5, 10, 15",type:"text",value:isoConfig.intervals})),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){_this.setState(function(state){return{isoConfig:_objectSpread(_objectSpread({},state.isoConfig),{},{units:_objectSpread(_objectSpread({},state.isoConfig.units),{},_defineProperty({},state.isoConfig.mode,ev.target.value))})}});_this.recomputeIfNeeded()},value:isoConfig.units[isoConfig.mode]},Object.keys(_this.props.units[isoConfig.mode]).map(function(unit){return/*#__PURE__*/React.createElement("option",{key:unit,value:unit},unit)})))))),/*#__PURE__*/React.createElement("div",{className:"routing-points-commands"},/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.addPoint("isoConfig",isoConfig.points.length)}},/*#__PURE__*/React.createElement(Icon,{icon:"plus"})," ",LocaleUtils.tr("routing.add")),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),_this.renderImportButton("isoConfig"),/*#__PURE__*/React.createElement("span",{className:"routing-points-commands-spacer"}),/*#__PURE__*/React.createElement("a",{href:"#",onClick:function onClick(){return _this.clearConfig("isoConfig")}},/*#__PURE__*/React.createElement(Icon,{icon:"clear"})," ",LocaleUtils.tr("routing.clear")))),isoConfig.busy?/*#__PURE__*/React.createElement("div",{className:"routing-busy"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("routing.computing")):null,isoConfig.result?_this.renderIsochroneResult(isoConfig):null)});_defineProperty(_this,"renderIsochroneResult",function(isoConfig){if(isoConfig.result.success===false){return/*#__PURE__*/React.createElement("div",{className:"routing-status-failure"},isoConfig.result.data.errorMsgId?LocaleUtils.tr(isoConfig.result.data.errorMsgId):isoConfig.result.data.error)}else{return/*#__PURE__*/React.createElement("div",{className:"routing-result"},/*#__PURE__*/React.createElement("div",{className:"routing-result-summary"},/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"export"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.exportIsochrone},LocaleUtils.tr("routing.export"))),/*#__PURE__*/React.createElement("span",{className:"routing-result-spacer"}),/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement(Icon,{icon:"layers"})," ",/*#__PURE__*/React.createElement("a",{href:"#",onClick:_this.addIsochroneLayer},LocaleUtils.tr("routing.addlayer")))))}});_defineProperty(_this,"renderSearchField",function(entry,idx,config,removeable){var placeholder=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;return/*#__PURE__*/React.createElement("div",{className:"routing-search-field controlgroup",key:"field"+idx},/*#__PURE__*/React.createElement(SearchWidget,{placeholder:placeholder,resultSelected:function resultSelected(result){return _this.searchResultSelected(config,idx,result)},role:"input",searchParams:_this.state.searchParams,searchProviders:_this.state.searchProviders,value:entry.text}),idx===0?/*#__PURE__*/React.createElement("button",{className:"button",disabled:!_this.props.locatePos,onClick:function onClick(){return _this.updatePoint(config,0,_this.locatePos())},role:"suffix"},/*#__PURE__*/React.createElement(Icon,{icon:"screenshot"})):null,removeable?/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this.removePoint(config,idx)},role:"suffix"},/*#__PURE__*/React.createElement(Icon,{icon:"remove"})):null)});_defineProperty(_this,"renderImportButton",function(config){return/*#__PURE__*/React.createElement("label",{className:"routing-import-button",title:LocaleUtils.tr("routing.importhint")},/*#__PURE__*/React.createElement(Icon,{icon:"import"})," ",LocaleUtils.tr("routing.importpoints"),/*#__PURE__*/React.createElement("input",{onChange:function onChange(ev){return _this.importPoints(ev,config)},type:"file"}))});_defineProperty(_this,"locatePos",function(){return{pos:_toConsumableArray(_this.props.locatePos),text:_this.props.locatePos.map(function(x){return x.toFixed(4)}).join(", "),crs:"EPSG:4326"}});_defineProperty(_this,"updateSetting",function(mode,diff){_this.setState(function(state){return{settings:_objectSpread(_objectSpread({},state.settings),{},_defineProperty({},mode,_objectSpread(_objectSpread({},state.settings[mode]),diff)))}});_this.recomputeIfNeeded()});_defineProperty(_this,"addPoint",function(config){var index=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1;var entry=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{text:"",pos:null};_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:[].concat(_toConsumableArray(state[config].points.slice(0,index)),[entry],_toConsumableArray(state[config].points.slice(index)))}))});if(entry.pos){_this.recomputeIfNeeded()}});_defineProperty(_this,"updatePoint",function(config,idx,diff){_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:[].concat(_toConsumableArray(state[config].points.slice(0,idx)),[_objectSpread(_objectSpread({},state[config].points[idx]),diff)],_toConsumableArray(state[config].points.slice(idx+1)))}))});_this.recomputeIfNeeded()});_defineProperty(_this,"importPoints",function(ev,config){var reader=new FileReader;reader.onload=function(loadev){try{var obj=JSON.parse(loadev.target.result);var crs="EPSG:4326";if(obj.crs&&obj.crs.properties){crs=CoordinatesUtils.fromOgcUrnCrs(obj.crs.properties.name)}var prec=CoordinatesUtils.getPrecision(crs);_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:obj.features.map(function(feature){var coordinates=feature.geometry.coordinates;return{text:coordinates.map(function(x){return x.toFixed(prec)}).join(", ")+" ("+crs+")",pos:coordinates,crs:crs}})}))});_this.recomputeIfNeeded()}catch(e){// eslint-disable-next-line
12
12
  alert(LocaleUtils.tr("routing.importerror"))}};reader.readAsText(ev.target.files[0])});_defineProperty(_this,"removePoint",function(config,idx){_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:[].concat(_toConsumableArray(state[config].points.slice(0,idx)),_toConsumableArray(state[config].points.slice(idx+1)))}))});_this.recomputeIfNeeded()});_defineProperty(_this,"clearConfig",function(config){var newPoints=config==="routeConfig"?[{text:"",pos:null,crs:null},{text:"",pos:null,crs:null}]:[{text:"",pos:null,crs:null}];_this.setState(function(state){return _defineProperty({},config,_objectSpread(_objectSpread({},state[config]),{},{points:newPoints,result:null}))});_this.props.removeLayer("routinggeometries");_this.props.removeLayer("routingmarkers");_this.recomputeIfNeeded()});_defineProperty(_this,"reverseRoutePts",function(){_this.setState(function(state){return{routeConfig:_objectSpread(_objectSpread({},state.routeConfig),{},{points:state.routeConfig.points.reverse()})}});_this.recomputeIfNeeded()});_defineProperty(_this,"updateRouteConfig",function(diff){var recompute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_this.setState(function(state){return{routeConfig:_objectSpread(_objectSpread({},state.routeConfig),diff)}});if(recompute){_this.recomputeIfNeeded()}});_defineProperty(_this,"updateIsoConfig",function(diff){var recompute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_this.setState(function(state){return{isoConfig:_objectSpread(_objectSpread({},state.isoConfig),diff)}});if(recompute){_this.recomputeIfNeeded()}});_defineProperty(_this,"searchResultSelected",function(config,idx,result){if(result){_this.updatePoint(config,idx,{text:result.text,pos:[result.x,result.y],crs:result.crs})}else{_this.updatePoint(config,idx,{text:"",pos:null,crs:null})}});_defineProperty(_this,"updateRoutingMarkers",function(){var points=[];if(_this.state.currentTab==="Route"){points=_this.state.routeConfig.points}else{points=_this.state.isoConfig.points}var layer={id:"routingmarkers",role:LayerRole.MARKER,styleName:"marker"};var features=points.filter(function(point){return point.pos}).map(function(point,idx){return{type:"Feature",crs:point.crs,geometry:{type:"Point",coordinates:point.pos},properties:{label:_this.props.showPinLabels&&_this.state.routeConfig.result?String(idx+1):null}}});_this.props.addLayerFeatures(layer,features,true)});_defineProperty(_this,"computeRoute",function(){var locations=_this.state.routeConfig.points.filter(function(entry){return entry.pos}).map(function(entry){return CoordinatesUtils.reproject(entry.pos,entry.crs,"EPSG:4326")});_this.props.removeLayer("routinggeometries");_this.updateRouteConfig({busy:locations.length>=2,result:null},false);if(locations.length<2){return}if(_this.state.routeConfig.roundtrip){locations.push(locations[0])}var settings=_objectSpread({},_this.state.settings[_this.state.mode]);if(_this.state.routeConfig.excludeLayer){var layer=_this.props.layers.find(function(l){return l.id===_this.state.routeConfig.excludeLayer});if(layer){settings.exclude_polygons=layer.features.filter(function(feature){return feature.geometry.type==="Polygon"}).map(function(feature){return VectorLayerUtils.reprojectGeometry(feature.geometry,_this.props.mapCrs,"EPSG:4326").coordinates[0]})}}settings.optimized_route=_this.state.routeConfig.optimized_route;RoutingInterface.computeRoute(_this.state.mode,locations,settings,function(success,result){if(success){// Add routing leg geometries
13
13
  var _layer={id:"routinggeometries",role:LayerRole.SELECTION,styleName:"default",styleOptions:{strokeColor:[10,10,255,1],strokeWidth:4,strokeDash:[]}};var features=[];result.legs.forEach(function(leg){leg.maneuvers.forEach(function(man){features.push({type:"Feature",crs:"EPSG:4326",styleOptions:{strokeColor:man.color},geometry:{type:"LineString",coordinates:leg.coordinates.slice(man.geom_indices[0],man.geom_indices[1]+1)}})})});_this.props.addLayerFeatures(_layer,features,true);// Reorder locations based on routing result, keeping null entries
14
- var _this$state$routeConf=_this.state.routeConfig.points.reduce(function(res,point,idx){return point.pos?_objectSpread(_objectSpread({},res),{},{points:[].concat(_toConsumableArray(res.points),[point])}):_objectSpread(_objectSpread({},res),{},{nullPoints:[].concat(_toConsumableArray(res.nullPoints),[{point:point,idx:idx}])})},{points:[],nullPoints:[]}),points=_this$state$routeConf.points,nullPoints=_this$state$routeConf.nullPoints;var reorderedPoints=result.locations.map(function(location){return points[location.orig_idx]}).filter(Boolean);nullPoints.forEach(function(entry){reorderedPoints.splice(entry.idx,0,entry.point)});_this.updateRouteConfig({points:reorderedPoints,result:{success:success,data:result},busy:false},false);if(_this.props.zoomAuto){_this.props.zoomToExtent(result.summary.bounds,"EPSG:4326",-1)}}else{_this.updateRouteConfig({result:{success:success,data:result},busy:false},false)}})});_defineProperty(_this,"computeIsochrone",function(){var intervalValid=!!_this.state.isoConfig.intervals.match(/^\d+(,\s*\d+)*$/);if(!intervalValid){return}var locations=_this.state.isoConfig.points.filter(function(entry){return entry.pos}).map(function(entry){return CoordinatesUtils.reproject(entry.pos,entry.crs,"EPSG:4326")});_this.props.removeLayer("routinggeometries");_this.updateIsoConfig({busy:true,result:null},false);var unitsFactor=_this.props.units[_this.state.isoConfig.mode][_this.state.isoConfig.units[_this.state.isoConfig.mode]];var contourOptions={mode:_this.state.isoConfig.mode,intervals:_this.state.isoConfig.intervals.split(",").map(function(entry){return parseInt(entry.trim(),10)/unitsFactor}).sort()};RoutingInterface.computeIsochrone(_this.state.mode,locations,contourOptions,_this.state.settings[_this.state.mode],function(success,result){if(success){var layer={id:"routinggeometries",role:LayerRole.SELECTION,styleOptions:{strokeColor:[10,10,255,1],fillColor:[10,10,255,0.5],strokeWidth:4,strokeDash:[]}};var features=result.areas.map(function(area){return{type:"Feature",crs:"EPSG:4326",geometry:{type:"Polygon",coordinates:[area]}}});_this.props.addLayerFeatures(layer,features,true);if(_this.props.zoomAuto){_this.props.zoomToExtent(result.bounds,"EPSG:4326",-0.5)}}_this.updateIsoConfig({result:{success:success,data:result},busy:false},false)})});_defineProperty(_this,"recomputeIfNeeded",function(){clearTimeout(_this.recomputeTimeout);_this.recomputeTimeout=setTimeout(function(){if(_this.state.currentTab==="Route"&&_this.state.routeConfig.points.filter(function(entry){return entry.pos}).length>=2){_this.computeRoute()}else if(_this.state.currentTab==="Reachability"&&_this.state.isoConfig.points.filter(function(entry){return entry.pos}).length>0){_this.computeIsochrone()}_this.recomputeTimeout=null},750)});_defineProperty(_this,"exportRoute",function(){var data=JSON.stringify({type:"FeatureCollection",features:_this.state.routeConfig.result.data.legs.map(function(leg){return{type:"Feature",properties:{time:leg.time,length:leg.length},geometry:{type:"LineString",coordinates:leg.coordinates}}})});FileSaver.saveAs(new Blob([data],{type:"text/plain;charset=utf-8"}),"route.json")});_defineProperty(_this,"exportIsochrone",function(){var data=JSON.stringify({type:"FeatureCollection",features:_this.state.isoConfig.result.data.areas.map(function(area){return{type:"Feature",geometry:{type:"Polygon",coordinates:[area]}}})});FileSaver.saveAs(new Blob([data],{type:"text/plain;charset=utf-8"}),"isochrone.json")});_defineProperty(_this,"onSortChange",function(order,sortable,ev){var newpoints=_this.state.routeConfig.points.slice(0);var moved=newpoints.splice(ev.oldIndex,1)[0];newpoints.splice(ev.newIndex,0,moved);_this.updateRouteConfig({points:newpoints})});_this.recomputeTimeout=null;_this.state.mode=_this.props.enabledModes[0];return _this}_inherits(Routing,_React$Component);return _createClass(Routing,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;// Recollect search providers
14
+ var _this$state$routeConf=_this.state.routeConfig.points.reduce(function(res,point,idx){return point.pos?_objectSpread(_objectSpread({},res),{},{points:[].concat(_toConsumableArray(res.points),[point])}):_objectSpread(_objectSpread({},res),{},{nullPoints:[].concat(_toConsumableArray(res.nullPoints),[{point:point,idx:idx}])})},{points:[],nullPoints:[]}),points=_this$state$routeConf.points,nullPoints=_this$state$routeConf.nullPoints;var reorderedPoints=result.locations.map(function(location){return points[location.orig_idx]}).filter(Boolean);nullPoints.forEach(function(entry){reorderedPoints.splice(entry.idx,0,entry.point)});_this.updateRouteConfig({points:reorderedPoints,result:{success:success,data:result},busy:false},false);if(_this.props.zoomAuto){_this.props.zoomToExtent(result.summary.bounds,"EPSG:4326",-1)}}else{_this.updateRouteConfig({result:{success:success,data:result},busy:false},false)}})});_defineProperty(_this,"computeIsochrone",function(){var intervalValid=!!_this.state.isoConfig.intervals.match(/^\d+(,\s*\d+)*$/);if(!intervalValid){return}var locations=_this.state.isoConfig.points.filter(function(entry){return entry.pos}).map(function(entry){return CoordinatesUtils.reproject(entry.pos,entry.crs,"EPSG:4326")});_this.props.removeLayer("routinggeometries");_this.updateIsoConfig({busy:true,result:null},false);var unitsFactor=_this.props.units[_this.state.isoConfig.mode][_this.state.isoConfig.units[_this.state.isoConfig.mode]];var contourOptions={mode:_this.state.isoConfig.mode,intervals:_this.state.isoConfig.intervals.split(",").map(function(entry){return parseInt(entry.trim(),10)/unitsFactor}).sort()};RoutingInterface.computeIsochrone(_this.state.mode,locations,contourOptions,_this.state.settings[_this.state.mode],function(success,result){if(success){var layer={id:"routinggeometries",role:LayerRole.SELECTION,styleOptions:{strokeColor:[10,10,255,1],fillColor:[10,10,255,0.5],strokeWidth:4,strokeDash:[]}};var features=result.areas.map(function(area){return{type:"Feature",crs:"EPSG:4326",geometry:{type:"Polygon",coordinates:[area]}}});_this.props.addLayerFeatures(layer,features,true);if(_this.props.zoomAuto){_this.props.zoomToExtent(result.bounds,"EPSG:4326",-0.5)}}_this.updateIsoConfig({result:{success:success,data:result},busy:false},false)})});_defineProperty(_this,"recomputeIfNeeded",function(){clearTimeout(_this.recomputeTimeout);_this.recomputeTimeout=setTimeout(function(){if(_this.state.currentTab==="Route"&&_this.state.routeConfig.points.filter(function(entry){return entry.pos}).length>=2){_this.computeRoute()}else if(_this.state.currentTab==="Reachability"&&_this.state.isoConfig.points.filter(function(entry){return entry.pos}).length>0){_this.computeIsochrone()}_this.recomputeTimeout=null},750)});_defineProperty(_this,"collectRoutingFeatures",function(){return _this.state.routeConfig.result.data.legs.map(function(leg){return{type:"Feature",properties:{time:leg.time,length:leg.length},geometry:{type:"LineString",coordinates:leg.coordinates},styleName:"default",styleOptions:{strokeColor:[10,10,255,1],strokeWidth:4,strokeDash:[]}}})});_defineProperty(_this,"exportRoute",function(){var data=JSON.stringify({type:"FeatureCollection",features:_this.collectRoutingFeatures()});FileSaver.saveAs(new Blob([data],{type:"text/plain;charset=utf-8"}),"route.json")});_defineProperty(_this,"addRouteLayer",function(){var layer={id:uuidv4(),crs:"EPSG:4326",title:LocaleUtils.tr("routing.route"),type:"vector"};_this.props.addLayerFeatures(layer,_this.collectRoutingFeatures());_this.props.setCurrentTask("LayerTree")});_defineProperty(_this,"collectIsochroneFeatures",function(){return _this.state.isoConfig.result.data.areas.map(function(area){return{type:"Feature",geometry:{type:"Polygon",coordinates:[area]},styleName:"default",styleOptions:{strokeColor:[10,10,255,1],fillColor:[10,10,255,0.5],strokeWidth:4,strokeDash:[]}}})});_defineProperty(_this,"exportIsochrone",function(){var data=JSON.stringify({type:"FeatureCollection",features:_this.collectIsochroneFeatures()});FileSaver.saveAs(new Blob([data],{type:"text/plain;charset=utf-8"}),"isochrone.json")});_defineProperty(_this,"addIsochroneLayer",function(){var layer={id:uuidv4(),crs:"EPSG:4326",title:LocaleUtils.tr("routing.reachability"),type:"vector"};_this.props.addLayerFeatures(layer,[_this.collectIsochroneFeatures()]);_this.props.setCurrentTask("LayerTree")});_defineProperty(_this,"onSortChange",function(order,sortable,ev){var newpoints=_this.state.routeConfig.points.slice(0);var moved=newpoints.splice(ev.oldIndex,1)[0];newpoints.splice(ev.newIndex,0,moved);_this.updateRouteConfig({points:newpoints})});_this.recomputeTimeout=null;_this.state.mode=_this.props.enabledModes[0];return _this}_inherits(Routing,_React$Component);return _createClass(Routing,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;// Recollect search providers
15
15
  if(this.props.searchProviders!==prevProps.searchProviders){this.setState({searchProviders:this.props.enabledProviders.map(function(key){return _this2.props.searchProviders[key]}).filter(Boolean),searchParams:{mapcrs:this.props.mapCrs,displaycrs:this.props.displayCrs}})}// Activated / message
16
16
  if(this.props.task.id==="Routing"){this.props.setCurrentTask(null);if(!this.state.visible){this.setState({visible:true})}var taskData=this.props.task.data||{};if(taskData.from){this.setState({currentTab:"Route"});this.updatePoint("routeConfig",0,taskData.from)}if(taskData.to){this.setState({currentTab:"Route"});this.updatePoint("routeConfig",this.state.routeConfig.points.length-1,taskData.to)}if(taskData.via){this.setState({currentTab:"Route"});this.addPoint("routeConfig",-1,taskData.via)}if(taskData.isocenter){this.setState({currentTab:"Reachability"});this.updateIsoConfig({points:[taskData.isocenter]})}if(taskData.isoextracenter){this.setState({currentTab:"Reachability"});this.updateIsoConfig({points:[].concat(_toConsumableArray(this.state.isoConfig.points),[taskData.isoextracenter])})}}// Window closed
17
17
  if(!this.state.visible&&prevState.visible){this.props.removeLayer("routinggeometries");this.props.removeLayer("routingmarkers");this.updateRouteConfig({points:[{text:"",pos:null,crs:null},{text:"",pos:null,crs:null}],result:null},false);this.updateIsoConfig({point:{text:"",pos:null,crs:null},result:null},false)}// No further processing beyond here if not visible
@@ -20,4 +20,4 @@ if(this.state.currentTab!==prevState.currentTab){this.props.removeLayer("routing
20
20
  if(this.state.mode!==prevState.mode){this.recomputeIfNeeded()}// Routing markers
21
21
  if(this.state.currentTab!==prevState.currentTab||this.state.routeConfig.points!==prevState.routeConfig.points||this.state.isoConfig.points!==prevState.isoConfig.points){this.updateRoutingMarkers()}// Theme changed
22
22
  if(this.props.theme!==prevProps.theme){this.setState({visible:false})}// Recompute when exclude layer changes
23
- if(this.state.currentTab==="Route"&&this.state.routeConfig.excludeLayer&&this.props.layers!==prevProps.layers){var newlayer=this.props.layers.find(function(layer){return layer.id===_this2.state.routeConfig.excludeLayer});var prevLayer=prevProps.layers.find(function(layer){return layer.id===_this2.state.routeConfig.excludeLayer});if(newlayer!==prevLayer){this.recomputeIfNeeded()}}}},{key:"render",value:function render(){var _this3=this;if(!this.state.visible){return null}var tabButtons=[{key:"Route",label:LocaleUtils.tr("routing.route")},{key:"Reachability",label:LocaleUtils.tr("routing.reachability")}];var tabRenderers={Route:this.renderRouteWidget,Reachability:this.renderIsochroneWidget};var buttons=[{key:"auto",icon:"routing-car",tooltip:LocaleUtils.tr("routing.mode_auto")},{key:"heavyvehicle",icon:"routing-truck",tooltip:LocaleUtils.tr("routing.mode_heavyvehicle")},{key:"transit",icon:"routing-train",tooltip:LocaleUtils.tr("routing.mode_transit")},{key:"bicycle",icon:"routing-bicycle",tooltip:LocaleUtils.tr("routing.mode_bicycle")},{key:"pedestrian",icon:"routing-walking",tooltip:LocaleUtils.tr("routing.mode_walking")}];var enabledButtons=this.props.enabledModes.map(function(entry){return buttons.find(function(button){return button.key===entry})});return/*#__PURE__*/React.createElement(ResizeableWindow,{dockable:this.props.geometry.side,icon:"routing",initialHeight:this.props.geometry.initialHeight,initialWidth:this.props.geometry.initialWidth,initialX:this.props.geometry.initialX,initialY:this.props.geometry.initialY,initiallyDocked:this.props.geometry.initiallyDocked,onClose:function onClose(){return _this3.setState({visible:false})},title:LocaleUtils.tr("routing.windowtitle")},/*#__PURE__*/React.createElement("div",{className:"routing-body",role:"body"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.currentTab,buttons:tabButtons,className:"routing-buttonbar",onClick:function onClick(key){return _this3.setState({currentTab:key})}}),/*#__PURE__*/React.createElement("div",{className:"routing-frame"},/*#__PURE__*/React.createElement("div",{className:"routing-buttons controlgroup"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.mode,buttons:enabledButtons,onClick:function onClick(key){return _this3.setState({mode:key})}}),/*#__PURE__*/React.createElement("button",{className:"button"+(this.state.settingsPopup?" pressed":""),onClick:function onClick(){return _this3.setState(function(state){return{settingsPopup:!state.settingsPopup}})}},/*#__PURE__*/React.createElement(Icon,{icon:"cog"})),this.state.settingsPopup?this.renderSettings():null),tabRenderers[this.state.currentTab]())))}}])}(React.Component);_defineProperty(Routing,"propTypes",{addLayerFeatures:PropTypes.func,displayCrs:PropTypes.string,/** List of enabled routing modes. */enabledModes:PropTypes.arrayOf(PropTypes.string),/** List of search providers to use for routing location search. */enabledProviders:PropTypes.arrayOf(PropTypes.string),/** Default window geometry with size, position and docking status. Positive position values (including '0') are related to top (InitialY) and left (InitialX), negative values (including '-0') to bottom (InitialY) and right (InitialX). */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool,side:PropTypes.string}),layers:PropTypes.array,locatePos:PropTypes.array,mapCrs:PropTypes.string,removeLayer:PropTypes.func,searchProviders:PropTypes.object,setCurrentTask:PropTypes.func,/** Whether to label the routing waypoint pins with the route point number. */showPinLabels:PropTypes.bool,task:PropTypes.object,theme:PropTypes.object,/** Set of units for isochrone time/distance intervals to use. */units:PropTypes.object,/** Automatically zoom to the extent of the route */zoomAuto:PropTypes.bool,zoomToExtent:PropTypes.func});_defineProperty(Routing,"defaultProps",{enabledModes:["auto","heavyvehicle","transit","bicycle","pedestrian"],enabledProviders:["coordinates","nominatim"],geometry:{initialWidth:320,initialHeight:640,initialX:0,initialY:0,initiallyDocked:true,side:"left"},showPinLabels:true,units:{time:{min:1,s:60},distance:{km:1,m:1000}},zoomAuto:true});export default connect(createSelector([function(state){return state},searchProvidersSelector],function(state,searchProviders){return{displayCrs:state.map.displayCrs,layers:state.layers.flat,locatePos:state.locate.position,mapCrs:state.map.projection,searchProviders:searchProviders,task:state.task,theme:state.theme.current}}),{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,setCurrentTask:setCurrentTask,zoomToExtent:zoomToExtent})(Routing);
23
+ if(this.state.currentTab==="Route"&&this.state.routeConfig.excludeLayer&&this.props.layers!==prevProps.layers){var newlayer=this.props.layers.find(function(layer){return layer.id===_this2.state.routeConfig.excludeLayer});var prevLayer=prevProps.layers.find(function(layer){return layer.id===_this2.state.routeConfig.excludeLayer});if(newlayer!==prevLayer){this.recomputeIfNeeded()}}}},{key:"render",value:function render(){var _this3=this;if(!this.state.visible){return null}var tabButtons=[{key:"Route",label:LocaleUtils.tr("routing.route")},{key:"Reachability",label:LocaleUtils.tr("routing.reachability")}];var tabRenderers={Route:this.renderRouteWidget,Reachability:this.renderIsochroneWidget};var buttons=[{key:"auto",icon:"routing-car",tooltip:LocaleUtils.tr("routing.mode_auto")},{key:"heavyvehicle",icon:"routing-truck",tooltip:LocaleUtils.tr("routing.mode_heavyvehicle")},{key:"transit",icon:"routing-train",tooltip:LocaleUtils.tr("routing.mode_transit")},{key:"bicycle",icon:"routing-bicycle",tooltip:LocaleUtils.tr("routing.mode_bicycle")},{key:"pedestrian",icon:"routing-walking",tooltip:LocaleUtils.tr("routing.mode_walking")}];var enabledButtons=this.props.enabledModes.map(function(entry){return buttons.find(function(button){return button.key===entry})});return/*#__PURE__*/React.createElement(ResizeableWindow,{dockable:this.props.geometry.side,icon:"routing",initialHeight:this.props.geometry.initialHeight,initialWidth:this.props.geometry.initialWidth,initialX:this.props.geometry.initialX,initialY:this.props.geometry.initialY,initiallyDocked:this.props.geometry.initiallyDocked,onClose:function onClose(){return _this3.setState({visible:false})},title:LocaleUtils.tr("routing.windowtitle")},/*#__PURE__*/React.createElement("div",{className:"routing-body",role:"body"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.currentTab,buttons:tabButtons,className:"routing-buttonbar",onClick:function onClick(key){return _this3.setState({currentTab:key})}}),/*#__PURE__*/React.createElement("div",{className:"routing-frame"},/*#__PURE__*/React.createElement("div",{className:"routing-buttons controlgroup"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.mode,buttons:enabledButtons,onClick:function onClick(key){return _this3.setState({mode:key})}}),/*#__PURE__*/React.createElement("button",{className:"button"+(this.state.settingsPopup?" pressed":""),onClick:function onClick(){return _this3.setState(function(state){return{settingsPopup:!state.settingsPopup}})}},/*#__PURE__*/React.createElement(Icon,{icon:"cog"})),this.state.settingsPopup?this.renderSettings():null),tabRenderers[this.state.currentTab]())))}}])}(React.Component);_defineProperty(Routing,"propTypes",{addLayerFeatures:PropTypes.func,displayCrs:PropTypes.string,/** List of enabled routing modes. */enabledModes:PropTypes.arrayOf(PropTypes.string),/** List of search providers to use for routing location search. */enabledProviders:PropTypes.arrayOf(PropTypes.string),/** Default window geometry with size, position and docking status. Positive position values (including '0') are related to top (InitialY) and left (InitialX), negative values (including '-0') to bottom (InitialY) and right (InitialX). */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool,side:PropTypes.string}),layers:PropTypes.array,locatePos:PropTypes.array,mapCrs:PropTypes.string,removeLayer:PropTypes.func,searchProviders:PropTypes.object,setCurrentTask:PropTypes.func,/** Whether to label the routing waypoint pins with the route point number. */showPinLabels:PropTypes.bool,task:PropTypes.object,theme:PropTypes.object,/** Set of units for isochrone time/distance intervals to use. */units:PropTypes.object,/** Automatically zoom to the extent of the route */zoomAuto:PropTypes.bool,zoomToExtent:PropTypes.func});_defineProperty(Routing,"defaultProps",{enabledModes:["auto","heavyvehicle","transit","bicycle","pedestrian"],enabledProviders:["coordinates","nominatim"],geometry:{initialWidth:480,initialHeight:640,initialX:0,initialY:0,initiallyDocked:true,side:"left"},showPinLabels:true,units:{time:{min:1,s:60},distance:{km:1,m:1000}},zoomAuto:true});export default connect(createSelector([function(state){return state},searchProvidersSelector],function(state,searchProviders){return{displayCrs:state.map.displayCrs,layers:state.layers.flat,locatePos:state.locate.position,mapCrs:state.map.projection,searchProviders:searchProviders,task:state.task,theme:state.theme.current}}),{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,setCurrentTask:setCurrentTask,zoomToExtent:zoomToExtent})(Routing);
@@ -4,12 +4,12 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole,addLayerFeatures,removeLayer,clearLayer}from"../actions/layers";import{setSnappingConfig}from"../actions/map";import{changeRedliningState,resetRedliningState}from"../actions/redlining";import{setCurrentTask}from"../actions/task";import TaskBar from"../components/TaskBar";import LocaleUtils from"../utils/LocaleUtils";import"./style/Redlining.css";import"./style/ScratchDrawing.css";/**
7
+ */import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole,addLayerFeatures,removeLayer,clearLayer}from"../actions/layers";import{setSnappingConfig}from"../actions/map";import{changeRedliningState,resetRedliningState}from"../actions/redlining";import{setCurrentTask}from"../actions/task";import TaskBar from"../components/TaskBar";import LocaleUtils from"../utils/LocaleUtils";import"./style/Redlining.css";import"./style/ScratchDrawing.css";/**
8
8
  * Task which which can be invoked by other tools to draw a geometry and pass it to a callback.
9
9
  *
10
10
  * Only useful for third-party code, i.e. over the JavaScript API.
11
11
  *
12
12
  * Invoke as `setCurrentTask("ScratchDrawing", null, null, {callback: <function(features, crs)>});`
13
- */var ScratchDrawing=/*#__PURE__*/function(_React$Component){function ScratchDrawing(props){var _this;_classCallCheck(this,ScratchDrawing);_this=_callSuper(this,ScratchDrawing,[props]);_defineProperty(_this,"createDrawLayer",function(data){var layerId=uuidv1();var features=(data.initialFeatures||[]).map(function(feature){return _objectSpread(_objectSpread({},feature),{},{id:uuidv1(),shape:feature.geometry.type,styleName:"default",styleOptions:_this.styleOptions(_this.drawingStyle(data.style))})});var layer={id:layerId,role:LayerRole.USERLAYER,type:"vector"};_this.props.addLayerFeatures(layer,features,true);return layerId});_defineProperty(_this,"drawingStyle",function(style){return _objectSpread({borderColor:[255,0,0,1],size:2,fillColor:[255,255,255,0.5],text:""},style)});_defineProperty(_this,"styleOptions",function(styleProps){return{strokeColor:styleProps.borderColor,strokeWidth:1+0.5*styleProps.size,fillColor:styleProps.fillColor,circleRadius:5+styleProps.size,strokeDash:[],headmarker:styleProps.headmarker,tailmarker:styleProps.tailmarker}});_defineProperty(_this,"submitGeometry",function(){var _this$props$layers$fi;var features=((_this$props$layers$fi=_this.props.layers.find(function(l){return l.id===_this.props.redlining.layer}))===null||_this$props$layers$fi===void 0?void 0:_this$props$layers$fi.features)||[];_this.submitted=true;_this.props.task.data.callback(features,_this.props.projection);_this.props.setCurrentTask(null)});_this.submitted=false;return _this}_inherits(ScratchDrawing,_React$Component);return _createClass(ScratchDrawing,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){// Clear when task changes
13
+ */var ScratchDrawing=/*#__PURE__*/function(_React$Component){function ScratchDrawing(props){var _this;_classCallCheck(this,ScratchDrawing);_this=_callSuper(this,ScratchDrawing,[props]);_defineProperty(_this,"createDrawLayer",function(data){var layerId=uuidv4();var features=(data.initialFeatures||[]).map(function(feature){return _objectSpread(_objectSpread({},feature),{},{id:uuidv4(),shape:feature.geometry.type,styleName:"default",styleOptions:_this.styleOptions(_this.drawingStyle(data.style))})});var layer={id:layerId,role:LayerRole.USERLAYER,type:"vector"};_this.props.addLayerFeatures(layer,features,true);return layerId});_defineProperty(_this,"drawingStyle",function(style){return _objectSpread({borderColor:[255,0,0,1],size:2,fillColor:[255,255,255,0.5],text:""},style)});_defineProperty(_this,"styleOptions",function(styleProps){return{strokeColor:styleProps.borderColor,strokeWidth:1+0.5*styleProps.size,fillColor:styleProps.fillColor,circleRadius:5+styleProps.size,strokeDash:[],headmarker:styleProps.headmarker,tailmarker:styleProps.tailmarker}});_defineProperty(_this,"submitGeometry",function(){var _this$props$layers$fi;var features=((_this$props$layers$fi=_this.props.layers.find(function(l){return l.id===_this.props.redlining.layer}))===null||_this$props$layers$fi===void 0?void 0:_this$props$layers$fi.features)||[];_this.submitted=true;_this.props.task.data.callback(features,_this.props.projection);_this.props.setCurrentTask(null)});_this.submitted=false;return _this}_inherits(ScratchDrawing,_React$Component);return _createClass(ScratchDrawing,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){// Clear when task changes
14
14
  if(this.props.task.id!=="ScratchDrawing"&&prevProps.task.id==="ScratchDrawing"){if(!this.submitted){prevProps.task.data.callback(null,null);this.submitted=true}this.props.removeLayer(prevProps.redlining.layer);this.props.resetRedliningState()}// Setup redlining state
15
15
  if(this.props.task!==prevProps.task&&this.props.task.id==="ScratchDrawing"){if(prevProps.task.id==="ScratchDrawing"){this.props.removeLayer(prevProps.redlining.layer);if(!this.submitted){prevProps.task.data.callback(null,null);this.submitted=true}}this.submitted=false;var data=this.props.task.data;var layerId=this.createDrawLayer(data);this.props.setSnappingConfig(data.snapping,data.snappingActive);this.props.changeRedliningState({action:"PickDraw",geomType:data.geomType,layer:layerId,layerTitle:null,drawMultiple:data.drawMultiple,style:this.drawingStyle(data.style)})}}},{key:"render",value:function render(){var _this$props$task$data,_this2=this;return/*#__PURE__*/React.createElement(TaskBar,{task:"ScratchDrawing"},/*#__PURE__*/React.createElement("div",{className:"scratch-drawing-taskbar-body",role:"body"},/*#__PURE__*/React.createElement("span",null,(_this$props$task$data=this.props.task.data)===null||_this$props$task$data===void 0?void 0:_this$props$task$data.message),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this2.submitGeometry()}},LocaleUtils.tr("scratchdrawing.finish"))))}}])}(React.Component);_defineProperty(ScratchDrawing,"propTypes",{addLayerFeatures:PropTypes.func,changeRedliningState:PropTypes.func,clearLayer:PropTypes.func,layers:PropTypes.array,projection:PropTypes.string,redlining:PropTypes.object,removeLayer:PropTypes.func,resetRedliningState:PropTypes.func,setCurrentTask:PropTypes.func,setSnappingConfig:PropTypes.func,task:PropTypes.object});export default connect(function(state){return{task:state.task,layers:state.layers.flat,redlining:state.redlining,projection:state.map.projection,theme:state.theme.current}},{changeRedliningState:changeRedliningState,addLayerFeatures:addLayerFeatures,clearLayer:clearLayer,removeLayer:removeLayer,resetRedliningState:resetRedliningState,setCurrentTask:setCurrentTask,setSnappingConfig:setSnappingConfig})(ScratchDrawing);
@@ -4,7 +4,7 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import dateParser,{Format}from"any-date-parser";import dayjs from"dayjs";import utc from"dayjs/plugin/utc";import isEmpty from"lodash.isempty";import isEqual from"lodash.isequal";import ol from"openlayers";import PropTypes from"prop-types";import{createSelector}from"reselect";import{v1 as uuidv1}from"uuid";import{setLayerDimensions,addLayerFeatures,refreshLayer,removeLayer,LayerRole}from"../actions/layers";import{setCurrentTask,setCurrentTaskBlocked}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import FixedTimeline from"../components/timeline/FixedTimeline";import InfiniteTimeline from"../components/timeline/InfiniteTimeline";import TimelineFeaturesSlider from"../components/timeline/TimelineFeaturesSlider";import ButtonBar from"../components/widgets/ButtonBar";import NumberInput from"../components/widgets/NumberInput";import ToggleSwitch from"../components/widgets/ToggleSwitch";import IdentifyUtils from"../utils/IdentifyUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import VectorLayerUtils from"../utils/VectorLayerUtils";import markerIcon from"../utils/img/marker-icon.png";import"./style/TimeManager.css";dayjs.extend(utc);var DateUnitLabels={"ms":LocaleUtils.trmsg("timemanager.unit.milliseconds"),"s":LocaleUtils.trmsg("timemanager.unit.seconds"),"m":LocaleUtils.trmsg("timemanager.unit.minutes"),"h":LocaleUtils.trmsg("timemanager.unit.hours"),"d":LocaleUtils.trmsg("timemanager.unit.days"),"M":LocaleUtils.trmsg("timemanager.unit.months"),"y":LocaleUtils.trmsg("timemanager.unit.years"),"10y":LocaleUtils.trmsg("timemanager.unit.decade"),"100y":LocaleUtils.trmsg("timemanager.unit.century")};var qgisDateFormat=new Format({// $dateExpr $hour $minute $second $millisecond $zone $offset
7
+ */import React from"react";import{connect}from"react-redux";import dateParser,{Format}from"any-date-parser";import dayjs from"dayjs";import utc from"dayjs/plugin/utc";import isEmpty from"lodash.isempty";import isEqual from"lodash.isequal";import ol from"openlayers";import PropTypes from"prop-types";import{createSelector}from"reselect";import{v4 as uuidv4}from"uuid";import{setLayerDimensions,addLayerFeatures,refreshLayer,removeLayer,LayerRole}from"../actions/layers";import{setCurrentTask,setCurrentTaskBlocked}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import FixedTimeline from"../components/timeline/FixedTimeline";import InfiniteTimeline from"../components/timeline/InfiniteTimeline";import TimelineFeaturesSlider from"../components/timeline/TimelineFeaturesSlider";import ButtonBar from"../components/widgets/ButtonBar";import NumberInput from"../components/widgets/NumberInput";import ToggleSwitch from"../components/widgets/ToggleSwitch";import IdentifyUtils from"../utils/IdentifyUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import VectorLayerUtils from"../utils/VectorLayerUtils";import markerIcon from"../utils/img/marker-icon.png";import"./style/TimeManager.css";dayjs.extend(utc);var DateUnitLabels={"ms":LocaleUtils.trmsg("timemanager.unit.milliseconds"),"s":LocaleUtils.trmsg("timemanager.unit.seconds"),"m":LocaleUtils.trmsg("timemanager.unit.minutes"),"h":LocaleUtils.trmsg("timemanager.unit.hours"),"d":LocaleUtils.trmsg("timemanager.unit.days"),"M":LocaleUtils.trmsg("timemanager.unit.months"),"y":LocaleUtils.trmsg("timemanager.unit.years"),"10y":LocaleUtils.trmsg("timemanager.unit.decade"),"100y":LocaleUtils.trmsg("timemanager.unit.century")};var qgisDateFormat=new Format({// $dateExpr $hour $minute $second $millisecond $zone $offset
8
8
  matcher:/^(.*?)[\s,-]*([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d|60)(?:[.,](\d{9}|\d{6}|\d{1,3}))?)?[\s,-]*\(?(UTC)?[\s,-]*([+-]0\d?:?(?:[0-5]\d)?)?[\s,-]*\)?$/i,// eslint-disable-next-line
9
9
  handler:function handler(_ref){var _ref2=_slicedToArray(_ref,8),match=_ref2[0],dateExpr=_ref2[1],hour=_ref2[2],minute=_ref2[3],second=_ref2[4],millisecond=_ref2[5],zone=_ref2[6],offset=_ref2[7];var result={};if(dateExpr){result=this.parser.attempt(dateExpr);if(result.invalid){return result}}result.hour=hour;result.minute=minute;if(second){result.second=second}if(millisecond&&millisecond.length>3){result.millisecond=millisecond.slice(0,3)}else if(millisecond){result.millisecond=millisecond}if(offset){result.offset=offset}return result}});dateParser.addFormat(qgisDateFormat);// QGIS server does not return any feature that does not have "enddate" set.
10
10
  // To workaround this limitation, a placeholder date is used to make features
@@ -15,7 +15,7 @@ handler:function handler(_ref){var _ref2=_slicedToArray(_ref,8),match=_ref2[0],d
15
15
  var DUMMY_END_DATE=new Date("9999-01-01 00:00:00");/**
16
16
  * Allows controling the time dimension of temporal WMS layers.
17
17
  */var TimeManager=/*#__PURE__*/function(_React$Component){function TimeManager(props){var _this;_classCallCheck(this,TimeManager);_this=_callSuper(this,TimeManager,[props]);_defineProperty(_this,"renderBody",function(){var timeButtons=[{key:"rewind",tooltip:LocaleUtils.tr("timemanager.rewind"),icon:"nav-start"},{key:"now",tooltip:LocaleUtils.tr("timemanager.now"),icon:"today"},{key:"prev",tooltip:LocaleUtils.tr("timemanager.stepback"),icon:"nav-left"},{key:"playrev",tooltip:LocaleUtils.tr("timemanager.playrev"),icon:"triangle-left",disabled:_this.state.animationActive},{key:"stop",tooltip:LocaleUtils.tr("timemanager.stop"),icon:"square",disabled:!_this.state.animationActive},{key:"play",tooltip:LocaleUtils.tr("timemanager.play"),icon:"triangle-right",disabled:_this.state.animationActive},{key:"next",tooltip:LocaleUtils.tr("timemanager.stepfwd"),icon:"nav-right"},{key:"loop",tooltip:LocaleUtils.tr("timemanager.loop"),icon:"refresh",pressed:_this.state.animationLoop}];var markerConfiguration=_objectSpread(_objectSpread({},TimeManager.defaultProps.markerConfiguration),_this.props.markerConfiguration);var options=/*#__PURE__*/React.createElement("div",{className:"time-manager-options"},/*#__PURE__*/React.createElement("table",null,/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("timemanager.stepsize"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{max:100,min:1,mobile:true,onChange:function onChange(value){return _this.setState({stepSize:value})},value:_this.state.stepSize})),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({stepSizeUnit:ev.target.value})},value:_this.state.stepSizeUnit},_this.props.stepUnits.map(function(unit){return/*#__PURE__*/React.createElement("option",{key:unit,value:unit},LocaleUtils.tr(DateUnitLabels[unit]))})))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("timemanager.animationinterval"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{max:10,min:1,mobile:true,onChange:function onChange(value){return _this.setState({animationInterval:value})},value:_this.state.animationInterval})),/*#__PURE__*/React.createElement("td",null,"\xA0",LocaleUtils.tr("timemanager.unit.seconds"))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("timemanager.timeline"),":"),/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({timelineMode:ev.target.value})},value:_this.state.timelineMode},/*#__PURE__*/React.createElement("option",{value:"fixed"},LocaleUtils.tr("timemanager.timeline_fixed")),/*#__PURE__*/React.createElement("option",{value:"infinite"},LocaleUtils.tr("timemanager.timeline_infinite"))))),_this.state.timelineDisplay!=="hidden"?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("timemanager.timelinedisplay"),":"),/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({timelineDisplay:ev.target.value})},value:_this.state.timelineDisplay},/*#__PURE__*/React.createElement("option",{value:"minimal"},LocaleUtils.tr("timemanager.displayminimal")),/*#__PURE__*/React.createElement("option",{value:"features"},LocaleUtils.tr("timemanager.displayfeatures")),/*#__PURE__*/React.createElement("option",{value:"layers"},LocaleUtils.tr("timemanager.displaylayers"))))):null)));var timeSpan=_this.state.endTime!==null?_this.state.endTime.diff(_this.state.startTime):dayjs().diff(_this.state.startTime);var Timeline=_this.state.timelineMode==="infinite"?InfiniteTimeline:FixedTimeline;var filterActive=!isEmpty(_this.props.filter.filterParams)||!!_this.props.filter.filterGeom;var startdate=_this.state.timeData.values.length>0?_this.state.timeData.values[0].hour(0).minute(0).second(0):null;var enddate=_this.state.timeData.values.length>0?_this.state.timeData.values[_this.state.timeData.values.length-1].hour(23).minute(59).second(59):null;if(startdate&&_this.props.filter.timeRange&&dayjs(_this.props.filter.timeRange.tstart)>startdate){startdate=dayjs(_this.props.filter.timeRange.tstart)}if(enddate&&_this.props.filter.timeRange&&dayjs(_this.props.filter.timeRange.tend)<enddate){enddate=dayjs(_this.props.filter.timeRange.tend)}return/*#__PURE__*/React.createElement("div",{className:"time-manager-body",role:"body"},/*#__PURE__*/React.createElement("div",{className:"time-manager-toolbar"},/*#__PURE__*/React.createElement("div",{className:"time-manager-toolbar-controls"},/*#__PURE__*/React.createElement("span",{className:"time-manager-toolbar-block"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("timemanager.toggle")),/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.timeEnabled,onChange:_this.toggleTimeEnabled})),/*#__PURE__*/React.createElement(ButtonBar,{buttons:timeButtons,disabled:!_this.state.timeEnabled,onClick:_this.animationButtonClicked}),_this.props.markerConfiguration.markersAvailable?/*#__PURE__*/React.createElement("span",{className:"time-manager-toolbar-block"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("timemanager.markers"),": \xA0"),/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.markersEnabled,onChange:function onChange(value){return _this.setState({markersEnabled:value})},readOnly:!_this.state.markersCanBeEnabled})):null),/*#__PURE__*/React.createElement("div",{className:"time-manager-options-menubutton"},/*#__PURE__*/React.createElement("button",{className:"button"+(_this.state.settingsPopup?" pressed":""),onClick:function onClick(){return _this.setState(function(state){return{settingsPopup:!state.settingsPopup}})}},/*#__PURE__*/React.createElement(Icon,{icon:"cog"})),_this.state.settingsPopup?options:null)),filterActive?/*#__PURE__*/React.createElement("div",{className:"time-manager-filter-warning"},/*#__PURE__*/React.createElement(Icon,{icon:"warning"})," ",LocaleUtils.tr("timemanager.filterwarning")," ",/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this.props.setCurrentTask("MapFilter")},type:"button"},LocaleUtils.tr("timemanager.edit"))):null,/*#__PURE__*/React.createElement("div",{className:"time-manager-timeline"},/*#__PURE__*/React.createElement(Timeline,{currentTimestamp:_this.state.currentTimestamp,dataEndTime:enddate,dataStartTime:startdate,dateFormat:_this.props.dateFormat,dialogWidth:_this.state.dialogWidth,endTime:_this.state.endTime,setEndTime:_this.setEndTime,setMarkersCanBeEnabled:function setMarkersCanBeEnabled(value){return _this.setState({markersCanBeEnabled:value,markersEnabled:false})},setStartTime:_this.setStartTime,startTime:_this.state.startTime,timeSpan:timeSpan},function(computePixelFromTime,computeTimeFromPixel){return/*#__PURE__*/React.createElement(TimelineFeaturesSlider,{computePixelFromTime:computePixelFromTime,computeTimeFromPixel:computeTimeFromPixel,currentTimestamp:_this.state.currentTimestamp,cursorFormat:_this.props.cursorFormat,dateFormat:_this.props.dateFormat,displayMode:_this.state.timelineDisplay,endTime:_this.state.endTime,markerConfiguration:markerConfiguration,markersEnabled:_this.state.markersEnabled,startTime:_this.state.startTime,stepSizeUnit:_this.state.stepSizeUnit,timeEnabled:_this.state.timeEnabled,timeFeatures:_this.state.timeFeatures,timestampChanged:function timestampChanged(timestamp){return _this.setState({currentTimestamp:timestamp})}})})))});_defineProperty(_this,"dialogGeomChanged",function(geom){_this.setState({dialogWidth:geom.docked?document.body.offsetWidth:geom.width})});_defineProperty(_this,"toggleTimeEnabled",function(enabled){clearInterval(_this.animationTimer);clearTimeout(_this.updateMapMarkersTimeout);_this.animationTimer=null;_this.updateMapMarkersTimeout=null;_this.setState(function(state){return{timeEnabled:enabled,currentTimestamp:+state.startTime,animationActive:false,timeMarkers:null}})});_defineProperty(_this,"animationButtonClicked",function(action){_this.stopAnimation();if(action==="rewind"){_this.setState(function(state){return{currentTimestamp:+state.startTime,animationActive:false}})}else if(action==="now"){_this.setState({currentTimestamp:+dayjs(),animationActive:false})}else if(action==="prev"){var newday=_this.step(-1);_this.setState(function(state){return{currentTimestamp:+Math.max(newday,state.startTime)}})}else if(action==="next"){var _newday=_this.step(+1);_this.setState(function(state){return{currentTimestamp:+Math.min(_newday,state.endTime)}})}else if(action==="stop"){/* Already stopped above, pass */}else if(action==="play"){var curday=dayjs(_this.state.currentTimestamp);var lastday=_this.state.endTime;if(curday>=lastday){_this.setState(function(state){return{currentTimestamp:+state.startTime}})}_this.animationTimer=setInterval(function(){_this.advanceAnimation(+1)},1000*_this.state.animationInterval);_this.setState({animationActive:true})}else if(action==="playrev"){var _curday=dayjs(_this.state.currentTimestamp);var firstday=_this.state.startTime;if(_curday<=firstday){_this.setState(function(state){return{currentTimestamp:+state.endTime}})}_this.animationTimer=setInterval(function(){_this.advanceAnimation(-1)},1000*_this.state.animationInterval);_this.setState({animationActive:true})}else if(action==="loop"){_this.setState(function(state){return{animationLoop:!state.animationLoop}})}});_defineProperty(_this,"advanceAnimation",function(stepdir){var newday=_this.step(stepdir);var firstday=_this.state.startTime;var lastday=_this.state.endTime;if(newday>lastday){if(stepdir>0&&_this.state.animationLoop){_this.setState(function(state){return{currentTimestamp:+state.startTime}})}else{_this.setState({currentTimestamp:+lastday,animationActive:false});clearInterval(_this.animationTimer);_this.animationTimer=null}}else if(newday<firstday){if(stepdir<0&&_this.state.animationLoop){_this.setState(function(state){return{currentTimestamp:+state.endTime}})}else{_this.setState({currentTimestamp:+firstday,animationActive:false});clearInterval(_this.animationTimer);_this.animationTimer=null}}else{_this.setState({currentTimestamp:+newday})}});_defineProperty(_this,"stopAnimation",function(){if(_this.state.animationActive){clearInterval(_this.animationTimer);_this.animationTimer=null;_this.setState({animationActive:false})}});_defineProperty(_this,"onClose",function(){_this.toggleTimeEnabled(false);_this.setState({visible:false});_this.props.removeLayer("timemarkers")});_defineProperty(_this,"step",function(direction){var day=dayjs(_this.state.currentTimestamp);var num=parseInt(_this.state.stepSizeUnit.slice(0,-1),10)||1;var newday=day.add(direction*_this.state.stepSize*num,_this.state.stepSizeUnit.slice(-1));if(_this.state.stepSizeUnit.endsWith("m")){return newday.second(0)}else if(_this.state.stepSizeUnit.endsWith("h")){return newday.second(0).minute(0)}else if(_this.state.stepSizeUnit.endsWith("d")){return newday.second(0).minute(0).hour(0)}else if(_this.state.stepSizeUnit.endsWith("M")){return newday.second(0).minute(0).hour(0).date(1)}else if(_this.state.stepSizeUnit.endsWith("y")){return newday.second(0).minute(0).hour(0).date(1).month(0)}return newday});_defineProperty(_this,"updateLayerTimeDimensions",function(timeData,currentTimestamp){var currentTime=_this.state.timeEnabled?new Date(currentTimestamp).toISOString():undefined;timeData.layers.forEach(function(layer){var dimensions=timeData.layerDimensions[layer.id].reduce(function(res,dimension){res[dimension.toUpperCase()]=currentTime;return res},_objectSpread({},layer.dimensionValues||{}));_this.props.setLayerDimensions(layer.id,dimensions)})});_defineProperty(_this,"setStartTime",function(value){var date=(value?dayjs.utc(value):_this.state.timeData.values[0]).hour(0).minute(0).second(0);if(_this.props.filter.timeRange&&_this.props.filter.timeRange.tstart>date){date=_this.props.filter.timeRange.tstart}if(date<_this.state.endTime){_this.setState({startTime:date})}if(dayjs(_this.state.currentTimestamp)<date){_this.setState({currentTimestamp:+date})}});_defineProperty(_this,"setEndTime",function(value){var date=(value?dayjs.utc(value):_this.state.timeData.values[_this.state.timeData.values.length-1]).hour(23).minute(59).second(59);if(_this.props.filter.timeRange&&_this.props.filter.timeRange.tend<date){date=_this.props.filter.timeRange.tstart}if(date>_this.state.startTime){_this.setState({endTime:date});if(dayjs(_this.state.currentTimestamp)>date){_this.setState({currentTimestamp:+date})}}});_defineProperty(_this,"updateTimeFeatures",function(timeData){// Query all features in extent
18
- var xmin=_this.props.map.bbox.bounds[0];var ymin=_this.props.map.bbox.bounds[1];var xmax=_this.props.map.bbox.bounds[2];var ymax=_this.props.map.bbox.bounds[3];var filterGeom=VectorLayerUtils.geoJSONGeomToWkt({type:"Polygon",coordinates:[[[xmin,ymin],[xmax,ymin],[xmax,ymax],[xmin,ymax],[xmin,ymin]]]});var pending=0;var reqUUID=uuidv1();timeData.layers.forEach(function(layer){var sublayerattrs=timeData.attributes[layer.id];var queryLayers=Object.keys(sublayerattrs).join(",");var options={GEOMCENTROID:true,with_htmlcontent:false,feature_count:_this.state.featureCount};var request=IdentifyUtils.buildFilterRequest(layer,queryLayers,filterGeom,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.state.timeFeatures&&_this.state.timeFeatures.reqUUID===reqUUID&&response){var layerFeatures=IdentifyUtils.parseXmlResponse(response,_this.props.map.projection,layer);_this.setState(function(state){return{timeFeatures:{features:_objectSpread(_objectSpread({},state.timeFeatures.features),Object.entries(layerFeatures).reduce(function(res,_ref3){var _ref4=_slicedToArray(_ref3,2),layername=_ref4[0],features=_ref4[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},layername,features.map(function(feature){var startdate=dateParser.fromString(feature.properties[sublayerattrs[feature.layername][0]]);var enddate=dateParser.fromString(feature.properties[sublayerattrs[feature.layername][1]]);if(enddate&&!enddate.invalid&&enddate.getFullYear()===DUMMY_END_DATE.getFullYear()){enddate=null}return _objectSpread(_objectSpread({},feature),{},{id:feature.layername+"::"+feature.id,properties:_objectSpread(_objectSpread({},feature.properties),{},{__startdate:dayjs.utc(startdate),__enddate:dayjs.utc(enddate)})})})))},{})),attributes:_objectSpread(_objectSpread({},state.timeFeatures.attributes),Object.entries(layerFeatures).reduce(function(res,_ref5){var _ref6=_slicedToArray(_ref5,2),layername=_ref6[0],features=_ref6[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},layername,Object.keys((features[0]||{properties:{}}).properties)))},{})),pendingRequests:state.timeFeatures.pendingRequests-1}}})}else{_this.setState(function(state){return{timeFeatures:_objectSpread(_objectSpread({},state.timeFeatures),{},{pendingRequests:state.timeFeatures.pendingRequests-1})}})}});++pending});_this.setState({timeFeatures:{features:{},attributes:{},pendingRequests:pending,reqUUID:reqUUID}})});_defineProperty(_this,"markerStyle",function(feature){var style=[];var currentTime=dayjs(_this.state.currentTimestamp);var featprops=feature.getProperties();if(_this.state.timeEnabled&&(featprops.__startdate>currentTime||featprops.__enddate<currentTime)){return style}var offset=_this.props.markerConfiguration.markerOffset;if(_this.props.markerConfiguration.markerPins){style.push(new ol.style.Style({image:new ol.style.Icon({anchor:[0.5,1],anchorXUnits:"fraction",anchorYUnits:"fraction",displacement:offset,src:markerIcon})}))}if(featprops.__startdate.isValid()&&featprops.__enddate.isValid()){var deltaT=_this.state.endTime.diff(_this.state.startTime);var markerStartTime=dayjs(Math.max(_this.state.startTime,featprops.__startdate));var markerEndTime=dayjs(Math.min(_this.state.endTime,featprops.__enddate));var markerMidTime=0.5*(markerStartTime+markerEndTime);var gradBarMaxWidth=192;var gradBarHeight=16;var gradBarWidth=gradBarMaxWidth*markerEndTime.diff(markerStartTime)/deltaT;var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var gradient=context.createLinearGradient(-gradBarWidth*(markerMidTime-_this.state.startTime)/(markerMidTime-markerStartTime),0,gradBarWidth*(_this.state.endTime-markerMidTime)/(markerEndTime-markerMidTime),0);var nStops=_this.props.markerConfiguration.gradient.length;_this.props.markerConfiguration.gradient.forEach(function(stop,idx){gradient.addColorStop(idx/(nStops-1),stop)});style.push(new ol.style.Style({image:new ol.style.RegularShape({fill:new ol.style.Fill({color:gradient}),stroke:new ol.style.Stroke({color:"black",width:1}),points:4,radius:gradBarWidth/Math.SQRT2,radius2:gradBarWidth,angle:0,scale:[1,1/gradBarWidth*gradBarHeight],displacement:[offset[0],offset[1]*gradBarHeight/gradBarWidth-gradBarHeight]})}))}return style});_this.animationTimer=null;_this.updateMapMarkersTimeout=null;TimeManager.defaultState.stepSize=props.defaultStepSize;TimeManager.defaultState.stepSizeUnit=props.defaultStepUnit;TimeManager.defaultState.timelineDisplay=props.defaultTimelineDisplay;TimeManager.defaultState.timeEnabled=props.defaultEnabled;if(!props.stepUnits.includes(TimeManager.defaultState.stepSizeUnit)){TimeManager.defaultState.stepSizeUnit=props.stepUnits[0]}TimeManager.defaultState.animationInterval=props.defaultAnimationInterval;TimeManager.defaultState.featureCount=props.defaultFeatureCount;TimeManager.defaultState.timelineMode=props.defaultTimelineMode;TimeManager.defaultState.timelineDisplay=props.defaultTimelineDisplay;_this.state=_objectSpread(_objectSpread({},_this.state),TimeManager.defaultState);return _this}_inherits(TimeManager,_React$Component);return _createClass(TimeManager,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;var activated=!prevProps.active&&this.props.active;if(activated){this.setState({visible:true});// Clear task immediately after showing, visibility is controlled by internal state
18
+ var xmin=_this.props.map.bbox.bounds[0];var ymin=_this.props.map.bbox.bounds[1];var xmax=_this.props.map.bbox.bounds[2];var ymax=_this.props.map.bbox.bounds[3];var filterGeom=VectorLayerUtils.geoJSONGeomToWkt({type:"Polygon",coordinates:[[[xmin,ymin],[xmax,ymin],[xmax,ymax],[xmin,ymax],[xmin,ymin]]]});var pending=0;var reqUUID=uuidv4();timeData.layers.forEach(function(layer){var sublayerattrs=timeData.attributes[layer.id];var queryLayers=Object.keys(sublayerattrs).join(",");var options={GEOMCENTROID:true,with_htmlcontent:false,feature_count:_this.state.featureCount};var request=IdentifyUtils.buildFilterRequest(layer,queryLayers,filterGeom,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.state.timeFeatures&&_this.state.timeFeatures.reqUUID===reqUUID&&response){var layerFeatures=IdentifyUtils.parseXmlResponse(response,_this.props.map.projection,layer);_this.setState(function(state){return{timeFeatures:{features:_objectSpread(_objectSpread({},state.timeFeatures.features),Object.entries(layerFeatures).reduce(function(res,_ref3){var _ref4=_slicedToArray(_ref3,2),layername=_ref4[0],features=_ref4[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},layername,features.map(function(feature){var startdate=dateParser.fromString(feature.properties[sublayerattrs[feature.layername][0]]);var enddate=dateParser.fromString(feature.properties[sublayerattrs[feature.layername][1]]);if(enddate&&!enddate.invalid&&enddate.getFullYear()===DUMMY_END_DATE.getFullYear()){enddate=null}return _objectSpread(_objectSpread({},feature),{},{id:feature.layername+"::"+feature.id,properties:_objectSpread(_objectSpread({},feature.properties),{},{__startdate:dayjs.utc(startdate),__enddate:dayjs.utc(enddate)})})})))},{})),attributes:_objectSpread(_objectSpread({},state.timeFeatures.attributes),Object.entries(layerFeatures).reduce(function(res,_ref5){var _ref6=_slicedToArray(_ref5,2),layername=_ref6[0],features=_ref6[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},layername,Object.keys((features[0]||{properties:{}}).properties)))},{})),pendingRequests:state.timeFeatures.pendingRequests-1}}})}else{_this.setState(function(state){return{timeFeatures:_objectSpread(_objectSpread({},state.timeFeatures),{},{pendingRequests:state.timeFeatures.pendingRequests-1})}})}});++pending});_this.setState({timeFeatures:{features:{},attributes:{},pendingRequests:pending,reqUUID:reqUUID}})});_defineProperty(_this,"markerStyle",function(feature){var style=[];var currentTime=dayjs(_this.state.currentTimestamp);var featprops=feature.getProperties();if(_this.state.timeEnabled&&(featprops.__startdate>currentTime||featprops.__enddate<currentTime)){return style}var offset=_this.props.markerConfiguration.markerOffset;if(_this.props.markerConfiguration.markerPins){style.push(new ol.style.Style({image:new ol.style.Icon({anchor:[0.5,1],anchorXUnits:"fraction",anchorYUnits:"fraction",displacement:offset,src:markerIcon})}))}if(featprops.__startdate.isValid()&&featprops.__enddate.isValid()){var deltaT=_this.state.endTime.diff(_this.state.startTime);var markerStartTime=dayjs(Math.max(_this.state.startTime,featprops.__startdate));var markerEndTime=dayjs(Math.min(_this.state.endTime,featprops.__enddate));var markerMidTime=0.5*(markerStartTime+markerEndTime);var gradBarMaxWidth=192;var gradBarHeight=16;var gradBarWidth=gradBarMaxWidth*markerEndTime.diff(markerStartTime)/deltaT;var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var gradient=context.createLinearGradient(-gradBarWidth*(markerMidTime-_this.state.startTime)/(markerMidTime-markerStartTime),0,gradBarWidth*(_this.state.endTime-markerMidTime)/(markerEndTime-markerMidTime),0);var nStops=_this.props.markerConfiguration.gradient.length;_this.props.markerConfiguration.gradient.forEach(function(stop,idx){gradient.addColorStop(idx/(nStops-1),stop)});style.push(new ol.style.Style({image:new ol.style.RegularShape({fill:new ol.style.Fill({color:gradient}),stroke:new ol.style.Stroke({color:"black",width:1}),points:4,radius:gradBarWidth/Math.SQRT2,radius2:gradBarWidth,angle:0,scale:[1,1/gradBarWidth*gradBarHeight],displacement:[offset[0],offset[1]*gradBarHeight/gradBarWidth-gradBarHeight]})}))}return style});_this.animationTimer=null;_this.updateMapMarkersTimeout=null;TimeManager.defaultState.stepSize=props.defaultStepSize;TimeManager.defaultState.stepSizeUnit=props.defaultStepUnit;TimeManager.defaultState.timelineDisplay=props.defaultTimelineDisplay;TimeManager.defaultState.timeEnabled=props.defaultEnabled;if(!props.stepUnits.includes(TimeManager.defaultState.stepSizeUnit)){TimeManager.defaultState.stepSizeUnit=props.stepUnits[0]}TimeManager.defaultState.animationInterval=props.defaultAnimationInterval;TimeManager.defaultState.featureCount=props.defaultFeatureCount;TimeManager.defaultState.timelineMode=props.defaultTimelineMode;TimeManager.defaultState.timelineDisplay=props.defaultTimelineDisplay;_this.state=_objectSpread(_objectSpread({},_this.state),TimeManager.defaultState);return _this}_inherits(TimeManager,_React$Component);return _createClass(TimeManager,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;var activated=!prevProps.active&&this.props.active;if(activated){this.setState({visible:true});// Clear task immediately after showing, visibility is controlled by internal state
19
19
  this.props.setCurrentTask(null)}if(!this.state.visible&&prevState.visible){this.updateLayerTimeDimensions(this.state.timeData,this.state.currentTimestamp);this.setState(TimeManager.defaultState);return}if(!activated&&!this.state.visible){return}if(this.props.theme!==prevProps.theme){this.setState({currentTimestamp:null})}if(activated||!isEqual(this.props.layerVisibilities,prevProps.layerVisibilities)){this.stopAnimation();var timeData={layerDimensions:{},values:new Set,attributes:{},layers:[]};this.props.layers.forEach(function(layer){if(layer.type==="wms"){var layertimeData=LayerUtils.getTimeDimensionValues(layer);if(layertimeData.names.size>0){timeData.layerDimensions[layer.id]=_toConsumableArray(layertimeData.names);layertimeData.values.forEach(function(x){return timeData.values.add(x)});timeData.attributes[layer.id]=_objectSpread(_objectSpread({},timeData.attributes[layer.id]),layertimeData.attributes);// Filter time dimension from layer - object cache in updateTimeFeatures below should query all objects regardless of time
20
20
  var layerNoTimeDims=_objectSpread({},layer);var layerDimsUC=timeData.layerDimensions[layer.id].map(function(name){return name.toUpperCase()});layerNoTimeDims.dimensionValues=Object.entries(layerNoTimeDims.dimensionValues||{}).reduce(function(res,_ref7){var _ref8=_slicedToArray(_ref7,2),key=_ref8[0],value=_ref8[1];if(layerDimsUC.includes(key)){return res}else{return _objectSpread(_objectSpread({},res),{},_defineProperty({},key,value))}},{});timeData.layers.push(layerNoTimeDims)}}});timeData.values=_toConsumableArray(timeData.values).sort().map(function(d){return dayjs.utc(d)});var startdate=timeData.values.length>0?timeData.values[0].hour(0).minute(0).second(0):null;var enddate=timeData.values.length>0?timeData.values[timeData.values.length-1].hour(23).minute(59).second(59):null;if(startdate&&this.props.filter.timeRange&&dayjs(this.props.filter.timeRange.tstart)>startdate){startdate=dayjs(this.props.filter.timeRange.tstart)}if(enddate&&this.props.filter.timeRange&&dayjs(this.props.filter.timeRange.tend)<enddate){enddate=dayjs(this.props.filter.timeRange.tend)}this.setState(function(state){var _state$currentTimesta;return{timeData:timeData,currentTimestamp:(_state$currentTimesta=state.currentTimestamp)!==null&&_state$currentTimesta!==void 0?_state$currentTimesta:timeData.values.length>0?+timeData.values[0]:null,startTime:startdate,endTime:enddate&&enddate.year()!==DUMMY_END_DATE.getFullYear()?enddate:null}});this.updateTimeFeatures(timeData)}else{if(this.state.currentTimestamp!==prevState.currentTimestamp||this.state.timeEnabled!==prevState.timeEnabled){this.updateLayerTimeDimensions(this.state.timeData,this.state.currentTimestamp)}if(this.state.visible&&this.props.map.bbox!==prevProps.map.bbox){this.updateTimeFeatures(this.state.timeData)}}if(this.props.filter.timeRange!==prevProps.filter.timeRange){this.setState(function(state){var startdate=state.timeData.values.length>0?state.timeData.values[0].hour(0).minute(0).second(0):null;var enddate=state.timeData.values.length>0?state.timeData.values[state.timeData.values.length-1].hour(23).minute(59).second(59):null;if(startdate&&_this2.props.filter.timeRange&&dayjs(_this2.props.filter.timeRange.tstart)>startdate){startdate=dayjs(_this2.props.filter.timeRange.tstart)}if(enddate&&_this2.props.filter.timeRange&&dayjs(_this2.props.filter.timeRange.tend)<enddate){enddate=dayjs(_this2.props.filter.timeRange.tend)}return{startTime:startdate,endTime:enddate&&enddate.year()!==DUMMY_END_DATE.getFullYear()?enddate:null}})}if(this.state.animationActive&&this.state.animationInterval!==prevState.animationInterval){this.stopAnimation()}if(!this.state.markersEnabled&&prevState.markersEnabled){this.props.removeLayer("timemarkers")}else if(this.state.markersEnabled&&this.state.timeFeatures){if(this.state.markersEnabled!==prevState.markersEnabled||this.state.timeFeatures!==prevState.timeFeatures){var layer={id:"timemarkers",role:LayerRole.MARKER,styleFunction:this.markerStyle,rev:+new Date};var features=Object.values(this.state.timeFeatures.features).flat();this.props.addLayerFeatures(layer,features,true)}else if(this.state.currentTimestamp!==prevState.currentTimestamp||this.state.timeEnabled!==prevState.timeEnabled){this.props.refreshLayer(function(layer){return layer.id==="timemarkers"})}}}},{key:"render",value:function render(){if(!this.state.visible){return null}var timeValues=this.state.timeData.values;var body=null;if(timeValues.length<2){body=/*#__PURE__*/React.createElement("div",{role:"body"},/*#__PURE__*/React.createElement("div",{className:"time-manager-notemporaldata"},LocaleUtils.tr("timemanager.notemporaldata")))}else{body=this.renderBody(timeValues)}return/*#__PURE__*/React.createElement(ResizeableWindow,{dockable:"bottom",icon:"clock",initialHeight:this.props.geometry.initialHeight,initialWidth:this.props.geometry.initialWidth,initialX:this.props.geometry.initialX,initialY:this.props.geometry.initialY,initiallyDocked:this.props.geometry.initiallyDocked,onClose:this.onClose,onGeometryChanged:this.dialogGeomChanged,scrollable:true,splitScreenWhenDocked:true,title:LocaleUtils.tr("timemanager.title")},body)}}])}(React.Component);_defineProperty(TimeManager,"propTypes",{active:PropTypes.bool,addLayerFeatures:PropTypes.func,/** The format of the time cursor label. Either `date`, `time` or `datetime`. */cursorFormat:PropTypes.string,/** The date format in the time controls, i.e. YYYY-MM-DD. */dateFormat:PropTypes.string,/** The default interval for the temporal animation, in seconds. */defaultAnimationInterval:PropTypes.number,/** Default for TimeManager enabled when loading application. `true` or `false` */defaultEnabled:PropTypes.bool,/** The default number of features that will be requested. */defaultFeatureCount:PropTypes.number,/** The default step size for the temporal animation, in step units. */defaultStepSize:PropTypes.number,/** The default step unit for the temporal animation, one of `ms`, `s`, `m`, `d`, `M`, `y`, `10y`, `100y` */defaultStepUnit:PropTypes.string,/** The default timeline display mode. One of `hidden`, `minimal`, `features`, `layers`. */defaultTimelineDisplay:PropTypes.string,/** The default timeline mode. One of `fixed`, `infinite`. */defaultTimelineMode:PropTypes.string,filter:PropTypes.object,/** Default window geometry with size, position and docking status. Positive position values (including '0') are related to top (InitialY) and left (InitialX), negative values (including '-0') to bottom (InitialY) and right (InitialX). */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool}),layerVisibilities:PropTypes.object,layers:PropTypes.array,map:PropTypes.object,/** The feature marker configuration. */markerConfiguration:PropTypes.shape({markersAvailable:PropTypes.bool,gradient:PropTypes.arrayOf(PropTypes.string),markerOffset:PropTypes.array,markerPins:PropTypes.bool}),refreshLayer:PropTypes.func,removeLayer:PropTypes.func,setCurrentTask:PropTypes.func,setLayerDimensions:PropTypes.func,/** The available temporal animation step units. */stepUnits:PropTypes.arrayOf(PropTypes.string),theme:PropTypes.object});_defineProperty(TimeManager,"defaultProps",{cursorFormat:"datetime",dateFormat:"YYYY-MM-DD[\n]HH:mm:ss",defaultAnimationInterval:1,defaultEnabled:false,defaultStepSize:1,defaultStepUnit:"d",defaultFeatureCount:100,defaultTimelineMode:"fixed",markerConfiguration:{markersAvailable:true,gradient:["#f7af7d","#eacc6e","#fef89a","#c5e09b","#a3d29c","#7cc096","#79c8c5","#34afce"],markerOffset:[0,0],markerPins:true},featureTimelineAvailable:true,stepUnits:["s","m","h","d","M","y"],geometry:{initialWidth:800,initialHeight:320,initiallyDocked:true}});_defineProperty(TimeManager,"defaultState",{timeEnabled:false,startTime:null,endTime:null,currentTimestamp:null,animationActive:false,animationLoop:false,animationInterval:1,stepSize:1,stepSizeUnit:"d",// 1 day
21
21
  dialogWidth:0,markersEnabled:false,markersCanBeEnabled:true,timelineDisplay:"layers",featureCount:100,timelineMode:"continuous",timeData:{layerDimensions:{},values:[],attributes:{},layers:[]},timeFeatures:null,settingsPopup:false,visible:false,geometry:{initialWidth:900,initialHeight:320,initialX:null,initialY:null,initiallyDocked:false}});var layerVisiblitiesSelector=createSelector([function(state){return state.layers.flat}],function(layers){return layers.filter(function(layer){return layer.type==="wms"}).reduce(function(res,layer){return _objectSpread(_objectSpread({},res),{},_defineProperty({},layer.id,LayerUtils.computeLayerVisibility(layer)))},{})});var selector=createSelector([function(state){return state},layerVisiblitiesSelector],function(state,layerVisibilities){return{active:state.task.id==="TimeManager",layers:state.layers.flat,filter:state.layers.filter,layerVisibilities:layerVisibilities,map:state.map,theme:state.theme.current}});export default connect(selector,{addLayerFeatures:addLayerFeatures,refreshLayer:refreshLayer,removeLayer:removeLayer,setLayerDimensions:setLayerDimensions,setCurrentTask:setCurrentTask,setCurrentTaskBlocked:setCurrentTaskBlocked})(TimeManager);
package/plugins/TopBar.js CHANGED
@@ -6,7 +6,7 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */import React from"react";import{connect}from"react-redux";import classnames from"classnames";import PropTypes from"prop-types";import{toggleFullscreen}from"../actions/display";import{openExternalUrl,setTopbarHeight}from"../actions/windows";import{Swipeable}from"../components/Swipeable";import ConfigUtils from"../utils/ConfigUtils";import LocaleUtils from"../utils/LocaleUtils";import ThemeUtils from"../utils/ThemeUtils";import"./style/TopBar.css";/**
8
8
  * Top bar, containing the logo, searchbar, task buttons and app menu.
9
- */var TopBar=/*#__PURE__*/function(_React$Component){function TopBar(){var _this;_classCallCheck(this,TopBar);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,TopBar,[].concat(args));_defineProperty(_this,"state",{allowedMenuItems:[],allowedToolbarItems:[]});_defineProperty(_this,"openUrl",function(url,target,title,icon){if(target==="iframe"){target=":iframedialog:externallinkiframe"}_this.props.openExternalUrl(url,target,{title:title,icon:icon})});_defineProperty(_this,"storeHeight",function(el){if(el){_this.props.setTopbarHeight(el.clientHeight)}});return _this}_inherits(TopBar,_React$Component);return _createClass(TopBar,[{key:"componentDidMount",value:function componentDidMount(){this.setState({allowedToolbarItems:ThemeUtils.allowedItems(this.props.toolbarItems,this.props.currentTheme),allowedMenuItems:ThemeUtils.allowedItems(this.props.menuItems,this.props.currentTheme)})}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.currentTheme!==prevProps.currentTheme){this.setState({allowedToolbarItems:ThemeUtils.allowedItems(this.props.toolbarItems,this.props.currentTheme),allowedMenuItems:ThemeUtils.allowedItems(this.props.menuItems,this.props.currentTheme)})}}},{key:"render",value:function render(){var _this2=this;var logo;var assetsPath=ConfigUtils.getAssetsPath();var isMobile=ConfigUtils.isMobile();if(isMobile||this.props.appMenuCompact){logo=assetsPath+"/img/logo-mobile."+this.props.logoFormat}else{logo=assetsPath+"/img/logo."+this.props.logoFormat}var classes=classnames({TopBar:true,mobile:isMobile,fullscreen:this.props.fullscreen});var logoEl=/*#__PURE__*/React.createElement("img",{className:"topbar-logo",src:this.props.logoSrc||logo});if(this.props.logoUrl){logoEl=/*#__PURE__*/React.createElement("a",{href:this.props.logoUrl,rel:"noreferrer",target:"_blank"},logoEl)}// Convert legacy minScale option to minScaleDenom
9
+ */var TopBar=/*#__PURE__*/function(_React$Component){function TopBar(){var _this;_classCallCheck(this,TopBar);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,TopBar,[].concat(args));_defineProperty(_this,"state",{allowedMenuItems:[],allowedToolbarItems:[]});_defineProperty(_this,"openUrl",function(url,target,title,icon){if(target==="iframe"){target=":iframedialog:externallinkiframe"}_this.props.openExternalUrl(url,target,{title:title,icon:icon})});_defineProperty(_this,"storeHeight",function(el){if(el){_this.props.setTopbarHeight(el.clientHeight)}});return _this}_inherits(TopBar,_React$Component);return _createClass(TopBar,[{key:"componentDidMount",value:function componentDidMount(){this.setState({allowedToolbarItems:ThemeUtils.allowedItems(this.props.toolbarItems,this.props.currentTheme),allowedMenuItems:ThemeUtils.allowedItems(this.props.menuItems,this.props.currentTheme)})}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.currentTheme!==prevProps.currentTheme){this.setState({allowedToolbarItems:ThemeUtils.allowedItems(this.props.toolbarItems,this.props.currentTheme),allowedMenuItems:ThemeUtils.allowedItems(this.props.menuItems,this.props.currentTheme)})}}},{key:"render",value:function render(){var _this2=this;var logo;var assetsPath=ConfigUtils.getAssetsPath();var isMobile=ConfigUtils.isMobile();if(isMobile){logo=assetsPath+"/img/logo-mobile."+this.props.logoFormat}else{logo=assetsPath+"/img/logo."+this.props.logoFormat}var classes=classnames({TopBar:true,mobile:isMobile,fullscreen:this.props.fullscreen});var logoEl=/*#__PURE__*/React.createElement("img",{className:"topbar-logo",src:this.props.logoSrc||logo});if(this.props.logoUrl){logoEl=/*#__PURE__*/React.createElement("a",{href:this.props.logoUrl,rel:"noreferrer",target:"_blank"},logoEl)}// Convert legacy minScale option to minScaleDenom
10
10
  var searchOptions=_objectSpread(_objectSpread({},TopBar.defaultProps.searchOptions),this.props.searchOptions);searchOptions.minScaleDenom=searchOptions.minScaleDenom||searchOptions.minScale;delete searchOptions.minScale;// Menu compact only available for desktop client
11
11
  var menuCompact=!isMobile?this.props.appMenuCompact:false;// Keep menu open when appMenu is in compact mode (Visible on Hover)
12
12
  var keepMenuOpen=menuCompact;// Menu should be visible on startup when appMenu is in compact mode (Visible on Hover)
@@ -4,8 +4,8 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{Line}from"react-chartjs-2";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole}from"../actions/layers";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import ButtonBar from"../components/widgets/ButtonBar";import NumberInput from"../components/widgets/NumberInput";import TextInput from"../components/widgets/TextInput";import IdentifyUtils from"../utils/IdentifyUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import"./style/ValueTool.css";/**
7
+ */import React from"react";import{Line}from"react-chartjs-2";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole}from"../actions/layers";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import ButtonBar from"../components/widgets/ButtonBar";import NumberInput from"../components/widgets/NumberInput";import TextInput from"../components/widgets/TextInput";import IdentifyUtils from"../utils/IdentifyUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import"./style/ValueTool.css";/**
8
8
  * Displays raster band values of active raster layers at the hovered mouse position,
9
9
  * queried via GetFeatureInfo.
10
- */var ValueTool=/*#__PURE__*/function(_React$Component){function ValueTool(props){var _this;_classCallCheck(this,ValueTool);_this=_callSuper(this,ValueTool,[props]);_defineProperty(_this,"renderTableTab",function(){if(isEmpty(_this.state.values)){return/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("valuetool.nodata")))}return/*#__PURE__*/React.createElement("table",{className:"valuetool-table"},/*#__PURE__*/React.createElement("tbody",null,Object.entries(_this.state.values).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],data=_ref2[1];var bandvals=Object.entries(data.values);if(_this.state.selectedBands[key]){var activeBands=_this.state.selectedBands[key].split(",").map(function(x){return parseInt(x.trim(),10)-1});bandvals=bandvals.filter(function(_,i){return activeBands.includes(i)})}return[/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("th",{colSpan:"2"},data.layertitle)),bandvals.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),bandname=_ref4[0],bandval=_ref4[1];return/*#__PURE__*/React.createElement("tr",{key:key+"_"+bandname},/*#__PURE__*/React.createElement("td",null,bandname),/*#__PURE__*/React.createElement("td",null,bandval))})]})))});_defineProperty(_this,"renderGraphTab",function(){var values=Object.values(_this.state.values).map(function(x){return Object.values(x.values)}).flat().filter(function(x){return x});var data={labels:values.map(function(_,i){return String(i)}),datasets:[{data:values,borderColor:"rgb(255,0,0)",borderWidth:2}]};var yAxisConfig={};if(_this.state.graphMinY){yAxisConfig.min=_this.state.graphMinY}if(_this.state.graphMaxY){yAxisConfig.max=_this.state.graphMaxY}var options={responsive:true,maintainAspectRatio:false,animation:{duration:0},scales:{y:yAxisConfig}};return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("div",{className:"valuetool-chart-options"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("valuetool.ymin"),": "),/*#__PURE__*/React.createElement(NumberInput,{onChange:function onChange(value){return _this.setState({graphMinY:value})},value:_this.state.graphMinY}),/*#__PURE__*/React.createElement("span",{style:{marginLeft:"0.5em"}}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("valuetool.ymax"),": "),/*#__PURE__*/React.createElement(NumberInput,{onChange:function onChange(value){return _this.setState({graphMaxY:value})},value:_this.state.graphMaxY})),/*#__PURE__*/React.createElement("div",{className:"valuetool-chart-container"},/*#__PURE__*/React.createElement(Line,{data:data,options:options})))});_defineProperty(_this,"renderOptionsTab",function(){var options=_this.state.showLayers==="selected"||_this.state.showBands==="selected"?[/*#__PURE__*/React.createElement("hr",{key:"sep"}),/*#__PURE__*/React.createElement("div",{key:"label"},LocaleUtils.tr("valuetool.selectlayersbands")),/*#__PURE__*/React.createElement("table",{className:"valuetool-table-selection",key:"table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.layer")),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.bands")):null),_this.props.layers.map(function(layer){var sublayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return sublayer.geometryType===null});return sublayers.map(function(sublayer){var key=layer.url+"#"+sublayer;return/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("td",null,_this.state.showLayers==="selected"?/*#__PURE__*/React.createElement(Icon,{icon:_this.state.selectedLayers.includes(key)?"checked":"unchecked",onClick:function onClick(){return _this.toggleSelectedLayer(key)}}):null,sublayer),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(TextInput,{onChange:function onChange(value){return _this.setLayerBands(key,value)},placeholder:LocaleUtils.tr("valuetool.all"),value:_this.state.selectedBands[key]||""})):null)})})))]:null;return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("table",{className:"valuetool-table-options"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showlayers"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showLayers:ev.target.value})},value:_this.state.showLayers},/*#__PURE__*/React.createElement("option",{value:"visible"},LocaleUtils.tr("valuetool.visiblelayers")),/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.alllayers")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedlayers"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showbands"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showBands:ev.target.value})},value:_this.state.showBands},/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.allbands")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedbands"))))))),options)});_defineProperty(_this,"toggleSelectedLayer",function(key){_this.setState(function(state){return{selectedLayers:state.selectedLayers.includes(key)?state.selectedLayers.filter(function(x){return x!==key}):[].concat(_toConsumableArray(state.selectedLayers),[key])}})});_defineProperty(_this,"setLayerBands",function(key,bands){_this.setState(function(state){return{selectedBands:_objectSpread(_objectSpread({},state.selectedBands),{},_defineProperty({},key,_toConsumableArray(new Set(bands.split(",").map(function(x){return parseInt(x.trim(),10)||0}).sort().filter(function(x){return x}))).join(", ")))}})});_defineProperty(_this,"onWindowClose",function(){_this.props.setCurrentTask(null)});_defineProperty(_this,"scheduleQueryValues",function(ev){var coordinate=ev.coordinate;clearTimeout(_this.queryTimeout);_this.queryTimeout=setTimeout(function(){return _this.queryValues(coordinate)},100)});_defineProperty(_this,"queryValues",function(coordinate){var options={info_format:"text/xml",feature_count:5,with_geometry:false,with_htmlcontent:false};var reqId=uuidv1();_this.reqId=reqId;var newValues={};_this.props.layers.forEach(function(layer){var layerActive=null;if(_this.state.showLayers==="all"){layerActive=function layerActive(){return true}}else if(_this.state.showLayers==="selected"){layerActive=function layerActive(sublayer){return _this.state.selectedLayers.includes(layer.url+"#"+sublayer.name)}}else if(_this.state.showLayers==="visible"){layerActive=function layerActive(sublayer){return sublayer.visibility}}var queryLayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return layerActive(sublayer)&&sublayer.geometryType===null});if(isEmpty(queryLayers)){return}// Preserve previous result rows, but with empty values, to prevent "flickering"
10
+ */var ValueTool=/*#__PURE__*/function(_React$Component){function ValueTool(props){var _this;_classCallCheck(this,ValueTool);_this=_callSuper(this,ValueTool,[props]);_defineProperty(_this,"renderTableTab",function(){if(isEmpty(_this.state.values)){return/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("valuetool.nodata")))}return/*#__PURE__*/React.createElement("table",{className:"valuetool-table"},/*#__PURE__*/React.createElement("tbody",null,Object.entries(_this.state.values).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],data=_ref2[1];var bandvals=Object.entries(data.values);if(_this.state.selectedBands[key]){var activeBands=_this.state.selectedBands[key].split(",").map(function(x){return parseInt(x.trim(),10)-1});bandvals=bandvals.filter(function(_,i){return activeBands.includes(i)})}return[/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("th",{colSpan:"2"},data.layertitle)),bandvals.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),bandname=_ref4[0],bandval=_ref4[1];return/*#__PURE__*/React.createElement("tr",{key:key+"_"+bandname},/*#__PURE__*/React.createElement("td",null,bandname),/*#__PURE__*/React.createElement("td",null,bandval))})]})))});_defineProperty(_this,"renderGraphTab",function(){var values=Object.values(_this.state.values).map(function(x){return Object.values(x.values)}).flat().filter(function(x){return x});var data={labels:values.map(function(_,i){return String(i)}),datasets:[{data:values,borderColor:"rgb(255,0,0)",borderWidth:2}]};var yAxisConfig={};if(_this.state.graphMinY){yAxisConfig.min=_this.state.graphMinY}if(_this.state.graphMaxY){yAxisConfig.max=_this.state.graphMaxY}var options={responsive:true,maintainAspectRatio:false,animation:{duration:0},scales:{y:yAxisConfig}};return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("div",{className:"valuetool-chart-options"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("valuetool.ymin"),": "),/*#__PURE__*/React.createElement(NumberInput,{onChange:function onChange(value){return _this.setState({graphMinY:value})},value:_this.state.graphMinY}),/*#__PURE__*/React.createElement("span",{style:{marginLeft:"0.5em"}}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("valuetool.ymax"),": "),/*#__PURE__*/React.createElement(NumberInput,{onChange:function onChange(value){return _this.setState({graphMaxY:value})},value:_this.state.graphMaxY})),/*#__PURE__*/React.createElement("div",{className:"valuetool-chart-container"},/*#__PURE__*/React.createElement(Line,{data:data,options:options})))});_defineProperty(_this,"renderOptionsTab",function(){var options=_this.state.showLayers==="selected"||_this.state.showBands==="selected"?[/*#__PURE__*/React.createElement("hr",{key:"sep"}),/*#__PURE__*/React.createElement("div",{key:"label"},LocaleUtils.tr("valuetool.selectlayersbands")),/*#__PURE__*/React.createElement("table",{className:"valuetool-table-selection",key:"table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.layer")),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.bands")):null),_this.props.layers.map(function(layer){var sublayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return sublayer.geometryType===null});return sublayers.map(function(sublayer){var key=layer.url+"#"+sublayer;return/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("td",null,_this.state.showLayers==="selected"?/*#__PURE__*/React.createElement(Icon,{icon:_this.state.selectedLayers.includes(key)?"checked":"unchecked",onClick:function onClick(){return _this.toggleSelectedLayer(key)}}):null,sublayer),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(TextInput,{onChange:function onChange(value){return _this.setLayerBands(key,value)},placeholder:LocaleUtils.tr("valuetool.all"),value:_this.state.selectedBands[key]||""})):null)})})))]:null;return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("table",{className:"valuetool-table-options"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showlayers"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showLayers:ev.target.value})},value:_this.state.showLayers},/*#__PURE__*/React.createElement("option",{value:"visible"},LocaleUtils.tr("valuetool.visiblelayers")),/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.alllayers")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedlayers"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showbands"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showBands:ev.target.value})},value:_this.state.showBands},/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.allbands")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedbands"))))))),options)});_defineProperty(_this,"toggleSelectedLayer",function(key){_this.setState(function(state){return{selectedLayers:state.selectedLayers.includes(key)?state.selectedLayers.filter(function(x){return x!==key}):[].concat(_toConsumableArray(state.selectedLayers),[key])}})});_defineProperty(_this,"setLayerBands",function(key,bands){_this.setState(function(state){return{selectedBands:_objectSpread(_objectSpread({},state.selectedBands),{},_defineProperty({},key,_toConsumableArray(new Set(bands.split(",").map(function(x){return parseInt(x.trim(),10)||0}).sort().filter(function(x){return x}))).join(", ")))}})});_defineProperty(_this,"onWindowClose",function(){_this.props.setCurrentTask(null)});_defineProperty(_this,"scheduleQueryValues",function(ev){var coordinate=ev.coordinate;clearTimeout(_this.queryTimeout);_this.queryTimeout=setTimeout(function(){return _this.queryValues(coordinate)},100)});_defineProperty(_this,"queryValues",function(coordinate){var options={info_format:"text/xml",feature_count:5,with_geometry:false,with_htmlcontent:false};var reqId=uuidv4();_this.reqId=reqId;var newValues={};_this.props.layers.forEach(function(layer){var layerActive=null;if(_this.state.showLayers==="all"){layerActive=function layerActive(){return true}}else if(_this.state.showLayers==="selected"){layerActive=function layerActive(sublayer){return _this.state.selectedLayers.includes(layer.url+"#"+sublayer.name)}}else if(_this.state.showLayers==="visible"){layerActive=function layerActive(sublayer){return sublayer.visibility}}var queryLayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return layerActive(sublayer)&&sublayer.geometryType===null});if(isEmpty(queryLayers)){return}// Preserve previous result rows, but with empty values, to prevent "flickering"
11
11
  queryLayers.forEach(function(sublayername){var key=layer.url+"#"+sublayername;if(_this.state.values[key]){newValues[key]=_objectSpread(_objectSpread({},_this.state.values[key]),{},{values:Object.fromEntries(Object.keys(_this.state.values[key].values).map(function(k){return[k,""]}))})}});var request=IdentifyUtils.buildRequest(layer,queryLayers.join(","),coordinate,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.reqId===reqId){var result=IdentifyUtils.parseXmlResponse(response||"",_this.props.map.projection,layer);_this.setState(function(state){return{values:_objectSpread(_objectSpread({},state.values),Object.entries(result).reduce(function(res,_ref5){var _ref6=_slicedToArray(_ref5,2),sublayername=_ref6[0],features=_ref6[1];var key=layer.url+"#"+sublayername;res[key]={layertitle:features[0].layertitle,values:features[0].properties};return res},{}))}})}})});_this.setState({values:newValues})});_this.queryTimeout=null;_this.reqId=null;_this.state=ValueTool.defaultState;return _this}_inherits(ValueTool,_React$Component);return _createClass(ValueTool,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.enabled&&!prevProps.enabled){MapUtils.getHook(MapUtils.ADD_POINTER_MOVE_LISTENER)(this.scheduleQueryValues)}else if(!this.props.enabled&&prevProps.enabled){MapUtils.getHook(MapUtils.REMOVE_POINTER_MOVE_LISTENER)(this.scheduleQueryValues);clearTimeout(this.queryTimeout);this.queryTimeout=null;this.setState(ValueTool.defaultState)}}},{key:"render",value:function render(){var _this2=this;if(!this.props.enabled){return null}var buttons=[{key:"Table",label:LocaleUtils.tr("valuetool.table")},{key:"Graph",label:LocaleUtils.tr("valuetool.graph")},{key:"Options",label:LocaleUtils.tr("valuetool.options")}];var tab=null;if(this.state.activeTab==="Table"){tab=this.renderTableTab()}else if(this.state.activeTab==="Graph"){tab=this.renderGraphTab()}else if(this.state.activeTab==="Options"){tab=this.renderOptionsTab()}return/*#__PURE__*/React.createElement(ResizeableWindow,{dockable:this.props.geometry.side,icon:"info-sign",initialHeight:this.props.geometry.initialHeight,initialWidth:this.props.geometry.initialWidth,initialX:this.props.geometry.initialX,initialY:this.props.geometry.initialY,initiallyDocked:this.props.geometry.initiallyDocked,onClose:this.onWindowClose,title:LocaleUtils.tr("valuetool.title")},/*#__PURE__*/React.createElement("div",{className:"valuetool-body",role:"body"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.activeTab,buttons:buttons,onClick:function onClick(key){return _this2.setState({activeTab:key})}}),tab))}}])}(React.Component);_defineProperty(ValueTool,"propTypes",{/** The number of decimal places to display for elevation values. */enabled:PropTypes.bool,/** Default window geometry with size, position and docking status. Positive position values (including '0') are related to top (InitialY) and left (InitialX), negative values (including '-0') to bottom (InitialY) and right (InitialX). */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool,side:PropTypes.string}),layers:PropTypes.array,map:PropTypes.object,setCurrentTask:PropTypes.func});_defineProperty(ValueTool,"defaultProps",{geometry:{initialWidth:240,initialHeight:320,initialX:0,initialY:0,initiallyDocked:false,side:"left"}});_defineProperty(ValueTool,"defaultState",{activeTab:"Table",showLayers:"visible",showBands:"all",selectedLayers:[],selectedBands:{},values:{},graphMinY:null,graphMaxY:null});export default connect(function(state){return{enabled:state.task.id==="ValueTool",layers:state.layers.flat.filter(function(layer){return(layer.role===LayerRole.THEME||layer.role===LayerRole.USERLAYER)&&(layer.infoFormats||[]).includes("text/xml")}),map:state.map}},{setCurrentTask:setCurrentTask})(ValueTool);
package/plugins/View3D.js CHANGED
@@ -13,10 +13,10 @@ if(_this.state.viewsLocked&&_this.focusedMap==="map3d"){var rotation=undefined;i
13
13
  var _ReducerIndex$reducer=ReducerIndex.reducers,processNotifications=_ReducerIndex$reducer.processNotifications,task=_ReducerIndex$reducer.task,windows=_ReducerIndex$reducer.windows;// Reducer for syncronization with parent store
14
14
  var forwardReducer=function forwardReducer(key,forwardActions,syncAction){return function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;if(forwardActions.includes(action.type)){// Forward to parent store
15
15
  StandardApp.store.dispatch(action);return state}else{return action.type===syncAction?action[key]:state}}};var displayActions=Object.values(displayExports).filter(function(x){return typeof x==="string"});var layersActions=Object.values(layersExports).filter(function(x){return typeof x==="string"});var mapActions=Object.values(mapExports).filter(function(x){return typeof x==="string"});var themeActions=Object.values(themeExports).filter(function(x){return typeof x==="string"});var display=forwardReducer("display",displayActions,"SYNC_DISPLAY_FROM_PARENT_STORE");var layers=forwardReducer("layers",layersActions,"SYNC_LAYERS_FROM_PARENT_STORE");var map=forwardReducer("map",mapActions,"SYNC_MAP_FROM_PARENT_STORE");var localConfig=forwardReducer("localConfig",[],"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE");var theme=forwardReducer("theme",themeActions,"SYNC_THEME_FROM_PARENT_STORE");_this.store=createStore({display:display,layers:layers,localConfig:localConfig,map:map,processNotifications:processNotifications,theme:theme,task:task,windows:windows});// Set stored state
16
- var storedState=_objectSpread({},props.startupState.map3d);if(props.startupParams.v3d){var values=props.startupParams.v3d.split(",").map(parseFloat).filter(function(x){return!isNaN(x)});if(values.length>=6){var _values$;storedState.camera=[values[0],values[1],values[2]];storedState.target=[values[3],values[4],values[5]];storedState.personHeight=(_values$=values[6])!==null&&_values$!==void 0?_values$:0}}if(props.startupParams.bl3d!==undefined){storedState.baseLayer=props.startupParams.bl3d}_this.state.storedState=storedState;return _this}_inherits(View3D,_React$Component);return _createClass(View3D,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.startupParams.v==="3d"){this.props.setView3dMode(View3DMode.FULLSCREEN)}else if(this.props.startupParams.v==="3d2d"){this.props.setView3dMode(View3DMode.SPLITSCREEN)}window.addEventListener("focus",this.trackFocus,true);this.syncParentStore({})}},{key:"componentWillUnmount",value:function componentWillUnmount(){window.removeEventListener("focus",this.trackFocus)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this,_this$props$theme$cur;if(this.props.view3dMode!==View3DMode.DISABLED&&prevProps.view3dMode===View3DMode.DISABLED){import("../components/map3d/Map3D").then(function(component){_this2.map3dComponent=component["default"];_this2.map3dComponentRef=null;_this2.setState({componentLoaded:true})})}else if(this.props.view3dMode===View3DMode.DISABLING&&prevProps.view3dMode!==View3DMode.DISABLING){if(this.map3dComponentRef){this.map3dComponentRef.store3dState().then(function(storedState){_this2.setState({storedState:storedState});UrlParams.updateParams({v3d:undefined,bl3d:undefined});_this2.props.setView3dMode(View3DMode.DISABLED)})}else{UrlParams.updateParams({v3d:undefined,bl3d:undefined});this.props.setView3dMode(View3DMode.DISABLED)}}else if(this.props.view3dMode===View3DMode.DISABLED&&prevProps.view3dMode!==View3DMode.DISABLED){this.map3dComponent=null;this.map3dComponentRef=null;this.setState({componentLoaded:false});if(this.firstPersonMarker){this.props.removeLayer("view3d-firstperson-marker");this.firstPersonMarker=false}}// Sync parts of parent store
16
+ var storedState=_objectSpread({},props.startupState.map3d);if(props.startupParams.v3d){var values=props.startupParams.v3d.split(",").map(parseFloat).filter(function(x){return!isNaN(x)});if(values.length>=6){var _values$;storedState.camera=[values[0],values[1],values[2]];storedState.target=[values[3],values[4],values[5]];storedState.personHeight=(_values$=values[6])!==null&&_values$!==void 0?_values$:0}}if(props.startupParams.bl3d!==undefined){storedState.baseLayer=props.startupParams.bl3d}_this.state.storedState=storedState;return _this}_inherits(View3D,_React$Component);return _createClass(View3D,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.startupParams.v==="3d"){this.props.setView3dMode(View3DMode.FULLSCREEN)}else if(this.props.startupParams.v==="3d2d"){this.props.setView3dMode(View3DMode.SPLITSCREEN)}window.addEventListener("focus",this.trackFocus,true);this.syncParentStore({})}},{key:"componentWillUnmount",value:function componentWillUnmount(){window.removeEventListener("focus",this.trackFocus)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this,_this$props$theme$cur;if(this.props.view3dMode!==View3DMode.DISABLED&&prevProps.view3dMode===View3DMode.DISABLED){import("../components/map3d/Map3D").then(function(component){_this2.map3dComponent=component["default"];_this2.map3dComponentRef=null;_this2.setState({componentLoaded:true})});this.syncParentStore(this.props,true)}else if(this.props.view3dMode===View3DMode.DISABLING&&prevProps.view3dMode!==View3DMode.DISABLING){if(this.map3dComponentRef){this.map3dComponentRef.store3dState().then(function(storedState){_this2.setState({storedState:storedState});UrlParams.updateParams({v3d:undefined,bl3d:undefined});_this2.props.setView3dMode(View3DMode.DISABLED)})}else{UrlParams.updateParams({v3d:undefined,bl3d:undefined});this.props.setView3dMode(View3DMode.DISABLED)}}else if(this.props.view3dMode===View3DMode.DISABLED&&prevProps.view3dMode!==View3DMode.DISABLED){this.map3dComponent=null;this.map3dComponentRef=null;this.setState({componentLoaded:false});if(this.firstPersonMarker){this.props.removeLayer("view3d-firstperson-marker");this.firstPersonMarker=false}}// Sync parts of parent store
17
17
  this.syncParentStore(prevProps);// Handle view mode change
18
18
  if(this.props.view3dMode!==prevProps.view3dMode){if(this.props.view3dMode===View3DMode.FULLSCREEN){UrlParams.updateParams({v:"3d"});this.setState({viewsLocked:false})}else if(this.props.view3dMode===View3DMode.SPLITSCREEN){UrlParams.updateParams({v:"3d2d"})}else{UrlParams.updateParams({v:"2d"})}}// Switch to 2D mode if new theme has no 3D configuration
19
19
  if(this.props.theme.current!==prevProps.theme.current&&!((_this$props$theme$cur=this.props.theme.current)!==null&&_this$props$theme$cur!==void 0&&_this$props$theme$cur.map3d)&&this.props.view3dMode!==View3DMode.DISABLED){this.props.setView3dMode(View3D.DISABLED)}// Lock views
20
20
  if(this.state.viewsLocked&&this.props.map.bbox!==prevProps.map.bbox&&this.focusedMap==="map"){this.sync2DExtent()}// Clear stored state when switching away from a theme
21
- if(prevProps.theme.current&&this.props.theme.current!==prevProps.theme.current){this.setState({storedState:null})}}},{key:"syncParentStore",value:function syncParentStore(prevProps){if(this.props.display!==prevProps.display){this.store.dispatch({type:"SYNC_DISPLAY_FROM_PARENT_STORE",display:this.props.display})}if(this.props.theme!==prevProps.theme){this.store.dispatch({type:"SYNC_THEME_FROM_PARENT_STORE",theme:this.props.theme})}if(this.props.localConfig!==prevProps.localConfig){this.store.dispatch({type:"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE",localConfig:this.props.localConfig})}if(this.props.layers!==prevProps.layers){this.store.dispatch({type:"SYNC_LAYERS_FROM_PARENT_STORE",layers:this.props.layers})}if(this.props.map!==prevProps.map){this.store.dispatch({type:"SYNC_MAP_FROM_PARENT_STORE",map:this.props.map})}}},{key:"render",value:function render(){var _this$props$theme$cur2;var button=(_this$props$theme$cur2=this.props.theme.current)!==null&&_this$props$theme$cur2!==void 0&&_this$props$theme$cur2.map3d?/*#__PURE__*/React.createElement(View3DSwitcher,{key:"View3DButton",position:this.props.buttonPosition}):null;return[button,this.render3DWindow()]}}])}(React.Component);_defineProperty(View3D,"propTypes",{addLayerFeatures:PropTypes.func,/** The position slot index of the 3d switch map button, from the bottom (0: bottom slot). */buttonPosition:PropTypes.number,/** The position of the navigation controls. Either `top` or `bottom`. */controlsPosition:PropTypes.string,/** The default scene quality factor (`20`: min, `100`: max). */defaultSceneQuality:PropTypes.number,display:PropTypes.object,/** Default window geometry. */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool}),layers:PropTypes.object,localConfig:PropTypes.object,map:PropTypes.object,/** Mouse buttons assignment. You can assign `pan`, `rotate`, `zoom` to each button. */mouseButtons:PropTypes.shape({left:PropTypes.string,middle:PropTypes.string,right:PropTypes.string}),panTo:PropTypes.func,/** Options to pass to the 3D plugins, in the form `{"<PluginName>": {<options>}}`.
21
+ if(prevProps.theme.current&&this.props.theme.current!==prevProps.theme.current){this.setState({storedState:null})}}},{key:"syncParentStore",value:function syncParentStore(prevProps){var force=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(this.props.view3dMode===View3DMode.DISABLED){return}if(this.props.display!==prevProps.display||force){this.store.dispatch({type:"SYNC_DISPLAY_FROM_PARENT_STORE",display:this.props.display})}if(this.props.theme!==prevProps.theme||force){this.store.dispatch({type:"SYNC_THEME_FROM_PARENT_STORE",theme:this.props.theme})}if(this.props.localConfig!==prevProps.localConfig||force){this.store.dispatch({type:"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE",localConfig:this.props.localConfig})}if(this.props.layers!==prevProps.layers||force){this.store.dispatch({type:"SYNC_LAYERS_FROM_PARENT_STORE",layers:this.props.layers})}if(this.props.map!==prevProps.map||force){this.store.dispatch({type:"SYNC_MAP_FROM_PARENT_STORE",map:this.props.map})}}},{key:"render",value:function render(){var _this$props$theme$cur2;var button=(_this$props$theme$cur2=this.props.theme.current)!==null&&_this$props$theme$cur2!==void 0&&_this$props$theme$cur2.map3d?/*#__PURE__*/React.createElement(View3DSwitcher,{key:"View3DButton",position:this.props.buttonPosition}):null;return[button,this.render3DWindow()]}}])}(React.Component);_defineProperty(View3D,"propTypes",{addLayerFeatures:PropTypes.func,/** The position slot index of the 3d switch map button, from the bottom (0: bottom slot). */buttonPosition:PropTypes.number,/** The position of the navigation controls. Either `top` or `bottom`. */controlsPosition:PropTypes.string,/** The default scene quality factor (`20`: min, `100`: max). */defaultSceneQuality:PropTypes.number,display:PropTypes.object,/** Default window geometry. */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool}),layers:PropTypes.object,localConfig:PropTypes.object,map:PropTypes.object,/** Mouse buttons assignment. You can assign `pan`, `rotate`, `zoom` to each button. */mouseButtons:PropTypes.shape({left:PropTypes.string,middle:PropTypes.string,right:PropTypes.string}),panTo:PropTypes.func,/** Options to pass to the 3D plugins, in the form `{"<PluginName>": {<options>}}`.
22
22
  * Refer to the documentation of the <a href="#plugins3d">3D plugins</a> for settable options. */pluginOptions:PropTypes.object,plugins3d:PropTypes.object,removeLayer:PropTypes.func,searchProviders:PropTypes.object,setView3dMode:PropTypes.func,startupParams:PropTypes.object,startupState:PropTypes.object,theme:PropTypes.object,view3dMode:PropTypes.number,zoomToPoint:PropTypes.func});_defineProperty(View3D,"defaultProps",{buttonPosition:6,controlsPosition:"top",geometry:{initialWidth:600,initialHeight:800,initialX:0,initialY:0,initiallyDocked:true},pluginOptions:{},mouseButtons:{left:"pan",middle:"zoom",right:"rotate"}});export default(function(plugins3d){return connect(function(state){return{plugins3d:plugins3d,display:state.display,map:state.map,layers:state.layers,theme:state.theme,localConfig:state.localConfig,view3dMode:state.display.view3dMode,startupParams:state.localConfig.startupParams,startupState:state.localConfig.startupState}},{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,panTo:panTo,zoomToPoint:zoomToPoint,setView3dMode:setView3dMode})(View3D)});
@@ -4,7 +4,7 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import ol from"openlayers";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole}from"../../actions/layers";import{setSnappingConfig}from"../../actions/map";import Icon from"../../components/Icon";import Spinner from"../../components/widgets/Spinner";import IdentifyUtils from"../../utils/IdentifyUtils";import LocaleUtils from"../../utils/LocaleUtils";import MapUtils from"../../utils/MapUtils";import VectorLayerUtils from"../../utils/VectorLayerUtils";import SnapInteraction from"./SnapInteraction";import"./style/SnappingSupport.css";/**
7
+ */import React from"react";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole}from"../../actions/layers";import{setSnappingConfig}from"../../actions/map";import Icon from"../../components/Icon";import Spinner from"../../components/widgets/Spinner";import IdentifyUtils from"../../utils/IdentifyUtils";import LocaleUtils from"../../utils/LocaleUtils";import MapUtils from"../../utils/MapUtils";import VectorLayerUtils from"../../utils/VectorLayerUtils";import SnapInteraction from"./SnapInteraction";import"./style/SnappingSupport.css";/**
8
8
  * Snapping support for the map component.
9
9
  */var SnappingSupport=/*#__PURE__*/function(_React$Component){function SnappingSupport(props){var _this;_classCallCheck(this,SnappingSupport);_this=_callSuper(this,SnappingSupport,[props]);_defineProperty(_this,"state",{reqId:null,// FeatureInfo request ID
10
10
  invalid:true,// Whether the feature cache needs to be rebuilt
@@ -18,6 +18,6 @@ var added=false;if(_this.props.mapObj.snapping.enabled){for(var i=0;i<interactio
18
18
  var scale=MapUtils.computeForZoom(_this.props.mapObj.scales,_this.props.mapObj.zoom);var snapLayers=(snappingConfig.snaplayers||[]).reduce(function(res,cur){if(cur.min!==undefined&&cur.min!==null&&scale<cur.min){// Below scale range
19
19
  return res}if(cur.max!==undefined&&cur.max!==null&&scale>=cur.max){// Above scale range
20
20
  return res}return[].concat(_toConsumableArray(res),[cur.name])},[]);// Gather local snap layers
21
- var snapToWfs=scale<snappingConfig.wfsMaxScale;var localLayers=[];_this.props.layers.forEach(function(layer){if(layer.role===LayerRole.USERLAYER&&(layer.type==="vector"||layer.type==="wfs"&&snapToWfs)){var olLayer=_this.props.map.getLayers().getArray().find(function(l){return l.get("id")===layer.id});if(olLayer&&olLayer.getSource()&&olLayer.getSource().getFeaturesInExtent){localLayers.push(olLayer)}}});_this.setState({reqId:null,havesnaplayers:!isEmpty(snapLayers)||!isEmpty(localLayers)});if(!_this.snapInteraction.getMap()||!_this.snapInteraction.getActive()){return}if(snapLayers.length===0){_this.addLocalSnapFeatures(localLayers);return}var xmin=_this.props.mapObj.bbox.bounds[0];var ymin=_this.props.mapObj.bbox.bounds[1];var xmax=_this.props.mapObj.bbox.bounds[2];var ymax=_this.props.mapObj.bbox.bounds[3];var filterGeom=VectorLayerUtils.geoJSONGeomToWkt({type:"Polygon",coordinates:[[[xmin,ymin],[xmax,ymin],[xmax,ymax],[xmin,ymax],[xmin,ymin]]]});var options={LAYERATTRIBS:JSON.stringify(snapLayers.reduce(function(res,key){return _objectSpread(_objectSpread({},res),{},_defineProperty({},key,[]))},{})),with_htmlcontent:false,with_bbox:false,feature_count:snappingConfig.featureCount||500};var request=IdentifyUtils.buildFilterRequest(themeLayer,snapLayers.join(","),filterGeom,_this.props.mapObj,options);var reqId=uuidv1();_this.setState({reqId:reqId});IdentifyUtils.sendRequest(request,function(response){if(_this.state.reqId!==reqId){return}if(response){var result=IdentifyUtils.parseXmlResponse(response,_this.props.mapObj.projection,themeLayer);var features=Object.values(result).reduce(function(res,cur){return[].concat(_toConsumableArray(res),_toConsumableArray(cur))},[]);var format=new ol.format.GeoJSON;var olFeatures=format.readFeatures({type:"FeatureCollection",features:features.map(function(feature){return _objectSpread(_objectSpread({},feature),{},{id:uuidv1()})})});_this.source.addFeatures(olFeatures);// Add features from local layers
21
+ var snapToWfs=scale<snappingConfig.wfsMaxScale;var localLayers=[];_this.props.layers.forEach(function(layer){if(layer.role===LayerRole.USERLAYER&&(layer.type==="vector"||layer.type==="wfs"&&snapToWfs)){var olLayer=_this.props.map.getLayers().getArray().find(function(l){return l.get("id")===layer.id});if(olLayer&&olLayer.getSource()&&olLayer.getSource().getFeaturesInExtent){localLayers.push(olLayer)}}});_this.setState({reqId:null,havesnaplayers:!isEmpty(snapLayers)||!isEmpty(localLayers)});if(!_this.snapInteraction.getMap()||!_this.snapInteraction.getActive()){return}if(snapLayers.length===0){_this.addLocalSnapFeatures(localLayers);return}var xmin=_this.props.mapObj.bbox.bounds[0];var ymin=_this.props.mapObj.bbox.bounds[1];var xmax=_this.props.mapObj.bbox.bounds[2];var ymax=_this.props.mapObj.bbox.bounds[3];var filterGeom=VectorLayerUtils.geoJSONGeomToWkt({type:"Polygon",coordinates:[[[xmin,ymin],[xmax,ymin],[xmax,ymax],[xmin,ymax],[xmin,ymin]]]});var options={LAYERATTRIBS:JSON.stringify(snapLayers.reduce(function(res,key){return _objectSpread(_objectSpread({},res),{},_defineProperty({},key,[]))},{})),with_htmlcontent:false,with_bbox:false,feature_count:snappingConfig.featureCount||500};var request=IdentifyUtils.buildFilterRequest(themeLayer,snapLayers.join(","),filterGeom,_this.props.mapObj,options);var reqId=uuidv4();_this.setState({reqId:reqId});IdentifyUtils.sendRequest(request,function(response){if(_this.state.reqId!==reqId){return}if(response){var result=IdentifyUtils.parseXmlResponse(response,_this.props.mapObj.projection,themeLayer);var features=Object.values(result).reduce(function(res,cur){return[].concat(_toConsumableArray(res),_toConsumableArray(cur))},[]);var format=new ol.format.GeoJSON;var olFeatures=format.readFeatures({type:"FeatureCollection",features:features.map(function(feature){return _objectSpread(_objectSpread({},feature),{},{id:uuidv4()})})});_this.source.addFeatures(olFeatures);// Add features from local layers
22
22
  _this.addLocalSnapFeatures(localLayers);_this.setState({invalid:false,reqId:null,havesnaplayers:true})}else{_this.setState({reqId:null})}})});_defineProperty(_this,"addLocalSnapFeatures",function(localLayers){var extent=_this.props.mapObj.bbox.bounds;var projection=ol.proj.get(_this.props.mapObj.projection);localLayers.forEach(function(olLayer){var olFeatures=olLayer.getSource().getFeaturesInExtent(extent,projection);_this.source.addFeatures(olFeatures)})});_this.source=new ol.source.Vector;_this.snapInteraction=new SnapInteraction({source:_this.source,edge:_this.snapToEdge(props.mapObj.snapping),vertex:_this.snapToVertex(props.mapObj.snapping)});_this.snapInteraction.setActive(_this.props.mapObj.snapping.active);_this.inEventHandler=false;props.map.getInteractions().on("add",_this.handleInteractionAdded);props.map.getInteractions().on("remove",_this.handleInteractionRemoved);MapUtils.registerHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK,function(pixel){var coo=props.map.getCoordinateFromPixel(pixel);var snapResult=_this.snapInteraction.snapTo(pixel,coo,props.map);return snapResult?props.map.getCoordinateFromPixel(snapResult.vertexPixel):coo});return _this}_inherits(SnappingSupport,_React$Component);return _createClass(SnappingSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;if(this.state.drawing&&(this.props.mapObj.bbox!==prevProps.mapObj.bbox||this.props.theme!==prevProps.theme)){this.setState({invalid:true});this.refreshFeatureCache(true)}else if(this.state.drawing&&this.props.layers!==prevProps.layers){var layersChanged=this.props.layers.find(function(layer){if(layer.role===LayerRole.THEME){var prev=prevProps.layers.find(function(prevLayer){return layer.id===prevLayer.id});return!prev||layer.rev!==prev.rev}else if(layer.role===LayerRole.USERLAYER&&layer.type==="vector"){var _prev=prevProps.layers.find(function(prevLayer){return layer.id===prevLayer.id});return!_prev||_prev.features!==layer.features}return false});if(layersChanged){this.setState({invalid:true});// Delay to avoid refreshing the cache before QGIS Server can pick up the new feature
23
23
  setTimeout(function(){_this2.refreshFeatureCache(true)},1500)}}if(this.props.mapObj.snapping.active!==prevProps.mapObj.snapping.active||this.state.drawing!==prevState.drawing){this.snapInteraction.setActive(this.props.mapObj.snapping.active!==false);this.snapInteraction.setSnapEdge(this.snapToEdge(this.props.mapObj.snapping));this.snapInteraction.setSnapVertex(this.snapToVertex(this.props.mapObj.snapping));if(this.props.mapObj.snapping.active){this.refreshFeatureCache()}}}},{key:"render",value:function render(){var _this3=this;if(!this.state.drawing||!this.props.mapObj.snapping.enabled){return null}var disabled=!this.state.havesnaplayers||this.props.mapObj.snapping.active===false;var toolbarClass=disabled?"snapping-toolbar-inactive":"";var snapEdge=this.snapToEdge(this.props.mapObj.snapping);var snapVertex=this.snapToVertex(this.props.mapObj.snapping);return/*#__PURE__*/React.createElement("div",{className:"snapping-toolbar-container"},/*#__PURE__*/React.createElement("div",{className:toolbarClass},this.state.reqId!==null?/*#__PURE__*/React.createElement(Spinner,null):/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement("button",{className:"button"+(snapVertex?" pressed":""),onClick:function onClick(){return _this3.toggleSnap("vertex")},title:LocaleUtils.tr("snapping.vertex")},/*#__PURE__*/React.createElement(Icon,{icon:"snap_vertex",size:"large"})),/*#__PURE__*/React.createElement("button",{className:"button"+(snapEdge?" pressed":""),onClick:function onClick(){return _this3.toggleSnap("edge")},title:LocaleUtils.tr("snapping.edge")},/*#__PURE__*/React.createElement(Icon,{icon:"snap_edge",size:"large"}))),"\xA0",this.state.reqId?LocaleUtils.tr("snapping.loading"):LocaleUtils.tr("snapping.snappingenabled")))}}])}(React.Component);_defineProperty(SnappingSupport,"propTypes",{layers:PropTypes.array,map:PropTypes.object,mapObj:PropTypes.object,setSnappingConfig:PropTypes.func,task:PropTypes.string,theme:PropTypes.object});export default connect(function(state){return{layers:state.layers.flat,mapObj:state.map,task:state.task.id,theme:state.theme.current}},{setSnappingConfig:setSnappingConfig})(SnappingSupport);
Binary file
Binary file
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
3
+
4
+ <svg
5
+ fill="#000000"
6
+ version="1.1"
7
+ id="Capa_1"
8
+ width="24"
9
+ height="24"
10
+ viewBox="0 0 3.7559999 3.756"
11
+ xml:space="preserve"
12
+ sodipodi:docname="person.svg"
13
+ inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
14
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
15
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ xmlns:svg="http://www.w3.org/2000/svg"><defs
18
+ id="defs1" /><sodipodi:namedview
19
+ id="namedview1"
20
+ pagecolor="#aaaaaa"
21
+ bordercolor="#666666"
22
+ borderopacity="1.0"
23
+ inkscape:showpageshadow="2"
24
+ inkscape:pageopacity="0.0"
25
+ inkscape:pagecheckerboard="0"
26
+ inkscape:deskcolor="#d1d1d1"
27
+ inkscape:zoom="8"
28
+ inkscape:cx="5.25"
29
+ inkscape:cy="15.1875"
30
+ inkscape:window-width="1920"
31
+ inkscape:window-height="1172"
32
+ inkscape:window-x="0"
33
+ inkscape:window-y="0"
34
+ inkscape:window-maximized="1"
35
+ inkscape:current-layer="g1" />
36
+ <g
37
+ id="g1"
38
+ transform="matrix(0.0275,0,0,0.0275,0.15651372,0.15649997)">
39
+ <path
40
+ id="path1"
41
+ d="M 62.55504 1.0151515e-06 A 15.7 15.7 0 0 0 46.849465 15.694461 A 15.7 15.7 0 0 0 62.55504 31.400036 A 15.7 15.7 0 0 0 78.2495 15.694461 A 15.7 15.7 0 0 0 62.55504 1.0151515e-06 z M 43.248187 37.202096 C 39.948187 37.202096 37.246056 39.904226 37.246056 43.204226 L 37.246056 80.306285 C 37.246056 83.605285 39.948187 86.297301 43.248187 86.297301 L 46.649394 86.297301 L 46.649394 119.19787 C 46.649394 122.49787 49.251524 125.2 52.651524 125.2 L 72.547476 125.2 C 75.847476 125.2 78.549607 122.49787 78.549607 119.19787 L 78.549607 86.297301 L 81.950814 86.297301 C 85.251814 86.297301 87.952944 83.605285 87.952944 80.306285 L 87.952944 43.204226 C 87.952944 39.904226 85.251814 37.202096 81.950814 37.202096 L 43.248187 37.202096 z "
42
+ style="stroke-width:5.69090902;stroke-dasharray:none;stroke:#ffffff;stroke-opacity:1" />
43
+
44
+ </g>
45
+ </svg>
Binary file