qwc2 2025.7.10 → 2025.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/search.js +7 -0
- package/components/CoordinateDisplayer.js +1 -1
- package/components/SearchBox.js +4 -4
- package/components/StandardApp.js +3 -3
- package/components/map3d/Compare3D.js +1 -1
- package/components/map3d/Map3D.js +3 -2
- package/components/map3d/Map3DLight.js +1 -1
- package/components/map3d/MapControls3D.js +2 -2
- package/components/map3d/drawtool/EditTool3D.js +1 -1
- package/components/map3d/drawtool/NumericInput3D.js +1 -1
- package/components/widgets/AccordeonWidget.js +1 -1
- package/components/widgets/Input.js +1 -1
- package/package.json +1 -1
- package/plugins/BottomBar.js +1 -1
- package/plugins/FeatureForm.js +2 -2
- package/plugins/HeightProfile.js +8 -8
- package/plugins/Identify.js +2 -2
- package/plugins/MapCompare.js +1 -1
- package/plugins/MapExport.js +2 -2
- package/plugins/MapInfoTooltip.js +2 -2
- package/plugins/MapTip.js +1 -1
- package/plugins/Portal.js +1 -1
- package/plugins/Print.js +4 -4
- package/plugins/StartupMarker.js +2 -2
- package/plugins/TimeManager.js +1 -1
- package/plugins/ValueTool.js +1 -1
- package/plugins/View3D.js +7 -7
- package/plugins/map/SnapSupport.js +1 -1
- package/plugins/map/SnappingSupport.js +1 -1
- package/plugins/style/HeightProfile.css +6 -1
- package/plugins/style/MapCompare.css +3 -2
- package/reducers/layers.js +2 -2
- package/reducers/search.js +7 -0
- package/scripts/gen-plugin-docs.js +1 -1
- package/scripts/makeIconkit.js +1 -1
- package/utils/ElevationInterface.js +6 -2
- package/utils/LayerUtils.js +2 -2
- package/utils/PermaLinkUtils.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function
|
|
1
|
+
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t["return"]||t["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/**
|
|
2
2
|
* Copyright 2018-2024 Sourcepole AG
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
@@ -31,4 +31,4 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
31
31
|
* render() { return ...; }
|
|
32
32
|
* };
|
|
33
33
|
* ```
|
|
34
|
-
*/var MapInfoTooltip=/*#__PURE__*/function(_React$Component){function MapInfoTooltip(){var _this;_classCallCheck(this,MapInfoTooltip);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,MapInfoTooltip,[].concat(args));_defineProperty(_this,"state",{point:null,elevation:null,extraInfo:null});_defineProperty(_this,"clear",function(){_this.setState({point:null,
|
|
34
|
+
*/var MapInfoTooltip=/*#__PURE__*/function(_React$Component){function MapInfoTooltip(){var _this;_classCallCheck(this,MapInfoTooltip);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,MapInfoTooltip,[].concat(args));_defineProperty(_this,"state",{point:null,elevation:null,extraInfo:null});_defineProperty(_this,"clear",function(){_this.setState({point:null,elevation:null,extraInfo:null})});return _this}_inherits(MapInfoTooltip,_React$Component);return _createClass(MapInfoTooltip,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var _this2=this;if(!this.props.enabled&&this.state.point){this.clear();return}var newPoint=this.props.map.click;if(!newPoint||newPoint.button!==2){if(this.state.point){this.clear()}}else{var oldPoint=prevProps.map.click;if(!oldPoint||oldPoint.pixel[0]!==newPoint.pixel[0]||oldPoint.pixel[1]!==newPoint.pixel[1]){this.setState({point:newPoint,elevation:null,extraInfo:null});var pos=newPoint.coordinate;var crs=this.props.map.projection;getElevationInterface().getElevation(pos,crs).then(function(elevation){_this2.setState({elevation:elevation})})["catch"](function(){});var mapInfoService=ConfigUtils.getConfigProp("mapInfoService");if(mapInfoService){axios.get(mapInfoService,{params:{pos:pos.join(","),crs:crs}}).then(function(response){_this2.setState({extraInfo:response.data.results})})["catch"](function(){})}}}}},{key:"render",value:function render(){var _this3=this;if(!this.state.point){return null}var info=[];var projections=[this.props.map.displayCrs];if(!projections.includes(this.props.map.projection)){projections.push(this.props.map.projection)}if(this.props.includeWGS84&&!projections.includes("EPSG:4326")){projections.push("EPSG:4326")}projections.map(function(crs){var coo=CoordinatesUtils.reproject(_this3.state.point.coordinate,_this3.props.map.projection,crs);var decimals=CoordinatesUtils.getPrecision(crs);info.push([(CoordinatesUtils.getAvailableCRS()[crs]||{label:crs}).label,coo.map(function(x){return LocaleUtils.toLocaleFixed(x,decimals)}).join(", ")])});if(this.state.elevation){var elevs=this.state.elevation.list;if(!elevs){elevs=[{elevation:this.state.elevation,dataset:null}]}var _iterator=_createForOfIteratorHelper(elevs),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var data=_step.value;info.push([LocaleUtils.tr("mapinfotooltip.elevation")+(data.dataset?" ("+data.dataset+")":""),data.elevation.toFixed(this.props.elevationPrecision)+" m"])}}catch(err){_iterator.e(err)}finally{_iterator.f()}}if(this.state.extraInfo){info.push.apply(info,_toConsumableArray(this.state.extraInfo))}var title=LocaleUtils.tr("mapinfotooltip.title");var pixel=MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK)(this.state.point.coordinate);var style={left:pixel[0]+"px",top:pixel[1]+"px"};var text=info.map(function(entry){return entry.join(": ")}).join("\n");var routingButtons=null;if(ConfigUtils.havePlugin("Routing")){var prec=CoordinatesUtils.getPrecision(this.props.map.displayCrs);var pos=CoordinatesUtils.reproject(this.state.point.coordinate,this.props.map.projection,this.props.map.displayCrs);var point={text:pos.map(function(x){return x.toFixed(prec)}).join(", ")+" ("+this.props.map.displayCrs+")",pos:_toConsumableArray(pos),crs:this.props.map.displayCrs};routingButtons=/*#__PURE__*/React.createElement("table",{className:"mapinfotooltip-body-routing"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("b",null,LocaleUtils.tr("routing.route"),":")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this3.props.setCurrentTask("Routing",null,null,{from:point})}},LocaleUtils.tr("routing.fromhere")),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this3.props.setCurrentTask("Routing",null,null,{to:point})}},LocaleUtils.tr("routing.tohere")),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this3.props.setCurrentTask("Routing",null,null,{via:point})}},LocaleUtils.tr("routing.addviapoint"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("b",null,LocaleUtils.tr("routing.reachability"),":")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this3.props.setCurrentTask("Routing",null,null,{isocenter:point})}},LocaleUtils.tr("routing.isocenter")),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this3.props.setCurrentTask("Routing",null,null,{isoextracenter:point})}},LocaleUtils.tr("routing.isoextracenter")))))))}return/*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement("div",{className:"mapinfotooltip",style:style},/*#__PURE__*/React.createElement("div",{className:"mapinfotooltip-window"},/*#__PURE__*/React.createElement("div",{className:"mapinfotooltip-titlebar"},/*#__PURE__*/React.createElement("span",{className:"mapinfotooltip-title"},title),/*#__PURE__*/React.createElement(CopyButton,{buttonClass:"mapinfotooltip-button",text:text}),/*#__PURE__*/React.createElement(Icon,{className:"mapinfotooltip-button",icon:"remove",onClick:this.clear})),/*#__PURE__*/React.createElement("div",{className:"mapinfotooltip-body"},/*#__PURE__*/React.createElement("table",null,/*#__PURE__*/React.createElement("tbody",null,info.map(function(entry,index){return/*#__PURE__*/React.createElement("tr",{key:"row"+index},/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("b",null,entry[0],":")),/*#__PURE__*/React.createElement("td",null,entry[1]))}))),routingButtons,this.props.plugins.map(function(Plugin,idx){return/*#__PURE__*/React.createElement(Plugin,{closePopup:_this3.clear,key:idx,point:_this3.state.point,projection:_this3.props.map.projection})})))),this.context)}}])}(React.Component);_defineProperty(MapInfoTooltip,"contextType",MapContainerPortalContext);_defineProperty(MapInfoTooltip,"propTypes",{/** The number of decimal places to display for elevation values. */elevationPrecision:PropTypes.number,enabled:PropTypes.bool,includeWGS84:PropTypes.bool,map:PropTypes.object,/** Additional plugin components for the map info tooltip. */plugins:PropTypes.array,setCurrentTask:PropTypes.func});_defineProperty(MapInfoTooltip,"defaultProps",{elevationPrecision:0,includeWGS84:true,plugins:[]});export default(function(plugins){return connect(function(state){return{enabled:state.task.identifyEnabled,map:state.map,plugins:plugins}},{setCurrentTask:setCurrentTask})(MapInfoTooltip)});
|
package/plugins/MapTip.js
CHANGED
|
@@ -10,6 +10,6 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
10
10
|
* Queries the map tips configured in the QGIS layer properites over GetFeatureInfo.
|
|
11
11
|
*
|
|
12
12
|
* The map tip needs to be configured in QGIS Layer Properties → Display.
|
|
13
|
-
*/var MapTip=/*#__PURE__*/function(_React$Component){function MapTip(){var _this;_classCallCheck(this,MapTip);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,MapTip,[].concat(args));_defineProperty(_this,"state",{maptips:{},maptipsLayerOrder:[],mousePos:null,pos:null});_defineProperty(_this,"getMapMousePos",function(ev){_this.clearMaptip();clearTimeout(_this.mouseStateTimeout);_this.mouseStateTimeout=setTimeout(function(){_this.setState({mousePos:{coordinate:ev.coordinate,pixel:ev.pixel}})},100)});_defineProperty(_this,"clearMaptip",function(){clearTimeout(_this.timeoutId);_this.timeoutId=null;if(_this.state.pos){_this.props.removeLayer("maptipselection");_this.setState({maptips:{},maptipsOrder:[],pos:null})}});_defineProperty(_this,"queryMapTip",function(pos){_this.timeoutId=null;var options={info_format:"text/xml",feature_count:_this.props.layerFeatureCount,FI_POINT_TOLERANCE:16,FI_LINE_TOLERANCE:8,FI_POLYGON_TOLERANCE:4,with_maptip:true,with_htmlcontent:false};var reqId=uuidv1();_this.reqId=reqId;var layerOrder=[];_this.props.layers.forEach(function(layer){if(!(layer.role===LayerRole.THEME||layer.role===LayerRole.USERLAYER)||!(layer.infoFormats||[]).includes("text/xml")||isEmpty(layer.queryLayers)){return}var queryLayers=layer.queryLayers;if(!isEmpty(layer.drawingOrder)){queryLayers=layer.drawingOrder.slice(0).reverse().filter(function(entry){return layer.queryLayers.includes(entry)})}layerOrder.push(layer.id);var request=IdentifyUtils.buildRequest(layer,queryLayers.join(","),_this.state.mousePos.coordinate,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.reqId===reqId){var result=IdentifyUtils.parseXmlResponse(response||"",_this.props.map.projection);var mapTips=[];var features=[];var _iterator=_createForOfIteratorHelper(request.params.layers.split(",")),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var sublayer=_step.value;var sublayerFeatures=(result[sublayer]||[]).filter(function(feature){return feature.properties.maptip});features.push.apply(features,_toConsumableArray(sublayerFeatures));mapTips.push.apply(mapTips,_toConsumableArray(sublayerFeatures.map(function(feature){return feature.properties.maptip})))}}catch(err){_iterator.e(err)}finally{_iterator.f()}if(_this.props.showFeatureSelection&&!isEmpty(features)){var sellayer={id:"maptipselection",role:LayerRole.SELECTION};_this.props.addLayerFeatures(sellayer,features,true)}_this.setState(function(state){return{pos:pos,maptips:_objectSpread(_objectSpread({},state.maptips),{},_defineProperty({},layer.id,mapTips))}})}})});_this.setState({maptipsLayerOrder:layerOrder})});_defineProperty(_this,"parsedContent",function(text){var options={replace:function replace(node){if(node.name==="a"){return/*#__PURE__*/React.createElement("a",{href:node.attribs.href,onClick:node.attribs.onclick?function(ev){return _this.evalOnClick(ev,node.attribs.onclick)}:_this.attributeLinkClicked,target:node.attribs.target||"_blank"},domToReact(node.children,options))}return undefined}};return htmlReactParser(text,options)});_defineProperty(_this,"evalOnClick",function(ev,onclick){// eslint-disable-next-line
|
|
13
|
+
*/var MapTip=/*#__PURE__*/function(_React$Component){function MapTip(){var _this;_classCallCheck(this,MapTip);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,MapTip,[].concat(args));_defineProperty(_this,"state",{maptips:{},maptipsLayerOrder:[],mousePos:null,pos:null});_defineProperty(_this,"getMapMousePos",function(ev){_this.clearMaptip();clearTimeout(_this.mouseStateTimeout);_this.mouseStateTimeout=setTimeout(function(){_this.setState({mousePos:{coordinate:ev.coordinate,pixel:ev.pixel}})},100)});_defineProperty(_this,"clearMaptip",function(){clearTimeout(_this.timeoutId);_this.timeoutId=null;if(_this.state.pos){_this.props.removeLayer("maptipselection");_this.setState({maptips:{},maptipsOrder:[],pos:null})}});_defineProperty(_this,"queryMapTip",function(pos){_this.timeoutId=null;var options={info_format:"text/xml",feature_count:_this.props.layerFeatureCount,FI_POINT_TOLERANCE:16,FI_LINE_TOLERANCE:8,FI_POLYGON_TOLERANCE:4,with_maptip:true,with_htmlcontent:false};var reqId=uuidv1();_this.reqId=reqId;var layerOrder=[];_this.props.layers.forEach(function(layer){if(!(layer.role===LayerRole.THEME||layer.role===LayerRole.USERLAYER)||!(layer.infoFormats||[]).includes("text/xml")||isEmpty(layer.queryLayers)){return}var queryLayers=layer.queryLayers;if(!isEmpty(layer.drawingOrder)){queryLayers=layer.drawingOrder.slice(0).reverse().filter(function(entry){return layer.queryLayers.includes(entry)})}layerOrder.push(layer.id);var request=IdentifyUtils.buildRequest(layer,queryLayers.join(","),_this.state.mousePos.coordinate,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.reqId===reqId){var result=IdentifyUtils.parseXmlResponse(response||"",_this.props.map.projection,layer);var mapTips=[];var features=[];var _iterator=_createForOfIteratorHelper(request.params.layers.split(",")),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var sublayer=_step.value;var sublayerFeatures=(result[sublayer]||[]).filter(function(feature){return feature.properties.maptip});features.push.apply(features,_toConsumableArray(sublayerFeatures));mapTips.push.apply(mapTips,_toConsumableArray(sublayerFeatures.map(function(feature){return feature.properties.maptip})))}}catch(err){_iterator.e(err)}finally{_iterator.f()}if(_this.props.showFeatureSelection&&!isEmpty(features)){var sellayer={id:"maptipselection",role:LayerRole.SELECTION};_this.props.addLayerFeatures(sellayer,features,true)}_this.setState(function(state){return{pos:pos,maptips:_objectSpread(_objectSpread({},state.maptips),{},_defineProperty({},layer.id,mapTips))}})}})});_this.setState({maptipsLayerOrder:layerOrder})});_defineProperty(_this,"parsedContent",function(text){var options={replace:function replace(node){if(node.name==="a"){return/*#__PURE__*/React.createElement("a",{href:node.attribs.href,onClick:node.attribs.onclick?function(ev){return _this.evalOnClick(ev,node.attribs.onclick)}:_this.attributeLinkClicked,target:node.attribs.target||"_blank"},domToReact(node.children,options))}return undefined}};return htmlReactParser(text,options)});_defineProperty(_this,"evalOnClick",function(ev,onclick){// eslint-disable-next-line
|
|
14
14
|
eval(onclick);ev.preventDefault()});_defineProperty(_this,"attributeLinkClicked",function(ev){_this.props.openExternalUrl(ev.target.href,ev.target.target,{docked:_this.props.iframeDialogsInitiallyDocked});ev.preventDefault()});_defineProperty(_this,"positionMapTip",function(el){if(el){var x=_this.state.pos[0];var y=_this.state.pos[1];var parentBBox=el.parentElement.getBoundingClientRect();var bbox=el.getBoundingClientRect();if(x+bbox.width>parentBBox.width){x-=bbox.width}if(y+bbox.height>parentBBox.height){y-=bbox.height}el.style.left=x+"px";el.style.top=y+"px"}});return _this}_inherits(MapTip,_React$Component);return _createClass(MapTip,[{key:"componentDidMount",value:function componentDidMount(){MapUtils.getHook(MapUtils.ADD_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentWillUnmount",value:function componentWillUnmount(){MapUtils.getHook(MapUtils.REMOVE_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;if(this.props.map!==prevProps.map){this.clearMaptip()}if(this.props.mapTipsEnabled&&this.state.mousePos&&this.state.mousePos!==prevState.mousePos&&(isEmpty(this.state.pos)||Math.abs(this.state.mousePos.pixel[0]-this.state.pos[0])>5||Math.abs(this.state.mousePos.pixel[1]-this.state.pos[1])>5)){this.timeoutId=setTimeout(function(){return _this2.queryMapTip(_this2.state.mousePos.pixel)},500)}else if(!this.props.mapTipsEnabled&&prevProps.mapTipsEnabled){this.clearMaptip()}}},{key:"render",value:function render(){var _this3=this;if(!isEmpty(this.state.maptips)&&this.state.pos){// Render off-screen first to measure dimensions, then place as necessary
|
|
15
15
|
var style={left:10000+"px",top:10000+"px",maxHeight:this.props.maxHeight,maxWidth:this.props.maxWidth};var bufferPos={left:this.state.pos[0]-8+"px",top:this.state.pos[1]-8+"px"};return/*#__PURE__*/ReactDOM.createPortal([/*#__PURE__*/React.createElement("div",{id:"MapTipPointerBuffer",key:"MapTipPointerBuffer",style:bufferPos}),/*#__PURE__*/React.createElement("div",{id:"MapTip",key:"MapTip",ref:this.positionMapTip,style:style},this.state.maptipsLayerOrder.map(function(key){return _this3.state.maptips[key]||[]}).flat().map(function(maptip,idx){return/*#__PURE__*/React.createElement("div",{key:idx},_this3.parsedContent(maptip))}))],this.context)}return null}}])}(React.Component);_defineProperty(MapTip,"contextType",MapContainerPortalContext);_defineProperty(MapTip,"propTypes",{addLayerFeatures:PropTypes.func,iframeDialogsInitiallyDocked:PropTypes.bool,/** The maximum number of feature maptips to display for a single layer. */layerFeatureCount:PropTypes.number,layers:PropTypes.array,map:PropTypes.object,mapTipsEnabled:PropTypes.bool,/** The maximum height of the maptip popop bubble, as a CSS string. */maxHeight:PropTypes.string,/** The maximum height of the maptip popop bubble, as a CSS string. */maxWidth:PropTypes.string,openExternalUrl:PropTypes.func,removeLayer:PropTypes.func,/** Whether to show the maptip feature selection on the map or not */showFeatureSelection:PropTypes.bool});_defineProperty(MapTip,"defaultProps",{layerFeatureCount:5,maxHeight:"15em",maxWidth:"20em",showFeatureSelection:true});export default connect(function(state){return{mapTipsEnabled:state.map.maptips&&state.task.identifyEnabled,layers:state.layers.flat,map:state.map}},{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,openExternalUrl:openExternalUrl})(MapTip);
|
package/plugins/Portal.js
CHANGED
|
@@ -7,4 +7,4 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
7
7
|
*/import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{setCurrentTask}from"../actions/task";import{openExternalUrl}from"../actions/windows";import AppMenu from"../components/AppMenu";import Icon from"../components/Icon";import ThemeList from"../components/ThemeList";import ConfigUtils from"../utils/ConfigUtils";import LocaleUtils from"../utils/LocaleUtils";import{UrlParams}from"../utils/PermaLinkUtils";import ThemeUtils from"../utils/ThemeUtils";import"./style/Portal.css";/**
|
|
8
8
|
* Displays a landing lage, consisting of a full-screen theme switcher and a configurable menu.
|
|
9
9
|
*/var Portal=/*#__PURE__*/function(_React$Component){function Portal(){var _this;_classCallCheck(this,Portal);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,Portal,[].concat(args));_defineProperty(_this,"state",{filter:"",popupClosed:false,menuVisible:false});_defineProperty(_this,"openUrl",function(url,target,title){if(target==="iframe"){target=":iframedialog:externallinkiframe"}_this.props.openExternalUrl(url,target,{title:title,zIndex:250})});_defineProperty(_this,"menuToggled",function(visible){_this.setState({menuVisible:visible})});return _this}_inherits(Portal,_React$Component);return _createClass(Portal,[{key:"componentDidMount",value:function componentDidMount(){if(!this.props.startupParams.t&&!this.props.startupParams.k&&!this.props.startupParams.bk){this.props.setCurrentTask("Portal")}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.currentTask==="Portal"&&(this.props.currentTask!==prevProps.currentTask||this.props.currentTheme!==prevProps.currentTheme||this.props.map!==prevProps.map)){UrlParams.clear()}else if(!prevProps.themes&&this.props.themes&&this.props.currentTask!=="Portal"){// Show portal if no theme is to be loaded
|
|
10
|
-
var theme=ThemeUtils.getThemeById(this.props.themes,this.props.startupParams.t);if((!theme||theme.restricted)&&(ConfigUtils.getConfigProp("dontLoadDefaultTheme")||!this.props.themes.defaultTheme)){this.props.setCurrentTask("Portal")}}}},{key:"render",value:function render(){var _this2=this;if(this.props.currentTask!=="Portal"){return null}var assetsPath=ConfigUtils.getAssetsPath();var preserveSettings=ConfigUtils.getConfigProp("preserveSettingsOnPortalThemeSwitch");return/*#__PURE__*/React.createElement("div",{className:"Portal"},/*#__PURE__*/React.createElement("div",{className:"portal-topbar"},/*#__PURE__*/React.createElement("img",{className:"portal-logo",src:assetsPath+"/img/"+this.props.logo}),/*#__PURE__*/React.createElement("span",{className:"portal-topbar-text",dangerouslySetInnerHTML:{__html:this.props.topBarText}}),/*#__PURE__*/React.createElement("input",{className:"portal-search-field",onChange:function onChange(ev){return _this2.setState({filter:ev.target.value})},placeholder:LocaleUtils.tr("portal.filter"),type:"text",value:this.state.filter}),/*#__PURE__*/React.createElement("span",{className:"portal-topbar-spacer"})
|
|
10
|
+
var theme=ThemeUtils.getThemeById(this.props.themes,this.props.startupParams.t);if((!theme||theme.restricted)&&(ConfigUtils.getConfigProp("dontLoadDefaultTheme")||!this.props.themes.defaultTheme)){this.props.setCurrentTask("Portal")}}}},{key:"render",value:function render(){var _this2=this;if(this.props.currentTask!=="Portal"){return null}var assetsPath=ConfigUtils.getAssetsPath();var preserveSettings=ConfigUtils.getConfigProp("preserveSettingsOnPortalThemeSwitch");return/*#__PURE__*/React.createElement("div",{className:"Portal"},/*#__PURE__*/React.createElement("div",{className:"portal-topbar"},/*#__PURE__*/React.createElement("img",{className:"portal-logo",src:assetsPath+"/img/"+this.props.logo}),/*#__PURE__*/React.createElement("span",{className:"portal-topbar-text",dangerouslySetInnerHTML:{__html:this.props.topBarText}}),/*#__PURE__*/React.createElement("input",{className:"portal-search-field",onChange:function onChange(ev){return _this2.setState({filter:ev.target.value})},placeholder:LocaleUtils.tr("portal.filter"),type:"text",value:this.state.filter}),/*#__PURE__*/React.createElement("span",{className:"portal-topbar-spacer"}),this.props.menuItems.length>0?/*#__PURE__*/React.createElement(AppMenu,{appMenuClearsTask:false,buttonLabel:LocaleUtils.tr("portal.menulabel"),keepMenuOpen:this.props.keepMenuOpen,menuItems:this.props.menuItems,onMenuToggled:this.menuToggled,openExternalUrl:this.openUrl,showOnStartup:this.props.showMenuOnStartup}):null),/*#__PURE__*/React.createElement("div",{className:"portal-body "+(this.state.menuVisible?"portal-body-menuvisible":"")},/*#__PURE__*/React.createElement(ThemeList,{collapsibleGroups:this.props.collapsibleGroups,dontPreserveSettingsOnSwitch:!preserveSettings,filter:this.state.filter})),/*#__PURE__*/React.createElement("div",{className:"portal-bottombar"},this.props.userName?/*#__PURE__*/React.createElement("div",{className:"portal-bottombar-user"},/*#__PURE__*/React.createElement(Icon,{icon:"logout"}),/*#__PURE__*/React.createElement("span",null,this.props.userName)):null,/*#__PURE__*/React.createElement("div",{className:"portal-bottombar-links"},(this.props.bottomBarLinks||[]).map(function(link,idx){var _link$label;var label=(_link$label=link.label)!==null&&_link$label!==void 0?_link$label:LocaleUtils.tr(link.labelmsgid);return/*#__PURE__*/React.createElement("a",{href:"#",key:"l"+idx,onClick:function onClick(ev){ev.preventDefault();_this2.openUrl(link.href,link.target,label)}},label)}))))}}])}(React.Component);_defineProperty(Portal,"propTypes",{/** Links to show in the portal bottom bar */bottomBarLinks:PropTypes.arrayOf(PropTypes.shape({href:PropTypes.string,label:PropTypes.string,labelmsgid:PropTypes.string,target:PropTypes.string})),/** Whether to allow collapsing groups in the theme switcher. */collapsibleGroups:PropTypes.bool,currentTask:PropTypes.string,currentTheme:PropTypes.object,keepMenuOpen:PropTypes.bool,/** Name of a logo image below assets/img. */logo:PropTypes.string,map:PropTypes.object,/** Portal menu items, in the same format as the TopBar menu items. */menuItems:PropTypes.array,openExternalUrl:PropTypes.func,setCurrentTask:PropTypes.func,/** Whether the menu should be visible on startup. */showMenuOnStartup:PropTypes.bool,startupParams:PropTypes.object,themes:PropTypes.object,/** Portal title text to show in the top bar. */topBarText:PropTypes.string,userName:PropTypes.string});_defineProperty(Portal,"defaultProps",{collapsibleGroups:true,menuItems:[]});var selector=function selector(state){return{currentTask:state.task.id,currentTheme:state.theme.current,map:state.map,themes:state.theme.themes,startupParams:state.localConfig.startupParams,userName:state.localConfig.username||""}};export default connect(selector,{setCurrentTask:setCurrentTask,openExternalUrl:openExternalUrl})(Portal);
|
package/plugins/Print.js
CHANGED
|
@@ -15,9 +15,9 @@ var printParams=LayerUtils.collectPrintParams(_this.props.layers,_this.props.the
|
|
|
15
15
|
var printDpi=parseInt(_this.state.dpi,10)||0;if(_this.props.printMapHighlights){var highlightParams=VectorLayerUtils.createPrintHighlighParams(_this.props.layers,mapCrs,_this.state.scale,printDpi,_this.props.scaleFactor);formData[mapName+":HIGHLIGHT_GEOM"]=highlightParams.geoms.join(";");formData[mapName+":HIGHLIGHT_SYMBOL"]=highlightParams.styles.join(";");formData[mapName+":HIGHLIGHT_LABELSTRING"]=highlightParams.labels.join(";");formData[mapName+":HIGHLIGHT_LABELCOLOR"]=highlightParams.labelFillColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERCOLOR"]=highlightParams.labelOutlineColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERSIZE"]=highlightParams.labelOutlineSizes.join(";");formData[mapName+":HIGHLIGHT_LABELSIZE"]=highlightParams.labelSizes.join(";");formData[mapName+":HIGHLIGHT_LABEL_DISTANCE"]=highlightParams.labelDist.join(";");formData[mapName+":HIGHLIGHT_LABEL_ROTATION"]=highlightParams.labelRotations.join(";")}// Add grid params
|
|
16
16
|
var printGrid=_this.props.theme.printGrid;if(!isEmpty(printGrid)){if(_this.state.grid){var cur=0;while(cur<printGrid.length-1&&_this.state.scale<printGrid[cur].s){cur+=1}formData[mapName+":GRID_INTERVAL_X"]=printGrid[cur].x;formData[mapName+":GRID_INTERVAL_Y"]=printGrid[cur].y}else{formData[mapName+":GRID_INTERVAL_X"]=0;formData[mapName+":GRID_INTERVAL_Y"]=0}}// Add dimension values
|
|
17
17
|
_this.props.layers.forEach(function(layer){if(layer.role===LayerRole.THEME){Object.entries(layer.dimensionValues||{}).forEach(function(_ref5){var _ref6=_slicedToArray(_ref5,2),key=_ref6[0],value=_ref6[1];if(value!==undefined){formData[key]=value}})}});// Add extra print parameters
|
|
18
|
-
var extraOptions=Object.fromEntries((_this.props.theme.extraPrintParameters||"").split("&").filter(Boolean).map(function(entry){return entry.split("=")}));Object.entries(extraOptions).forEach(function(_ref7){var _ref8=_slicedToArray(_ref7,2),key=_ref8[0],value=_ref8[1];formData[key]=value});var pages=[formData];if(_this.state.printSeriesEnabled){pages=_this.state.extents.map(function(extent,index){var fd=structuredClone(formData);fd.name=(index+1).toString().padStart(2,"0");fd[_this.state.layout.map.name+":extent"]=_this.formatExtent(extent);return fd})}var timestamp=dayjs(new Date).format("YYYYMMDD_HHmmss");var fileName=_this.props.fileNameTemplate.replace("{username}",ConfigUtils.getConfigProp("username",null,"")).replace("{tenant}",ConfigUtils.getConfigProp("tenant",null,"")).replace("{theme}",_this.props.theme.id).replace("{timestamp}",timestamp);// batch print all pages
|
|
19
|
-
_this.batchPrint(pages,fileName)["catch"](function(e){_this.setState({outputLoaded:true,printOutputVisible:false});if(e.response){/* eslint-disable-next-line */console.warn(new TextDecoder().decode(e.response.data))}/* eslint-disable-next-line */alert("Print failed")})["finally"](function(){_this.setState({printing:false})})});_this.printForm=null;_this.state.grid=props.gridInitiallyEnabled;_this.state.dpi=props.defaultDpi;_this.state.selectedFormat=props.formats[0];return _this}_inherits(Print,_React$Component);return _createClass(Print,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(prevProps.theme!==this.props.theme){if(this.props.theme&&!isEmpty(this.props.theme.print)){var layouts=this.props.theme.print.filter(function(l){return l.map}).sort(function(a,b){return a.name.split("/").pop().localeCompare(b.name.split("/").pop(),undefined,{numeric:true})});var layout=layouts.find(function(l){return l["default"]})||layouts[0];this.setState({layouts:layouts,layout:layout,atlasFeatures:[]})}else{this.setState({layouts:[],layout:null,atlasFeatures:[]})}}if(this.state.atlasFeatures!==prevState.atlasFeatures){if(!isEmpty(this.state.atlasFeatures)){var layer={id:"print-pick-selection",role:LayerRole.SELECTION,skipPrint:true};this.props.addLayerFeatures(layer,this.state.atlasFeatures,true)}else if(!isEmpty(prevState.atlasFeatures)){this.props.clearLayer("print-pick-selection")}}if(this.state.printSeriesEnabled&&this.state.selectedFormat!=="application/pdf"){this.setState({selectedFormat:"application/pdf"})}}},{key:"render",value:function render(){var
|
|
20
|
-
promises=pages.map(function(formData){return
|
|
18
|
+
var extraOptions=Object.fromEntries((_this.props.theme.extraPrintParameters||"").split("&").filter(Boolean).map(function(entry){return entry.split("=")}));Object.entries(extraOptions).forEach(function(_ref7){var _ref8=_slicedToArray(_ref7,2),key=_ref8[0],value=_ref8[1];formData[key]=value});var pages=[formData];if(_this.state.printSeriesEnabled){pages=_this.state.extents.map(function(extent,index){var fd=structuredClone(formData);fd.name=(index+1).toString().padStart(2,"0");fd[_this.state.layout.map.name+":extent"]=_this.formatExtent(extent);return fd})}var timestamp=dayjs(new Date).format("YYYYMMDD_HHmmss");var fileName=_this.props.fileNameTemplate.replace("{layout}",_this.state.layout.name).replace("{username}",ConfigUtils.getConfigProp("username",null,"")).replace("{tenant}",ConfigUtils.getConfigProp("tenant",null,"")).replace("{theme}",_this.props.theme.id).replace("{themeTitle}",_this.props.theme.title||"").replace("{timestamp}",timestamp);// batch print all pages
|
|
19
|
+
_this.batchPrint(pages,fileName)["catch"](function(e){_this.setState({outputLoaded:true,printOutputVisible:false});if(e.response){/* eslint-disable-next-line */console.warn(new TextDecoder().decode(e.response.data))}/* eslint-disable-next-line */alert("Print failed")})["finally"](function(){_this.setState({printing:false})})});_this.printForm=null;_this.state.grid=props.gridInitiallyEnabled;_this.state.dpi=props.defaultDpi;_this.state.selectedFormat=props.formats[0];return _this}_inherits(Print,_React$Component);return _createClass(Print,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;if(prevProps.theme!==this.props.theme){if(this.props.theme&&!isEmpty(this.props.theme.print)){var sortDir=this.props.layoutSortOrder==="desc"?-1:1;var layouts=this.props.theme.print.filter(function(l){return l.map&&!l.name.split("/").pop().startsWith(_this2.props.layoutHidePrefix)}).sort(function(a,b){return sortDir*a.name.split("/").pop().localeCompare(b.name.split("/").pop(),undefined,{numeric:true})});var layout=layouts.find(function(l){return l["default"]})||layouts[0];this.setState({layouts:layouts,layout:layout,atlasFeatures:[]})}else{this.setState({layouts:[],layout:null,atlasFeatures:[]})}}if(this.state.atlasFeatures!==prevState.atlasFeatures){if(!isEmpty(this.state.atlasFeatures)){var layer={id:"print-pick-selection",role:LayerRole.SELECTION,skipPrint:true};this.props.addLayerFeatures(layer,this.state.atlasFeatures,true)}else if(!isEmpty(prevState.atlasFeatures)){this.props.clearLayer("print-pick-selection")}}if(this.state.printSeriesEnabled&&this.state.selectedFormat!=="application/pdf"){this.setState({selectedFormat:"application/pdf"})}}},{key:"render",value:function render(){var _this3=this;var minMaxTooltip=this.state.minimized?LocaleUtils.tr("print.maximize"):LocaleUtils.tr("print.minimize");var extraTitlebarContent=/*#__PURE__*/React.createElement(Icon,{className:"print-minimize-maximize",icon:this.state.minimized?"chevron-down":"chevron-up",onClick:function onClick(){return _this3.setState(function(state){return{minimized:!state.minimized}})},title:minMaxTooltip});return[/*#__PURE__*/React.createElement(SideBar,{extraTitlebarContent:extraTitlebarContent,icon:"print",id:"Print",key:"Print",onHide:this.onHide,onShow:this.onShow,side:this.props.side,title:LocaleUtils.tr("appmenu.items.Print"),width:"20em"},function(){return{body:_this3.state.minimized?null:_this3.renderBody(),extra:[_this3.renderPrintSelection()]}}),this.renderPrintOutputWindow(),this.props.active&&this.state.layout&&this.state.layout.atlasCoverageLayer&&!this.state.printSeriesEnabled?/*#__PURE__*/React.createElement(PickFeature,{featurePicked:this.selectAtlasFeature,key:"FeaturePicker",layerFilter:{url:this.props.theme.url,name:this.state.layout.atlasCoverageLayer}}):null]}},{key:"batchPrint",value:function(){var _batchPrint=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(pages,fileName){var _this4=this;var promises,docs,files,file,fileURL,_iterator,_step,_file;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:// Print pages on server
|
|
20
|
+
promises=pages.map(function(formData){return _this4.printRequest(formData)});// Collect printing results
|
|
21
21
|
_context.next=3;return Promise.all(promises);case 3:docs=_context.sent;_context.next=6;return this.collectFiles(docs,fileName);case 6:files=_context.sent;// Download or display files
|
|
22
|
-
if(this.props.inlinePrintOutput&&files.length===1){file=files.pop();fileURL=URL.createObjectURL(file.content);this.setState({pdfData:file,pdfDataUrl:fileURL,outputLoaded:true})}else{_iterator=_createForOfIteratorHelper(files);try{for(_iterator.s();!(_step=_iterator.n()).done;){_file=_step.value;FileSaver.saveAs(_file.content,_file.fileName)}}catch(err){_iterator.e(err)}finally{_iterator.f()}}case 8:case"end":return _context.stop()}},_callee,this)}));function batchPrint(_x,_x2){return _batchPrint.apply(this,arguments)}return batchPrint}()},{key:"printRequest",value:function(){var _printRequest=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(formData){var data,config,response,contentType;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:data=Object.entries(formData).map(function(pair){return pair.map(function(entry){return encodeURIComponent(entry).replace(/%20/g,"+")}).join("=")}).join("&");config={headers:{"Content-Type":"application/x-www-form-urlencoded"},responseType:"arraybuffer"};_context2.next=4;return axios.post(this.props.theme.printUrl,data,config);case 4:response=_context2.sent;contentType=response.headers["content-type"];return _context2.abrupt("return",{name:formData.name,data:response.data,contentType:contentType});case 7:case"end":return _context2.stop()}},_callee2,this)}));function printRequest(_x3){return _printRequest.apply(this,arguments)}return printRequest}()},{key:"collectFiles",value:function(){var _collectFiles=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(docs,fileName){var
|
|
22
|
+
if(this.props.inlinePrintOutput&&files.length===1){file=files.pop();fileURL=URL.createObjectURL(file.content);this.setState({pdfData:file,pdfDataUrl:fileURL,outputLoaded:true})}else{_iterator=_createForOfIteratorHelper(files);try{for(_iterator.s();!(_step=_iterator.n()).done;){_file=_step.value;FileSaver.saveAs(_file.content,_file.fileName)}}catch(err){_iterator.e(err)}finally{_iterator.f()}}case 8:case"end":return _context.stop()}},_callee,this)}));function batchPrint(_x,_x2){return _batchPrint.apply(this,arguments)}return batchPrint}()},{key:"printRequest",value:function(){var _printRequest=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(formData){var data,config,response,contentType;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:data=Object.entries(formData).map(function(pair){return pair.map(function(entry){return encodeURIComponent(entry).replace(/%20/g,"+")}).join("=")}).join("&");config={headers:{"Content-Type":"application/x-www-form-urlencoded"},responseType:"arraybuffer"};_context2.next=4;return axios.post(this.props.theme.printUrl,data,config);case 4:response=_context2.sent;contentType=response.headers["content-type"];return _context2.abrupt("return",{name:formData.name,data:response.data,contentType:contentType});case 7:case"end":return _context2.stop()}},_callee2,this)}));function printRequest(_x3){return _printRequest.apply(this,arguments)}return printRequest}()},{key:"collectFiles",value:function(){var _collectFiles=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(docs,fileName){var _this5=this;var data,content,_data,_content;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!(docs.length>1&&this.state.downloadMode==="onepdf")){_context3.next=6;break}_context3.next=3;return this.collectOnePdf(docs);case 3:data=_context3.sent;content=new Blob([data],{type:"application/pdf"});return _context3.abrupt("return",[{content:content,fileName:fileName+".pdf"}]);case 6:if(!(docs.length>1&&this.state.downloadMode==="onezip")){_context3.next=12;break}_context3.next=9;return this.collectOneZip(docs,fileName);case 9:_data=_context3.sent;_content=new Blob([_data],{type:"application/zip"});return _context3.abrupt("return",[{content:_content,fileName:fileName+".zip"}]);case 12:return _context3.abrupt("return",docs.map(function(doc){var content=new Blob([doc.data],{type:doc.contentType});var ext=_this5.state.selectedFormat.split(";")[0].split("/").pop();var appendix=doc.name?"_"+doc.name:"";return{content:content,fileName:fileName+appendix+"."+ext}}));case 13:case"end":return _context3.stop()}},_callee3,this)}));function collectFiles(_x4,_x5){return _collectFiles.apply(this,arguments)}return collectFiles}()},{key:"collectOnePdf",value:function(){var _collectOnePdf=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(docs){var _yield$import,PDFDocument,mergedDoc,_iterator2,_step2,doc,pdfBytes,copiedPages,_iterator3,_step3,page;return _regeneratorRuntime().wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return import("pdf-lib");case 2:_yield$import=_context4.sent;PDFDocument=_yield$import.PDFDocument;_context4.next=6;return PDFDocument.create();case 6:mergedDoc=_context4.sent;_iterator2=_createForOfIteratorHelper(docs);_context4.prev=8;_iterator2.s();case 10:if((_step2=_iterator2.n()).done){_context4.next=22;break}doc=_step2.value;_context4.next=14;return PDFDocument.load(doc.data);case 14:pdfBytes=_context4.sent;_context4.next=17;return mergedDoc.copyPages(pdfBytes,pdfBytes.getPageIndices());case 17:copiedPages=_context4.sent;_iterator3=_createForOfIteratorHelper(copiedPages);try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){page=_step3.value;mergedDoc.addPage(page)}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}case 20:_context4.next=10;break;case 22:_context4.next=27;break;case 24:_context4.prev=24;_context4.t0=_context4["catch"](8);_iterator2.e(_context4.t0);case 27:_context4.prev=27;_iterator2.f();return _context4.finish(27);case 30:_context4.next=32;return mergedDoc.save();case 32:return _context4.abrupt("return",_context4.sent);case 33:case"end":return _context4.stop()}},_callee4,null,[[8,24,27,30]])}));function collectOnePdf(_x6){return _collectOnePdf.apply(this,arguments)}return collectOnePdf}()},{key:"collectOneZip",value:function(){var _collectOneZip=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(docs,fileName){var mergedDoc,_iterator4,_step4,doc,file,ext,appendix;return _regeneratorRuntime().wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:mergedDoc=new JSZip;_iterator4=_createForOfIteratorHelper(docs);try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){doc=_step4.value;file=new Blob([doc.data],{type:doc.contentType});ext=this.state.selectedFormat.split(";")[0].split("/").pop();appendix=doc.name?"_"+doc.name:"";mergedDoc.file(fileName+appendix+"."+ext,file)}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}_context5.next=5;return mergedDoc.generateAsync({type:"arraybuffer"});case 5:return _context5.abrupt("return",_context5.sent);case 6:case"end":return _context5.stop()}},_callee5,this)}));function collectOneZip(_x7,_x8){return _collectOneZip.apply(this,arguments)}return collectOneZip}()}])}(React.Component);_defineProperty(Print,"propTypes",{active:PropTypes.bool,addLayerFeatures:PropTypes.func,/** Whether to allow GeoPDF export. Requires QGIS Server 3.32 or newer. */allowGeoPdfExport:PropTypes.bool,clearLayer:PropTypes.func,/** The default print dpi. */defaultDpi:PropTypes.number,/** The factor to apply to the map scale to determine the initial print map scale. */defaultScaleFactor:PropTypes.number,/** Show an option to print a series of extents. */displayPrintSeries:PropTypes.bool,/** Whether to display the printing rotation control. */displayRotation:PropTypes.bool,/** Template for the name of the generated files when downloading. Can contain the placeholders `{layout}`, `{username}`, `{tenant}`, `{theme}`, `{themeTitle}`, `{timestamp}`. */fileNameTemplate:PropTypes.string,/** Export layout format mimetypes. If format is not supported by QGIS Server, print will fail. */formats:PropTypes.arrayOf(PropTypes.string),/** Whether the grid is enabled by default. */gridInitiallyEnabled:PropTypes.bool,/** Whether to hide form fields which contain autopopulated values (i.e. search result label). */hideAutopopulatedFields:PropTypes.bool,/** Whether to display the print output in an inline dialog instead triggering a download. */inlinePrintOutput:PropTypes.bool,layers:PropTypes.array,/** Hide layouts which begin with this prefix. */layoutHidePrefix:PropTypes.string,/** Layout sort order, asc or desc. */layoutSortOrder:PropTypes.string,map:PropTypes.object,/** Whether to print external layers. Requires QGIS Server 3.x! */printExternalLayers:PropTypes.bool,/** Whether to print highlights on the map, e.g. selected features or redlining. */printMapHighlights:PropTypes.bool,/** Scale factor to apply to line widths, font sizes, ... of redlining drawings passed to GetPrint. */scaleFactor:PropTypes.number,setIdentifyEnabled:PropTypes.func,setSnappingConfig:PropTypes.func,/** The side of the application on which to display the sidebar. */side:PropTypes.string,theme:PropTypes.object});_defineProperty(Print,"defaultProps",{defaultDpi:300,defaultScaleFactor:0.5,displayPrintSeries:false,displayRotation:true,fileNameTemplate:"{theme}_{timestamp}",gridInitiallyEnabled:false,layoutSortOrder:"asc",formats:["application/pdf","image/jpeg","image/png","image/svg"],inlinePrintOutput:false,printExternalLayers:true,printMapHighlights:true,scaleFactor:1.9,// Experimentally determined...
|
|
23
23
|
side:"right"});var selector=function selector(state){return{active:state.task.id==="Print",theme:state.theme.current,map:state.map,layers:state.layers.flat}};export default connect(selector,{addLayerFeatures:addLayerFeatures,clearLayer:clearLayer,setSnappingConfig:setSnappingConfig})(Print);
|
package/plugins/StartupMarker.js
CHANGED
|
@@ -4,9 +4,9 @@ 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{addMarker,removeMarker}from"../actions/layers"
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{addMarker,removeMarker}from"../actions/layers";/**
|
|
8
8
|
* Displays a marker when starting up the viewer.
|
|
9
9
|
*
|
|
10
10
|
* The marked is displayed in the center of the map if `c=<x>,<y>&hc=1` is set in the URL.
|
|
11
|
-
*/var StartupMarker=/*#__PURE__*/function(_React$Component){function StartupMarker(props){var _this;_classCallCheck(this,StartupMarker);_this=_callSuper(this,StartupMarker,[props]);_this.markerSet=false;return _this}_inherits(StartupMarker,_React$Component);return _createClass(StartupMarker,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var highlight=["true","1"].includes(""+(this.props.startupParams&&this.props.startupParams.hc||"").toLowerCase());if(highlight&&this.props.theme&&!prevProps.theme&&this.props.startupParams.c){
|
|
11
|
+
*/var StartupMarker=/*#__PURE__*/function(_React$Component){function StartupMarker(props){var _this;_classCallCheck(this,StartupMarker);_this=_callSuper(this,StartupMarker,[props]);_this.markerSet=false;return _this}_inherits(StartupMarker,_React$Component);return _createClass(StartupMarker,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var highlight=["true","1"].includes(""+(this.props.startupParams&&this.props.startupParams.hc||"").toLowerCase());if(highlight&&this.props.theme&&!prevProps.theme&&this.props.startupParams.c){var point=this.props.startupParams.c.split(/[;,]/g).map(function(x){return parseFloat(x)});prevProps.addMarker("startupposmarker",point,"",this.props.startupParams.crs||this.props.map.projection);this.markerSet=true}else if(this.markerSet){if(this.props.removeMode==="onpan"&&this.props.map.center!==prevProps.map.center&&this.props.map.zoom===prevProps.map.zoom||this.props.removeMode==="onzoom"&&this.props.map.zoom!==prevProps.map.zoom||this.props.removeMode==="onclickonmarker"&&this.props.click&&(this.props.click.features||[]).find(function(feature){return feature.id==="startupposmarker"})){prevProps.removeMarker("startupposmarker");this.markerSet=false}}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(StartupMarker,"propTypes",{addMarker:PropTypes.func,click:PropTypes.object,map:PropTypes.object,removeMarker:PropTypes.func,/** When to remove the marker. Possible choices: onpan, onzoom, onclickonmarker. */removeMode:PropTypes.string,// onpan, onzoom, onclickonmarker
|
|
12
12
|
startupParams:PropTypes.object,theme:PropTypes.object});_defineProperty(StartupMarker,"defaultProps",{removeMode:"onpan"});export default connect(function(state){return{startupParams:state.localConfig.startupParams,click:state.map.click||{},map:state.map,theme:state.theme.current}},{addMarker:addMarker,removeMarker:removeMarker})(StartupMarker);
|
package/plugins/TimeManager.js
CHANGED
|
@@ -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);_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=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
|
|
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/ValueTool.js
CHANGED
|
@@ -8,4 +8,4 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
8
8
|
* Displays raster band values of active raster layers at the hovered mouse position,
|
|
9
9
|
* queried via GetFeatureInfo.
|
|
10
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"
|
|
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);_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);
|
|
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
|
@@ -4,10 +4,10 @@ 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,Provider}from"react-redux";import PropTypes from"prop-types";import{createSelector}from"reselect";import*as displayExports from"../actions/display";import{setView3dMode,View3DMode}from"../actions/display";import*as layersExports from"../actions/layers";import{LayerRole,addLayerFeatures,removeLayer}from"../actions/layers";import{panTo,zoomToPoint}from"../actions/map";import*as mapExports from"../actions/map";import*as themeExports from"../actions/theme";import PluginsContainer from"../components/PluginsContainer";import ResizeableWindow from"../components/ResizeableWindow";import StandardApp from"../components/StandardApp";import View3DSwitcher from"../components/map3d/View3DSwitcher";import Spinner from"../components/widgets/Spinner";import ReducerIndex from"../reducers/index";import searchProvidersSelector from"../selectors/searchproviders";import{createStore}from"../stores/StandardStore";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import{UrlParams}from"../utils/PermaLinkUtils";import personIcon from"../utils/img/person.png";import"./style/View3D.css";/**
|
|
7
|
+
*/import React from"react";import{connect,Provider}from"react-redux";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{createSelector}from"reselect";import*as displayExports from"../actions/display";import{setView3dMode,View3DMode}from"../actions/display";import*as layersExports from"../actions/layers";import{LayerRole,addLayerFeatures,removeLayer}from"../actions/layers";import{panTo,zoomToPoint}from"../actions/map";import*as mapExports from"../actions/map";import*as themeExports from"../actions/theme";import PluginsContainer from"../components/PluginsContainer";import ResizeableWindow from"../components/ResizeableWindow";import StandardApp from"../components/StandardApp";import View3DSwitcher from"../components/map3d/View3DSwitcher";import Spinner from"../components/widgets/Spinner";import ReducerIndex from"../reducers/index";import searchProvidersSelector from"../selectors/searchproviders";import{createStore}from"../stores/StandardStore";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import{UrlParams}from"../utils/PermaLinkUtils";import personIcon from"../utils/img/person.png";import"./style/View3D.css";/**
|
|
8
8
|
* Displays a 3D map view.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* ### Configuration
|
|
11
11
|
*
|
|
12
12
|
* To add a 3D View to a theme, add the following configuration block to a theme item in `themesConfig.json`:
|
|
13
13
|
* ```
|
|
@@ -58,7 +58,7 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
58
58
|
* - The `objects3d` entry contains an optional list of GLTF objects to add to the scene.
|
|
59
59
|
*
|
|
60
60
|
*
|
|
61
|
-
*
|
|
61
|
+
* ### Styling
|
|
62
62
|
*
|
|
63
63
|
* The tileset style JSON is a [3D Tiles stylesheet](https://github.com/CesiumGS/3d-tiles/tree/main/specification/Styling),
|
|
64
64
|
* of which currently the `color` section is supported, and which may in addition also contain a `batchstyles` section as follows:
|
|
@@ -87,15 +87,15 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
87
87
|
* - The color declarations in the `batchstyles` section override any color resulting from a color expression in the `color` section.
|
|
88
88
|
* - You must ensure that your 3D tiles batch table contains all batch attributes which are referenced as variables in a color expression!
|
|
89
89
|
*
|
|
90
|
-
*
|
|
90
|
+
* ### Import
|
|
91
91
|
*
|
|
92
92
|
* To import scene objects in formats other than GLTF, a `ogcProcessesUrl` in `config.json` needs to point to a BBOX OGC processes server.
|
|
93
|
-
*/var View3D=/*#__PURE__*/function(_React$Component){function View3D(props){var _this;_classCallCheck(this,View3D);_this=_callSuper(this,View3D,[props]);_defineProperty(_this,"state",{componentLoaded:false,windowDetached:false,viewsLocked:false,storedState:null});_defineProperty(_this,"render3DWindow",function(){if(_this.props.view3dMode>View3DMode.DISABLED){var extraControls=[{icon:"sync",callback:_this.sync2DExtent,title:LocaleUtils.tr("map3d.syncview")},{icon:"lock",callback:_this.setLockViews,title:LocaleUtils.tr("map3d.lockview"),active:_this.state.viewsLocked}];if(!_this.state.windowDetached){extraControls.push({icon:"maximize",callback:function callback(){return _this.props.setView3dMode(View3DMode.FULLSCREEN)},title:LocaleUtils.tr("window.maximize")})}var Map3D=_this.map3dComponent;var options={defaultDay:_this.props.defaultDay,defaultTime:_this.props.defaultTime,searchMinScaleDenom:_this.props.searchMinScaleDenom,tileInfoServiceUrl:_this.props.tileInfoServiceUrl,importedTilesBaseUrl:_this.props.importedTilesBaseUrl};return/*#__PURE__*/React.createElement(ResizeableWindow,{extraControls:extraControls,fullscreen:_this.props.view3dMode===View3DMode.FULLSCREEN,icon:"map3d",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,key:"View3DWindow",maximizeable:false,onClose:_this.onClose,onExternalWindowResized:_this.redrawScene,onFocusChanged:_this.windowFocusChanged,onGeometryChanged:_this.onGeometryChanged,splitScreenWhenDocked:true,splitTopAndBottomBar:true,title:LocaleUtils.tr("map3d.title")},_this.state.componentLoaded?/*#__PURE__*/React.createElement(Provider,{role:"body",store:_this.store},/*#__PURE__*/React.createElement(PluginsContainer,{className:"plugins-container-3d",plugins:_this.props.plugins,pluginsAppConfig:{},pluginsConfig:_this.props.pluginsConfig},/*#__PURE__*/React.createElement(Map3D,{innerRef:_this.setRef,onCameraChanged:_this.onCameraChanged,onMapInitialized:_this.setupMap,options:options,searchProviders:_this.props.searchProviders,theme:_this.props.theme}),_this.props.view3dMode===View3DMode.DISABLING?/*#__PURE__*/React.createElement("div",{className:"view3d-busy-overlay"},/*#__PURE__*/React.createElement(Spinner,null),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("view3d.storingstate"))):null)):null)}return null});_defineProperty(_this,"onClose",function(){_this.props.setView3dMode(View3DMode.
|
|
94
|
-
if(_this.state.viewsLocked&&_this.focusedMap==="map3d"){var rotation=undefined;if(camera){rotation=Math.atan2(center[1]-camera[1],center[0]-camera[0])-0.5*Math.PI;var distance=Math.sqrt((camera[0]-center[0])*(camera[0]-center[0])+(camera[1]-center[1])*(camera[1]-center[1])+(camera[2]-center[2])*(camera[2]-center[2]));var fovrad=fov/180*Math.PI;var bboxWidth=distance*(2*Math.tan(fovrad/2));var bbox=[-0.5*bboxWidth,0,0.5*bboxWidth,0];var zoom=MapUtils.getZoomForExtent(bbox,_this.props.map.resolutions,_this.props.map.size,0,_this.props.map.scales.length-1);_this.props.zoomToPoint(center.slice(0,2),zoom,_this.props.theme.mapCrs,rotation);if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-cone");_this.firstPersonMarker=false}}else{_this.props.panTo(center.slice(0,2),_this.props.theme.mapCrs,rotation);var feature={geometry:{type:"Point",coordinates:center.slice(0,2)},crs:_this.props.theme.mapCrs,styleName:"marker",styleOptions:{iconSrc:personIcon}};var layer={id:"view3d-firstperson-marker",role:LayerRole.MARKER};_this.props.addLayerFeatures(layer,[feature],true);_this.firstPersonMarker=true}}else if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-marker");_this.firstPersonMarker=false}});_defineProperty(_this,"setRef",function(ref){_this.map3dComponentRef=ref});_defineProperty(_this,"sync2DExtent",function(){if(_this.map3dComponentRef){_this.map3dComponentRef.setViewToExtent(_this.props.map.bbox.bounds,_this.props.map.bbox.rotation)}});_defineProperty(_this,"setLockViews",function(){_this.setState(function(state){return{viewsLocked:!state.viewsLocked}});if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-marker");_this.firstPersonMarker=false}});_defineProperty(_this,"setupMap",function(){if(_this.map3dComponentRef){if(_this.state.storedState){_this.map3dComponentRef.restore3dState(_this.state.storedState)}else{_this.sync2DExtent()}}});_defineProperty(_this,"redrawScene",function(ev){if(_this.map3dComponentRef){_this.map3dComponentRef.redrawScene(ev)}});_defineProperty(_this,"trackFocus",function(ev){var _mapEl$contains,_map3dEl$contains;var mapEl=document.getElementById("map");var map3dEl=document.getElementById("map3d");if(mapEl!==null&&mapEl!==void 0&&(_mapEl$contains=mapEl.contains)!==null&&_mapEl$contains!==void 0&&_mapEl$contains.call(mapEl,document.activeElement)){_this.focusedMap="map"}else if(map3dEl!==null&&map3dEl!==void 0&&(_map3dEl$contains=map3dEl.contains)!==null&&_map3dEl$contains!==void 0&&_map3dEl$contains.call(map3dEl,document.activeElement)){_this.focusedMap="map3d"}else{_this.focusedMap=null}});_this.map3dComponent=null;_this.map3dComponentRef=null;_this.focusedMap=null;_this.firstPersonMarker=true;// Subset of 2d reducers
|
|
93
|
+
*/var View3D=/*#__PURE__*/function(_React$Component){function View3D(props){var _this;_classCallCheck(this,View3D);_this=_callSuper(this,View3D,[props]);_defineProperty(_this,"state",{componentLoaded:false,windowDetached:false,viewsLocked:false,storedState:null});_defineProperty(_this,"render3DWindow",function(){if(_this.props.view3dMode>View3DMode.DISABLED){var extraControls=[{icon:"sync",callback:_this.sync2DExtent,title:LocaleUtils.tr("map3d.syncview")},{icon:"lock",callback:_this.setLockViews,title:LocaleUtils.tr("map3d.lockview"),active:_this.state.viewsLocked}];if(!_this.state.windowDetached){extraControls.push({icon:"maximize",callback:function callback(){return _this.props.setView3dMode(View3DMode.FULLSCREEN)},title:LocaleUtils.tr("window.maximize")})}var Map3D=_this.map3dComponent;var options={defaultDay:_this.props.defaultDay,defaultTime:_this.props.defaultTime,searchMinScaleDenom:_this.props.searchMinScaleDenom,tileInfoServiceUrl:_this.props.tileInfoServiceUrl,importedTilesBaseUrl:_this.props.importedTilesBaseUrl};return/*#__PURE__*/React.createElement(ResizeableWindow,{extraControls:extraControls,fullscreen:_this.props.view3dMode===View3DMode.FULLSCREEN,icon:"map3d",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,key:"View3DWindow",maximizeable:false,onClose:_this.onClose,onExternalWindowResized:_this.redrawScene,onFocusChanged:_this.windowFocusChanged,onGeometryChanged:_this.onGeometryChanged,splitScreenWhenDocked:true,splitTopAndBottomBar:true,title:LocaleUtils.tr("map3d.title")},_this.state.componentLoaded?/*#__PURE__*/React.createElement(Provider,{role:"body",store:_this.store},/*#__PURE__*/React.createElement(PluginsContainer,{className:"plugins-container-3d",plugins:_this.props.plugins,pluginsAppConfig:{},pluginsConfig:_this.props.pluginsConfig},/*#__PURE__*/React.createElement(Map3D,{innerRef:_this.setRef,onCameraChanged:_this.onCameraChanged,onMapInitialized:_this.setupMap,options:options,searchProviders:_this.props.searchProviders,theme:_this.props.theme}),_this.props.view3dMode===View3DMode.DISABLING?/*#__PURE__*/React.createElement("div",{className:"view3d-busy-overlay"},/*#__PURE__*/React.createElement(Spinner,null),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("view3d.storingstate"))):null)):null)}return null});_defineProperty(_this,"onClose",function(){_this.props.setView3dMode(View3DMode.DISABLING)});_defineProperty(_this,"onGeometryChanged",function(geometry){if(geometry.maximized&&_this.props.view3dMode!==View3DMode.FULLSCREEN){_this.props.setView3dMode(View3DMode.FULLSCREEN)}_this.setState({windowDetached:geometry.detached})});_defineProperty(_this,"onCameraChanged",function(center,camera,fov){// Note: If camera pos is NULL, we are in first-person-view
|
|
94
|
+
if(_this.state.viewsLocked&&_this.focusedMap==="map3d"){var rotation=undefined;if(camera){rotation=Math.atan2(center[1]-camera[1],center[0]-camera[0])-0.5*Math.PI;var distance=Math.sqrt((camera[0]-center[0])*(camera[0]-center[0])+(camera[1]-center[1])*(camera[1]-center[1])+(camera[2]-center[2])*(camera[2]-center[2]));var fovrad=fov/180*Math.PI;var bboxWidth=distance*(2*Math.tan(fovrad/2));var bbox=[-0.5*bboxWidth,0,0.5*bboxWidth,0];var zoom=MapUtils.getZoomForExtent(bbox,_this.props.map.resolutions,_this.props.map.size,0,_this.props.map.scales.length-1);_this.props.zoomToPoint(center.slice(0,2),zoom,_this.props.theme.mapCrs,rotation);if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-cone");_this.firstPersonMarker=false}}else{_this.props.panTo(center.slice(0,2),_this.props.theme.mapCrs,rotation);var feature={geometry:{type:"Point",coordinates:center.slice(0,2)},crs:_this.props.theme.mapCrs,styleName:"marker",styleOptions:{iconSrc:personIcon}};var layer={id:"view3d-firstperson-marker",role:LayerRole.MARKER};_this.props.addLayerFeatures(layer,[feature],true);_this.firstPersonMarker=true}}else if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-marker");_this.firstPersonMarker=false}});_defineProperty(_this,"setRef",function(ref){_this.map3dComponentRef=ref});_defineProperty(_this,"sync2DExtent",function(){if(_this.map3dComponentRef){_this.map3dComponentRef.setViewToExtent(_this.props.map.bbox.bounds,_this.props.map.bbox.rotation)}});_defineProperty(_this,"setLockViews",function(){_this.setState(function(state){return{viewsLocked:!state.viewsLocked}});if(_this.firstPersonMarker){_this.props.removeLayer("view3d-firstperson-marker");_this.firstPersonMarker=false}});_defineProperty(_this,"setupMap",function(){if(_this.map3dComponentRef){if(!isEmpty(_this.state.storedState)){_this.map3dComponentRef.restore3dState(_this.state.storedState)}else{_this.sync2DExtent()}}});_defineProperty(_this,"redrawScene",function(ev){if(_this.map3dComponentRef){_this.map3dComponentRef.redrawScene(ev)}});_defineProperty(_this,"trackFocus",function(ev){var _mapEl$contains,_map3dEl$contains;var mapEl=document.getElementById("map");var map3dEl=document.getElementById("map3d");if(mapEl!==null&&mapEl!==void 0&&(_mapEl$contains=mapEl.contains)!==null&&_mapEl$contains!==void 0&&_mapEl$contains.call(mapEl,document.activeElement)){_this.focusedMap="map"}else if(map3dEl!==null&&map3dEl!==void 0&&(_map3dEl$contains=map3dEl.contains)!==null&&_map3dEl$contains!==void 0&&_map3dEl$contains.call(map3dEl,document.activeElement)){_this.focusedMap="map3d"}else{_this.focusedMap=null}});_this.map3dComponent=null;_this.map3dComponentRef=null;_this.focusedMap=null;_this.firstPersonMarker=true;// Subset of 2d reducers
|
|
95
95
|
var _ReducerIndex$reducer=ReducerIndex.reducers,processNotifications=_ReducerIndex$reducer.processNotifications,task=_ReducerIndex$reducer.task,windows=_ReducerIndex$reducer.windows;// Reducer for syncronization with parent store
|
|
96
96
|
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
|
|
97
97
|
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
|
|
98
|
-
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)}},{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){this.map3dComponentRef.store3dState().then(function(storedState){_this2.setState({storedState:storedState});_this2.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
|
|
98
|
+
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)}},{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){this.map3dComponentRef.store3dState().then(function(storedState){_this2.setState({storedState:storedState});UrlParams.updateParams({v3d:undefined,bl3d:undefined});_this2.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
|
|
99
99
|
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})}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:undefined})}}// Switch to 2D mode if new theme has no 3D configuration
|
|
100
100
|
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
|
|
101
101
|
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
|
|
@@ -4,4 +4,4 @@ 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 axios from"axios";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole}from"../../actions/layers";import FeatureStyles from"../../utils/FeatureStyles";import IdentifyUtils from"../../utils/IdentifyUtils";import MapUtils from"../../utils/MapUtils";var SnapSupport=/*#__PURE__*/function(_React$Component){function SnapSupport(props){var _this;_classCallCheck(this,SnapSupport);_this=_callSuper(this,SnapSupport,[props]);_defineProperty(_this,"state",{mousePos:null});_defineProperty(_this,"getMapMousePos",function(ev){_this.setState({mousePos:{coordinate:ev.coordinate,pixel:ev.pixel}})});_defineProperty(_this,"addSnapFeatures",function(geojson){_this.reset();var format=new ol.format.GeoJSON;var features=format.readFeatures(geojson);var _iterator=_createForOfIteratorHelper(features),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var feature=_step.value;_this.snapSource.addFeature(feature)}}catch(err){_iterator.e(err)}finally{_iterator.f()}});_defineProperty(_this,"addSnapInteraction",function(){_this.snapInteraction=new ol.interaction.Snap({source:_this.snapSource});_this.props.map.addInteraction(_this.snapInteraction)});_defineProperty(_this,"getFeature",function(){_this.timeoutId=null;var layers=_this.props.layers.find(function(layer){return layer.role===LayerRole.THEME});var queryLayers=_this.props.layers.reduce(function(accum,layer){return layer.role===LayerRole.THEME?accum.concat(layer.queryLayers):accum},[]).join(",");if(!layers||!queryLayers){return}var options={info_format:"text/xml",feature_count:20,FI_POINT_TOLERANCE:16,FI_LINE_TOLERANCE:8,FI_POLYGON_TOLERANCE:4};var request=IdentifyUtils.buildRequest(layers,queryLayers,_this.state.mousePos.coordinate,_this.props.mapObj,options);axios.get(request.url,{params:request.params}).then(function(response){var results=IdentifyUtils.parseXmlResponse(response.data,_this.props.mapObj.projection);var features=[];results.forEach(function(result){var _iterator2=_createForOfIteratorHelper(result),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var feature=_step2.value;if(feature.geometry){feature.id=uuidv4();features.push(feature)}}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}});if(!features){return}var geojson={type:"FeatureCollection",crs:{type:"name",properties:{name:_this.props.mapObj.projection}},features:features};_this.addSnapFeatures(geojson);_this.addSnapInteraction()})});_defineProperty(_this,"reset",function(){if(_this.snapInteractions){_this.props.map.removeInteraction(_this.snapInteraction)}var _iterator3=_createForOfIteratorHelper(_this.snapSource.getFeatures()),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var feature=_step3.value;_this.snapSource.removeFeature(feature)}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}});var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])};_this.snapSource=new ol.source.Vector;_this.snapLayer=new ol.layer.Vector({source:_this.snapSource,zIndex:1000000,style:[FeatureStyles.interaction({},true),FeatureStyles.interactionVertex({geometryFunction:geometryFunction},true)]});_this.props.map.addLayer(_this.snapLayer);_this.curPos=null;return _this}_inherits(SnapSupport,_React$Component);return _createClass(SnapSupport,[{key:"componentDidMount",value:function componentDidMount(){MapUtils.getHook(MapUtils.ADD_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentWillUnmount",value:function componentWillUnmount(){MapUtils.getHook(MapUtils.REMOVE_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var _this2=this;if(this.props.drawing&&this.state.mousePos&&(!this.curPos||Math.abs(this.state.mousePos.pixel[0]-this.curPos[0])>5||Math.abs(this.state.mousePos.pixel[1]-this.curPos[1])>5)){clearTimeout(this.timeoutId);this.curPos=this.state.mousePos.pixel;this.timeoutId=setTimeout(function(){return _this2.getFeature()},500)}else if(!this.props.drawing&&prevProps.drawing){this.reset()}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(SnapSupport,"propTypes",{drawing:PropTypes.bool,layers:PropTypes.array,map:PropTypes.object,mapObj:PropTypes.object});var selector=function selector(state){return{drawing:["Redlining","Measure","Editing"].includes(state.task.id),mapObj:state.map,layers:state.layers.flat}};export default connect(selector,{})(SnapSupport);
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import axios from"axios";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole}from"../../actions/layers";import FeatureStyles from"../../utils/FeatureStyles";import IdentifyUtils from"../../utils/IdentifyUtils";import MapUtils from"../../utils/MapUtils";var SnapSupport=/*#__PURE__*/function(_React$Component){function SnapSupport(props){var _this;_classCallCheck(this,SnapSupport);_this=_callSuper(this,SnapSupport,[props]);_defineProperty(_this,"state",{mousePos:null});_defineProperty(_this,"getMapMousePos",function(ev){_this.setState({mousePos:{coordinate:ev.coordinate,pixel:ev.pixel}})});_defineProperty(_this,"addSnapFeatures",function(geojson){_this.reset();var format=new ol.format.GeoJSON;var features=format.readFeatures(geojson);var _iterator=_createForOfIteratorHelper(features),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var feature=_step.value;_this.snapSource.addFeature(feature)}}catch(err){_iterator.e(err)}finally{_iterator.f()}});_defineProperty(_this,"addSnapInteraction",function(){_this.snapInteraction=new ol.interaction.Snap({source:_this.snapSource});_this.props.map.addInteraction(_this.snapInteraction)});_defineProperty(_this,"getFeature",function(){_this.timeoutId=null;var layers=_this.props.layers.find(function(layer){return layer.role===LayerRole.THEME});var queryLayers=_this.props.layers.reduce(function(accum,layer){return layer.role===LayerRole.THEME?accum.concat(layer.queryLayers):accum},[]).join(",");if(!layers||!queryLayers){return}var options={info_format:"text/xml",feature_count:20,FI_POINT_TOLERANCE:16,FI_LINE_TOLERANCE:8,FI_POLYGON_TOLERANCE:4};var request=IdentifyUtils.buildRequest(layers,queryLayers,_this.state.mousePos.coordinate,_this.props.mapObj,options);axios.get(request.url,{params:request.params}).then(function(response){var results=IdentifyUtils.parseXmlResponse(response.data,_this.props.mapObj.projection,layers);var features=[];results.forEach(function(result){var _iterator2=_createForOfIteratorHelper(result),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var feature=_step2.value;if(feature.geometry){feature.id=uuidv4();features.push(feature)}}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}});if(!features){return}var geojson={type:"FeatureCollection",crs:{type:"name",properties:{name:_this.props.mapObj.projection}},features:features};_this.addSnapFeatures(geojson);_this.addSnapInteraction()})});_defineProperty(_this,"reset",function(){if(_this.snapInteractions){_this.props.map.removeInteraction(_this.snapInteraction)}var _iterator3=_createForOfIteratorHelper(_this.snapSource.getFeatures()),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var feature=_step3.value;_this.snapSource.removeFeature(feature)}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}});var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])};_this.snapSource=new ol.source.Vector;_this.snapLayer=new ol.layer.Vector({source:_this.snapSource,zIndex:1000000,style:[FeatureStyles.interaction({},true),FeatureStyles.interactionVertex({geometryFunction:geometryFunction},true)]});_this.props.map.addLayer(_this.snapLayer);_this.curPos=null;return _this}_inherits(SnapSupport,_React$Component);return _createClass(SnapSupport,[{key:"componentDidMount",value:function componentDidMount(){MapUtils.getHook(MapUtils.ADD_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentWillUnmount",value:function componentWillUnmount(){MapUtils.getHook(MapUtils.REMOVE_POINTER_MOVE_LISTENER)(this.getMapMousePos)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var _this2=this;if(this.props.drawing&&this.state.mousePos&&(!this.curPos||Math.abs(this.state.mousePos.pixel[0]-this.curPos[0])>5||Math.abs(this.state.mousePos.pixel[1]-this.curPos[1])>5)){clearTimeout(this.timeoutId);this.curPos=this.state.mousePos.pixel;this.timeoutId=setTimeout(function(){return _this2.getFeature()},500)}else if(!this.props.drawing&&prevProps.drawing){this.reset()}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(SnapSupport,"propTypes",{drawing:PropTypes.bool,layers:PropTypes.array,map:PropTypes.object,mapObj:PropTypes.object});var selector=function selector(state){return{drawing:["Redlining","Measure","Editing"].includes(state.task.id),mapObj:state.map,layers:state.layers.flat}};export default connect(selector,{})(SnapSupport);
|
|
@@ -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);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=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
|
|
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);
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
bottom: 0;
|
|
9
9
|
cursor: ew-resize;
|
|
10
10
|
display: flex;
|
|
11
|
-
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
justify-content: center;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
#MapCompare
|
|
15
|
+
#MapCompare div.map-compare-handle {
|
|
15
16
|
height: 3em;
|
|
16
17
|
width: 3em;
|
|
17
18
|
margin-left: -1.375em;
|