@geoscene/core 4.34.9 → 4.34.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +18 -18
- package/analysis/ViewshedVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
- package/assets/geoscene/core/workers/chunks/0f735b0dec173142f3b6.js +1 -1
- package/assets/geoscene/core/workers/chunks/3a457e718a901a45902e.js +1 -1
- package/assets/geoscene/core/workers/chunks/49571d6875de1f2e7e25.js +32 -32
- package/assets/geoscene/core/workers/chunks/7565b382f6b3d2cb46a3.js +1 -1
- package/assets/geoscene/core/workers/chunks/9ff8ee6ed6b98c03ae7e.js +1 -1
- package/assets/geoscene/core/workers/chunks/aa78b69219d9a0ef1c54.js +1 -1
- package/assets/geoscene/core/workers/chunks/ce16489cf7eb0d78c741.js +1 -1
- package/assets/geoscene/core/workers/chunks/d6e0528eacee7ea4c1ce.js +1 -1
- package/assets/geoscene/core/workers/chunks/f651c05604eab83aef5f.js +1 -1
- package/bundle/lib/fflate.js +12 -0
- package/copyright.txt +1654 -1654
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
- package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
- package/layers/voxel/drill/common.js +5 -0
- package/package.json +30 -30
- package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/ViewshedLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
- package/views/draw/expert/AttackArrowDrawer.js +5 -0
- package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
- package/views/draw/expert/BaseDrawer.js +5 -0
- package/views/draw/expert/Constant.js +5 -0
- package/views/draw/expert/CurveDrawer.js +5 -0
- package/views/draw/expert/CurveFlagDrawer.js +5 -0
- package/views/draw/expert/CurvedArrowDrawer.js +5 -0
- package/views/draw/expert/EllipseDrawer.js +5 -0
- package/views/draw/expert/ExpertDraw.js +5 -0
- package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
- package/views/draw/expert/LuneDrawer.js +5 -0
- package/views/draw/expert/PincerArrowDrawer.js +5 -0
- package/views/draw/expert/SectorDrawer.js +5 -0
- package/views/draw/expert/SquadCombatDrawer.js +5 -0
- package/views/draw/expert/StraightArrowDrawer.js +5 -0
- package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
- package/views/draw/expert/plot/Constants.js +5 -0
- package/views/draw/expert/plot/PlotTypes.js +5 -0
- package/views/draw/expert/plot/plots/Arc.js +41 -0
- package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
- package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/Circle.js +5 -0
- package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
- package/views/draw/expert/plot/plots/Curve.js +5 -0
- package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
- package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
- package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
- package/views/draw/expert/plot/plots/Ellipse.js +5 -0
- package/views/draw/expert/plot/plots/FineArrow.js +5 -0
- package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
- package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
- package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
- package/views/draw/expert/plot/plots/Lune.js +5 -0
- package/views/draw/expert/plot/plots/Marker.js +16 -0
- package/views/draw/expert/plot/plots/Plot.js +5 -0
- package/views/draw/expert/plot/plots/Polygon.js +18 -0
- package/views/draw/expert/plot/plots/Polyline.js +19 -0
- package/views/draw/expert/plot/plots/Rectangle.js +28 -0
- package/views/draw/expert/plot/plots/Sector.js +5 -0
- package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
- package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
- package/views/draw/expert/plot/utils/plot_util.js +5 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});try{const decryptEnabled=this.decrypt?.enabled??true;if(decryptEnabled&&this.decrypt?.url){this._decodeData=await t(this.decrypt?.url,{query:{},responseType:"json"})}}catch(error){console.log(error)}if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type"${U}"`);await this._ensureLoadBeforeSave();const o=I(this.portalItem,"portal-item",!0),i={layers:[this.write({},o)]};return await Promise.all(o.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.url&&(this.portalItem.url=this.url),this.portalItem.title||(this.portalItem.title=this.title),T(this.portalItem,t,0),await b(this.portalItem,i,this.resourceReferences,o),l(o),this.portalItem}async _validateAgainstJSONSchema(e,t,i){const s=i?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,i.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(o.getLogger(this).error(`_validateAgainstJSONSchema():${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(y)],E.prototype,"id",void 0),e([s({type:d})],E.prototype,"spatialReference",void 0),e([a("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:p})],E.prototype,"fullExtent",void 0),e([a("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:c})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([a("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([a("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([a("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([n("geoscene.layers.mixins.SceneService")],E),E},R=-1e38;function L(e){if(null!=e.spatialReference)return d.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=o?new d(o):null}function O(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<R)return;const o=t.halfSize,i=t.center[2],s=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]);e.zmin=i-s,e.zmax=i+s}function T(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};export{_ as SceneService,U as sceneServiceItemType,O as updateExtentFromPageObb};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue,useCanvas: r.tileInfo?.format === "TerrainDEM"});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
|
|
5
|
+
import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;o==="webp"&&(m.width=c,m.height=h),m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import{load as p,decode as d}from"./Qb3.js";import u from"./Raw.js";import{decodeTileOrStrip as f,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as g}from"./utils.js";var w=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,b,x,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),c=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif"]);async function b(e,s){if(!g)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:f,pixels:m,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:m,mask:w,statistics:p.map(({minValue:t,maxValue:e})=>new i(t,e)),bandMasks:f,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function x(e,i){await p();const s=d(e);if(!s)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:r,height:n,pixels:o}=s,h=new a({width:r,height:n,pixelType:"u16",pixels:o});return h.updateStatistics(),h}async function k(t,i){const s=await m(t,{...i,noDataValue:i.tiffNoDataValue,matchAllNoData:i.matchAllNoData});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function T(t,e){const i=await f(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function C(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function I(t,e){return C(new l(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,i){const{pixelTypeCtor:s}=P(e.pixelType),r=(0,u.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function D(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const i=new Uint8Array(t),s=new w(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function S(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=b;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=x;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return T(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=j(e)),i.useCanvas&&y.has(r))return S(e,r,i,s);const n=O(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map((t,a)=>n(e.slice(t,h[a+1]),i)),s=await Promise.all(t);o=s[0],o.pixels=s.map(t=>t.pixels[0]);const r=s.map(t=>t.mask);s.some(t=>null!=t)&&(r.forEach((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))}),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&M(o),o}export{R as decode,L as getFormat};
|
|
5
|
+
import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import{load as p,decode as d}from"./Qb3.js";import u from"./Raw.js";import{decodeTileOrStrip as f,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as g}from"./utils.js";var w=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,b,x,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),c=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif","webp"]);async function b(e,s){if(!g)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:f,pixels:m,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:m,mask:w,statistics:p.map(({minValue:t,maxValue:e})=>new i(t,e)),bandMasks:f,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function x(e,i){await p();const s=d(e);if(!s)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:r,height:n,pixels:o}=s,h=new a({width:r,height:n,pixelType:"u16",pixels:o});return h.updateStatistics(),h}async function k(t,i){const s=await m(t,{...i,noDataValue:i.tiffNoDataValue,matchAllNoData:i.matchAllNoData});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function T(t,e){const i=await f(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function C(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function I(t,e){return C(new l(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,i){const{pixelTypeCtor:s}=P(e.pixelType),r=(0,u.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function D(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const i=new Uint8Array(t),s=new w(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function S(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const headerLength = Math.min(e.byteLength, 12);const a = new Uint8Array(e, 0, headerLength);let i="";if (headerLength >= 12 && 82 === a[0] && 73 === a[1] && 70 === a[2] && 70 === a[3] && 87 === a[8] && 69 === a[9] && 66 === a[10] && 80 === a[11]) {return i = "webp";}return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=b;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=x;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return T(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=j(e)),i.useCanvas&&y.has(r))return S(e,r,i,s);const n=O(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map((t,a)=>n(e.slice(t,h[a+1]),i)),s=await Promise.all(t);o=s[0],o.pixels=s.map(t=>t.pixels[0]);const r=s.map(t=>t.mask);s.some(t=>null!=t)&&(r.forEach((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))}),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&M(o),o}export{R as decode,L as getFormat};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Point from'../../../geometry/Point.js';import MeshSymbol3D from'../../../symbols/MeshSymbol3D.js';import FillSymbol3DLayer from'../../../symbols/FillSymbol3DLayer.js';import GraphicsLayer from"../../../layers/GraphicsLayer.js";import GroupLayer from"../../../layers/GroupLayer.js";import VoxelSlice from"../../../layers/voxel/VoxelSlice.js";import TimeSlider from"../../../widgets/TimeSlider.js";import TimeExtent from"../../../time/TimeExtent.js";import{merge}from'../../../geometry/support/meshUtils.js';import Graphic from"../../../Graphic.js";import{GeometryCreator}from'./common.js';const CANVAS_SIZE=16*2;class VoxelContinuousDrill{constructor(optional){const config={currentVariableId:1,verticalExaggeration:1,fixedCylinderRadius:false,widthCylinder:20,depthCylinder:20,densificationFactor:1,drillType:'cylinder',...optional,offsetGraphicsLayer:{x:0,y:0,z:0,...optional.offsetGraphicsLayer}};const _drillData=config.drillData;if(!_drillData)throw new Error('请传入钻孔数据!');const _view=config.view;if(!_view)throw new Error('请传入 SceneView 对象!');const _vxlLayer=config.vxlLayer;if(!_vxlLayer)throw new Error('请传入体元图层!');const _map=_view.map;const{data,variable}=_drillData;if(!validArray(data)||!validArray(variable))throw new Error('数据格式不正确,或者数据为空!');Object.assign(this,{view:_view,map:_map,data_:data,_vxlLayer:_vxlLayer,variable,_currentVariableId:config.currentVariableId,_verticalExaggeration:config.verticalExaggeration,_drillType:config.drillType,fixedCylinderRadius:config.fixedCylinderRadius,widthCylinder:config.widthCylinder,depthCylinder:config.depthCylinder,densificationFactor:config.densificationFactor,offsetGraphicsLayer:config.offsetGraphicsLayer,});this._drillingGraphicsLayers=[];this._locationCylinders=[];this._timeSliderStops=[];this._colorAndValues={};this._originalZs=[];this._currentZs=[];this.cachedCanvas=null;this._heightCylinders=new Array(this.data_.length);this._heightOrigins=new Array(this.data_.length);this._originalFirstZs=[];this._gui=dat?new dat.GUI():null;this._timeSlider=null;this._meshSymbol3D=new MeshSymbol3D({symbolLayers:[new FillSymbol3DLayer({castShadows:false})]});this.initializeOriginalZs();this.createDrillLayers();this.bindAllControls()}initializeOriginalZs(){this.data_.forEach((item,index)=>{this._originalZs[index]=[...item.zs];this._currentZs[index]=[...item.zs];this._originalFirstZs[index]=item.zs[0];if(item.zs.length>=2){this._heightOrigins[index]=Math.abs(item.zs[1]-item.zs[0])}else{this._heightOrigins[index]=0}this._heightCylinders[index]=this._heightOrigins[index]})}createDrillLayers(){const{data_:drillData,map,_locationCylinders:locationPoints,_drillingGraphicsLayers:drillingLayers,_timeSliderStops:timeStops,}=this;if(!drillData?.length)throw new Error('Invalid drill data');if(!map)throw new Error('Map not initialized');const processDrillData=(item,index)=>{const{xy}=item;locationPoints[index]=new Point({spatialReference:this.view.spatialReference??map.spatialReference,x:xy[0],y:xy[1],z:this._currentZs[index][0]})};const createTimeSlice=(time,drillIndex,sliceIndex)=>{const date=new Date(time);return new GraphicsLayer({id:`graphicsLayer${drillIndex}${sliceIndex}`,visibilityTimeExtent:{start:date,end:date}})};drillData.forEach((drillItem,drillIndex)=>{processDrillData(drillItem,drillIndex);const timeLayers=new GroupLayer({id:`groupLayer${drillIndex}`,layers:Object.values(drillItem.volume).map((volumeItem,sliceIndex)=>{if(drillIndex===0){timeStops.push(new Date(volumeItem.time))}return createTimeSlice(volumeItem.time,drillIndex,sliceIndex)})});drillingLayers.push(timeLayers)});map.addMany(drillingLayers)}bindAllControls(){['bindTimeSlider','bindDrillLayerVisibilityToggle','bindDrillLayerOffsetToggle','bindLayerSliceToggle','bindDrillTypeToggle','bindVariableToggle','bindExaggerationToggle'].forEach(method=>this[method]())}createCylinderForGradient(zArray,drillIndex,voxelData){const{_locationCylinders:locations,_meshSymbol3D:symbol,fixedCylinderRadius,widthCylinder,depthCylinder,densificationFactor,verticalExaggeration,drillType,_heightCylinders:heights,_colorAndValues:colorMap}=this;if(!validArray(zArray)||!validArray(voxelData))return[];if(zArray.length!==voxelData.length)throw new Error('数据长度不匹配');const scale=fixedCylinderRadius?1:Math.max(1,Math.sqrt(verticalExaggeration));const width=widthCylinder*scale;const depth=depthCylinder*scale;const location=locations[drillIndex];const totalHeight=heights[drillIndex];if(!totalHeight||totalHeight<=0){console.warn(`钻孔${drillIndex}的高度无效:${totalHeight}`);return[]}const geometryCreator=GeometryCreator[drillType];console.time('createCylinderForGradient');const geometries=zArray.map((zValue,index)=>{location.z=zValue;const dataPoints=(index>0&&index<zArray.length-1)?[voxelData[index-1],voxelData[index]]:[voxelData[index]];const colors=dataPoints.map(value=>{const key=findClosestKey(colorMap,value);return colorMap.get(key)});this.cachedCanvas=this.cachedCanvas||document.createElement('canvas');let cachedCanvas=this.cachedCanvas;cachedCanvas.width=cachedCanvas.height=CANVAS_SIZE;let imageData;if(dataPoints.length===1||dataPoints[0]===dataPoints[1]){imageData=createLinearGradient(cachedCanvas,[colors[0]])}else{imageData=createLinearGradient(cachedCanvas,colors)}const material={colorTexture:{data:imageData,wrap:'clamp'}};return geometryCreator(location,{size:{height:totalHeight,width,depth},densificationFactor,material})});console.timeEnd('createCylinderForGradient');return new Graphic({geometry:merge(geometries),symbol})}updateVerticalData(){const{data_,verticalExaggeration,_vxlLayer,_heightOrigins,_originalZs,}=this;if(!verticalExaggeration){throw new Error('体元未渲染!');}const dataLength=data_.length;if(_vxlLayer){_vxlLayer.getVolumeStyle().verticalExaggeration=verticalExaggeration}if(!this._bottomZs){this._bottomZs=new Array(dataLength);this.data_.forEach((item,index)=>{const baseZ=this._originalZs[index][0];const height=this._heightOrigins[index];this._bottomZs[index]=baseZ-height/2})}for(let i=0;i<dataLength;i++){const originalZs=_originalZs[i];const bottomZ=this._bottomZs[i];const step=_heightOrigins[i]*verticalExaggeration;const initialValue=bottomZ+(step*0.5);const len=originalZs.length;this._currentZs[i]=[];let current=initialValue;for(let j=0;j<len;j++){this._currentZs[i][j]=current;current+=step}this._heightCylinders[i]=step;data_[i].zs=[...this._currentZs[i]]}}updateDrillingGraphics(){const{data_,variable,_drillingGraphicsLayers,stretchRange,currentVariableId,_currentZs,}=this;for(let i=0;i<_drillingGraphicsLayers.length;i++){const timeGraphicsLayers=_drillingGraphicsLayers[i];const currentData=data_[i];const currentVariableValue=variable[currentVariableId];timeGraphicsLayers.allLayers.forEach((graphicsLayer,index)=>{const zsData=_currentZs[i];const volumeData=currentData.volume[index];const variableData=volumeData[currentVariableValue];const normalizedData=normalizeArray(variableData,stretchRange);graphicsLayer.graphics=[this.createCylinderForGradient(zsData,i,normalizedData)]})}console.log('钻孔图形更新完成',_drillingGraphicsLayers)}updateSlices(voxelPosition){const{voxelSliceX,voxelSliceY,_vxlLayer,sliceXAxisSlider,sliceYAxisSlider,}=this;voxelSliceX.point=voxelPosition;voxelSliceY.point=voxelPosition;const sliceAxisSliders=[sliceXAxisSlider,sliceYAxisSlider];const voxelSlices=[voxelSliceX,voxelSliceY];function bindAxis(){for(let i=0;i<sliceAxisSliders.length;i++){const sliceAxisSlider=sliceAxisSliders[i];const xslc=voxelSlices[i];_vxlLayer.getVolumeStyle(null).slices.add(xslc);if(sliceAxisSlider){sliceAxisSlider.value=voxelPosition[i].toFixed(2);sliceAxisSlider.addEventListener("calciteSliderInput",function(){xslc.point[i]=sliceAxisSlider.value;xslc.point=xslc.point})}}}bindAxis()}render(pointObjectArray){const{view,}=this;const vxlLayer=this._vxlLayer;view.whenLayerView(vxlLayer).then(()=>{const vm=vxlLayer.getVolume();const vs=vxlLayer.getVariableStyle();const voxelPosition=validArray(pointObjectArray)&&vm.computeVoxelSpaceLocation(pointObjectArray.at(-1));this.updateSlices(voxelPosition);this._colorAndValues=new Map();if(vs.transferFunction){this.stretchRange=vs.transferFunction.stretchRange;const colorStops=vs.transferFunction.colorStops;colorStops.forEach((item)=>{this._colorAndValues.set(item.position,item.color)})}this.verticalExaggeration=vxlLayer.getVolumeStyle()?.verticalExaggeration;if(this.verticalExaggerationToggle){this.verticalExaggerationToggle.setValue(this.verticalExaggeration)}view.goTo({target:this._drillingGraphicsLayers,fov:35,tilt:78.3926687063094,heading:243.2677195416981,},{duration:1500})})}set drillType(drillType){this._drillType=drillType;this.updateDrillingGraphics()}get drillType(){return this._drillType}set currentVariableId(variableId){this._currentVariableId=variableId;this._vxlLayer.currentVariableId=this._currentVariableId;this.updateDrillingGraphics()}get currentVariableId(){return this._currentVariableId}set verticalExaggeration(value){this._verticalExaggeration=value;const startTime=performance.now();this.updateVerticalData();const endTime=performance.now();console.log(`垂直夸张更新执行时间:${endTime-startTime}ms`);this.updateDrillingGraphics()}get verticalExaggeration(){return this._verticalExaggeration}bindLayerSliceToggle(axis){axis={...axis,x:"sliceXAxisSlider",y:"sliceYAxisSlider",z:"sliceZAxisSlider",};this.sliceXAxisSlider=document.getElementById(axis.x);this.sliceYAxisSlider=document.getElementById(axis.y);this.sliceZAxisSlider=document.getElementById(axis.z);this.voxelSliceX=new VoxelSlice({orientation:270,tilt:90,point:[0,0,0]});this.voxelSliceY=new VoxelSlice({orientation:180,tilt:90,point:[0,0,0]});this.voxelSliceZ=new VoxelSlice({orientation:0,tilt:0,point:[0,0,0]})}bindDrillLayerOffsetToggle(){const{offsetGraphicsLayer,_drillingGraphicsLayers}=this;function offsetXY(val,lastOffset){for(let i=0;i<_drillingGraphicsLayers.length;i++){const timeGraphicsLayers=_drillingGraphicsLayers[i];timeGraphicsLayers.allLayers.forEach((graphicsLayer)=>{const graphics=graphicsLayer.graphics;graphics.forEach((graphic)=>{graphic.geometry.offset(...lastOffset);graphic.geometry.offset(...val)})})}}let lastOffsetX=0;let lastOffsetY=0;let lastOffsetZ=0;function changeEventX(val){offsetXY([val,0,0],[lastOffsetX,0,0]);lastOffsetX=-val}function changeEventY(val){offsetXY([0,val,0],[0,lastOffsetY,0]);lastOffsetY=-val}function changeEventZ(val){offsetXY([0,0,val],[0,0,lastOffsetZ]);lastOffsetZ=-val}this._gui?.add(offsetGraphicsLayer,'x',-100,100).name("调整x值").step(0.1).onFinishChange(changeEventX);this._gui?.add(offsetGraphicsLayer,'y',-100,100).name("调整y值").step(0.1).onFinishChange(changeEventY);this._gui?.add(offsetGraphicsLayer,'z',-100,1000).name("调整z值").step(1).onFinishChange(changeEventZ)}bindDrillLayerVisibilityToggle(id="layerVisibilityToggle"){const layerVisibilityToggle=document.getElementById(id);layerVisibilityToggle?.addEventListener("calciteSwitchChange",()=>{for(let i=0;i<this._drillingGraphicsLayers.length;i++){const timeGraphicsLayers=this._drillingGraphicsLayers[i];timeGraphicsLayers.visible=!timeGraphicsLayers.visible}})}bindTimeSlider(container="timeSlider"){const{_timeSliderStops:dates,view}=this;this._timeSlider=new TimeSlider({container,mode:"instant",timeVisible:true,playRate:2000,stops:{dates},loop:true,fullTimeExtent:new TimeExtent({start:dates[0],end:dates[dates.length-1]}),view});view.ui.add(this._timeSlider,"bottom-left")}bindVariableToggle(id="variableSelect"){const thisObject=this;const variableSelect=document.getElementById(id);if(variableSelect){for(let i=0;i<this.variable.length;++i){const vxlVariable={id:i,label:this.variable[i]};const item=document.createElement("calcite-option");item.setAttribute("label",vxlVariable.label);item.setAttribute("value",vxlVariable.id);if(i===thisObject.currentVariableId){item.selected=true}variableSelect.hidden=false;variableSelect.appendChild(item)}variableSelect.addEventListener("calciteSelectChange",function(){thisObject.currentVariableId=variableSelect.selectedOption.value})}}bindDrillTypeToggle(id="switchDrillTypeToggle"){const thisObject=this;const switchDrillTypeToggle=document.getElementById("switchDrillTypeToggle");switchDrillTypeToggle&&(switchDrillTypeToggle.disabled=false);switchDrillTypeToggle?.addEventListener("calciteSwitchChange",()=>{thisObject.drillType='cylinder'===thisObject.drillType?'box':'cylinder'})}bindExaggerationToggle(){const thisObject=this;this.verticalExaggerationToggle=this._gui?.add(this,'_verticalExaggeration',1.0,10.0).name("调整夸张值").step(0.1).onFinishChange(function(value){thisObject.verticalExaggeration=value})}destroy(){this._gui?.destroy();this.view?.ui.remove(this._timeSlider);this.map?.removeMany(this.map?.allLayers.filter((layer)=>layer.type==="group"));if(this.cachedCanvas){this.cachedCanvas.width=1;this.cachedCanvas.height=1;this.cachedCanvas=null}delete this.sliceXAxisSlider;delete this.sliceYAxisSlider;delete this.sliceZAxisSlider;delete this.voxelSliceX;delete this.voxelSliceY;delete this.voxelSliceZ}}function findClosestKey(map,target){const keys=Array.from(map.keys());if(keys.length===0)return undefined;return keys.reduce((prev,curr)=>Math.abs(curr-target)<Math.abs(prev-target)?curr:prev)}function normalizeArray(arr,stretchRange){const[min,max]=stretchRange;const rangeDiff=max-min;if(rangeDiff===0)return arr.map(()=>0);return arr.map(value=>{const clamped=Math.max(min,Math.min(value,max));return(clamped-min)/rangeDiff})}function validArray(array){return Array.isArray(array)&&array.length>0}function createLinearGradient(canvas,colors){const DEFAULT_COLOR=[1,1,1,1];if(!validArray(colors)){return createFallbackCanvas(DEFAULT_COLOR)}const ctx=canvas.getContext('2d',{willReadFrequently:true,alpha:false});configureContext(ctx);const gradient=ctx.createLinearGradient(0,0,0,CANVAS_SIZE);configureColorStops(gradient,colors);ctx.fillStyle=colors.length===1?colors[0]:gradient;ctx.fillRect(0,0,CANVAS_SIZE,CANVAS_SIZE);const img=new Image();img.src=canvas.toDataURL();ctx.clearRect(0,0,canvas.width,canvas.height);return img;function createCanvas(size){const cachedCanvas=document.createElement('canvas');cachedCanvas.width=cachedCanvas.height=size;return cachedCanvas}function configureContext(context){context.globalAlpha=1;context.globalCompositeOperation='lighter'}function configureColorStops(gradientObj,colorArray){const stopCount=colorArray.length;colorArray.forEach((color,index)=>{const stopPosition=stopCount>1?index/(stopCount-1):1;gradientObj.addColorStop(stopPosition,color)})}function createFallbackCanvas(color){const canvas=createCanvas(1);const ctx=canvas.getContext('2d');ctx.fillStyle=`rgba(${color.join(',')})`;ctx.fillRect(0,0,1,1);return canvas}}export default VoxelContinuousDrill;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Point from'../../../geometry/Point.js';import{merge}from'../../../geometry/support/meshUtils.js';import MeshSymbol3D from'../../../symbols/MeshSymbol3D.js';import FillSymbol3DLayer from'../../../symbols/FillSymbol3DLayer.js';import Graphic from'../../../Graphic.js';import GraphicsLayer from'../../../layers/GraphicsLayer.js';import VoxelSlice from'../../../layers/voxel/VoxelSlice.js';import{GeometryCreator}from'./common.js';const CONFIG={voxelSlice:{orientation:270,tilt:90,initialPoint:[71.1,0,0]},drillType:'cylinder',cylinder:{width:2000,depth:2000,densificationFactor:1},view:{fov:35,zoom:13,tilt:85.3926687063094,heading:-95.2677195416981,duration:1500},};function validArray(array){return Array.isArray(array)&&array.length>0}function createVoxelSlice(point){return new VoxelSlice({orientation:CONFIG.voxelSlice.orientation,tilt:CONFIG.voxelSlice.tilt,point:point})}class VoxelDiscreteDrill{constructor(optional){const config={currentVariableId:1,verticalExaggeration:1,fixedCylinderRadius:false,popupEnabled:false,widthCylinder:20,depthCylinder:20,densificationFactor:1,drillType:'cylinder',...optional,};const _drillData=config.drillData;if(!_drillData)throw new Error('请传入钻孔数据!');const _view=config.view;if(!_view)throw new Error('请传入 SceneView 对象!');const _vxlLayer=config.vxlLayer;if(!_vxlLayer)throw new Error('请传入体元图层!');const _map=_view.map;const{data,variable}=_drillData;if(!validArray(data)||!validArray(variable))throw new Error('数据格式不正确,或者数据为空!');this.currentVariableId=0;this.lastOffsetX=0;this.lastOffsetY=0;this.originalZsArray=[];this.zArrays=[];this.heightOrigins=[];this.heightCylinders=[];this.originalFirstZs=[];this.drillLocations=[];this.drillType=CONFIG.drillType;this._data=data;this.voxelLayer=_vxlLayer;this.map=_map;this.view=_view;this.displayMode='all';this.currentPointIndex=0}render(pointObjectArray){this.graphicsLayer=new GraphicsLayer();this.map.add(this.graphicsLayer);this.map.ground.navigationConstraint='none';this.view.whenLayerView(this.voxelLayer).then(()=>{this.setupVoxelControls();this.setupDrillHoles();const vm=this.voxelLayer.getVolume();const voxelPosition=validArray(pointObjectArray)&&vm.computeVoxelSpaceLocation(pointObjectArray.at(-1));const xSliceObj=this.voxelLayer.getVolumeStyle(null).slices.getItemAt(0);xSliceObj.point=voxelPosition})}setupVoxelControls(){const xSlice=createVoxelSlice(CONFIG.voxelSlice.initialPoint);this.voxelLayer.getVolumeStyle(null).slices=[xSlice];this.voxelLayer.currentVariableId=this.currentVariableId;this.voxelLayer.popupEnabled=true}setupDrillHoles(){this.voxelStyle=this.voxelLayer.getVolumeStyle();this.updateVariableStyle();this.initializeAllZParameters();this.updateAllZArrays();this.initAllDrillLocations();this.updateDrillHoles();this.setupGUI();this.view.goTo({target:this.graphicsLayer,...CONFIG.view},{duration:CONFIG.view.duration})}initializeAllZParameters(){this.originalZsArray=[];this.heightOrigins=[];this.heightCylinders=[];this.originalFirstZs=[];this.zArrays=[];this._data.forEach((pointData,index)=>{this.originalZsArray[index]=[...pointData.zs];this.originalFirstZs[index]=pointData.zs[0];this.heightOrigins[index]=pointData.zs[1]-pointData.zs[0];this.heightCylinders[index]=this.heightOrigins[index];this.zArrays[index]=[...pointData.zs]})}initAllDrillLocations(){this.drillLocations=[];this._data.forEach((pointData,index)=>{this.drillLocations[index]=new Point({spatialReference:this.view.spatialReference??this.map.spatialReference,x:pointData.xy[0],y:pointData.xy[1],z:pointData.zs[0]})})}updateAllZArrays(){const stl=this.voxelStyle;const exaggeration=stl.verticalExaggeration;console.log("垂直夸张值:",exaggeration);this._data.forEach((pointData,index)=>{const originalZs=pointData.zs;if(exaggeration!==1.0){this.zArrays[index]=originalZs.map(z=>z*exaggeration);this.heightCylinders[index]=this.heightOrigins[index]*exaggeration}else{this.zArrays[index]=[...originalZs];this.heightCylinders[index]=this.heightOrigins[index]}})}updateVariableStyle(){this.variableStyle=this.voxelLayer.getVariableStyle();this.colorMap={};const uniqueValues=this.variableStyle.uniqueValues?.items||[];uniqueValues.forEach(item=>{if(item.value!==undefined){this.colorMap[item.value]=item.color}})}updateDrillHoles(){this.graphicsLayer.removeAll();let renderIndices=Array.from({length:this._data.length},(_,i)=>i);this.geometryCreator=GeometryCreator[this.drillType];renderIndices.forEach(pointIndex=>{const pointData=this._data[pointIndex];const pollutantData=pointData.volume.Attr;const zArray=this.zArrays[pointIndex];const height=this.heightCylinders[pointIndex];const verticalExaggeration=this.voxelStyle.verticalExaggeration||1.0;if(!pollutantData){console.warn(`点位${pointIndex}的污染物数据不存在`);return}const width=CONFIG.cylinder.width*Math.max(1,Math.sqrt(verticalExaggeration));const depth=CONFIG.cylinder.depth*Math.max(1,Math.sqrt(verticalExaggeration));const geometries=[];for(let i=0;i<zArray.length;i++){const value=pollutantData[i];if(value===null)continue;this.drillLocations[pointIndex].z=zArray[i];geometries.push(this.geometryCreator(this.drillLocations[pointIndex],{size:{height,width,depth},densificationFactor:CONFIG.cylinder.densificationFactor,material:{color:this.colorMap[value]||[255,255,255,0.5]}}).offset(0,-depth/2,0))}this.graphicsLayer.add(new Graphic({geometry:merge(geometries),symbol:new MeshSymbol3D({symbolLayers:[new FillSymbol3DLayer()]}),attributes:{pointIndex:pointIndex}}))});console.log('钻孔更新完成:',{renderIndices:renderIndices,verticalExaggeration:this.voxelStyle.verticalExaggeration,graphicsCount:this.graphicsLayer.graphics.length})}offsetGraphics(valX,valY){const graphics=this.graphicsLayer.graphics;graphics.forEach(graphic=>{graphic.geometry.offset(this.lastOffsetX,this.lastOffsetY,0);graphic.geometry.offset(valX,valY,0)});this.lastOffsetX=-valX;this.lastOffsetY=-valY}setupGUI(){if(typeof dat==='undefined'){console.warn('dat.GUI 未加载,跳过GUI初始化');return}try{const gui=new dat.GUI({name:'钻孔控制'});const offsetControls={x:0,y:0};gui.add(offsetControls,'x',-1000,1000).name('X偏移').step(0.1).onChange((val)=>this.offsetGraphics(val,0));gui.add(offsetControls,'y',-1000,1000).name('Y偏移').step(0.1).onChange((val)=>this.offsetGraphics(0,val));const verticalExaggerationCtrl=gui.add(this.voxelStyle,'verticalExaggeration',1.0,5.0).name('垂直夸张').step(0.1);verticalExaggerationCtrl.onFinishChange((value)=>{this.updateAllZArrays();this.updateDrillHoles()});gui.add({type:this.drillType},'type',['box','cylinder']).name('钻孔类型').onChange((value)=>{if(value!==this.drillType){this.drillType=value;this.updateDrillHoles()}});const sliceCtrl={position:CONFIG.voxelSlice.initialPoint[0]};gui.add(sliceCtrl,'position',0,700).name('切片位置').step(0.1).onChange((value)=>{const xSliceObj=this.voxelLayer.getVolumeStyle(null).slices.getItemAt(0);xSliceObj.point=[value,0,0]})}catch(error){console.error('初始化GUI时出错:',error)}}}export default VoxelDiscreteDrill;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import Mesh from'../../../geometry/Mesh.js';export const BoxVertexAttributesGenerator=(()=>{const cache=new Map();return{get(){const cacheKey=`boxVertexAttributes`;if(!cache.has(cacheKey)){const uvs=[];const frontUV=[0,0,0,1,1,1,1,0];uvs.push(...frontUV,...frontUV);const faceConfigs=[{indices:[0,1,2,0,2,3],isTransparent:false},{indices:[1,5,6,1,6,2],isTransparent:true},{indices:[5,4,7,5,7,6],isTransparent:false},{indices:[4,0,3,4,3,7],isTransparent:true},{indices:[4,5,1,4,1,0],isTransparent:false},{indices:[3,2,6,3,6,7],isTransparent:false}];cache.set(cacheKey,{uvs,faceConfigs})}return cache.get(cacheKey)}}})();export const CylinderVertexAttributesGenerator=(()=>{const cache=new Map();const precomputeAngles=(segments)=>{const cosTable=new Array(segments);const sinTable=new Array(segments);const step=(Math.PI*2)/segments;for(let i=0;i<segments;i++){const angle=i*step;cosTable[i]=Math.cos(angle);sinTable[i]=Math.sin(angle)}return{cosTable,sinTable}};const generatePositions=(center,size,segments,cosTable,sinTable)=>{const{x:cx,y:cy,z:cz}=center;const{width,depth,height}=size;const positions=new Array(segments*2*3);const radiusX=width/2;const radiusY=depth/2;for(let i=0;i<segments;i++){const cos=cosTable[i];const sin=sinTable[i];const x=cx+cos*radiusX;const y=cy+sin*radiusY;const baseIdx=i*3;const topIdx=(i+segments)*3;positions[baseIdx]=x;positions[baseIdx+1]=y;positions[baseIdx+2]=cz;positions[topIdx]=x;positions[topIdx+1]=y;positions[topIdx+2]=cz+height}return positions};return{create(center,segments,size){const cacheKey=`${segments}`;if(!cache.has(cacheKey)){const angleData=precomputeAngles(segments);const uv=new Array(segments*4);const faces=new Array(segments*6);for(let i=0;i<segments;i++){const u=i/segments;const baseUV=i*2;const topUV=(i+segments)*2;uv[baseUV]=u;uv[baseUV+1]=0;uv[topUV]=u;uv[topUV+1]=1}for(let i=0;i<segments;i++){const next=(i+1)%segments;const idx=i*6;faces[idx]=i;faces[idx+1]=i+segments;faces[idx+2]=next+segments;faces[idx+3]=i;faces[idx+4]=next+segments;faces[idx+5]=next}cache.set(cacheKey,{cosTable:angleData.cosTable,sinTable:angleData.sinTable,uv,faces})}const{cosTable,sinTable,uv,faces}=cache.get(cacheKey);return{uv:[...uv],position:generatePositions(center,size,segments,cosTable,sinTable),faces:[...faces]}}}})();export const GeometryCreator={cylinder:function(center,{material,size,densificationFactor}){let height=size.height;let width=size.width;let depth=size.depth;const segments=16*Math.pow(2,densificationFactor);const vertexAttributes=CylinderVertexAttributesGenerator.create(center,segments,size);const faces=vertexAttributes.faces;const position=vertexAttributes.position;const uv=vertexAttributes.uv;const shading='smooth';const vertexSpace='georeferenced';const spatialReference=center.spatialReference;const mesh=new Mesh({center,components:[{faces,shading,material}],vertexSpace,vertexAttributes:{position,uv},spatialReference,});return mesh.offset(width,depth/2,-height/2)},box:function(center,{material,size,geometryPosition}){const{width:fullWidth,depth:fullDepth,height:fullHeight}=size;const halfWidth=fullWidth/2;const halfDepth=fullDepth/2;let height=fullHeight;const vertices=[];const frontX=center.x+halfWidth;vertices.push(frontX,center.y+halfDepth,center.z,frontX,center.y+halfDepth,center.z+height,frontX,center.y-halfDepth,center.z+height,frontX,center.y-halfDepth,center.z);const backX=center.x-halfWidth;vertices.push(backX,center.y+halfDepth,center.z,backX,center.y+halfDepth,center.z+height,backX,center.y-halfDepth,center.z+height,backX,center.y-halfDepth,center.z);let{faceConfigs,uvs}=BoxVertexAttributesGenerator.get(material);const shading='smooth';const components=faceConfigs.map(({indices,isTransparent})=>({faces:indices,shading,material:isTransparent?{color:"transparent"}:material}));const mesh=new Mesh({center,components,vertexSpace:'georeferenced',vertexAttributes:{position:vertices,uv:uvs},spatialReference:center.spatialReference,});return mesh.offset(fullWidth,halfDepth,-height/2)}}
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geoscene/core",
|
|
3
|
-
"version": "4.34.
|
|
4
|
-
"homepage": "https://js.geoscene.cn",
|
|
5
|
-
"description": "GeoScene Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"GeoScene",
|
|
8
|
-
"javascript",
|
|
9
|
-
"map",
|
|
10
|
-
"3D",
|
|
11
|
-
"2D",
|
|
12
|
-
"visualization",
|
|
13
|
-
"analytics",
|
|
14
|
-
"spatial",
|
|
15
|
-
"data-driven",
|
|
16
|
-
"gis"
|
|
17
|
-
],
|
|
18
|
-
"license": "SEE LICENSE IN copyright.txt",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@amcharts/amcharts5": "~5.14.1",
|
|
21
|
-
"@arcgis/toolkit": "^4.34.0",
|
|
22
|
-
"@esri/arcgis-html-sanitizer": "~4.1.0",
|
|
23
|
-
"@
|
|
24
|
-
"@vaadin/grid": "~24.9.1",
|
|
25
|
-
"@zip.js/zip.js": "~2.8.7",
|
|
26
|
-
"luxon": "~3.7.2",
|
|
27
|
-
"marked": "~16.3.0",
|
|
28
|
-
"tslib": "^2.8.1"
|
|
29
|
-
},
|
|
30
|
-
"type": "module"
|
|
1
|
+
{
|
|
2
|
+
"name": "@geoscene/core",
|
|
3
|
+
"version": "4.34.11",
|
|
4
|
+
"homepage": "https://js.geoscene.cn",
|
|
5
|
+
"description": "GeoScene Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"GeoScene",
|
|
8
|
+
"javascript",
|
|
9
|
+
"map",
|
|
10
|
+
"3D",
|
|
11
|
+
"2D",
|
|
12
|
+
"visualization",
|
|
13
|
+
"analytics",
|
|
14
|
+
"spatial",
|
|
15
|
+
"data-driven",
|
|
16
|
+
"gis"
|
|
17
|
+
],
|
|
18
|
+
"license": "SEE LICENSE IN copyright.txt",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@amcharts/amcharts5": "~5.14.1",
|
|
21
|
+
"@arcgis/toolkit": "^4.34.0",
|
|
22
|
+
"@esri/arcgis-html-sanitizer": "~4.1.0",
|
|
23
|
+
"@geoscene/calcite-components": "^3.3.3",
|
|
24
|
+
"@vaadin/grid": "~24.9.1",
|
|
25
|
+
"@zip.js/zip.js": "~2.8.7",
|
|
26
|
+
"luxon": "~3.7.2",
|
|
27
|
+
"marked": "~16.3.0",
|
|
28
|
+
"tslib": "^2.8.1"
|
|
29
|
+
},
|
|
30
|
+
"type": "module"
|
|
31
31
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Error.js";const i={"area-measurement":()=>import("./AreaMeasurementAnalysisView3D.js"),dimension:()=>import("./DimensionAnalysisView3D.js"),"direct-line-measurement":()=>import("./DirectLineMeasurementAnalysisView3D.js"),"elevation-profile":()=>import("./ElevationProfileAnalysisView3D.js"),"line-of-sight":()=>import("./LineOfSightAnalysisView3D.js"),slice:()=>import("./SliceAnalysisView3D.js"),viewshed:()=>import("./ViewshedAnalysisView3D.js"),"volume-measurement":()=>import("./VolumeMeasurementAnalysisView3D.js")};function s(s){const n=i[s.type];if(!n)throw new e("analysis-view-module-import-utils:analysis-not-supported",`Analysis
|
|
5
|
+
import e from"../../../core/Error.js";const i={"area-measurement":()=>import("./AreaMeasurementAnalysisView3D.js"),dimension:()=>import("./DimensionAnalysisView3D.js"),"direct-line-measurement":()=>import("./DirectLineMeasurementAnalysisView3D.js"),"elevation-profile":()=>import("./ElevationProfileAnalysisView3D.js"),"line-of-sight":()=>import("./LineOfSightAnalysisView3D.js"),slice:()=>import("./SliceAnalysisView3D.js"),viewshed:(viewsheds)=>{let loadVideo=false;try{if(viewsheds?.some(viewshed=>viewshed.type==='video')){loadVideo=true}}catch(e){console.error(e)}return loadVideo?import("../../../analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js"):import("./ViewshedAnalysisView3D.js")},"volume-measurement":()=>import("./VolumeMeasurementAnalysisView3D.js")};function s(s){const n=i[s.type];if(!n)throw new e("analysis-view-module-import-utils:analysis-not-supported",`Analysis"${s.type}"is not supported`);const viewsheds=s.viewsheds?.items;return viewsheds?n(viewsheds):n()}export{s as importAnalysisViewModule};
|