qwc2 2025.10.9 → 2025.10.13

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.
@@ -6,6 +6,6 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */import React from"react";import{connect}from"react-redux";import axios from"axios";import clone from"clone";import DOMPurify from"dompurify";import FileSaver from"file-saver";import htmlReactParser,{domToReact}from"html-react-parser";import JSZip from"jszip";import isEmpty from"lodash.isempty";import omit from"lodash.omit";import PropTypes from"prop-types";import{setActiveLayerInfo}from"../actions/layerinfo";import{LayerRole,addLayerFeatures,removeLayer,changeLayerProperty}from"../actions/layers";import{zoomToPoint}from"../actions/map";import{openExternalUrl}from"../actions/windows";import ConfigUtils from"../utils/ConfigUtils";import CoordinatesUtils from"../utils/CoordinatesUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import MiscUtils from"../utils/MiscUtils";import VectorLayerUtils from"../utils/VectorLayerUtils";import Icon from"./Icon";import Spinner from"./widgets/Spinner";import"./style/IdentifyViewer.css";var EXCLUDE_PROPS=["featurereport","displayfield","layername","layertitle","layerinfo","attribnames","clickPos","displayname","bbox"];var EXCLUDE_ATTRS=["htmlContent","htmlContentInline"];var BuiltinExporters=[{id:"json",title:"json",allowClipboard:true,"export":function _export(json,callback){var data=JSON.stringify(json,null," ");callback({data:data,type:"text/plain;charset=utf-8",filename:"results.json"})}},{id:"geojson",title:"geojson",allowClipboard:true,"export":function _export(json,callback){var featureCollection={type:"FeatureCollection",features:Object.values(json).flat().map(function(entry){var feature=omit(entry,EXCLUDE_PROPS);feature.properties=omit(feature.properties,EXCLUDE_ATTRS);if(feature.geometry){feature.crs={type:"name",properties:{name:CoordinatesUtils.toOgcUrnCrs(entry.crs)}}}return feature})};var data=JSON.stringify(featureCollection,null," ");callback({data:data,type:"application/geo+json;charset=utf-8",filename:"results.json"})}},{id:"csv",title:"CSV",allowClipboard:true,"export":function _export(json,callback){var dataset=[];Object.entries(json).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),layerName=_ref2[0],features=_ref2[1];features.forEach(function(feature){dataset.push([feature.layertitle+": "+feature.displayname]);Object.entries(feature.properties||{}).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),attrib=_ref4[0],value=_ref4[1];if(!EXCLUDE_ATTRS.includes(attrib)){dataset.push(["",attrib,String(value)])}});if(feature.geometry){dataset.push(["","geometry",VectorLayerUtils.geoJSONGeomToWkt(feature.geometry)])}})});var csv=dataset.map(function(row){return row.map(function(field){return field?"\"".concat(field.replace("\"","\"\""),"\""):""}).join("\t")}).join("\n");callback({data:csv,type:"text/plain;charset=utf-8",filename:"results.csv"})}},{id:"csvzip",title:"CSV+ZIP",allowClipboard:false,"export":function _export(json,callback){var data=[];var filenames=[];Object.entries(json).forEach(function(_ref5){var _features$0$propertie,_features$;var _ref6=_slicedToArray(_ref5,2),layerName=_ref6[0],features=_ref6[1];var exportAttrs=Object.keys((_features$0$propertie=(_features$=features[0])===null||_features$===void 0?void 0:_features$.properties)!==null&&_features$0$propertie!==void 0?_features$0$propertie:{}).filter(function(attr){return!EXCLUDE_ATTRS.includes(attr)});var dataset=[_toConsumableArray(exportAttrs)];if(features[0].geometry){dataset[0].push("geometry")}features.forEach(function(feature){var row=exportAttrs.map(function(attr){return String(feature.properties[attr])});if(feature.geometry){row.push(VectorLayerUtils.geoJSONGeomToWkt(feature.geometry))}dataset.push(row)});var csv=dataset.map(function(row){return row.map(function(field){return"\"".concat(field.replace("\"","\"\""),"\"")}).join(";")}).join("\n");data.push(csv);filenames.push(features[0].layername)});if(data.length>1){var zip=new JSZip;for(var i=0;i<data.length;i++){var blob=new Blob([data[i]],{type:"text/csv;charset=utf-8"});zip.file(filenames[i]+".csv",blob)}zip.generateAsync({type:"arraybuffer"}).then(function(result){callback({data:result,type:"application/zip",filename:"results.zip"})})}else{callback({data:data[0],type:"text/csv;charset=utf-8",filename:filenames[0]+".csv"})}}},{id:"shapefile",title:"Shapefile",allowClipboard:false,"export":function _export(json,callback){import("@mapbox/shp-write").then(function(shpwriteMod){var shpwrite=shpwriteMod["default"];var layers=Object.entries(json);var options={outputType:"arraybuffer",types:{point:"points",polygon:"polygons",polyline:"lines"}};var promises=layers.map(function(_ref7){var _features$2;var _ref8=_slicedToArray(_ref7,2),layerName=_ref8[0],features=_ref8[1];var geojson={type:"FeatureCollection",features:features.map(function(entry){return omit(entry,EXCLUDE_PROPS)})};var layerOptions=_objectSpread(_objectSpread({},options),{},{folder:layerName});var crs=(_features$2=features[0])===null||_features$2===void 0?void 0:_features$2.crs;if(crs){var wkt=CoordinatesUtils.getEsriWktFromCrs(crs);if(wkt){layerOptions.prj=wkt}}return shpwrite.zip(geojson,layerOptions).then(function(shpData){return{layerName:layerName,shpData:shpData}})});Promise.all(promises).then(function(results){if(results.length===1){callback({data:results[0].shpData,type:"application/zip",filename:results[0].layerName+".zip"})}else{var zip=new JSZip;results.forEach(function(_ref9){var layerName=_ref9.layerName,shpData=_ref9.shpData;zip.file(layerName+".zip",shpData)});zip.generateAsync({type:"arraybuffer"}).then(function(result){callback({data:result,type:"application/zip",filename:"shapefiles.zip"})})}})})}},{id:"xlsx",title:"XLSX",allowClipboard:false,"export":function _export(json,callback){import("xlsx").then(function(xlsx){var document=xlsx.utils.book_new();Object.entries(json).forEach(function(_ref10){var _features$0$propertie2,_features$3;var _ref11=_slicedToArray(_ref10,2),layerName=_ref11[0],features=_ref11[1];var exportAttrs=Object.keys((_features$0$propertie2=(_features$3=features[0])===null||_features$3===void 0?void 0:_features$3.properties)!==null&&_features$0$propertie2!==void 0?_features$0$propertie2:{}).filter(function(attr){return!EXCLUDE_ATTRS.includes(attr)});var dataset=[_toConsumableArray(exportAttrs)];if(features[0].geometry){dataset[0].push("geometry")}features.forEach(function(feature){var row=exportAttrs.map(function(attr){return feature.properties[attr]});if(feature.geometry){var geomWkt=VectorLayerUtils.geoJSONGeomToWkt(feature.geometry);if(geomWkt.length<32768){row.push(geomWkt)}else{row.push("Geometry too large")}}dataset.push(row)});var worksheet=xlsx.utils.aoa_to_sheet(dataset);var sheetName=features[0].layertitle.slice(0,30).replace(/[\\/?*[]]?/g,"_");xlsx.utils.book_append_sheet(document,worksheet,sheetName)});var data=xlsx.write(document,{type:"buffer"});callback({data:data,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",filename:"results.xlsx"})})}}];var IdentifyViewer=/*#__PURE__*/function(_React$Component){function IdentifyViewer(props){var _this;_classCallCheck(this,IdentifyViewer);_this=_callSuper(this,IdentifyViewer,[props]);_defineProperty(_this,"state",{expanded:{},expandedResults:{},resultTree:{},reports:{},currentResult:null,currentLayer:null,exportFormat:"geojson",selectedAggregatedReport:"",generatingReport:false,selectedLayer:""});_defineProperty(_this,"updateResultTree",function(){var layers=Object.keys(_this.props.identifyResults);var currentResult=null;var currentLayer=null;if(layers.length===1&&_this.props.identifyResults[layers[0]].length===1){currentLayer=layers[0];currentResult=_this.props.identifyResults[layers[0]][0]}_this.setState({resultTree:clone(_this.props.identifyResults),currentResult:currentResult,currentLayer:currentLayer,reports:LayerUtils.collectFeatureReports(_this.props.layers)})});_defineProperty(_this,"setHighlightedResults",function(results,resultTree){if(!results&&_this.props.highlightAllResults){var selectedLayer=_this.state.selectedLayer||"";results=Object.keys(resultTree).reduce(function(res,layer){var layerData=resultTree[selectedLayer||layer];return res.concat(layerData.map(function(result){return _objectSpread(_objectSpread({},result),{},{id:"".concat(selectedLayer||layer,".").concat(result.id)})}))},[])}results=(results||[]).filter(function(result){return result.type.toLowerCase()==="feature"}).map(function(feature){var newFeature=_objectSpread(_objectSpread({},feature),{},{properties:{}});// Ensure selection style is used
8
8
  delete newFeature.styleName;delete newFeature.styleOptions;return newFeature});if(!isEmpty(results)){var layer={id:"__identifyviewerhighlight",role:LayerRole.SELECTION};_this.props.addLayerFeatures(layer,results,true)}else{_this.props.removeLayer("__identifyviewerhighlight")}});_defineProperty(_this,"getExpandedClass",function(path,deflt){var expanded=_this.state.expanded[path]!==undefined?_this.state.expanded[path]:deflt;return expanded?"identify-layer-expandable identify-layer-expanded":"identify-layer-expandable"});_defineProperty(_this,"toggleExpanded",function(path,deflt){var newstate=_this.state.expanded[path]!==undefined?!_this.state.expanded[path]:!deflt;var diff={};diff[path]=newstate;if(_this.state.currentLayer===path&&!newstate){_this.setState(function(state){return _objectSpread(_objectSpread({},state),{},{expanded:_objectSpread(_objectSpread({},state.expanded),diff),currentResult:null,currentLayer:null})})}else{_this.setState(function(state){return _objectSpread(_objectSpread({},state),{},{expanded:_objectSpread(_objectSpread({},state.expanded),diff)})})}});_defineProperty(_this,"setCurrentResult",function(layer,result){if(_this.state.currentResult===result){_this.setState({currentResult:null,currentLayer:null})}else{_this.setState({currentResult:result,currentLayer:layer});_this.scrollIntoView=true}});_defineProperty(_this,"removeResultLayer",function(layer){_this.setState(function(state){var newResultTree=_objectSpread({},state.resultTree);delete newResultTree[layer];_this.setState({resultTree:newResultTree,currentResult:state.currentLayer===layer?null:state.currentResult,currentLayer:state.currentLayer===layer?null:state.currentLayer})})});_defineProperty(_this,"removeResult",function(layer,result){_this.setState(function(state){var newResultTree=_objectSpread({},state.resultTree);newResultTree[layer]=state.resultTree[layer].filter(function(item){return item!==result});if(isEmpty(newResultTree[layer])){delete newResultTree[layer]}var selectedLayer=isEmpty(newResultTree[layer])?"":state.selectedLayer;return{resultTree:newResultTree,currentResult:state.currentResult===result?null:state.currentResult,selectedLayer:selectedLayer}})});_defineProperty(_this,"exportResults",function(){var clipboard=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var filteredResults={};Object.keys(_this.state.selectedLayer!==""?_defineProperty({},_this.state.selectedLayer,_this.state.resultTree[_this.state.selectedLayer]):_this.state.resultTree).map(function(key){if(!isEmpty(_this.state.resultTree[key])){filteredResults[key]=_this.state.resultTree[key]}});_this["export"](filteredResults,clipboard)});_defineProperty(_this,"exportResultLayer",function(layer){_this["export"](_defineProperty({},layer,_this.state.resultTree[layer]))});_defineProperty(_this,"exportResult",function(layer,result){_this["export"](_defineProperty({},layer,[result]))});_defineProperty(_this,"export",function(json){var clipboard=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var exporter=_this.getExporters().find(function(entry){return entry.id===_this.state.exportFormat});if(exporter){if(!_this.props.exportGeometry){json=Object.entries(json).reduce(function(res,_ref13){var _ref14=_slicedToArray(_ref13,2),layerId=_ref14[0],features=_ref14[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},layerId,features.map(function(feature){return omit(feature,["geometry"])})))},{})}exporter["export"](json,function(result){if(clipboard&&exporter.allowClipboard){navigator.clipboard.writeText(result.data)}else{FileSaver.saveAs(new Blob([result.data],{type:result.type}),result.filename)}})}});_defineProperty(_this,"renderLayer",function(layer){var results=_this.state.resultTree[layer];if(results.length===0){return null}return/*#__PURE__*/React.createElement("div",{className:_this.getExpandedClass(layer,true),key:layer},/*#__PURE__*/React.createElement("div",{className:"identify-result-entry",onMouseEnter:function onMouseEnter(){return _this.setHighlightedResults(results,_this.state.resultTree)},onMouseLeave:function onMouseLeave(){return _this.setHighlightedResults(_this.state.currentResult===null?null:[_this.state.currentResult],_this.state.resultTree)}},/*#__PURE__*/React.createElement("span",{className:"clickable",onClick:function onClick(){return _this.toggleExpanded(layer,true)}},/*#__PURE__*/React.createElement("b",null,results[0].layertitle)),/*#__PURE__*/React.createElement(Icon,{className:"identify-remove-result",icon:"minus-sign",onClick:function onClick(){return _this.removeResultLayer(layer)}}),_this.props.enableExport===true||!isEmpty(_this.props.enableExport)?/*#__PURE__*/React.createElement(Icon,{className:"identify-export-result",icon:"export",onClick:function onClick(){return _this.exportResultLayer(layer)}}):null),/*#__PURE__*/React.createElement("div",{className:"identify-layer-entries"},results.map(function(result){return _this.renderResult(layer,result)})))});_defineProperty(_this,"renderResult",function(layer,result){var ref=_this.state.currentResult===result&&_this.scrollIntoView?function(el){_this.currentResultElRef=el}:null;return/*#__PURE__*/React.createElement("div",{className:"identify-result-entry",key:result.id,onMouseEnter:function onMouseEnter(){return _this.setHighlightedResults([result],_this.state.resultTree)},onMouseLeave:function onMouseLeave(){return _this.setHighlightedResults(_this.state.currentResult===null?null:[_this.state.currentResult],_this.state.resultTree)}},/*#__PURE__*/React.createElement("span",{className:_this.state.currentResult===result?"active clickable":"clickable",onClick:function onClick(){return _this.setCurrentResult(layer,result)},ref:ref},result.displayname),/*#__PURE__*/React.createElement(Icon,{className:"identify-remove-result",icon:"minus-sign",onClick:function onClick(){return _this.removeResult(layer,result)}}),_this.props.enableExport===true||!isEmpty(_this.props.enableExport)?/*#__PURE__*/React.createElement(Icon,{className:"identify-export-result",icon:"export",onClick:function onClick(){return _this.exportResult(layer,result)}}):null)});_defineProperty(_this,"renderResultAttributes",function(layer,result,resultClass){if(!result){return null}var resultbox=null;var extraattribs=null;var inlineExtaAttribs=false;var featureReports=_this.state.reports[layer]||[];if(result.featureReport){featureReports.push({title:result.layertitle,template:result.featureReport})}if(result.type==="text"){resultbox=/*#__PURE__*/React.createElement("pre",{className:"identify-result-box"},result.text)}else if(result.type==="html"){resultbox=/*#__PURE__*/React.createElement("iframe",{className:"identify-result-box",onLoad:function onLoad(ev){return _this.setIframeContent(ev.target,result.text)},ref:function ref(el){return _this.pollIframe(el,result.text)}})}else if(result.properties.htmlContent){if(result.properties.htmlContentInline){resultbox=/*#__PURE__*/React.createElement("div",{className:"identify-result-box"},_this.parsedContent(result.properties.htmlContent))}else{resultbox=/*#__PURE__*/React.createElement("iframe",{className:"identify-result-box",onLoad:function onLoad(ev){return _this.setIframeContent(ev.target,result.properties.htmlContent)},ref:function ref(el){return _this.pollIframe(el,result.properties.htmlContent)}})}}else{var _rows;inlineExtaAttribs=true;var properties=Object.keys(result.properties)||[];var rows=[];if(properties.length===1&&result.properties.maptip){rows=properties.map(function(attrib){return/*#__PURE__*/React.createElement("tr",{key:attrib},/*#__PURE__*/React.createElement("td",{className:"identify-attr-value"},_this.attribValue(result.properties[attrib],attrib,layer,result)))})}else{rows=properties.map(function(attrib){if(_this.props.theme.skipEmptyFeatureAttributes&&(result.properties[attrib]===""||result.properties[attrib]===null||result.properties[attrib]==="NULL")){return null}return/*#__PURE__*/React.createElement("tr",{key:attrib},/*#__PURE__*/React.createElement("td",{className:"identify-attr-title "+_this.props.longAttributesDisplay},/*#__PURE__*/React.createElement("i",null,attrib)),/*#__PURE__*/React.createElement("td",{className:"identify-attr-value "+_this.props.longAttributesDisplay},_this.attribValue(result.properties[attrib],attrib,layer,result)))})}(_rows=rows).push.apply(_rows,_toConsumableArray(_this.computeExtraAttributes(layer,result)));featureReports.forEach(function(report,idx){rows.push(/*#__PURE__*/React.createElement("tr",{key:"__featurereport"+idx},/*#__PURE__*/React.createElement("td",{className:"identify-attr-title "+_this.props.longAttributesDisplay},/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("identify.featureReport")+": "+report.title)),/*#__PURE__*/React.createElement("td",{className:"identify-attr-value "+_this.props.longAttributesDisplay},/*#__PURE__*/React.createElement("a",{href:_this.getFeatureReportUrl(report,result)},LocaleUtils.tr("identify.link")))))});if(isEmpty(rows)){rows=/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",{className:"identify-attr-value"},/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("identify.noattributes"))))}resultbox=/*#__PURE__*/React.createElement("div",{className:"identify-result-box"},/*#__PURE__*/React.createElement("table",{className:"attribute-list"},/*#__PURE__*/React.createElement("tbody",null,rows)))}if(!inlineExtaAttribs&&(_this.props.attributeCalculator||!isEmpty(_this.state.reports[layer]))){extraattribs=/*#__PURE__*/React.createElement("div",{className:"identify-result-box"},/*#__PURE__*/React.createElement("table",{className:"attribute-list"},/*#__PURE__*/React.createElement("tbody",null,_this.computeExtraAttributes(layer,result),featureReports.map(function(report,idx){return/*#__PURE__*/React.createElement("tr",{key:"report"+idx},/*#__PURE__*/React.createElement("td",{className:"identify-attr-title "+_this.props.longAttributesDisplay},/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("identify.featureReport")+": "+report.title)),/*#__PURE__*/React.createElement("td",{className:"identify-attr-value "+_this.props.longAttributesDisplay},/*#__PURE__*/React.createElement("a",{href:_this.getFeatureReportUrl(report,result),rel:"noreferrer",target:"_blank"},LocaleUtils.tr("identify.link"))))}))))}var zoomToFeatureButton=null;if(result.bbox&&result.crs){zoomToFeatureButton=/*#__PURE__*/React.createElement(Icon,{icon:"zoom",onClick:function onClick(){return _this.zoomToResult(result)}})}var key=result+":"+result.id;var expanded=_this.state.expandedResults[key];return/*#__PURE__*/React.createElement("div",{className:resultClass,key:"results-attributes"},/*#__PURE__*/React.createElement("div",{className:"identify-result-title"},_this.props.collapsible?/*#__PURE__*/React.createElement(Icon,{icon:expanded?"triangle-down":"triangle-right",onClick:function onClick(){return _this.setState(function(state){return{expandedResults:_objectSpread(_objectSpread({},state.expandedResults),{},_defineProperty({},key,!expanded))}})}}):null,/*#__PURE__*/React.createElement("span",null,(_this.props.showLayerTitles?result.layertitle+": ":"")+result.displayname),zoomToFeatureButton,/*#__PURE__*/React.createElement(Icon,{icon:"info-sign",onClick:function onClick(){return _this.showLayerInfo(layer)}}),/*#__PURE__*/React.createElement(Icon,{icon:"trash",onClick:function onClick(){return _this.removeResult(layer,result)}})),_this.props.collapsible&&!expanded?null:/*#__PURE__*/React.createElement("div",{className:"identify-result-container"},resultbox,extraattribs))});_defineProperty(_this,"computeExtraAttributes",function(layer,result){var _window$qwc;var rows=[];Object.values(((_window$qwc=window.qwc2)===null||_window$qwc===void 0?void 0:_window$qwc.__attributeCalculators)||{}).forEach(function(calc,idx){var row=calc(layer,result);if(row.length===2){rows.push(/*#__PURE__*/React.createElement("tr",{key:"custom-attr-"+idx},/*#__PURE__*/React.createElement("td",{className:"identify-attr-title"},/*#__PURE__*/React.createElement("i",null,row[0])),/*#__PURE__*/React.createElement("td",{className:"identify-attr-value"},row[1])))}else if(row.length===1){rows.push(/*#__PURE__*/React.createElement("tr",{key:"custom-attr-"+idx},/*#__PURE__*/React.createElement("td",{colSpan:"2"},row[0])))}});if(_this.props.attributeCalculator){rows.push.apply(rows,_toConsumableArray(_this.props.attributeCalculator(layer,result)))}return rows});_defineProperty(_this,"getExporters",function(){var _window$qwc2;return[].concat(BuiltinExporters,_toConsumableArray(_this.props.customExporters),_toConsumableArray(Object.values(((_window$qwc2=window.qwc2)===null||_window$qwc2===void 0?void 0:_window$qwc2.__identifyExportes)||[])))});_defineProperty(_this,"setIframeContent",function(iframe,html){if(iframe.getAttribute("identify-content-set")){return}iframe.setAttribute("identify-content-set",true);iframe.contentWindow.document.open();iframe.contentWindow.document.write(html);iframe.contentWindow.document.close()});_defineProperty(_this,"pollIframe",function(iframe,html){if(iframe&&!iframe.getAttribute("identify-content-set")){var interval=setInterval(function(){if(iframe.getAttribute("identify-content-set")){return clearInterval(interval)}if(iframe.contentWindow&&iframe.contentWindow.document){iframe.setAttribute("identify-content-set",true);iframe.contentWindow.document.open();iframe.contentWindow.document.write(html);iframe.contentWindow.document.close();clearInterval(interval)}return true},500)}});_defineProperty(_this,"collectFeatureReportTemplates",function(entry){var reports={};if(entry.sublayers){var _iterator=_createForOfIteratorHelper(entry.sublayers),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var sublayer=_step.value;reports=_objectSpread(_objectSpread({},reports),_this.collectFeatureReportTemplates(sublayer))}}catch(err){_iterator.e(err)}finally{_iterator.f()}}else if(entry.featureReport){reports[entry.name]=entry.featureReport}return reports});_defineProperty(_this,"findFeatureReportTemplate",function(layer){var reports={};_this.props.layers.filter(function(l){return l.role===LayerRole.THEME}).forEach(function(themeLayer){reports=_objectSpread(_objectSpread({},reports),_this.collectFeatureReportTemplates(themeLayer))});return reports[layer]||null});_defineProperty(_this,"getFeatureReportUrl",function(report,result){var serviceUrl=ConfigUtils.getConfigProp("documentServiceUrl").replace(/\/$/,"");var params={feature:result.id,x:result.clickPos[0],y:result.clickPos[1],crs:_this.props.map.projection,single_report:report.single_report||false};var path="/"+report.template+"."+(report.format||"pdf");var query=Object.keys(params).map(function(key){return encodeURIComponent(key)+"="+encodeURIComponent(params[key])}).join("&");return serviceUrl+path+"?"+query});_defineProperty(_this,"downloadAggregatedReport",function(){var _this$state$selectedA=_this.state.selectedAggregatedReport.split("::"),_this$state$selectedA2=_slicedToArray(_this$state$selectedA,2),layername=_this$state$selectedA2[0],idx=_this$state$selectedA2[1];var report=_this.state.reports[layername][idx];var results=_this.state.resultTree[layername];var serviceUrl=ConfigUtils.getConfigProp("documentServiceUrl").replace(/\/$/,"");var params={feature:results.map(function(result){return result.id}).join(","),x:results[0].clickPos[0],y:results[0].clickPos[1],crs:_this.props.map.projection,single_report:report.single_report||false};_this.setState({generatingReport:true});var url=serviceUrl+"/"+report.template;axios.get(url,{params:params,responseType:"arraybuffer"}).then(function(response){var filename=(report.filename||report.title.replace(" ","_"))+"."+(report.format||"pdf");FileSaver.saveAs(new Blob([response.data],{type:"application/pdf"}),filename);_this.setState({generatingReport:false})})["catch"](function(){/* eslint-disable-next-line */alert(LocaleUtils.tr("identify.reportfail"));_this.setState({generatingReport:false})})});_defineProperty(_this,"showLayerInfo",function(layer){var _layer$split=layer.split("#"),_layer$split2=_slicedToArray(_layer$split,2),layerUrl=_layer$split2[0],layerName=_layer$split2[1];var match=LayerUtils.searchLayer(_this.props.layers,layerUrl,layerName);if(match){_this.props.setActiveLayerInfo(match.layer,match.sublayer)}});_defineProperty(_this,"attribValue",function(text,attrName,layer,result){if(_typeof(text)==="object"){text=JSON.stringify(text)}if(_this.props.replaceImageUrls&&/^https?:\/\/.*\.(jpg|jpeg|png|bmp)$/i.exec(text)){return/*#__PURE__*/React.createElement("a",{href:text,rel:"noreferrer",target:"_blank"},/*#__PURE__*/React.createElement("img",{src:text}))}text=""+text;// Ensure text is a string
9
- text=_this.props.attributeTransform(attrName,text,layer,result);text=MiscUtils.addLinkAnchors(text);return _this.parsedContent(text)});_defineProperty(_this,"parsedContent",function(text){text=DOMPurify.sanitize(text,{ADD_ATTR:["target"]}).replace("&#10;","<br />");var options={replace:function replace(node){if(node.name==="a"){return/*#__PURE__*/React.createElement("a",{href:node.attribs.href,onClick:_this.attributeLinkClicked,target:node.attribs.target||"_blank"},domToReact(node.children,options))}return undefined}};return htmlReactParser(text,options)});_defineProperty(_this,"attributeLinkClicked",function(ev){_this.props.openExternalUrl(ev.target.href,ev.target.target,{docked:_this.props.iframeDialogsInitiallyDocked});ev.preventDefault()});_defineProperty(_this,"zoomToResult",function(result){var zoom=0;var maxZoom=MapUtils.computeZoom(_this.props.map.scales,_this.props.theme.minSearchScaleDenom||1000);if(result.bbox[0]!==result.bbox[2]&&result.bbox[1]!==result.bbox[3]){zoom=Math.max(0,MapUtils.getZoomForExtent(result.bbox,_this.props.map.resolutions,_this.props.map.size,0,maxZoom+1)-1)}else{zoom=maxZoom}var x=0.5*(result.bbox[0]+result.bbox[2]);var y=0.5*(result.bbox[1]+result.bbox[3]);_this.props.zoomToPoint([x,y],zoom,_this.props.map.projection);var path=[];var sublayer=null;var layer=_this.props.layers.find(function(l){return l.role===LayerRole.THEME&&(sublayer=LayerUtils.searchSubLayer(l,"name",result.layername,path))});if(layer&&sublayer){_this.props.changeLayerProperty(layer.id,"visibility",true,path)}});_this.currentResultElRef=null;_this.scrollIntoView=false;_this.state.exportFormat=!Array.isArray(props.enableExport)||props.enableExport.includes("geojson")?"geojson":props.enableExport[0];return _this}_inherits(IdentifyViewer,_React$Component);return _createClass(IdentifyViewer,[{key:"componentDidMount",value:function componentDidMount(){this.updateResultTree()}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.identifyResults!==prevProps.identifyResults){this.updateResultTree()}if(prevState.currentResult!==this.state.currentResult||prevState.resultTree!==this.state.resultTree){this.setHighlightedResults(this.state.currentResult===null?null:[this.state.currentResult],this.state.resultTree)}// Scroll to selected result
10
- if(this.state.currentResult&&this.state.currentResult!==prevState.currentResult&&this.currentResultElRef&&this.scrollIntoView){this.currentResultElRef.parentNode.scrollTop=this.currentResultElRef.offsetTop-this.currentResultElRef.parentNode.offsetTop;this.scrollIntoView=false;this.currentResultElRef=null}}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.props.removeLayer("__identifyviewerhighlight")}},{key:"render",value:function render(){var _this2=this,_exporters$find;var tree=this.props.displayResultTree;var body=null;if(tree){var contents=Object.keys(this.state.resultTree).map(function(layer){return _this2.renderLayer(layer)});var attributes=this.renderResultAttributes(this.state.currentLayer,this.state.currentResult,"identify-result-tree-frame");var resultsContainerStyle={maxHeight:attributes?"10em":"initial"};body=[/*#__PURE__*/React.createElement("div",{className:"identify-results-container",key:"results-container",style:resultsContainerStyle},contents),attributes]}else{body=/*#__PURE__*/React.createElement("div",{className:"identify-flat-results-list"},this.props.showLayerSelector?/*#__PURE__*/React.createElement("div",{className:"identify-selectbox"},/*#__PURE__*/React.createElement("select",{className:"identify-layer-select",onChange:function onChange(e){var selectedLayer=e.target.value;_this2.setState({selectedLayer:selectedLayer})}},/*#__PURE__*/React.createElement("option",{value:""},LocaleUtils.tr("identify.layerall")),Object.keys(this.state.resultTree).filter(function(key){return _this2.state.resultTree[key].length}).map(function(layer){return/*#__PURE__*/React.createElement("option",{key:layer,value:layer},_this2.state.resultTree[layer][0].layertitle)})),/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.featurecount"),": ",Object.values(this.state.selectedLayer!==""?this.state.resultTree[this.state.selectedLayer]:this.state.resultTree).flat().length)):null,Object.keys(this.state.selectedLayer!==""?_defineProperty({},this.state.selectedLayer,this.state.resultTree[this.state.selectedLayer]):this.state.resultTree).map(function(layer){var layerResults=_this2.state.resultTree[layer];return layerResults.map(function(result){var resultClass=_this2.state.currentResult===result?"identify-result-frame-highlighted":"identify-result-frame-normal";return/*#__PURE__*/React.createElement("div",{key:result.id,onMouseEnter:function onMouseEnter(){return _this2.setState({currentResult:result,currentLayer:layer})},onMouseLeave:function onMouseLeave(){return _this2.setState({currentResult:null,currentLayer:null})}},_this2.renderResultAttributes(layer,result,resultClass))})}))}// "el.style.background='inherit'": HACK to trigger an additional repaint, since Safari/Chrome on iOS render the element cut off the first time
11
- var exporters=this.getExporters();var clipboardExportDisabled=((_exporters$find=exporters.find(function(entry){return entry.id===_this2.state.exportFormat}))===null||_exporters$find===void 0?void 0:_exporters$find.allowClipboard)!==true;return/*#__PURE__*/React.createElement("div",{className:"identify-body",ref:function ref(el){if(el)el.style.background="inherit"}},body,this.props.enableExport===true||!isEmpty(this.props.enableExport)?/*#__PURE__*/React.createElement("div",{className:"identify-buttonbox"},/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.export"),":\xA0"),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("select",{className:"combo identify-export-format",onChange:function onChange(ev){return _this2.setState({exportFormat:ev.target.value})},value:this.state.exportFormat},exporters.filter(function(entry){return!Array.isArray(_this2.props.enableExport)||_this2.props.enableExport.includes(entry.id)}).map(function(entry){var _entry$title;return/*#__PURE__*/React.createElement("option",{key:entry.id,value:entry.id},(_entry$title=entry.title)!==null&&_entry$title!==void 0?_entry$title:LocaleUtils.tr(entry.titleMsgId))})),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this2.exportResults()},title:LocaleUtils.tr("identify.download")},/*#__PURE__*/React.createElement(Icon,{icon:"export"})),/*#__PURE__*/React.createElement("button",{className:"button",disabled:clipboardExportDisabled,onClick:function onClick(){return _this2.exportResults(true)},title:LocaleUtils.tr("identify.clipboard")},/*#__PURE__*/React.createElement(Icon,{icon:"copy"})))):null,this.props.enableAggregatedReports&&Object.keys(this.state.reports).length>0?/*#__PURE__*/React.createElement("div",{className:"identify-buttonbox"},/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.aggregatedreport"),":\xA0"),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("select",{className:"combo identify-export-format",onChange:function onChange(ev){return _this2.setState({selectedAggregatedReport:ev.target.value})},value:this.state.selectedAggregatedReport},/*#__PURE__*/React.createElement("option",{disabled:true,value:""},LocaleUtils.tr("identify.selectreport")),Object.entries(this.state.reports).map(function(_ref16){var _ref17=_slicedToArray(_ref16,2),layername=_ref17[0],reports=_ref17[1];return reports.map(function(report,idx){return/*#__PURE__*/React.createElement("option",{key:layername+"::"+idx,value:layername+"::"+idx},report.title)})})),/*#__PURE__*/React.createElement("button",{className:"button",disabled:!this.state.selectedAggregatedReport||this.state.generatingReport,onClick:this.downloadAggregatedReport},this.state.generatingReport?/*#__PURE__*/React.createElement(Spinner,null):/*#__PURE__*/React.createElement(Icon,{icon:"report"})))):null)}}])}(React.Component);_defineProperty(IdentifyViewer,"propTypes",{addLayerFeatures:PropTypes.func,attributeCalculator:PropTypes.func,attributeTransform:PropTypes.func,changeLayerProperty:PropTypes.func,collapsible:PropTypes.bool,customExporters:PropTypes.array,displayResultTree:PropTypes.bool,enableAggregatedReports:PropTypes.bool,enableExport:PropTypes.oneOfType([PropTypes.bool,PropTypes.array]),exportGeometry:PropTypes.bool,highlightAllResults:PropTypes.bool,identifyResults:PropTypes.object,iframeDialogsInitiallyDocked:PropTypes.bool,layers:PropTypes.array,longAttributesDisplay:PropTypes.oneOf(["ellipsis","wrap"]),map:PropTypes.object,openExternalUrl:PropTypes.func,removeLayer:PropTypes.func,replaceImageUrls:PropTypes.bool,setActiveLayerInfo:PropTypes.func,showLayerSelector:PropTypes.bool,showLayerTitles:PropTypes.bool,theme:PropTypes.object,zoomToPoint:PropTypes.func});_defineProperty(IdentifyViewer,"defaultProps",{longAttributesDisplay:"ellipsis",customExporters:[],displayResultTree:true,attributeCalculator:function attributeCalculator(/* layer, feature */){return[]},attributeTransform:function attributeTransform(name,value/* , layer, feature */){return value},enableAggregatedReports:true,showLayerTitles:true,showLayerSelector:true,highlightAllResults:true});var selector=function selector(state){return{theme:state.theme.current,layers:state.layers.flat,map:state.map}};export default connect(selector,{addLayerFeatures:addLayerFeatures,changeLayerProperty:changeLayerProperty,removeLayer:removeLayer,setActiveLayerInfo:setActiveLayerInfo,openExternalUrl:openExternalUrl,zoomToPoint:zoomToPoint})(IdentifyViewer);
9
+ text=_this.props.attributeTransform(attrName,text,layer,result);text=MiscUtils.addLinkAnchors(text);return _this.parsedContent(text)});_defineProperty(_this,"parsedContent",function(text){text=DOMPurify.sanitize(text,{ADD_ATTR:["target"]}).replace("&#10;","<br />");var options={replace:function replace(node){if(node.name==="a"){return/*#__PURE__*/React.createElement("a",{href:node.attribs.href,onClick:_this.attributeLinkClicked,target:node.attribs.target||"_blank"},domToReact(node.children,options))}return undefined}};return htmlReactParser(text,options)});_defineProperty(_this,"attributeLinkClicked",function(ev){_this.props.openExternalUrl(ev.target.href,ev.target.target,{docked:_this.props.iframeDialogsInitiallyDocked});ev.preventDefault()});_defineProperty(_this,"zoomToResult",function(result){var zoom=0;var maxZoom=MapUtils.computeZoom(_this.props.map.scales,_this.props.theme.minSearchScaleDenom||1000);if(result.bbox[0]!==result.bbox[2]&&result.bbox[1]!==result.bbox[3]){zoom=Math.max(0,MapUtils.getZoomForExtent(result.bbox,_this.props.map.resolutions,_this.props.map.size,0,maxZoom+1)-1)}else{zoom=maxZoom}var x=0.5*(result.bbox[0]+result.bbox[2]);var y=0.5*(result.bbox[1]+result.bbox[3]);_this.props.zoomToPoint([x,y],zoom,_this.props.map.projection);var path=[];var sublayer=null;var layer=_this.props.layers.find(function(l){return l.role===LayerRole.THEME&&(sublayer=LayerUtils.searchSubLayer(l,"name",result.layername,path))});if(layer&&sublayer){_this.props.changeLayerProperty(layer.id,"visibility",true,path)}});_this.currentResultElRef=null;_this.scrollIntoView=false;_this.state.exportFormat=!Array.isArray(props.enableExport)?"geojson":props.enableExport[0];return _this}_inherits(IdentifyViewer,_React$Component);return _createClass(IdentifyViewer,[{key:"componentDidMount",value:function componentDidMount(){this.updateResultTree()}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.identifyResults!==prevProps.identifyResults){this.updateResultTree()}if(prevState.currentResult!==this.state.currentResult||prevState.resultTree!==this.state.resultTree){this.setHighlightedResults(this.state.currentResult===null?null:[this.state.currentResult],this.state.resultTree)}// Scroll to selected result
10
+ if(this.state.currentResult&&this.state.currentResult!==prevState.currentResult&&this.currentResultElRef&&this.scrollIntoView){this.currentResultElRef.parentNode.scrollTop=this.currentResultElRef.offsetTop-this.currentResultElRef.parentNode.offsetTop;this.scrollIntoView=false;this.currentResultElRef=null}}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.props.removeLayer("__identifyviewerhighlight")}},{key:"render",value:function render(){var _this2=this,_exporters$this$state;var tree=this.props.displayResultTree;var body=null;if(tree){var contents=Object.keys(this.state.resultTree).map(function(layer){return _this2.renderLayer(layer)});var attributes=this.renderResultAttributes(this.state.currentLayer,this.state.currentResult,"identify-result-tree-frame");var resultsContainerStyle={maxHeight:attributes?"10em":"initial"};body=[/*#__PURE__*/React.createElement("div",{className:"identify-results-container",key:"results-container",style:resultsContainerStyle},contents),attributes]}else{body=/*#__PURE__*/React.createElement("div",{className:"identify-flat-results-list"},this.props.showLayerSelector?/*#__PURE__*/React.createElement("div",{className:"identify-selectbox"},/*#__PURE__*/React.createElement("select",{className:"identify-layer-select",onChange:function onChange(e){var selectedLayer=e.target.value;_this2.setState({selectedLayer:selectedLayer})}},/*#__PURE__*/React.createElement("option",{value:""},LocaleUtils.tr("identify.layerall")),Object.keys(this.state.resultTree).filter(function(key){return _this2.state.resultTree[key].length}).map(function(layer){return/*#__PURE__*/React.createElement("option",{key:layer,value:layer},_this2.state.resultTree[layer][0].layertitle)})),/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.featurecount"),": ",Object.values(this.state.selectedLayer!==""?this.state.resultTree[this.state.selectedLayer]:this.state.resultTree).flat().length)):null,Object.keys(this.state.selectedLayer!==""?_defineProperty({},this.state.selectedLayer,this.state.resultTree[this.state.selectedLayer]):this.state.resultTree).map(function(layer){var layerResults=_this2.state.resultTree[layer];return layerResults.map(function(result){var resultClass=_this2.state.currentResult===result?"identify-result-frame-highlighted":"identify-result-frame-normal";return/*#__PURE__*/React.createElement("div",{key:result.id,onMouseEnter:function onMouseEnter(){return _this2.setState({currentResult:result,currentLayer:layer})},onMouseLeave:function onMouseLeave(){return _this2.setState({currentResult:null,currentLayer:null})}},_this2.renderResultAttributes(layer,result,resultClass))})}))}// "el.style.background='inherit'": HACK to trigger an additional repaint, since Safari/Chrome on iOS render the element cut off the first time
11
+ var exporters=Object.fromEntries(this.getExporters().map(function(exporter){return[exporter.id,exporter]}));var enabledExporters=Array.isArray(this.props.enableExport)?this.props.enableExport:Object.keys(exporters);var clipboardExportDisabled=((_exporters$this$state=exporters[this.state.exportFormat])===null||_exporters$this$state===void 0?void 0:_exporters$this$state.allowClipboard)!==true;return/*#__PURE__*/React.createElement("div",{className:"identify-body",ref:function ref(el){if(el)el.style.background="inherit"}},body,this.props.enableExport===true||!isEmpty(this.props.enableExport)?/*#__PURE__*/React.createElement("div",{className:"identify-buttonbox"},/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.export"),":\xA0"),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("select",{className:"combo identify-export-format",onChange:function onChange(ev){return _this2.setState({exportFormat:ev.target.value})},value:this.state.exportFormat},enabledExporters.map(function(id){var _exporters$id$title;return/*#__PURE__*/React.createElement("option",{key:id,value:id},(_exporters$id$title=exporters[id].title)!==null&&_exporters$id$title!==void 0?_exporters$id$title:LocaleUtils.tr(exporters[id].titleMsgId))})),/*#__PURE__*/React.createElement("button",{className:"button",onClick:function onClick(){return _this2.exportResults()},title:LocaleUtils.tr("identify.download")},/*#__PURE__*/React.createElement(Icon,{icon:"export"})),/*#__PURE__*/React.createElement("button",{className:"button",disabled:clipboardExportDisabled,onClick:function onClick(){return _this2.exportResults(true)},title:LocaleUtils.tr("identify.clipboard")},/*#__PURE__*/React.createElement(Icon,{icon:"copy"})))):null,this.props.enableAggregatedReports&&Object.keys(this.state.reports).length>0?/*#__PURE__*/React.createElement("div",{className:"identify-buttonbox"},/*#__PURE__*/React.createElement("span",{className:"identify-buttonbox-spacer"}),/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("identify.aggregatedreport"),":\xA0"),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement("select",{className:"combo identify-export-format",onChange:function onChange(ev){return _this2.setState({selectedAggregatedReport:ev.target.value})},value:this.state.selectedAggregatedReport},/*#__PURE__*/React.createElement("option",{disabled:true,value:""},LocaleUtils.tr("identify.selectreport")),Object.entries(this.state.reports).map(function(_ref16){var _ref17=_slicedToArray(_ref16,2),layername=_ref17[0],reports=_ref17[1];return reports.map(function(report,idx){return/*#__PURE__*/React.createElement("option",{key:layername+"::"+idx,value:layername+"::"+idx},report.title)})})),/*#__PURE__*/React.createElement("button",{className:"button",disabled:!this.state.selectedAggregatedReport||this.state.generatingReport,onClick:this.downloadAggregatedReport},this.state.generatingReport?/*#__PURE__*/React.createElement(Spinner,null):/*#__PURE__*/React.createElement(Icon,{icon:"report"})))):null)}}])}(React.Component);_defineProperty(IdentifyViewer,"propTypes",{addLayerFeatures:PropTypes.func,attributeCalculator:PropTypes.func,attributeTransform:PropTypes.func,changeLayerProperty:PropTypes.func,collapsible:PropTypes.bool,customExporters:PropTypes.array,displayResultTree:PropTypes.bool,enableAggregatedReports:PropTypes.bool,enableExport:PropTypes.oneOfType([PropTypes.bool,PropTypes.array]),exportGeometry:PropTypes.bool,highlightAllResults:PropTypes.bool,identifyResults:PropTypes.object,iframeDialogsInitiallyDocked:PropTypes.bool,layers:PropTypes.array,longAttributesDisplay:PropTypes.oneOf(["ellipsis","wrap"]),map:PropTypes.object,openExternalUrl:PropTypes.func,removeLayer:PropTypes.func,replaceImageUrls:PropTypes.bool,setActiveLayerInfo:PropTypes.func,showLayerSelector:PropTypes.bool,showLayerTitles:PropTypes.bool,theme:PropTypes.object,zoomToPoint:PropTypes.func});_defineProperty(IdentifyViewer,"defaultProps",{longAttributesDisplay:"ellipsis",customExporters:[],displayResultTree:true,attributeCalculator:function attributeCalculator(/* layer, feature */){return[]},attributeTransform:function attributeTransform(name,value/* , layer, feature */){return value},enableAggregatedReports:true,showLayerTitles:true,showLayerSelector:true,highlightAllResults:true});var selector=function selector(state){return{theme:state.theme.current,layers:state.layers.flat,map:state.map}};export default connect(selector,{addLayerFeatures:addLayerFeatures,changeLayerProperty:changeLayerProperty,removeLayer:removeLayer,setActiveLayerInfo:setActiveLayerInfo,openExternalUrl:openExternalUrl,zoomToPoint:zoomToPoint})(IdentifyViewer);
@@ -10,4 +10,4 @@ return}// create an interaction to draw with
10
10
  _this.drawInteraction=new ol.interaction.Draw({stopClick:true,source:_this.selectionLayer.getSource(),condition:_this.props.drawCondition,type:typeMap[_this.props.geomType],style:function style(feature){return FeatureStyles[_this.props.styleName](feature,_objectSpread(_objectSpread({},_this.props.styleOptions),{},{circleRadius:0}))},geometryFunction:_this.props.geomType==="Box"?ol.interaction.createBox():undefined});_this.drawInteraction.on("drawstart",function(evt){// clear previous sketches
11
11
  _this.selectionLayer.getSource().clear();evt.feature.on("change",function(){return _this.updateMeasurements(evt.feature)})},_this);_this.drawInteraction.on("drawend",function(evt){_this.updateSelectionState(evt.feature.getGeometry())},_this)}_this.map.addInteraction(_this.drawInteraction);window.addEventListener("keydown",_this.checkModifier);window.addEventListener("keyup",_this.checkModifier);if(_this.props.cursor){_this.map.getViewport().style.cursor=_this.props.cursor}});_defineProperty(_this,"removeDrawInteraction",function(){if(_this.drawInteraction!==null){_this.map.removeInteraction(_this.drawInteraction);_this.drawInteraction=null}window.removeEventListener("keydown",_this.checkModifier);window.removeEventListener("keyup",_this.checkModifier);_this.map.getViewport().style.cursor=""});_defineProperty(_this,"checkModifier",function(ev){var down=ev.type==="keydown";_this.setState(function(state){return{modifiers:{alt:ev.key==="Alt"?down:state.modifiers.alt,ctrl:ev.key==="Control"?down:state.modifiers.ctrl,shift:ev.key==="Shift"?down:state.modifiers.shift}}})});_defineProperty(_this,"updateSelectionState",function(geometry){if(!geometry){return}var coords=_this.props.geomType==="Circle"?null:geometry.getCoordinates();if(_this.props.geomType==="Circle"){// Also store poligonized circle
12
12
  var center=geometry.getCenter();var radius=geometry.getRadius();var deg2rad=Math.PI/180;var polycords=[Array.apply(null,Array(91)).map(function(item,index){return[center[0]+radius*Math.cos(4*index*deg2rad),center[1]+radius*Math.sin(4*index*deg2rad)]})];_this.setState({geometry:{type:"Polygon",coordinates:polycords,center:center,radius:radius}})}else if(_this.props.geomType==="DragBox"||_this.props.geomType==="Box"){var boxcoords=[[Math.min(coords[0][0][0],coords[0][2][0]),Math.min(coords[0][0][1],coords[0][2][1]),Math.max(coords[0][0][0],coords[0][2][0]),Math.max(coords[0][0][1],coords[0][2][1])]];_this.setState({geometry:{type:"Polygon",coordinates:boxcoords}})}else{_this.setState({geometry:{type:_this.props.geomType,coordinates:coords}})}});_defineProperty(_this,"updateMeasurements",function(feature){if(!_this.props.measure){return}var settings={lenUnit:"metric",areaUnit:"metric"};MeasureUtils.updateFeatureMeasurements(feature,_this.props.geomType,_this.props.projection,settings)});_this.drawInteraction=null;_this.map=MapUtils.getHook(MapUtils.GET_MAP);// create a layer to draw on
13
- _this.selectionLayer=new ol.layer.Vector({source:new ol.source.Vector,zIndex:1000000,style:function style(feature){return FeatureStyles[_this.props.styleName](feature,_this.props.styleOptions)}});_this.map.addLayer(_this.selectionLayer);_this.selectionLayer.setVisible(!_this.props.hideGeometry);return _this}_inherits(MapSelection,_React$Component);return _createClass(MapSelection,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.active){this.addDrawInteraction()}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.hideGeometry!==prevProps.hideGeometry){this.selectionLayer.setVisible(!this.props.hideGeometry)}if(this.props.geomType!==prevProps.geomType){this.selectionLayer.getSource().clear()}if(this.props.active&&!prevProps.active||this.props.active&&this.props.geomType!==prevProps.geomType){this.addDrawInteraction()}else if(!this.props.active&&prevProps.active){this.removeDrawInteraction()}if(this.state.geometry!==prevState.geometry){if(this.state.geometry!==this.props.geometry){this.props.geometryChanged(this.state.geometry,_objectSpread({},this.state.modifiers))}}if(this.props.geometry!==prevProps.geometry&&this.props.geometry!==this.state.geometry){if(!this.props.geometry){this.selectionLayer.getSource().clear()}else{var feature=this.selectionLayer.getSource().getFeatures()[0];if(!feature){feature=new ol.Feature;this.selectionLayer.getSource().addFeature(feature)}if(this.props.geometry.type==="Point"){feature.setGeometry(new ol.geom.Point(this.props.geometry.coordinates))}else if(this.props.geometry.type==="MultiPoint"){feature.setGeometry(new ol.geom.Multi(this.props.geometry.coordinates))}else if(this.props.geometry.type==="LineString"){feature.setGeometry(new ol.geom.LineString(this.props.geometry.coordinates))}else if(this.props.geometry.type==="MultiLineString"){feature.setGeometry(new ol.geom.MultiLineString(this.props.geometry.coordinates))}else if(this.props.geometry.type==="Polygon"){if(this.props.geometry.center&&this.props.geometry.radius){feature.setGeometry(new ol.geom.Circle(this.props.geometry.center,this.props.geometry.radius))}else{feature.setGeometry(new ol.geom.Polygon(this.props.geometry.coordinates))}}else if(this.props.geometry.type==="MultiPolygon"){feature.setGeometry(new ol.geom.MultiPolygon(this.props.geometry.coordinates))}this.setState({geometry:this.props.geometry})}}}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.map.removeLayer(this.selectionLayer);this.removeDrawInteraction()}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(MapSelection,"propTypes",{/** Whether the selection tool is active */active:PropTypes.bool,/** Optional, a css-cursor to use when drawing */cursor:PropTypes.string,/** The draw interaction condition. */drawCondition:PropTypes.func,/** The selection geometry type (Point, LineString, Polygon, Circle, DragBox, Box) */geomType:PropTypes.string,/** Initial geometry or geometry to update. */geometry:PropTypes.object,/** The callback which is invoked with a drawn geometry. */geometryChanged:PropTypes.func,/** Whether to hide the current selection (except while drawing). */hideGeometry:PropTypes.bool,/** Whether to show measurements while drawing. */measure:PropTypes.bool,projection:PropTypes.string,/** Optional: the selection feature style name. */styleName:PropTypes.string,/** Optional: the selection feature style options. */styleOptions:PropTypes.object});_defineProperty(MapSelection,"defaultProps",{drawCondition:function drawCondition(event){return event.originalEvent.buttons===1},styleName:"default",styleOptions:{}});export default connect(function(state){return{projection:state.map.projection}},{})(MapSelection);
13
+ _this.selectionLayer=new ol.layer.Vector({source:new ol.source.Vector,zIndex:1000000,style:function style(feature){return FeatureStyles[_this.props.styleName](feature,_this.props.styleOptions)}});_this.selectionLayer.setVisible(!_this.props.hideGeometry);return _this}_inherits(MapSelection,_React$Component);return _createClass(MapSelection,[{key:"componentDidMount",value:function componentDidMount(){this.map.addLayer(this.selectionLayer);if(this.props.active){this.addDrawInteraction()}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.hideGeometry!==prevProps.hideGeometry){this.selectionLayer.setVisible(!this.props.hideGeometry)}if(this.props.geomType!==prevProps.geomType){this.selectionLayer.getSource().clear()}if(this.props.active&&!prevProps.active||this.props.active&&this.props.geomType!==prevProps.geomType){this.addDrawInteraction()}else if(!this.props.active&&prevProps.active){this.removeDrawInteraction()}if(this.state.geometry!==prevState.geometry){if(this.state.geometry!==this.props.geometry){this.props.geometryChanged(this.state.geometry,_objectSpread({},this.state.modifiers))}}if(this.props.geometry!==prevProps.geometry&&this.props.geometry!==this.state.geometry){if(!this.props.geometry){this.selectionLayer.getSource().clear()}else{var feature=this.selectionLayer.getSource().getFeatures()[0];if(!feature){feature=new ol.Feature;this.selectionLayer.getSource().addFeature(feature)}if(this.props.geometry.type==="Point"){feature.setGeometry(new ol.geom.Point(this.props.geometry.coordinates))}else if(this.props.geometry.type==="MultiPoint"){feature.setGeometry(new ol.geom.Multi(this.props.geometry.coordinates))}else if(this.props.geometry.type==="LineString"){feature.setGeometry(new ol.geom.LineString(this.props.geometry.coordinates))}else if(this.props.geometry.type==="MultiLineString"){feature.setGeometry(new ol.geom.MultiLineString(this.props.geometry.coordinates))}else if(this.props.geometry.type==="Polygon"){if(this.props.geometry.center&&this.props.geometry.radius){feature.setGeometry(new ol.geom.Circle(this.props.geometry.center,this.props.geometry.radius))}else{feature.setGeometry(new ol.geom.Polygon(this.props.geometry.coordinates))}}else if(this.props.geometry.type==="MultiPolygon"){feature.setGeometry(new ol.geom.MultiPolygon(this.props.geometry.coordinates))}this.setState({geometry:this.props.geometry})}}}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.map.removeLayer(this.selectionLayer);this.removeDrawInteraction()}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(MapSelection,"propTypes",{/** Whether the selection tool is active */active:PropTypes.bool,/** Optional, a css-cursor to use when drawing */cursor:PropTypes.string,/** The draw interaction condition. */drawCondition:PropTypes.func,/** The selection geometry type (Point, LineString, Polygon, Circle, DragBox, Box) */geomType:PropTypes.string,/** Initial geometry or geometry to update. */geometry:PropTypes.object,/** The callback which is invoked with a drawn geometry. */geometryChanged:PropTypes.func,/** Whether to hide the current selection (except while drawing). */hideGeometry:PropTypes.bool,/** Whether to show measurements while drawing. */measure:PropTypes.bool,projection:PropTypes.string,/** Optional: the selection feature style name. */styleName:PropTypes.string,/** Optional: the selection feature style options. */styleOptions:PropTypes.object});_defineProperty(MapSelection,"defaultProps",{drawCondition:function drawCondition(event){return event.originalEvent.buttons===1},styleName:"default",styleOptions:{}});export default connect(function(state){return{projection:state.map.projection}},{})(MapSelection);
@@ -12,19 +12,19 @@ Object.entries(prevColorLayers).forEach(function(_ref3){var _ref4=_slicedToArray
12
12
  tiles.tiles.addEventListener("load-tile-set",function(_ref7){var tileSet=_ref7.tileSet;if(tileSet.root.parent===null){var bbox=new Box3;tiles.tiles.getBoundingBox(bbox);var center=bbox.getCenter(new Vector3);tiles.tiles.group.position.sub(center);if(matrix){tiles.tiles.group.parent.applyMatrix4(matrix)}else{tiles.tiles.group.parent.position.copy(center)}tiles.tiles.group.parent.updateMatrixWorld(true);if(label){tiles.tiles.group.parent.userData.label=label;updateObjectLabel(tiles.tiles.group.parent,_this2.state.sceneContext)}}_this2.instance.notifyChange(tiles);if(showEditTool){_this2.props.setCurrentTask("EditDataset3D",null,null,{objectId:name})}});tiles.tiles.addEventListener("needs-update",function(){_this2.instance.notifyChange(tiles)});// Apply style when loading tile
13
13
  tiles.tiles.addEventListener("load-model",function(_ref8){var scene=_ref8.scene;scene.userData.tilesetName=name;scene.userData.featureIdAttr="id";Tiles3DStyle.applyTileStyle(scene,_this2.state.sceneContext.sceneObjects[name],_this2.state.sceneContext);_this2.instance.notifyChange(tiles)});// Show/hide labels when tile visibility changes
14
14
  tiles.tiles.addEventListener("tile-visibility-change",function(_ref9){var _scene$userData$tileL,_scene$userData;var scene=_ref9.scene,visible=_ref9.visible;Object.values((_scene$userData$tileL=scene===null||scene===void 0||(_scene$userData=scene.userData)===null||_scene$userData===void 0?void 0:_scene$userData.tileLabels)!==null&&_scene$userData$tileL!==void 0?_scene$userData$tileL:{}).forEach(function(l){l.labelObject.visible=visible;l.labelObject.element.style.display=visible?"initial":"none"})});tiles.castShadow=true;tiles.receiveShadow=true;tiles.userData.layertree=true;_this2.instance.add(tiles);_this2.objectMap[name]=tiles;_this2.setState(function(state){var objectState=_objectSpread({imported:true,visibility:true,opacity:255,layertree:true,title:name},options);return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:_objectSpread(_objectSpread({},state.sceneContext.sceneObjects),{},_defineProperty({},name,objectState))})}})});_defineProperty(_this2,"addSceneObject",function(objectId,object){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var showEditTool=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;_this2.sceneObjectGroup.add(object);_this2.objectMap[objectId]=object;_this2.instance.notifyChange(object);_this2.setState(function(state){var objectState=_objectSpread({visibility:true,opacity:255,layertree:false},options);return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:_objectSpread(_objectSpread({},state.sceneContext.sceneObjects),{},_defineProperty({},objectId,objectState))})}});if(showEditTool){_this2.props.setCurrentTask("EditDataset3D",null,null,{objectId:objectId})}});_defineProperty(_this2,"getSceneObject",function(objectId){return _this2.objectMap[objectId]});_defineProperty(_this2,"removeSceneObject",function(objectId){var callback=arguments.length>1&&arguments[1]!==undefined?arguments[1]:undefined;var object=_this2.objectMap[objectId];if(!object){return}// Ensure labels are removed
15
- object.traverse(function(c){if(c.isCSS2DObject){c.element.parentNode.removeChild(c.element)}});if(object.tiles){_this2.instance.remove(object)}else{_this2.sceneObjectGroup.remove(object)}delete _this2.objectMap[objectId];_this2.instance.notifyChange();_this2.setState(function(state){var newSceneObjects=_objectSpread({},state.sceneContext.sceneObjects);delete newSceneObjects[objectId];return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:newSceneObjects})}},callback)});_defineProperty(_this2,"updateSceneObject",function(objectId,options){_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:_objectSpread(_objectSpread({},state.sceneContext.sceneObjects),{},_defineProperty({},objectId,_objectSpread(_objectSpread({},state.sceneContext.sceneObjects[objectId]),options)))})}})});_defineProperty(_this2,"zoomToObject",function(objectId){var margin=arguments.length>1&&arguments[1]!==undefined?arguments[1]:20;var obj=_this2.state.sceneContext.getSceneObject(objectId);var bbox=new Box3;if(obj!==null&&obj!==void 0&&obj.tiles){obj.tiles.getBoundingBox(bbox)}else{bbox.setFromObject(obj)}if(!bbox.isEmpty()){var bounds=[bbox.min.x-margin,bbox.min.y-margin,bbox.max.x+margin,bbox.max.y+margin];_this2.state.sceneContext.setViewToExtent(bounds,0)}});_defineProperty(_this2,"getMap",function(){return _this2.map});_defineProperty(_this2,"setupContainer",function(el){if(el){_this2.container=el;el.resizeObserver=new ResizeObserver(function(entries){var rect=entries[0].contentRect;_this2.state.sceneContext.scene.view.dispatchEvent({type:"view-resized",width:rect.width,height:rect.height})});el.resizeObserver.observe(el);_this2.setupInstance()}});_defineProperty(_this2,"setupInstance",function(){var _this2$props$theme$ma,_this2$props$theme$ma2,_this2$props$theme$ma3,_this2$props$theme$ma6,_this2$props$theme$ma7,_this2$props$theme$ma8;if(_this2.instance){_this2.disposeInstance()}if(!_this2.props.theme){return}var projection=_this2.props.theme.mapCrs;// Setup instance
15
+ object.traverse(function(c){if(c.isCSS2DObject){c.element.parentNode.removeChild(c.element)}});if(object.tiles){_this2.instance.remove(object)}else{_this2.sceneObjectGroup.remove(object)}delete _this2.objectMap[objectId];_this2.instance.notifyChange();_this2.setState(function(state){var newSceneObjects=_objectSpread({},state.sceneContext.sceneObjects);delete newSceneObjects[objectId];return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:newSceneObjects})}},callback)});_defineProperty(_this2,"updateSceneObject",function(objectId,options){_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{sceneObjects:_objectSpread(_objectSpread({},state.sceneContext.sceneObjects),{},_defineProperty({},objectId,_objectSpread(_objectSpread({},state.sceneContext.sceneObjects[objectId]),options)))})}})});_defineProperty(_this2,"zoomToObject",function(objectId){var margin=arguments.length>1&&arguments[1]!==undefined?arguments[1]:20;var obj=_this2.state.sceneContext.getSceneObject(objectId);var bbox=new Box3;if(obj!==null&&obj!==void 0&&obj.tiles){obj.tiles.getBoundingBox(bbox)}else{bbox.setFromObject(obj)}if(!bbox.isEmpty()){var bounds=[bbox.min.x-margin,bbox.min.y-margin,bbox.max.x+margin,bbox.max.y+margin];_this2.state.sceneContext.setViewToExtent(bounds,0)}});_defineProperty(_this2,"getMap",function(){return _this2.map});_defineProperty(_this2,"setupContainer",function(el){if(el){_this2.container=el;el.resizeObserver=new ResizeObserver(function(entries){var rect=entries[0].contentRect;_this2.state.sceneContext.scene.view.dispatchEvent({type:"view-resized",width:rect.width,height:rect.height})});el.resizeObserver.observe(el);_this2.setupInstance()}});_defineProperty(_this2,"setupInstance",function(){var _this2$props$theme$ma,_this2$props$theme$ma2,_this2$props$theme$ma3,_this2$props$theme$ma4,_this2$props$theme$ma5,_this2$props$theme$ma8,_this2$props$theme$ma9,_this2$props$theme$ma10;if(_this2.instance){_this2.disposeInstance()}if(!_this2.props.theme){return}var projection=_this2.props.theme.mapCrs;// Setup instance
16
16
  _this2.instance=new Instance({target:_this2.container,crs:projection,renderer:{clearColor:0,preserveDrawingBuffer:true}});_this2.sceneObjectGroup=new Group;_this2.instance.add(_this2.sceneObjectGroup);// Setup map
17
- var bounds=CoordinatesUtils.reprojectBbox(_this2.props.theme.initialBbox.bounds,_this2.props.theme.initialBbox.crs,projection);var extent=new Extent(projection,bounds[0],bounds[2],bounds[1],bounds[3]);_this2.map=new Map({extent:extent,backgroundColor:"white"});_this2.instance.add(_this2.map);// Setup camera
17
+ var initialBbox=(_this2$props$theme$ma=(_this2$props$theme$ma2=_this2.props.theme.map3d)===null||_this2$props$theme$ma2===void 0?void 0:_this2$props$theme$ma2.extent)!==null&&_this2$props$theme$ma!==void 0?_this2$props$theme$ma:_this2.props.theme.initialBbox;var bounds=CoordinatesUtils.reprojectBbox(initialBbox.bounds,initialBbox.crs,projection);var extent=new Extent(crs,bounds[0],bounds[2],bounds[1],bounds[3]);_this2.map=new Map({extent:extent,backgroundColor:"white"});_this2.instance.add(_this2.map);// Setup camera
18
18
  var center=extent.center();_this2.instance.view.camera.position.set(center.x,center.y,0.5*(extent.east-extent.west));// Skybox
19
19
  var cubeTextureLoader=new CubeTextureLoader;cubeTextureLoader.setPath(ConfigUtils.getAssetsPath()+"/3d/skybox/");var cubeTexture=cubeTextureLoader.load(["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"]);_this2.instance.scene.background=cubeTexture;// Setup elevation
20
- var demUrl=MiscUtils.resolveAssetsPath((_this2$props$theme$ma=(_this2$props$theme$ma2=_this2.props.theme.map3d)===null||_this2$props$theme$ma2===void 0||(_this2$props$theme$ma2=_this2$props$theme$ma2.dtm)===null||_this2$props$theme$ma2===void 0?void 0:_this2$props$theme$ma2.url)!==null&&_this2$props$theme$ma!==void 0?_this2$props$theme$ma:"");var demCrs=((_this2$props$theme$ma3=_this2.props.theme.map3d)===null||_this2$props$theme$ma3===void 0||(_this2$props$theme$ma3=_this2$props$theme$ma3.dtm)===null||_this2$props$theme$ma3===void 0?void 0:_this2$props$theme$ma3.crs)||"EPSG:3857";if(demUrl){var _this2$props$theme$ma4,_this2$props$theme$ma5;var demSource=new GeoTIFFSource({url:demUrl,crs:demCrs});var demMin=(_this2$props$theme$ma4=_this2.props.theme.map3d.dtm.min)!==null&&_this2$props$theme$ma4!==void 0?_this2$props$theme$ma4:undefined;var demMax=(_this2$props$theme$ma5=_this2.props.theme.map3d.dtm.max)!==null&&_this2$props$theme$ma5!==void 0?_this2$props$theme$ma5:undefined;var elevationLayer=new ElevationLayer({name:"dem",extent:extent,source:demSource,minmax:demMin!==undefined&&demMax!==undefined?{demMin:demMin,demMax:demMax}:undefined});_this2.addLayer("__dtm",elevationLayer)}// Collect baselayers
21
- var externalLayers={};var baseLayers=ThemeUtils.createThemeBackgroundLayers(((_this2$props$theme$ma6=_this2.props.theme.map3d)===null||_this2$props$theme$ma6===void 0?void 0:_this2$props$theme$ma6.basemaps)||[],_this2.props.themes,null,externalLayers);for(var _i=0,_Object$keys=Object.keys(externalLayers);_i<_Object$keys.length;_i++){var key=_Object$keys[_i];var idx=key.indexOf(":");var service=key.slice(0,idx);var serviceUrl=key.slice(idx+1);ServiceLayerUtils.findLayers(service,serviceUrl,externalLayers[key],projection,function(id,layer){// Don't expose sublayers
20
+ var demUrl=MiscUtils.resolveAssetsPath((_this2$props$theme$ma3=(_this2$props$theme$ma4=_this2.props.theme.map3d)===null||_this2$props$theme$ma4===void 0||(_this2$props$theme$ma4=_this2$props$theme$ma4.dtm)===null||_this2$props$theme$ma4===void 0?void 0:_this2$props$theme$ma4.url)!==null&&_this2$props$theme$ma3!==void 0?_this2$props$theme$ma3:"");var demCrs=((_this2$props$theme$ma5=_this2.props.theme.map3d)===null||_this2$props$theme$ma5===void 0||(_this2$props$theme$ma5=_this2$props$theme$ma5.dtm)===null||_this2$props$theme$ma5===void 0?void 0:_this2$props$theme$ma5.crs)||"EPSG:3857";if(demUrl){var _this2$props$theme$ma6,_this2$props$theme$ma7;var demSource=new GeoTIFFSource({url:demUrl,crs:demCrs});var demMin=(_this2$props$theme$ma6=_this2.props.theme.map3d.dtm.min)!==null&&_this2$props$theme$ma6!==void 0?_this2$props$theme$ma6:undefined;var demMax=(_this2$props$theme$ma7=_this2.props.theme.map3d.dtm.max)!==null&&_this2$props$theme$ma7!==void 0?_this2$props$theme$ma7:undefined;var elevationLayer=new ElevationLayer({name:"dem",extent:extent,source:demSource,minmax:demMin!==undefined&&demMax!==undefined?{demMin:demMin,demMax:demMax}:undefined});_this2.addLayer("__dtm",elevationLayer)}// Collect baselayers
21
+ var externalLayers={};var baseLayers=ThemeUtils.createThemeBackgroundLayers(((_this2$props$theme$ma8=_this2.props.theme.map3d)===null||_this2$props$theme$ma8===void 0?void 0:_this2$props$theme$ma8.basemaps)||[],_this2.props.themes,null,externalLayers);for(var _i=0,_Object$keys=Object.keys(externalLayers);_i<_Object$keys.length;_i++){var key=_Object$keys[_i];var idx=key.indexOf(":");var service=key.slice(0,idx);var serviceUrl=key.slice(idx+1);ServiceLayerUtils.findLayers(service,serviceUrl,externalLayers[key],projection,function(id,layer){// Don't expose sublayers
22
22
  if(layer){layer.sublayers=null}_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{baseLayers:LayerUtils.replacePlaceholderLayer(state.sceneContext.baseLayers,id,layer)})}})})}// Collect color layers
23
23
  var colorLayers=_this2.collectColorLayers([],[]);var sceneObjects={};_this2.objectMap={};// Add 3d tiles
24
- (((_this2$props$theme$ma7=_this2.props.theme.map3d)===null||_this2$props$theme$ma7===void 0?void 0:_this2$props$theme$ma7.tiles3d)||[]).forEach(function(entry){var _entry$title;var tiles=new Tiles3D({url:MiscUtils.resolveAssetsPath(entry.url),errorTarget:32});tiles.tiles.addEventListener("load-tile-set",function(){_this2.instance.notifyChange(tiles)});tiles.tiles.addEventListener("needs-update",function(){_this2.instance.notifyChange(tiles)});// Apply style when loading tile
24
+ (((_this2$props$theme$ma9=_this2.props.theme.map3d)===null||_this2$props$theme$ma9===void 0?void 0:_this2$props$theme$ma9.tiles3d)||[]).forEach(function(entry){var _entry$title;var tiles=new Tiles3D({url:MiscUtils.resolveAssetsPath(entry.url),errorTarget:32});tiles.tiles.addEventListener("load-tile-set",function(){_this2.instance.notifyChange(tiles)});tiles.tiles.addEventListener("needs-update",function(){_this2.instance.notifyChange(tiles)});// Apply style when loading tile
25
25
  tiles.tiles.addEventListener("load-model",function(_ref10){var _entry$idAttr;var scene=_ref10.scene;scene.userData.tilesetName=entry.name;scene.userData.featureIdAttr=(_entry$idAttr=entry.idAttr)!==null&&_entry$idAttr!==void 0?_entry$idAttr:"id";Tiles3DStyle.applyTileStyle(scene,_this2.state.sceneContext.sceneObjects[entry.name],_this2.state.sceneContext);_this2.instance.notifyChange(tiles)});// Show/hide labels when tile visibility changes
26
26
  tiles.tiles.addEventListener("tile-visibility-change",function(_ref11){var _scene$userData$tileL2,_scene$userData2;var scene=_ref11.scene,visible=_ref11.visible;Object.values((_scene$userData$tileL2=scene===null||scene===void 0||(_scene$userData2=scene.userData)===null||_scene$userData2===void 0?void 0:_scene$userData2.tileLabels)!==null&&_scene$userData$tileL2!==void 0?_scene$userData$tileL2:{}).forEach(function(label){label.labelObject.visible=visible;label.labelObject.element.style.display=visible?"initial":"none"})});tiles.castShadow=true;tiles.receiveShadow=true;tiles.userData.layertree=true;_this2.instance.add(tiles);_this2.objectMap[entry.name]=tiles;sceneObjects[entry.name]={visibility:true,opacity:255,layertree:true,title:(_entry$title=entry.title)!==null&&_entry$title!==void 0?_entry$title:entry.name,baseColor:entry.baseColor,styles:entry.styles,style:entry.style||Object.keys(entry.styles||{})[0]||null,tilesetStyle:null,idAttr:entry.idAttr,colorAttr:entry.colorAttr,alphaAttr:entry.alphaAttr,labelAttr:entry.labelAttr}});// Add other objects
27
- (((_this2$props$theme$ma8=_this2.props.theme.map3d)===null||_this2$props$theme$ma8===void 0?void 0:_this2$props$theme$ma8.objects3d)||[]).forEach(function(entry){importGltf(MiscUtils.resolveAssetsPath(entry.url),entry.name,_this2.state.sceneContext)});_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{scene:_this2.instance,map:_this2.map,mapCrs:projection,dtmUrl:demUrl,dtmCrs:demCrs,baseLayers:baseLayers,colorLayers:colorLayers,sceneObjects:sceneObjects}),sceneId:uuidv4()}});// Inspector
27
+ (((_this2$props$theme$ma10=_this2.props.theme.map3d)===null||_this2$props$theme$ma10===void 0?void 0:_this2$props$theme$ma10.objects3d)||[]).forEach(function(entry){importGltf(MiscUtils.resolveAssetsPath(entry.url),entry.name,_this2.state.sceneContext)});_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{scene:_this2.instance,map:_this2.map,mapCrs:projection,dtmUrl:demUrl,dtmCrs:demCrs,baseLayers:baseLayers,colorLayers:colorLayers,sceneObjects:sceneObjects}),sceneId:uuidv4()}});// Inspector
28
28
  if(["1","true"].includes((UrlParams.getParam("inspector")||"").toLowerCase())){var inspectorContainer=document.createElement("div");inspectorContainer.className="map3d-inspector";_this2.container.appendChild(inspectorContainer);_this2.inspector=new Inspector(inspectorContainer,_this2.instance)}_this2.instance.addEventListener("update-start",_this2.instanceOnUpdateStart);_this2.instance.addEventListener("update-end",_this2.instanceOnUpdateEnd);_this2.instance.addEventListener("before-entity-update",_this2.instanceOnBeforeEntityUpdate);_this2.instance.addEventListener("after-entity-update",_this2.instanceOnAfterEntityUpdate)});_defineProperty(_this2,"instanceOnUpdateStart",function(){var camera=_this2.instance.view.camera;var quality=_this2.state.sceneContext.settings.sceneQuality;var isFirstPerson=_this2.state.sceneContext.scene.view.controls.isFirstPerson;var maxDistance=isFirstPerson?200+20*quality:500+quality*quality;// Hide scene objects according to scene quality
29
29
  Object.entries(_this2.state.sceneContext.sceneObjects).forEach(function(_ref12){var _ref13=_slicedToArray(_ref12,2),objId=_ref13[0],options=_ref13[1];var object=_this2.objectMap[objId];if(options.layertree&&object.isObject3D&&object.visible){object.children.forEach(function(child){if(child.geometry){if(!child.geometry.boundingBox){child.geometry.computeBoundingBox()}var localCenter=child.geometry.boundingBox.getCenter(new Vector3);var worldCenter=localCenter.applyMatrix4(child.matrixWorld);var distance=camera.position.distanceTo(worldCenter);child.userData.__wasVisible=child.visible;if(distance>maxDistance){child.visible=false}}})}})});_defineProperty(_this2,"instanceOnUpdateEnd",function(){Object.entries(_this2.state.sceneContext.sceneObjects).forEach(function(_ref14){var _ref15=_slicedToArray(_ref14,2),objId=_ref15[0],options=_ref15[1];var object=_this2.objectMap[objId];if(options.layertree&&object.isObject3D){object.children.forEach(function(child){child.visible=child.userData.__wasVisible;delete child.userData.__wasVisible})}})});_defineProperty(_this2,"instanceOnBeforeEntityUpdate",function(_ref16){var entity=_ref16.entity;if(entity!==_this2.map){_this2.instance.view.camera.userData.__previousFar=_this2.instance.view.camera.far;var quality=_this2.state.sceneContext.settings.sceneQuality;var isFirstPerson=_this2.state.sceneContext.scene.view.controls.isFirstPerson;_this2.instance.view.camera.far=isFirstPerson?200+20*quality:500+quality*quality;_this2.instance.view.camera.updateProjectionMatrix()}});_defineProperty(_this2,"instanceOnAfterEntityUpdate",function(_ref17){var entity=_ref17.entity;if(entity!==_this2.map){_this2.instance.view.camera.far=_this2.instance.view.camera.userData.__previousFar;delete _this2.instance.view.camera.userData.__previousFar;_this2.instance.view.camera.updateProjectionMatrix()}});_defineProperty(_this2,"loadTilesetStyle",function(objectId,options){var _options$styles;var url=(_options$styles=options.styles)===null||_options$styles===void 0?void 0:_options$styles[options.style];if(_this2.tilesetStyles[url]){_this2.updateSceneObject(objectId,{tilesetStyle:_this2.tilesetStyles[url]})}else if(url){var fullUrl=MiscUtils.resolveAssetsPath(url);axios.get(fullUrl).then(function(response){_this2.tilesetStyles[url]=response.data;_this2.updateSceneObject(objectId,{tilesetStyle:_this2.tilesetStyles[url]})})["catch"](function(){_this2.tilesetStyles[url]={};_this2.updateSceneObject(objectId,{tilesetStyle:_this2.tilesetStyles[url]})})}else{_this2.tilesetStyles[url]=null;_this2.updateSceneObject(objectId,{tilesetStyle:_this2.tilesetStyles[url]})}});_defineProperty(_this2,"disposeInstance",function(){_this2.instance.removeEventListener("update-start",_this2.instanceOnUpdateStart);_this2.instance.removeEventListener("update-end",_this2.instanceOnUpdateEnd);_this2.instance.removeEventListener("before-entity-update",_this2.instanceOnBeforeEntityUpdate);_this2.instance.removeEventListener("after-entity-update",_this2.instanceOnAfterEntityUpdate);if(_this2.inspector){_this2.inspector.detach()}_this2.map.dispose({disposeLayers:true});Object.values(_this2.objectMap).forEach(function(object){_this2.instance.remove(object)});_this2.instance.dispose();_this2.inspector=null;_this2.map=null;_this2.objectMap={};_this2.sceneObjectGroup=null;_this2.instance=null;_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),Map3D.defaultSceneState)}});_this2.props.setCurrentTask(null)});_defineProperty(_this2,"onUnload",function(key){// Ensure scene has not already been disposed
30
30
  if(_this2.state.sceneId===key){_this2.disposeInstance()}});_defineProperty(_this2,"setupControls",function(instance){_this2.setState(function(state){return{sceneContext:_objectSpread(_objectSpread({},state.sceneContext),{},{setViewToExtent:instance===null||instance===void 0?void 0:instance.setViewToExtent,restoreView:instance===null||instance===void 0?void 0:instance.restoreView})}},_this2.props.onMapInitialized)});_defineProperty(_this2,"getTerrainHeightFromDTM",function(scenePos){var returnArray=true;if(!Array.isArray(scenePos[0])){returnArray=false;scenePos=[scenePos]}var dtmPos=scenePos.map(function(p){return CoordinatesUtils.reproject(p,_this2.state.sceneContext.mapCrs,_this2.state.sceneContext.dtmCrs)});var dtmExt=[Infinity,Infinity,-Infinity,-Infinity];dtmPos.forEach(function(p){dtmExt[0]=Math.min(dtmExt[0],p[0]);dtmExt[1]=Math.min(dtmExt[1],p[1]);dtmExt[2]=Math.max(dtmExt[2],p[0]);dtmExt[3]=Math.max(dtmExt[3],p[1])});return new Promise(function(resolve){if(!_this2.state.sceneContext.dtmUrl){resolve(returnArray?scenePos.map(function(x){return 0}):0);return}fromUrl(_this2.state.sceneContext.dtmUrl).then(function(tiff){tiff.getImage().then(function(image){var _image$fileDirectory=image.fileDirectory,ModelTiepoint=_image$fileDirectory.ModelTiepoint,ModelPixelScale=_image$fileDirectory.ModelPixelScale;// Extract scale and tiepoint values
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwc2",
3
- "version": "2025.10.09",
3
+ "version": "2025.10.13",
4
4
  "description": "QGIS Web Client",
5
5
  "author": "Sourcepole AG",
6
6
  "license": "BSD-2-Clause",
@@ -15,4 +15,4 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
15
15
  * for customized queries and templates for the result presentation.
16
16
  */var Identify=/*#__PURE__*/function(_React$Component){function Identify(){var _this;_classCallCheck(this,Identify);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,Identify,[].concat(args));_defineProperty(_this,"state",{mode:"Point",identifyResults:null,pendingRequests:0,radius:0,radiusUnits:_this.props.initialRadiusUnits,exitTaskOnResultsClose:null,filterGeom:null,filterGeomModifiers:{}});_defineProperty(_this,"identifyPoint",function(clickPoint){if(clickPoint){_this.setState(function(state){// Remove any search selection layer to avoid confusion
17
17
  _this.props.removeLayer("searchselection");var pendingRequests=0;var identifyResults=_this.props.click.modifiers.ctrl!==true?{}:state.identifyResults;var queryableLayers=[];queryableLayers=IdentifyUtils.getQueryLayers(_this.props.layers,_this.props.map);queryableLayers.forEach(function(l){var request=IdentifyUtils.buildRequest(l,l.queryLayers.join(","),clickPoint,_this.props.map,_this.props.params);++pendingRequests;IdentifyUtils.sendRequest(request,function(response){_this.setState(function(state2){return{pendingRequests:state2.pendingRequests-1}});if(response){_this.parseResult(response,l,request.params.info_format,clickPoint)}})});if(!isEmpty(_this.props.click.features)){_this.props.click.features.forEach(function(feature){var layer=_this.props.layers.find(function(l){return l.id===feature.layerId});if((layer===null||layer===void 0?void 0:layer.role)===LayerRole.USERLAYER){var _layer$features$find,_layer$features,_layer$features$find2,_layer$projection;var queryFeature=_objectSpread({},(_layer$features$find=(_layer$features=layer.features)===null||_layer$features===void 0||(_layer$features$find2=_layer$features.find)===null||_layer$features$find2===void 0?void 0:_layer$features$find2.call(_layer$features,function(f){return f.id===feature.id}))!==null&&_layer$features$find!==void 0?_layer$features$find:feature);if(!(queryFeature!==null&&queryFeature!==void 0&&queryFeature.properties)){return}if(!identifyResults[layer.name]){identifyResults[layer.name]=[]}queryFeature.crs=(_layer$projection=layer.projection)!==null&&_layer$projection!==void 0?_layer$projection:_this.props.map.projection;queryFeature.displayname=queryFeature.properties.name||queryFeature.properties.Name||queryFeature.properties.NAME||queryFeature.properties.label||queryFeature.properties.id||queryFeature.id;queryFeature.layertitle=layer.title||layer.name||layer.id;queryFeature.properties=Object.entries(queryFeature.properties).reduce(function(res,_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],val=_ref2[1];return _objectSpread(_objectSpread({},res),{},_defineProperty({},key,_typeof(val)==="object"?JSON.stringify(val):val))},{});identifyResults[layer.name].push(queryFeature)}})}_this.props.addMarker("identify",clickPoint,"",_this.props.map.projection);return{identifyResults:identifyResults,pendingRequests:pendingRequests}})}});_defineProperty(_this,"queryPoint",function(prevProps){if(_this.props.click.button!==0||_this.props.click===prevProps.click||(_this.props.click.features||[]).find(function(feature){return feature.id==="startupposmarker"})){return null}var searchMarker=(_this.props.click.features||[]).find(function(feature){return feature.id==="searchmarker"});if(searchMarker&&searchMarker.geometry.type==="Point"){return searchMarker.geometry.coordinates}return _this.props.click.coordinate});_defineProperty(_this,"identifyRegion",function(){var queryableLayers=IdentifyUtils.getQueryLayers(_this.props.layers,_this.props.map);var poly=_this.state.filterGeom.coordinates[0];if(poly.length<3||isEmpty(queryableLayers)){return}var identifyResults=_this.state.filterGeomModifiers.ctrl!==true?{}:_this.state.identifyResults;var center=[0,0];poly.forEach(function(point){center[0]+=point[0];center[1]+=point[1]});center[0]/=poly.length;center[1]/=poly.length;var filter=VectorLayerUtils.geoJSONGeomToWkt(_this.state.filterGeom);var pendingRequests=0;var params=_objectSpread({},_this.props.params);if(_this.props.params.region_feature_count){params.feature_count=_this.props.params.region_feature_count;delete params.region_feature_count}queryableLayers.forEach(function(layer){var request=IdentifyUtils.buildFilterRequest(layer,layer.queryLayers.join(","),filter,_this.props.map,params);++pendingRequests;IdentifyUtils.sendRequest(request,function(response){_this.setState(function(state){return{pendingRequests:state.pendingRequests-1}});if(response){_this.parseResult(response,layer,request.params.info_format,center)}});_this.setState({identifyResults:identifyResults,pendingRequests:pendingRequests})})});_defineProperty(_this,"identifyRadius",function(){var clickPoint=_this.state.filterGeom.center;var queryableLayers=IdentifyUtils.getQueryLayers(_this.props.layers,_this.props.map);if(isEmpty(queryableLayers)){return}var identifyResults=_this.state.filterGeomModifiers.ctrl!==true?{}:_this.state.identifyResults;var filter=VectorLayerUtils.geoJSONGeomToWkt(_this.state.filterGeom);var pendingRequests=0;var params=_objectSpread({},_this.props.params);if(_this.props.params.radius_feature_count){params.feature_count=_this.props.params.radius_feature_count;delete params.radius_feature_count}queryableLayers.forEach(function(layer){var request=IdentifyUtils.buildFilterRequest(layer,layer.queryLayers.join(","),filter,_this.props.map,params);++pendingRequests;IdentifyUtils.sendRequest(request,function(response){_this.setState(function(state){return{pendingRequests:state.pendingRequests-1}});if(response){_this.parseResult(response,layer,request.params.info_format,clickPoint)}});_this.setState({identifyResults:identifyResults,pendingRequests:pendingRequests})});_this.props.addMarker("identify",clickPoint,"",_this.props.map.projection)});_defineProperty(_this,"changeBufferUnit",function(ev){_this.setState({radiusUnits:ev.target.value})});_defineProperty(_this,"parseResult",function(response,layer,format,clickPoint){var newResults=IdentifyUtils.parseResponse(response,layer,format,clickPoint,_this.props.map.projection,_this.props.featureInfoReturnsLayerName);// Merge with previous
18
- _this.setState(function(state){var identifyResults=_objectSpread({},state.identifyResults);Object.entries(newResults).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),layername=_ref4[0],features=_ref4[1];var key=layer.url+"#"+layername;identifyResults[key]=features.reduce(function(result,feature){if(result.find(function(f){return f.id===feature.id})===undefined){result.push(feature)}return result},identifyResults[key]||[])});return{identifyResults:identifyResults}})});_defineProperty(_this,"onShow",function(mode,data){_this.setState({mode:mode||"Point",exitTaskOnResultsClose:data===null||data===void 0?void 0:data.exitTaskOnResultsClose});if(mode==="Point"&&data!==null&&data!==void 0&&data.pos){_this.identifyPoint(data.pos)}});_defineProperty(_this,"onToolClose",function(){_this.setState({mode:"Point",exitTaskOnResultsClose:null,filterGeom:null});if(_this.props.clearResultsOnClose){_this.clearResults()}});_defineProperty(_this,"onWindowClose",function(){_this.clearResults();if(_this.state.exitTaskOnResultsClose||_this.props.exitTaskOnResultsClose){_this.props.setCurrentTask(null)}});_defineProperty(_this,"clearResults",function(){_this.props.removeMarker("identify");_this.props.removeLayer("identifyslection");_this.props.removeLayer("identifyradiusbuffer");_this.setState({identifyResults:null,pendingRequests:0})});_defineProperty(_this,"updateRadius",function(radius,units){_this.setState(function(state){return{radius:radius,radiusUnits:units,filterGeom:_objectSpread(_objectSpread({},state.filterGeom),{},{radius:MeasureUtils.convertLength(radius,units,"m")})}})});_defineProperty(_this,"renderBody",function(){if(_this.state.mode==="Point"){return LocaleUtils.tr("infotool.clickhelpPoint")}else if(_this.state.mode==="Region"){return LocaleUtils.tr("infotool.clickhelpPolygon")}else if(_this.state.mode==="Radius"){var text=LocaleUtils.tr("infotool.clickhelpRadius");return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("div",null,text),/*#__PURE__*/React.createElement("div",{className:"identify-radius-controls controlgroup"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("infotool.radius"),":\xA0"),/*#__PURE__*/React.createElement(NumberInput,{disabled:!_this.state.filterGeom,max:1000000,min:1,mobile:true,onChange:function onChange(rad){return _this.updateRadius(rad,_this.state.radiusUnits)},value:_this.state.radius}),/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateRadius(_this.state.radius,ev.target.value)},value:_this.state.radiusUnits},/*#__PURE__*/React.createElement("option",{value:"m"},"m"),/*#__PURE__*/React.createElement("option",{value:"ft"},"ft"),/*#__PURE__*/React.createElement("option",{value:"km"},"km"),/*#__PURE__*/React.createElement("option",{value:"mi"},"mi"))))}return null});return _this}_inherits(Identify,_React$Component);return _createClass(Identify,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.enabled&&this.props.theme&&!prevProps.theme){var startupParams=this.props.startupParams;var haveIc=["1","true"].includes((startupParams.ic||"").toLowerCase());var c=(startupParams.c||"").split(/[;,]/g).map(function(x){return parseFloat(x)||0});if(haveIc&&c.length===2){var mapCrs=this.props.theme.mapCrs;this.identifyPoint(CoordinatesUtils.reproject(c,startupParams.crs||mapCrs,mapCrs))}}else if(this.props.theme!==prevProps.theme){this.clearResults()}else if(!this.props.enabled&&prevProps.enabled){if(this.props.clearResultsOnClose){this.clearResults()}}if(this.props.enabled){if(this.state.mode==="Point"){var clickPoint=this.queryPoint(prevProps);this.identifyPoint(clickPoint)}else if(this.state.mode==="Region"){if(this.state.filterGeom&&this.state.filterGeom!==prevState.filterGeom){this.identifyRegion()}}else if(this.state.mode==="Radius"){if(this.state.filterGeom&&this.state.filterGeom!==prevState.filterGeom){this.setState(function(state){return{radius:MeasureUtils.convertLength(state.filterGeom.radius,"m",state.radiusUnits)}});this.identifyRadius()}}}}},{key:"render",value:function render(){var _this2=this;var resultWindow=null;if(this.state.pendingRequests>0||this.state.identifyResults!==null){var body=null;if(isEmpty(this.state.identifyResults)){if(this.state.pendingRequests>0){body=/*#__PURE__*/React.createElement("div",{className:"identify-body",role:"body"},/*#__PURE__*/React.createElement("span",{className:"identify-body-message"},LocaleUtils.tr("identify.querying")))}else{body=/*#__PURE__*/React.createElement("div",{className:"identify-body",role:"body"},/*#__PURE__*/React.createElement("span",{className:"identify-body-message"},LocaleUtils.tr("identify.noresults")))}}else{body=/*#__PURE__*/React.createElement(IdentifyViewer,{attributeCalculator:this.props.attributeCalculator,attributeTransform:this.props.attributeTransform,customExporters:this.props.customExporters,displayResultTree:this.props.displayResultTree,enableAggregatedReports:this.props.enableAggregatedReports,enableExport:this.props.enableExport,exportGeometry:this.props.exportGeometry,highlightAllResults:this.props.highlightAllResults,identifyResults:this.state.identifyResults,iframeDialogsInitiallyDocked:this.props.iframeDialogsInitiallyDocked,longAttributesDisplay:this.props.longAttributesDisplay,replaceImageUrls:this.props.replaceImageUrls,role:"body",showLayerSelector:this.props.showLayerSelector})}resultWindow=/*#__PURE__*/React.createElement(ResizeableWindow,{busyIcon:this.state.pendingRequests>0,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,key:"IdentifyWindow",onClose:this.onWindowClose,title:LocaleUtils.tr("identify.title")},body)}return[resultWindow,/*#__PURE__*/React.createElement(TaskBar,{key:"IdentifyTaskBar",onHide:this.onToolClose,onShow:this.onShow,task:"Identify"},function(){return{body:_this2.renderBody()}}),this.state.mode==="Region"||this.state.mode==="Radius"?/*#__PURE__*/React.createElement(MapSelection,{active:true,geomType:this.state.mode==="Radius"?"Circle":"Polygon",geometry:this.state.filterGeom,geometryChanged:function geometryChanged(geom,mod){return _this2.setState({filterGeom:geom,filterGeomModifiers:mod})},key:"MapSelection",measure:this.state.mode==="Radius"}):null]}}])}(React.Component);_defineProperty(Identify,"propTypes",{addLayerFeatures:PropTypes.func,addMarker:PropTypes.func,/** Optional function for computing derived attributes. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */attributeCalculator:PropTypes.func,/** Optional function for transforming attribute values. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */attributeTransform:PropTypes.func,/** Whether to clear the identify results when exiting the identify tool. */clearResultsOnClose:PropTypes.bool,click:PropTypes.object,currentIdentifyTool:PropTypes.string,currentTask:PropTypes.string,/** Optional list of custom exporters to offer along with the built-in exporters. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */customExporters:PropTypes.array,/** Whether to display a tree overview of results (as opposed to a flat list of results). */displayResultTree:PropTypes.bool,/** Whether to enable the aggregated report download button. */enableAggregatedReports:PropTypes.bool,/** Whether to enable the export functionality. Either `true|false` or a list of single allowed formats (builtin formats: `json`, `geojson`, `csv`, `csvzip`) */enableExport:PropTypes.oneOfType([PropTypes.bool,PropTypes.array]),enabled:PropTypes.bool,/** Whether to clear the task when the results window is closed. */exitTaskOnResultsClose:PropTypes.bool,/** Whether to include the geometry in exported features. Default: `true`. */exportGeometry:PropTypes.bool,/** Whether to assume that XML GetFeatureInfo responses specify the technical layer name in the `name` attribute, rather than the layer title. */featureInfoReturnsLayerName: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}),/** Whether to highlight all results if no result is hovered */highlightAllResults:PropTypes.bool,iframeDialogsInitiallyDocked:PropTypes.bool,/** The initial radius units of the identify dialog in radius mode. One of 'm', 'ft', 'km', 'mi'. */initialRadiusUnits:PropTypes.string,layers:PropTypes.array,longAttributesDisplay:PropTypes.string,map:PropTypes.object,/** Extra params to append to the GetFeatureInfo request (i.e. `FI_POINT_TOLERANCE`, `FI_LINE_TOLERANCE`, `feature_count`, ...). Additionally, `region_feature_count` and `radius_feature_count` are supported. */params:PropTypes.object,removeLayer:PropTypes.func,removeMarker:PropTypes.func,/** Whether to replace an attribute value containing an URL to an image with an inline image. */replaceImageUrls:PropTypes.bool,selection:PropTypes.object,setCurrentTask:PropTypes.func,/** Whether to show a layer selector to filter the identify results by layer. */showLayerSelector:PropTypes.bool,startupParams:PropTypes.object,theme:PropTypes.object});_defineProperty(Identify,"defaultProps",{enableAggregatedReports:true,enableExport:true,exportGeometry:true,clearResultsOnClose:true,customExporters:[],longAttributesDisplay:"ellipsis",displayResultTree:true,replaceImageUrls:true,featureInfoReturnsLayerName:true,geometry:{initialWidth:240,initialHeight:320,initialX:0,initialY:0,initiallyDocked:false,side:"left"},initialRadiusUnits:"m",highlightAllResults:true,showLayerSelector:true});export default connect(function(state){var enabled=state.task.id==="Identify"||state.task.identifyEnabled&&ConfigUtils.getConfigProp("identifyTool",state.theme.current,"Identify")==="Identify";return{click:state.map.click||{modifiers:{}},enabled:enabled,layers:state.layers.flat,map:state.map,selection:state.selection,theme:state.theme.current,startupParams:state.localConfig.startupParams}},{addLayerFeatures:addLayerFeatures,addMarker:addMarker,removeMarker:removeMarker,removeLayer:removeLayer,setCurrentTask:setCurrentTask})(Identify);
18
+ _this.setState(function(state){var identifyResults=_objectSpread({},state.identifyResults);Object.entries(newResults).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),layername=_ref4[0],features=_ref4[1];var key=layer.url+"#"+layername;identifyResults[key]=features.reduce(function(result,feature){if(result.find(function(f){return f.id===feature.id})===undefined){result.push(feature)}return result},identifyResults[key]||[])});return{identifyResults:identifyResults}})});_defineProperty(_this,"onShow",function(mode,data){_this.setState({mode:mode||"Point",exitTaskOnResultsClose:data===null||data===void 0?void 0:data.exitTaskOnResultsClose});if(mode==="Point"&&data!==null&&data!==void 0&&data.pos){_this.identifyPoint(data.pos)}});_defineProperty(_this,"onToolClose",function(){_this.setState({mode:"Point",exitTaskOnResultsClose:null,filterGeom:null});if(_this.props.clearResultsOnClose){_this.clearResults()}});_defineProperty(_this,"onWindowClose",function(){_this.clearResults();if(_this.state.exitTaskOnResultsClose||_this.props.exitTaskOnResultsClose){_this.props.setCurrentTask(null)}});_defineProperty(_this,"clearResults",function(){_this.props.removeMarker("identify");_this.props.removeLayer("identifyslection");_this.props.removeLayer("identifyradiusbuffer");_this.setState({identifyResults:null,pendingRequests:0})});_defineProperty(_this,"updateRadius",function(radius,units){_this.setState(function(state){return{radius:radius,radiusUnits:units,filterGeom:_objectSpread(_objectSpread({},state.filterGeom),{},{radius:MeasureUtils.convertLength(radius,units,"m")})}})});_defineProperty(_this,"renderBody",function(){if(_this.state.mode==="Point"){return LocaleUtils.tr("infotool.clickhelpPoint")}else if(_this.state.mode==="Region"){return LocaleUtils.tr("infotool.clickhelpPolygon")}else if(_this.state.mode==="Radius"){var text=LocaleUtils.tr("infotool.clickhelpRadius");return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("div",null,text),/*#__PURE__*/React.createElement("div",{className:"identify-radius-controls controlgroup"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("infotool.radius"),":\xA0"),/*#__PURE__*/React.createElement(NumberInput,{disabled:!_this.state.filterGeom,max:1000000,min:1,mobile:true,onChange:function onChange(rad){return _this.updateRadius(rad,_this.state.radiusUnits)},value:_this.state.radius}),/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateRadius(_this.state.radius,ev.target.value)},value:_this.state.radiusUnits},/*#__PURE__*/React.createElement("option",{value:"m"},"m"),/*#__PURE__*/React.createElement("option",{value:"ft"},"ft"),/*#__PURE__*/React.createElement("option",{value:"km"},"km"),/*#__PURE__*/React.createElement("option",{value:"mi"},"mi"))))}return null});return _this}_inherits(Identify,_React$Component);return _createClass(Identify,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.enabled&&this.props.theme&&!prevProps.theme){var startupParams=this.props.startupParams;var haveIc=["1","true"].includes((startupParams.ic||"").toLowerCase());var c=(startupParams.c||"").split(/[;,]/g).map(function(x){return parseFloat(x)||0});if(haveIc&&c.length===2){var mapCrs=this.props.theme.mapCrs;this.identifyPoint(CoordinatesUtils.reproject(c,startupParams.crs||mapCrs,mapCrs))}}else if(this.props.theme!==prevProps.theme){this.clearResults()}else if(!this.props.enabled&&prevProps.enabled){if(this.props.clearResultsOnClose){this.clearResults()}}if(this.props.enabled){if(this.state.mode==="Point"){var clickPoint=this.queryPoint(prevProps);this.identifyPoint(clickPoint)}else if(this.state.mode==="Region"){if(this.state.filterGeom&&this.state.filterGeom!==prevState.filterGeom){this.identifyRegion()}}else if(this.state.mode==="Radius"){if(this.state.filterGeom&&this.state.filterGeom!==prevState.filterGeom){this.setState(function(state){return{radius:MeasureUtils.convertLength(state.filterGeom.radius,"m",state.radiusUnits)}});this.identifyRadius()}}}}},{key:"render",value:function render(){var _this2=this;var resultWindow=null;if(this.state.pendingRequests>0||this.state.identifyResults!==null){var body=null;if(isEmpty(this.state.identifyResults)){if(this.state.pendingRequests>0){body=/*#__PURE__*/React.createElement("div",{className:"identify-body",role:"body"},/*#__PURE__*/React.createElement("span",{className:"identify-body-message"},LocaleUtils.tr("identify.querying")))}else{body=/*#__PURE__*/React.createElement("div",{className:"identify-body",role:"body"},/*#__PURE__*/React.createElement("span",{className:"identify-body-message"},LocaleUtils.tr("identify.noresults")))}}else{body=/*#__PURE__*/React.createElement(IdentifyViewer,{attributeCalculator:this.props.attributeCalculator,attributeTransform:this.props.attributeTransform,customExporters:this.props.customExporters,displayResultTree:this.props.displayResultTree,enableAggregatedReports:this.props.enableAggregatedReports,enableExport:this.props.enableExport,exportGeometry:this.props.exportGeometry,highlightAllResults:this.props.highlightAllResults,identifyResults:this.state.identifyResults,iframeDialogsInitiallyDocked:this.props.iframeDialogsInitiallyDocked,longAttributesDisplay:this.props.longAttributesDisplay,replaceImageUrls:this.props.replaceImageUrls,role:"body",showLayerSelector:this.props.showLayerSelector})}resultWindow=/*#__PURE__*/React.createElement(ResizeableWindow,{busyIcon:this.state.pendingRequests>0,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,key:"IdentifyWindow",onClose:this.onWindowClose,title:LocaleUtils.tr("identify.title")},body)}return[resultWindow,/*#__PURE__*/React.createElement(TaskBar,{key:"IdentifyTaskBar",onHide:this.onToolClose,onShow:this.onShow,task:"Identify"},function(){return{body:_this2.renderBody()}}),this.state.mode==="Region"||this.state.mode==="Radius"?/*#__PURE__*/React.createElement(MapSelection,{active:true,geomType:this.state.mode==="Radius"?"Circle":"Polygon",geometry:this.state.filterGeom,geometryChanged:function geometryChanged(geom,mod){return _this2.setState({filterGeom:geom,filterGeomModifiers:mod})},key:"MapSelection",measure:this.state.mode==="Radius"}):null]}}])}(React.Component);_defineProperty(Identify,"propTypes",{addLayerFeatures:PropTypes.func,addMarker:PropTypes.func,/** Optional function for computing derived attributes. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */attributeCalculator:PropTypes.func,/** Optional function for transforming attribute values. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */attributeTransform:PropTypes.func,/** Whether to clear the identify results when exiting the identify tool. */clearResultsOnClose:PropTypes.bool,click:PropTypes.object,currentIdentifyTool:PropTypes.string,currentTask:PropTypes.string,/** Optional list of custom exporters to offer along with the built-in exporters. See js/IdentifyExtensions.js for details. This prop can be specified in the appConfig.js cfg section. */customExporters:PropTypes.array,/** Whether to display a tree overview of results (as opposed to a flat list of results). */displayResultTree:PropTypes.bool,/** Whether to enable the aggregated report download button. */enableAggregatedReports:PropTypes.bool,/** Whether to enable the export functionality. Either `true|false` or a list of single allowed formats (builtin formats: `json`, `geojson`, `csv`, `csvzip`, `shapefile`, `xlsx`). If a list is provided, the export formats will be sorted according to that list, and the default format will be the first format of the list. */enableExport:PropTypes.oneOfType([PropTypes.bool,PropTypes.array]),enabled:PropTypes.bool,/** Whether to clear the task when the results window is closed. */exitTaskOnResultsClose:PropTypes.bool,/** Whether to include the geometry in exported features. Default: `true`. */exportGeometry:PropTypes.bool,/** Whether to assume that XML GetFeatureInfo responses specify the technical layer name in the `name` attribute, rather than the layer title. */featureInfoReturnsLayerName: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}),/** Whether to highlight all results if no result is hovered */highlightAllResults:PropTypes.bool,iframeDialogsInitiallyDocked:PropTypes.bool,/** The initial radius units of the identify dialog in radius mode. One of 'm', 'ft', 'km', 'mi'. */initialRadiusUnits:PropTypes.string,layers:PropTypes.array,longAttributesDisplay:PropTypes.string,map:PropTypes.object,/** Extra params to append to the GetFeatureInfo request (i.e. `FI_POINT_TOLERANCE`, `FI_LINE_TOLERANCE`, `feature_count`, ...). Additionally, `region_feature_count` and `radius_feature_count` are supported. */params:PropTypes.object,removeLayer:PropTypes.func,removeMarker:PropTypes.func,/** Whether to replace an attribute value containing an URL to an image with an inline image. */replaceImageUrls:PropTypes.bool,selection:PropTypes.object,setCurrentTask:PropTypes.func,/** Whether to show a layer selector to filter the identify results by layer. */showLayerSelector:PropTypes.bool,startupParams:PropTypes.object,theme:PropTypes.object});_defineProperty(Identify,"defaultProps",{enableAggregatedReports:true,enableExport:true,exportGeometry:true,clearResultsOnClose:true,customExporters:[],longAttributesDisplay:"ellipsis",displayResultTree:true,replaceImageUrls:true,featureInfoReturnsLayerName:true,geometry:{initialWidth:240,initialHeight:320,initialX:0,initialY:0,initiallyDocked:false,side:"left"},initialRadiusUnits:"m",highlightAllResults:true,showLayerSelector:true});export default connect(function(state){var enabled=state.task.id==="Identify"||state.task.identifyEnabled&&ConfigUtils.getConfigProp("identifyTool",state.theme.current,"Identify")==="Identify";return{click:state.map.click||{modifiers:{}},enabled:enabled,layers:state.layers.flat,map:state.map,selection:state.selection,theme:state.theme.current,startupParams:state.localConfig.startupParams}},{addLayerFeatures:addLayerFeatures,addMarker:addMarker,removeMarker:removeMarker,removeLayer:removeLayer,setCurrentTask:setCurrentTask})(Identify);
package/plugins/View3D.js CHANGED
@@ -19,4 +19,4 @@ if(this.props.view3dMode!==prevProps.view3dMode){if(this.props.view3dMode===View
19
19
  if(this.props.theme.current!==prevProps.theme.current&&!((_this$props$theme$cur=this.props.theme.current)!==null&&_this$props$theme$cur!==void 0&&_this$props$theme$cur.map3d)&&this.props.view3dMode!==View3DMode.DISABLED){this.props.setView3dMode(View3D.DISABLED)}// Lock views
20
20
  if(this.state.viewsLocked&&this.props.map.bbox!==prevProps.map.bbox&&this.focusedMap==="map"){this.sync2DExtent()}// Clear stored state when switching away from a theme
21
21
  if(prevProps.theme.current&&this.props.theme.current!==prevProps.theme.current){this.setState({storedState:null})}}},{key:"syncParentStore",value:function syncParentStore(prevProps){var force=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(this.props.view3dMode===View3DMode.DISABLED){return}if(this.props.display!==prevProps.display||force){this.store.dispatch({type:"SYNC_DISPLAY_FROM_PARENT_STORE",display:this.props.display})}if(this.props.theme!==prevProps.theme||force){this.store.dispatch({type:"SYNC_THEME_FROM_PARENT_STORE",theme:this.props.theme})}if(this.props.localConfig!==prevProps.localConfig||force){this.store.dispatch({type:"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE",localConfig:this.props.localConfig})}if(this.props.layers!==prevProps.layers||force){this.store.dispatch({type:"SYNC_LAYERS_FROM_PARENT_STORE",layers:this.props.layers})}if(this.props.map!==prevProps.map||force){this.store.dispatch({type:"SYNC_MAP_FROM_PARENT_STORE",map:this.props.map})}}},{key:"render",value:function render(){var _this$props$theme$cur2;var button=(_this$props$theme$cur2=this.props.theme.current)!==null&&_this$props$theme$cur2!==void 0&&_this$props$theme$cur2.map3d?/*#__PURE__*/React.createElement(View3DSwitcher,{key:"View3DButton",position:this.props.buttonPosition}):null;return[button,this.render3DWindow()]}}])}(React.Component);_defineProperty(View3D,"propTypes",{addLayerFeatures:PropTypes.func,/** The position slot index of the 3d switch map button, from the bottom (0: bottom slot). */buttonPosition:PropTypes.number,/** The position of the navigation controls. Either `top` or `bottom`. */controlsPosition:PropTypes.string,/** The default scene quality factor (`20`: min, `100`: max). */defaultSceneQuality:PropTypes.number,display:PropTypes.object,/** Default window geometry. */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool}),layers:PropTypes.object,localConfig:PropTypes.object,map:PropTypes.object,/** Mouse buttons assignment. You can assign `pan`, `rotate`, `zoom` to each button. */mouseButtons:PropTypes.shape({left:PropTypes.string,middle:PropTypes.string,right:PropTypes.string}),panTo:PropTypes.func,/** Options to pass to the 3D plugins, in the form `{"<PluginName>": {<options>}}`.
22
- * Refer to the documentation of the <a href="#plugins3d">3D plugins</a> for settable options. */pluginOptions:PropTypes.object,plugins3d:PropTypes.object,removeLayer:PropTypes.func,searchProviders:PropTypes.object,setView3dMode:PropTypes.func,startupParams:PropTypes.object,startupState:PropTypes.object,theme:PropTypes.object,view3dMode:PropTypes.number,zoomToPoint:PropTypes.func});_defineProperty(View3D,"defaultProps",{buttonPosition:6,controlsPosition:"top",geometry:{initialWidth:600,initialHeight:800,initialX:0,initialY:0,initiallyDocked:true},pluginOptions:{},mouseButtons:{left:"pan",middle:"zoom",right:"rotate"}});export default(function(plugins3d){return connect(function(state){return{plugins3d:plugins3d,display:state.display,map:state.map,layers:state.layers,theme:state.theme,localConfig:state.localConfig,view3dMode:state.display.view3dMode,startupParams:state.localConfig.startupParams,startupState:state.localConfig.startupState}},{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,panTo:panTo,zoomToPoint:zoomToPoint,setView3dMode:setView3dMode})(View3D)});
22
+ * Refer to the documentation of the <a href="#plugins3d">3D plugins</a> for settable options. */pluginOptions:PropTypes.object,plugins3d:PropTypes.object,removeLayer:PropTypes.func,searchProviders:PropTypes.object,setView3dMode:PropTypes.func,startupParams:PropTypes.object,startupState:PropTypes.object,theme:PropTypes.object,view3dMode:PropTypes.number,zoomToPoint:PropTypes.func});_defineProperty(View3D,"defaultProps",{buttonPosition:6,controlsPosition:"top",defaultSceneQuality:100,geometry:{initialWidth:600,initialHeight:800,initialX:0,initialY:0,initiallyDocked:true},pluginOptions:{},mouseButtons:{left:"pan",middle:"zoom",right:"rotate"}});export default(function(plugins3d){return connect(function(state){return{plugins3d:plugins3d,display:state.display,map:state.map,layers:state.layers,theme:state.theme,localConfig:state.localConfig,view3dMode:state.display.view3dMode,startupParams:state.localConfig.startupParams,startupState:state.localConfig.startupState}},{addLayerFeatures:addLayerFeatures,removeLayer:removeLayer,panTo:panTo,zoomToPoint:zoomToPoint,setView3dMode:setView3dMode})(View3D)});