@arcgis/core 4.30.0-next.20240521 → 4.30.0-next.20240523
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/WebMap.js +1 -1
- package/assets/components/assets/icon/developerCredentials16.json +1 -0
- package/assets/components/assets/icon/developerCredentials24.json +1 -0
- package/assets/components/assets/icon/developerCredentials32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d7722531be4892293cb1.js → 00c49f6c84444e69f3a1.js} +1 -1
- package/assets/esri/core/workers/chunks/01927419855947110cc1.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{df26d7d07fed1f124fc2.js → 0903b492782dca69eb48.js} +1 -1
- package/assets/esri/core/workers/chunks/158c05b16372d8ed33ea.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/190913c221964292333b.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{2529a4b1e135223833f0.js → 2635ab64e75d4ec700a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{f965644347007e3d68e2.js → 27dc94db9ed42b237ecb.js} +1 -1
- package/assets/esri/core/workers/chunks/{e727392db3b7998e5c28.js → 357707efc0cb8a1842c1.js} +1 -1
- package/assets/esri/core/workers/chunks/{0ae3ea7a73f3b5083968.js → 3a01cf7e3355f3c78378.js} +1 -1
- package/assets/esri/core/workers/chunks/4268373bf374b2a6252a.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/43e1c935452b489e422e.js +1 -0
- package/assets/esri/core/workers/chunks/{938b158a7edbbb8e08a1.js → 44f8b57b0d8cfeabda1f.js} +1 -1
- package/assets/esri/core/workers/chunks/{15212a82e283d6df2873.js → 4ae885f257660545ceeb.js} +1 -1
- package/assets/esri/core/workers/chunks/{4ea2ced4b5ea1c8a1cee.js → 4ba866a10711b6a8158f.js} +1 -1
- package/assets/esri/core/workers/chunks/50ee28a1944bde74a7c1.js +1 -0
- package/assets/esri/core/workers/chunks/{d745c2df59e5d6c7a1dd.js → 53aa9124c11c03f70521.js} +1 -1
- package/assets/esri/core/workers/chunks/59b193d42e8abf9d4088.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{eafbe663f7a61d3222c5.js → 5efe1300a39ab9c7bbab.js} +1 -1
- package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js → 606f8b907166190a8b65.js} +2 -2
- package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js.LICENSE.txt → 606f8b907166190a8b65.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/653da6469fe62e061efc.js +1 -0
- package/assets/esri/core/workers/chunks/{5349b0de83ae4be8afe2.js → 6c1ded9acf5c8be493ea.js} +1 -1
- package/assets/esri/core/workers/chunks/{46225ebc10a4398170b5.js → 712ba8ad69b1aab6f508.js} +1 -1
- package/assets/esri/core/workers/chunks/{7d210c2a5a135da2c37d.js → 7c68dc664c0b4cf2a46b.js} +1 -1
- package/assets/esri/core/workers/chunks/88c7d84a1fde246ca71f.js +1 -0
- package/assets/esri/core/workers/chunks/9b04a666726b5d2ff3c5.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/9c75837b7e75f0f38dc0.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/a6b138f330625d98f856.js +1 -0
- package/assets/esri/core/workers/chunks/{e4a0fd9e0f8887009b92.js → a8a19e5a7ae4ec16480a.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcf0016d56df8a69f6c1.js → aa198e898b46c6e89d0b.js} +1 -1
- package/assets/esri/core/workers/chunks/b2562f5d0d5a44dc004e.js +1 -0
- package/assets/esri/core/workers/chunks/{04faa3bf4ef5a6f0ccb4.js → b3de9bc3e75476b0a7e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{bd0545bb100b3393fd85.js → bbec62f8792520993909.js} +1 -1
- package/assets/esri/core/workers/chunks/bcd230d67bac27a1b36d.js +1 -0
- package/assets/esri/core/workers/chunks/bf6e75cc75d3bdfb70cb.js +1 -0
- package/assets/esri/core/workers/chunks/{5acac4616c53a95cc48f.js → c0c8e1a709648e1305c6.js} +1 -1
- package/assets/esri/core/workers/chunks/c80568ff68be908b3c30.js +1 -0
- package/assets/esri/core/workers/chunks/{85f24b441369e50e6ee1.js → c96ab8d56830b8ce07ed.js} +1 -1
- package/assets/esri/core/workers/chunks/{4f3a87586e334c52d0bf.js → caffbaa8b0a67d117f34.js} +1 -1
- package/assets/esri/core/workers/chunks/ccad364912ff1d85a9dc.js +1 -0
- package/assets/esri/core/workers/chunks/{7b4ed96554722be59ae2.js → d8140b5316e80d734155.js} +1 -1
- package/assets/esri/core/workers/chunks/dde183c6bb1710ff16df.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/e3711bc5b100b64cac3a.js +1 -0
- package/assets/esri/core/workers/chunks/{2d5d66cee7c3ec992bcd.js → e93e59f6907fa4c1081c.js} +1 -1
- package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +15 -1
- package/assets/esri/themes/base/widgets/_Grid.scss +4 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/Tooltip.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/workers/InvokeHandler.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/interfaces.d.ts +543 -77
- package/layers/BuildingSceneLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/package.json +2 -2
- package/portal/PortalItem.js +1 -1
- package/portal/schemas/buildingSceneLayerItem.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
- package/rest/print.js +1 -1
- package/rest/support/printTaskUtils.js +1 -1
- package/smartMapping/renderers/support/referenceSizeUtils.js +1 -1
- package/smartMapping/support/adapters/support/layerUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/views/2d/GoToManager.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
- package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
- package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/editingTools/undoRecords.js +5 -0
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/widgets/CatalogLayerList/CatalogLayerListViewModel.d.ts +4 -0
- package/widgets/CatalogLayerList.d.ts +4 -0
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/FeatureForm/support/textManipulationUtils.js +1 -1
- package/widgets/FeatureTable/VisibleElements.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList/support/layerListUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/VideoPlayer/components/SettingsButton.js +1 -1
- package/assets/esri/core/workers/chunks/0753c636c2801f067235.js +0 -1
- package/assets/esri/core/workers/chunks/3716015ccf0888c0a21d.js +0 -1
- package/assets/esri/core/workers/chunks/3f86042d9c0cc2d9acba.js +0 -1
- package/assets/esri/core/workers/chunks/50936725c9bd23b780ef.js +0 -1
- package/assets/esri/core/workers/chunks/5c8c5290b9fcb5a4468f.js +0 -1
- package/assets/esri/core/workers/chunks/95fb6643bd54d354f266.js +0 -1
- package/assets/esri/core/workers/chunks/aa020d495f464eff0134.js +0 -1
- package/assets/esri/core/workers/chunks/b52295fa9cf2f3244b65.js +0 -1
- package/assets/esri/core/workers/chunks/cbb3a56e4072cdf25a9d.js +0 -1
- package/assets/esri/core/workers/chunks/f4f1e1c1758542434384.js +0 -1
- package/assets/esri/core/workers/chunks/fb48e8e42379fdf8a094.js +0 -1
- package/views/3d/interactive/editingTools/transform/undoRecords.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import e from"../../../core/Error.js";import t from"../Entity.js";import o from"../Relationship.js";import{geometryToWasm as i}from"./queryToWasmEncodedFactories.js";import n from"../../../geometry/Geometry.js";function r(i,n){if(!i.typeName)throw new e("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits");if(i instanceof t){const e=new n.EntityValue;e.deleteLater(),e.type_name=i.typeName;for(const[t,o]of Object.entries(i.properties))e.set_key_value(t,a(o,n));return i.id&&e.set_id(i.id),e}if(i instanceof o){const e=new n.RelationshipValue;e.deleteLater(),e.type_name=i.typeName;for(const[t,o]of Object.entries(i.properties))e.set_key_value(t,a(o,n));return i.id&&e.set_id(i.id),i.originId&&i.destinationId&&e.set_related_entity_ids(i.originId,i.destinationId),e}throw new e("knowledge-graph:applyEdits-encoding-failure","Could not determine the type of a named graph object passed to the encoder")}function s(e){return{xy_resolution:e.xyResolution,x_false_origin:e.xFalseOrigin,y_false_origin:e.yFalseOrigin,z_resolution:e.zResolution,z_false_origin:e.zFalseOrigin,m_resolution:e.mResolution,m_false_origin:e.mFalseOrigin}}function a(e,t){return null==e?
|
|
5
|
+
import"../../../geometry.js";import e from"../../../core/Error.js";import t from"../Entity.js";import o from"../Relationship.js";import{geometryToWasm as i}from"./queryToWasmEncodedFactories.js";import n from"../../../geometry/Geometry.js";function r(i,n){if(!i.typeName)throw new e("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits");if(i instanceof t){const e=new n.EntityValue;e.deleteLater(),e.type_name=i.typeName;for(const[t,o]of Object.entries(i.properties))e.set_key_value(t,a(o,n));return i.id&&e.set_id(i.id),e}if(i instanceof o){const e=new n.RelationshipValue;e.deleteLater(),e.type_name=i.typeName;for(const[t,o]of Object.entries(i.properties))e.set_key_value(t,a(o,n));return i.id&&e.set_id(i.id),i.originId&&i.destinationId&&e.set_related_entity_ids(i.originId,i.destinationId),e}throw new e("knowledge-graph:applyEdits-encoding-failure","Could not determine the type of a named graph object passed to the encoder")}function s(e){return{xy_resolution:e.xyResolution,x_false_origin:e.xFalseOrigin,y_false_origin:e.yFalseOrigin,z_resolution:e.zResolution,z_false_origin:e.zFalseOrigin,m_resolution:e.mResolution,m_false_origin:e.mFalseOrigin}}function a(e,t){return null==e?null:"object"!=typeof e||e instanceof Date?e:e instanceof n?i(e,t):null}export{s as inputQuantizationParametersToWasmFormat,r as namedObjectToWasm};
|
package/rest/print.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as i}from"../core/jsonMap.js";import{createScreenPoint as a,pt2px as r,px2pt as n}from"../core/screenUtils.js";import{normalize as o,dataComponents as s}from"../core/urlUtils.js";import l from"../geometry/Polygon.js";import{collectLabelingFields as c}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as y}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as p,getToken as f}from"./utils.js";import{execute as d}from"./geoprocessor/execute.js";import{submitJob as m}from"./geoprocessor/submitJob.js";import{toJSON as g}from"./support/fileFormat.js";import{toJSON as h}from"./support/layoutTemplate.js";import{getVisibleLayerViews as b,isScreenshotRequired as w,isBingMapsLayer as S,isCSVLayer as x,isBlendLayer as I,getSelectionSymbol as v,getContextBoundingBox as D,createPolygonLayer as L,createPolylineLayer as T,createPointLayer as O,createMultipointLayer as E}from"./support/printTaskUtils.js";import M from"./support/PrintTemplate.js";import{toJSON as P}from"./support/reportTemplate.js";const F={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},V=new i({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),N=new i({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),U=new Map;async function J(e,t,i){const a=await R(e,i),r=await A(t,a);if("sync"===await j(e,i)){const{results:t}=await d(e,r,void 0,i);return t?.[0]?.value}const n=await m(e,r,void 0,i);await n.waitForJobCompletion({interval:t.updateDelay});const{value:o}=await n.fetchResultData("Output_File",null,i);return o}async function R(e,i){const a=C(e),r=U.get(a)??{gpServerUrl:a,legendLayerNameMap:{},legendLayers:[]};return r.gpMetadata??=(await t(a,p({f:"json"},i))).data,r.cimVersion=r.gpMetadata.cimVersion,U.set(a,r),r}async function j(e,t){return fe(await R(e,t))}async function k(e,t){return(await R(e,t)).gpMetadata.tasks}async function A(t,i){i=i||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const a=t.template||new M;null==a.showLabels&&(a.showLabels=!0);const r=a.exportOptions;let n;const o=h(a.layout);if(r){if(n={dpi:r.dpi},"map_only"===o.toLowerCase()||""===o){const e=r.width,t=r.height;n.outputSize=null!=e&&null!=t?[e,t]:void 0}}const s=a.layoutOptions;let l;if(s){let e,t;"Miles"===s.scalebarUnit||"Kilometers"===s.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==s.scalebarUnit&&"Feet"!==s.scalebarUnit||(e="Meters",t="Feet"),l={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:{metricUnit:V.toJSON(e),metricLabel:e?F[e]:void 0,nonMetricUnit:V.toJSON(t),nonMetricLabel:t?F[t]:void 0}}}let c=null;s?.legendLayers&&(c=s.legendLayers.map((e=>{const t=e.layerId;i.legendLayerNameMap[t]=e.title;const a={id:t};return e.subLayerIds&&(a.subLayerIds=e.subLayerIds),a})));const u=await _(t,a,i);if(u.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,i=i=>{const a=i.text,r=i.font,n=r?.family?.toLowerCase();a&&r&&("arial"===n||"arial unicode ms"===n)&&(r.family=e.test(a)?"Arial Unicode MS":"Arial","normal"!==r.style&&t.test(a)&&(r.family="Arial Unicode MS"))};for(const a of u.operationalLayers)if(a.featureCollection?.layers)for(const e of a.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type&&i(t.symbol)}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&"esriTS"===t.symbol.type&&i(t.symbol)}}t.outSpatialReference&&(u.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(u,{exportOptions:n,layoutOptions:l||{}}),Object.assign(u.layoutOptions,{legendOptions:{operationalLayers:null!=c?c:i.legendLayers.slice()}}),i.legendLayers.length=0,U.set(i.gpServerUrl,i);const y={Web_Map_as_JSON:JSON.stringify(u),Format:g(a.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:P(a.report),Report_Item_ID:void 0};if(a.layoutItem){delete y.Layout_Template;const t=a.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(i.gpServerUrl),y.Layout_Item_ID=JSON.stringify({id:t.id})}if(a.reportItem){delete y.Report_Template;const t=a.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(i.gpServerUrl),y.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(y,t.extraParameters),y}async function _(e,t,i){const a=e.view;let r=a.spatialReference;const n={operationalLayers:await z(a,t,i)};t.includeTables&&(n.tables=await ae(a));let o=e.extent||i.ssExtent||a.extent;if(r?.isWrappable&&(o=o.clone()._normalize(!0),r=o.spatialReference),n.mapOptions={extent:o&&o.toJSON(),spatialReference:r&&r.toJSON(),showAttribution:t.attributionVisible},i.ssExtent=null,a.background&&(n.background=a.background.toJSON()),a.rotation&&(n.mapOptions.rotation=-a.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||a.scale),null!=a.timeExtent){const e=null!=a.timeExtent.start?a.timeExtent.start.getTime():null,t=null!=a.timeExtent.end?a.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function C(e){let t=e;const i=t.lastIndexOf("/GPServer/");return i>0&&(t=t.slice(0,i+9)),t}async function z(e,t,i){const a=[],r={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const o=b(e,n);for(const s of o){const e=s.layer;if(!e.loaded||"group"===e?.type)continue;let t;r.layerView=s,t=w(s)?await te(e,r,i):S(e)?$(e):x(e)?await q(e,r,i):"feature"===e?.type?await W(e,r,i):"geojson"===e?.type?await B(e,r,i):"graphics"===e?.type?await H(e,r,i):"imagery"===e?.type?G(e,i):"imagery-tile"===e?.type?await Q(e,r,i):"kml"===e?.type?await X(e,r,i):"map-image"===e?.type?Y(e,r,i):"map-notes"===e?.type?await Z(r,i):"open-street-map"===e?.type?ee():"stream"===e?.type?await ie(e,r,i):"tile"===e?.type?re(e,i):"vector-tile"===e?.type?await ne(e,r,i):"web-tile"===e?.type?oe(e):"wms"===e?.type?se(e,i):"wmts"===e?.type?le(e):await te(e,r,i),t&&(Array.isArray(t)?a.push(...t):(t.id=e.id,t.title=i.legendLayerNameMap[e.id]||e.title,t.opacity=s.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,I(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),a.push(t)))}if(n)for(const s of a)s.minScale=0,s.maxScale=0;if(e.graphics?.length){const r=await K(null,e.graphics,t,i);r&&a.push(r)}return a}function $(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function q(e,t,i){e.legendEnabled&&i.legendLayers.push({id:e.id});const a=t.layerView,r=t.printTemplate;let n;if(a.filter||e.portalItem&&"public"!==e.portalItem.access){return K(e,await pe(a),r,i)}return n={type:"CSV"},e.write(n,{origin:"web-map"}),delete n.popupInfo,delete n.layerType,n.showLabels=r.showLabels&&e.labelsVisible,n}async function K(e,t,i,a){let r;const n=L(),o=T(),s=O(),u=E(),y=O();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=a.legendLayerNameMap[e.id]||e.get("arcgisProps.title")||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),i=n.layerDefinition.drawingInfo;i&&(i.renderer=t);const a=o.layerDefinition.drawingInfo;a&&(a.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const l=u.layerDefinition.drawingInfo;l&&(l.renderer=t)}if(i.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=e.write({},{origin:"web-map"}),i=t.layerDefinition?.drawingInfo?.labelingInfo;if(i){r=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=i);const t=o.layerDefinition.drawingInfo;t&&(t.labelingInfo=i);const a=s.layerDefinition.drawingInfo;a&&(a.labelingInfo=i);const l=u.layerDefinition.drawingInfo;l&&(l.labelingInfo=i)}}}let p;e?.renderer||r||(delete n.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);const f=e?.fieldsIndex,d=e?.renderer;if(f){const t=new Set;r&&await c(t,e),d&&"function"==typeof d.collectRequiredFields&&await d.collectRequiredFields(t,f),p=Array.from(t);const i=f.fields.map((e=>e.toJSON()));n.layerDefinition.fields=i,o.layerDefinition.fields=i,s.layerDefinition.fields=i,u.layerDefinition.fields=i}const m=t?.length;let g;for(let c=0;c<m;c++){const e=t[c]||t.at(c);if(!1!==e.visible&&e.geometry){if(g=e.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol&&(g.symbol.angle||delete g.symbol.angle,de(g.symbol)?g.symbol=await ue(g.symbol,a):g.symbol.text&&delete g.attributes),(!i||!i.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===e.geometry.type?n.featureSet.features.push(g):"polyline"===e.geometry.type?o.featureSet.features.push(g):"point"===e.geometry.type?g.symbol?.text?y.featureSet.features.push(g):s.featureSet.features.push(g):"multipoint"===e.geometry.type?u.featureSet.features.push(g):"extent"===e.geometry.type&&(g.geometry=l.fromExtent(e.geometry).toJSON(),n.featureSet.features.push(g))}}const h=[n,o,u,s,y].filter((e=>e.featureSet.features.length>0));for(const l of h){const e=l.featureSet.features.every((e=>e.symbol));if(e&&(!i||!i.forceFeatureAttributes))for(const t of l.featureSet.features)delete t.attributes;e&&delete l.layerDefinition.drawingInfo,l.layerDefinition.drawingInfo?.renderer&&await ye(l.layerDefinition.drawingInfo.renderer,a)}return h.length?{featureCollection:{layers:h},showLabels:r}:null}async function W(e,t,i){let a;const r=e.renderer,n=parseFloat(i.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&n<2.9||"pie-chart"===r?.type||"dot-density"===r?.type&&n<2.6)return te(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const o=t.layerView,{printTemplate:s,view:l}=t,c="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(o.filter||c||!r||"field"in r&&null!=r.field&&!e.getField(r.field)){const t=await pe(o);a=await K(e,t,s,i)}else{if(a={id:(p=e.write()).id,title:p.title,url:p.url,layerType:p.layerType,customParameters:p.customParameters,layerDefinition:p.layerDefinition,charts:s.includeCharts?p.charts:void 0},a.showLabels=s.showLabels&&e.labelsVisible,ce(a,e),a.layerDefinition?.drawingInfo?.renderer&&(delete a.layerDefinition.minScale,delete a.layerDefinition.maxScale,await ye(a.layerDefinition.drawingInfo.renderer,i),"visualVariables"in r&&r.visualVariables&&r.visualVariables[0])){const e=r.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=y(e,l.scale);a.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,a.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=u(o);if(t&&(a.layerDefinition||(a.layerDefinition={}),a.layerDefinition.definitionExpression=a.layerDefinition.definitionExpression?`(${a.layerDefinition.definitionExpression}) AND (${t})`:t),o.hasHighlight?.()&&"getHighlightIds"in o){const t=o;a.selectionObjectIds=t.getHighlightIds(),a.selectionSymbol=v(e.geometryType,t.highlightOptions??l.highlightOptions)}}var p;return a}async function B(e,t,i){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return te(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});return K(e,await pe(t.layerView),t.printTemplate,i)}async function H(e,{printTemplate:t},i){return K(e,null,t,i)}function G(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(a=e.write()).layerType,customParameters:a.customParameters};var a;return i.bandIds=e.bandIds,i.compressionQuality=e.compressionQuality,i.format=e.format,i.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(i.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(i.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(i.layerDefinition??={},i.layerDefinition.drawingInfo??={},i.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),ce(i,e),i}async function Q(e,t,i){if("flow"===e.renderer?.type)return te(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const a={bandIds:(r=e.write()||{}).bandIds,customParameters:r.customParameters,interpolation:r.interpolation,layerDefinition:r.layerDefinition};var r;return a.layerType="ArcGISImageServiceLayer",ce(a,e),a}async function X(e,t,i){const a=t.printTemplate;if(!e.portalItem||"public"===e.portalItem.access){const t={type:"kml"};return e.write(t,{origin:"web-map"}),delete t.layerType,t.url=o(e.url),t}const r=[],n=t.layerView;n.allVisibleMapImages.forEach(((t,i)=>{const a={id:`${e.id}_image${i}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};"data:image/png;base64,"===t.href.substr(0,22)?a.imageData=t.href.substr(22):a.url=t.href,r.push(a)}));const s=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],l={id:e.id,...await K(null,s,a,i)};return r.push(l),r}function Y(e,{view:t},i){let a;const r={id:e.id,subLayerIds:[]};let n=[];const o=t.scale,s=e=>{const t=0===o,i=0===e.minScale||o<=e.minScale,a=0===e.maxScale||o>=e.maxScale;if(e.visible&&(t||i&&a))if(e.sublayers)e.sublayers.forEach(s);else{const t=e.toExportImageJSON(),i={id:e.id,name:e.title,layerDefinition:{drawingInfo:t.drawingInfo,definitionExpression:t.definitionExpression,source:t.source}};n.unshift(i),r.subLayerIds.push(e.id)}};var l;return e.sublayers&&e.sublayers.forEach(s),n.length&&(n=n.map((({id:e,name:t,layerDefinition:i})=>({id:e,name:t,layerDefinition:i}))),a={layerType:(l=e.write()).layerType,customParameters:l.customParameters},a.layers=n,a.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:r.subLayerIds,ce(a,e),e.legendEnabled&&i.legendLayers.push(r)),a}async function Z({layerView:e,printTemplate:t},i){const a=[],r=e.layer;if(null!=r.featureCollections)for(const n of r.featureCollections){const e=await K(n,n.source,t,i);e&&a.push(...e.featureCollection.layers)}else if(null!=r.sublayers)for(const n of r.sublayers){const e=await K(null,n.graphics,t,i);e&&a.push(...e.featureCollection.layers)}return{featureCollection:{layers:a}}}function ee(){return{type:"OpenStreetMap"}}async function te(e,{printTemplate:t,view:i},r){const n={type:"image"},o={format:"png",ignoreBackground:!0,ignorePadding:!0,layers:[e]};0!==i.rotation&&(o.rotation=0);const l=r.ssExtent||i.state.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==i.width%2),null!=e.height&&e.height>0&&(y=e.height%2==i.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===i.scale)&&96===c&&(!u||!y)&&i.state.extent.equals(i.extent)&&(o.area={x:0,y:0,width:i.width,height:i.height},u||(o.area.width-=1),y||(o.area.height-=1),!r.ssExtent)){const e=i.toMap(a(o.area.width,o.area.height));l.ymin=e.y,l.xmax=e.x,r.ssExtent=l}n.extent=l.clone()._normalize(!0).toJSON();const p=await i.takeScreenshot(o);return n.imageData=s(p.dataUrl)?.data,n}async function ie(e,{layerView:t,printTemplate:i},a){e.legendEnabled&&a.legendLayers.push({id:e.id});return K(e,await pe(t),i,a)}async function ae(e){const t=[],i=[];for(const r of e.map.allTables)"feature"!==r.type||r.loaded||i.push(r.load());i.length&&await Promise.allSettled(i);for(const r of e.map.allTables)if("feature"===r.type&&r.loaded&&r.isTable&&"feature-layer"===r.source?.type){const e={id:(a=r.write()).id,title:a.title,customParameters:a.customParameters,layerDefinition:{definitionExpression:a.layerDefinition?.definitionExpression},url:a.url};ce(e,r),t.push(e)}var a;return t.length?t:void 0}function re(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(a=e.write()).layerType,customParameters:a.customParameters};var a;return ce(i,e),i}async function ne(e,t,i){if(e.serviceUrl&&e.styleUrl){const t=f(e.styleUrl,e.apiKey),a=f(e.serviceUrl,e.apiKey);if(!t&&!a||"2.1.0"!==i.cimVersion){const i={type:"VectorTileLayer"};return i.styleUrl=o(e.styleUrl),i.token=t,a!==t&&(i.additionalTokens=[{url:e.serviceUrl,token:a}]),i}}return te(e,t,i)}function oe(e){const t=e.urlTemplate?.replace(/\${/g,"{"),i={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(i.subDomains=e.subDomains),i}function se(e,t){let i;const a=[],r=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(r):e.name&&a.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(r),a.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:a}),i={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:a,url:o(e.url),version:e.version}),i}function le(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:o(e.url)}}function ce(e,t){t.url&&(e.url=o(e.url||t.url),e.token=f(e.url,t.apiKey))}async function ue(e,i){i.canvas||(i.canvas=document.createElement("canvas"));const a=1024;i.canvas.width=a,i.canvas.height=a;const o=i.canvas.getContext("2d");let s,l;if(e.path){const t=new Path2D(e.path);t.closePath(),o.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",o.fill(t);const i=D(o);if(!i)return null;o.clearRect(0,0,a,a);const n=r(e.size)/Math.max(i.width,i.height);o.scale(n,n);const c=a/n,u=c/2-i.width/2-i.x,y=c/2-i.height/2-i.y;if(o.translate(u,y),Array.isArray(e.color)&&o.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const a=e.outline;o.lineWidth=r(a.width)/n,o.lineJoin="round",o.strokeStyle=`rgba(${a.color[0]},${a.color[1]},${a.color[2]},${a.color[3]/255})`,o.stroke(t),i.width+=o.lineWidth,i.height+=o.lineWidth}i.width*=n,i.height*=n;const p=o.getImageData(a/2-i.width/2,a/2-i.height/2,Math.ceil(i.width),Math.ceil(i.height));s=p.width,l=p.height,o.canvas.width=s,o.canvas.height=l,o.putImageData(p,0,0)}else{const i="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,a=(await t(i,{responseType:"image"})).data;s=r(e.width),l=r(e.height),o.canvas.width=s,o.canvas.height=l,o.drawImage(a,0,0,o.canvas.width,o.canvas.height)}return{type:"esriPMS",imageData:o.canvas.toDataURL("image/png").substr(22),angle:e.angle,contentType:"image/png",height:n(l),width:n(s),xoffset:e.xoffset,yoffset:e.yoffset}}async function ye(e,t){const i=e.type;if("simple"===i&&de(e.symbol))e.symbol=await ue(e.symbol,t);else if("uniqueValue"===i||"classBreaks"===i){de(e.defaultSymbol)&&(e.defaultSymbol=await ue(e.defaultSymbol,t));const a=e["uniqueValue"===i?"uniqueValueInfos":"classBreakInfos"];if(a)for(const e of a)de(e.symbol)&&(e.symbol=await ue(e.symbol,t))}}async function pe(e){return e.queryFeatures(e.createQuery()).then((e=>e.features))}function fe(e){return e.gpMetadata?.executionType?N.fromJSON(e.gpMetadata.executionType):"sync"}function de(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{J as execute,A as getGpPrintParams,C as getGpServerUrl,j as getMode,k as getTasks,U as printCacheMap};
|
|
5
|
+
import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as a}from"../core/jsonMap.js";import{createScreenPoint as i,pt2px as r,px2pt as n}from"../core/screenUtils.js";import{normalize as o,dataComponents as s}from"../core/urlUtils.js";import l from"../geometry/Polygon.js";import{collectLabelingFields as c}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as y}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as p,getToken as f}from"./utils.js";import{execute as m}from"./geoprocessor/execute.js";import{submitJob as d}from"./geoprocessor/submitJob.js";import{toJSON as g}from"./support/fileFormat.js";import{toJSON as h}from"./support/layoutTemplate.js";import{getVisibleLayerViews as b,isScreenshotRequired as w,isBingMapsLayer as S,isCSVLayer as x,isBlendLayer as I,getSelectionSymbol as v,getContextBoundingBox as D,createPolygonLayer as L,createPolylineLayer as T,createPointLayer as O,createMultipointLayer as E}from"./support/printTaskUtils.js";import P from"./support/PrintTemplate.js";import{toJSON as M}from"./support/reportTemplate.js";const F={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},V=new a({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),N=new a({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),U=new Map;async function J(e,t,a){const i=await R(e,a),r=await A(t,i);if("sync"===await j(e,a)){const{results:t}=await m(e,r,void 0,a);return t?.[0]?.value}const n=await d(e,r,void 0,a);await n.waitForJobCompletion({interval:t.updateDelay});const{value:o}=await n.fetchResultData("Output_File",null,a);return o}async function R(e,a){const i=C(e),r=U.get(i)??{gpServerUrl:i,legendLayerNameMap:{},legendLayers:[]};return r.gpMetadata??=(await t(i,p({f:"json"},a))).data,r.cimVersion=r.gpMetadata.cimVersion,U.set(i,r),r}async function j(e,t){return de(await R(e,t))}async function k(e,t){return(await R(e,t)).gpMetadata.tasks}async function A(t,a){a=a||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const i=t.template||new P;null==i.showLabels&&(i.showLabels=!0);const r=i.exportOptions;let n;const o=h(i.layout);if(r){if(n={dpi:r.dpi},"map_only"===o.toLowerCase()||""===o){const e=r.width,t=r.height;n.outputSize=null!=e&&null!=t?[e,t]:void 0}}const s=i.layoutOptions;let l;if(s){let e,t;"Miles"===s.scalebarUnit||"Kilometers"===s.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==s.scalebarUnit&&"Feet"!==s.scalebarUnit||(e="Meters",t="Feet"),l={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:{metricUnit:V.toJSON(e),metricLabel:e?F[e]:void 0,nonMetricUnit:V.toJSON(t),nonMetricLabel:t?F[t]:void 0}}}let c=null;s?.legendLayers&&(c=s.legendLayers.map((e=>{const t=e.layerId;a.legendLayerNameMap[t]=e.title;const i={id:t};return e.subLayerIds&&(i.subLayerIds=e.subLayerIds),i})));const u=await _(t,i,a);if(u.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,a=a=>{const i=a.text,r=a.font,n=r?.family?.toLowerCase();i&&r&&("arial"===n||"arial unicode ms"===n)&&(r.family=e.test(i)?"Arial Unicode MS":"Arial","normal"!==r.style&&t.test(i)&&(r.family="Arial Unicode MS"))};for(const i of u.operationalLayers)if(i.featureCollection?.layers)for(const e of i.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type&&a(t.symbol)}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&"esriTS"===t.symbol.type&&a(t.symbol)}}t.outSpatialReference&&(u.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(u,{exportOptions:n,layoutOptions:l||{}}),Object.assign(u.layoutOptions,{legendOptions:{operationalLayers:null!=c?c:a.legendLayers.slice()}}),a.legendLayers.length=0,U.set(a.gpServerUrl,a);const y={Web_Map_as_JSON:JSON.stringify(u),Format:g(i.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:M(i.report),Report_Item_ID:void 0};if(i.layoutItem){delete y.Layout_Template;const t=i.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(a.gpServerUrl),y.Layout_Item_ID=JSON.stringify({id:t.id})}if(i.reportItem){delete y.Report_Template;const t=i.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(a.gpServerUrl),y.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(y,t.extraParameters),y}async function _(e,t,a){const i=e.view;let r=i.spatialReference;const n={operationalLayers:await z(i,t,a)};t.includeTables&&(n.tables=await re(i));let o=e.extent||a.ssExtent||i.extent;if(r?.isWrappable&&(o=o.clone()._normalize(!0),r=o.spatialReference),n.mapOptions={extent:o&&o.toJSON(),spatialReference:r&&r.toJSON(),showAttribution:t.attributionVisible},a.ssExtent=null,i.background&&(n.background=i.background.toJSON()),i.rotation&&(n.mapOptions.rotation=-i.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||i.scale),null!=i.timeExtent){const e=null!=i.timeExtent.start?i.timeExtent.start.getTime():null,t=null!=i.timeExtent.end?i.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function C(e){let t=e;const a=t.lastIndexOf("/GPServer/");return a>0&&(t=t.slice(0,a+9)),t}async function z(e,t,a){const i=[],r={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const o=b(e,n);for(const s of o){const e=s.layer;if(!e.loaded||"layers"in e)continue;let t;r.layerView=s,t=w(s)?await ae(e,r,a):S(e)?$(e):x(e)?await K(e,r,a):"catalog-footprint"===e?.type?await q(e,r,a):"feature"===e?.type?await B(e,r,a):"geojson"===e?.type?await G(e,r,a):"graphics"===e?.type?await H(e,r,a):"imagery"===e?.type?Q(e,a):"imagery-tile"===e?.type?await X(e,r,a):"kml"===e?.type?await Y(e,r,a):"map-image"===e?.type?Z(e,r,a):"map-notes"===e?.type?await ee(r,a):"open-street-map"===e?.type?te():"stream"===e?.type?await ie(e,r,a):"tile"===e?.type?ne(e,a):"vector-tile"===e?.type?await oe(e,r,a):"web-tile"===e?.type?se(e):"wms"===e?.type?le(e,a):"wmts"===e?.type?ce(e):await ae(e,r,a),t&&(Array.isArray(t)?i.push(...t):(t.id=e.id,t.title=a.legendLayerNameMap[e.id]||e.title,t.opacity=s.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,I(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),i.push(t)))}if(n)for(const s of i)s.minScale=0,s.maxScale=0;if(e.graphics?.length){const r=await W(null,e.graphics,t,a);r&&i.push(r)}return i}function $(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function q(e,{layerView:t,printTemplate:a},i){if(parseFloat(i.cimVersion)<3.1){return W(e,await fe(t),a,i)}const r=e.parent,n={id:(o=me(r,"web-map")).id,url:o.url,layerType:o.layerType,customParameters:o.customParameters,dynamicGroupLayer:{visibility:!1},footprintLayer:o.footprintLayer,layerDefinition:o.layerDefinition};var o;return ue(n,r),n}async function K(e,t,a){e.legendEnabled&&a.legendLayers.push({id:e.id});const i=t.layerView,r=t.printTemplate;if(!(i.filter||e.portalItem&&"public"!==e.portalItem.access)){const t=me(e,"web-map");return t.type="CSV",delete t.popupInfo,delete t.layerType,t.showLabels=r.showLabels&&e.labelsVisible,t}return W(e,await fe(i),r,a)}async function W(e,t,a,i){let r;const n=L(),o=T(),s=O(),u=E(),y=O();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=i.legendLayerNameMap[e.id]||e.get("arcgisProps.title")||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),a=n.layerDefinition.drawingInfo;a&&(a.renderer=t);const i=o.layerDefinition.drawingInfo;i&&(i.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const l=u.layerDefinition.drawingInfo;l&&(l.renderer=t)}if(a.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=me(e,"web-map"),a=t.layerDefinition?.drawingInfo?.labelingInfo;if(a){r=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=a);const t=o.layerDefinition.drawingInfo;t&&(t.labelingInfo=a);const i=s.layerDefinition.drawingInfo;i&&(i.labelingInfo=a);const l=u.layerDefinition.drawingInfo;l&&(l.labelingInfo=a)}}}let p;e?.renderer||r||(delete n.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);const f=e?.fieldsIndex,m=e?.renderer;if(f){const t=new Set;r&&await c(t,e),m&&"function"==typeof m.collectRequiredFields&&await m.collectRequiredFields(t,f),p=Array.from(t);const a=f.fields.map((e=>e.toJSON()));n.layerDefinition.fields=a,o.layerDefinition.fields=a,s.layerDefinition.fields=a,u.layerDefinition.fields=a}const d=t?.length;let g;for(let c=0;c<d;c++){const e=t[c]||t.at(c);if(!1!==e.visible&&e.geometry){if(g=e.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol&&(g.symbol.angle||delete g.symbol.angle,ge(g.symbol)?g.symbol=await ye(g.symbol,i):g.symbol.text&&delete g.attributes),(!a||!a.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===e.geometry.type?n.featureSet.features.push(g):"polyline"===e.geometry.type?o.featureSet.features.push(g):"point"===e.geometry.type?g.symbol?.text?y.featureSet.features.push(g):s.featureSet.features.push(g):"multipoint"===e.geometry.type?u.featureSet.features.push(g):"extent"===e.geometry.type&&(g.geometry=l.fromExtent(e.geometry).toJSON(),n.featureSet.features.push(g))}}const h=[n,o,u,s,y].filter((e=>e.featureSet.features.length>0));for(const l of h){const e=l.featureSet.features.every((e=>e.symbol));if(e&&(!a||!a.forceFeatureAttributes))for(const t of l.featureSet.features)delete t.attributes;e&&delete l.layerDefinition.drawingInfo,l.layerDefinition.drawingInfo?.renderer&&await pe(l.layerDefinition.drawingInfo.renderer,i)}return h.length?{featureCollection:{layers:h},showLabels:r}:null}async function B(e,t,a){let i;const r=e.renderer,n=parseFloat(a.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&n<2.9||"pie-chart"===r?.type||"dot-density"===r?.type&&n<2.6)return ae(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});const o=t.layerView,{printTemplate:s,view:l}=t,c="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(o.filter||c||!r||"field"in r&&null!=r.field&&!e.getField(r.field)){const t=await fe(o);i=await W(e,t,s,a)}else{if(i={id:(p=me(e)).id,title:p.title,url:p.url,layerType:p.layerType,customParameters:p.customParameters,layerDefinition:p.layerDefinition,charts:s.includeCharts?p.charts:void 0},i.showLabels=s.showLabels&&e.labelsVisible,ue(i,e),i.layerDefinition?.drawingInfo?.renderer&&(delete i.layerDefinition.minScale,delete i.layerDefinition.maxScale,await pe(i.layerDefinition.drawingInfo.renderer,a),"visualVariables"in r&&r.visualVariables&&r.visualVariables[0])){const e=r.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=y(e,l.scale);i.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,i.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=u(o);if(t&&(i.layerDefinition||(i.layerDefinition={}),i.layerDefinition.definitionExpression=i.layerDefinition.definitionExpression?`(${i.layerDefinition.definitionExpression}) AND (${t})`:t),o.hasHighlight?.()&&"getHighlightIds"in o){const t=o;i.selectionObjectIds=t.getHighlightIds(),i.selectionSymbol=v(e.geometryType,t.highlightOptions??l.highlightOptions)}}var p;return i}async function G(e,t,a){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return ae(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});return W(e,await fe(t.layerView),t.printTemplate,a)}async function H(e,{printTemplate:t},a){return W(e,null,t,a)}function Q(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const a={layerType:(i=me(e)).layerType,customParameters:i.customParameters};var i;return a.bandIds=e.bandIds,a.compressionQuality=e.compressionQuality,a.format=e.format,a.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(a.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(a.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(a.layerDefinition??={},a.layerDefinition.drawingInfo??={},a.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),ue(a,e),a}async function X(e,t,a){if("flow"===e.renderer?.type)return ae(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});const i={bandIds:(r=me(e)).bandIds,customParameters:r.customParameters,interpolation:r.interpolation,layerDefinition:r.layerDefinition};var r;return i.layerType="ArcGISImageServiceLayer",ue(i,e),i}async function Y(e,t,a){const i=t.printTemplate;if(!e.portalItem||"public"===e.portalItem.access){const t=me(e,"web-map");return t.type="kml",delete t.layerType,t.url=o(e.url),t}const r=[],n=t.layerView;n.allVisibleMapImages.forEach(((t,a)=>{const i={id:`${e.id}_image${a}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};"data:image/png;base64,"===t.href.substr(0,22)?i.imageData=t.href.substr(22):i.url=t.href,r.push(i)}));const s=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],l={id:e.id,...await W(null,s,i,a)};return r.push(l),r}function Z(e,{view:t},a){let i;const r={id:e.id,subLayerIds:[]};let n=[];const o=t.scale,s=e=>{const t=0===o,a=0===e.minScale||o<=e.minScale,i=0===e.maxScale||o>=e.maxScale;if(e.visible&&(t||a&&i))if(e.sublayers)e.sublayers.forEach(s);else{const t=e.toExportImageJSON(),a={id:e.id,name:e.title,layerDefinition:{drawingInfo:t.drawingInfo,definitionExpression:t.definitionExpression,source:t.source}};n.unshift(a),r.subLayerIds.push(e.id)}};var l;return e.sublayers&&e.sublayers.forEach(s),n.length&&(n=n.map((({id:e,name:t,layerDefinition:a})=>({id:e,name:t,layerDefinition:a}))),i={layerType:(l=me(e)).layerType,customParameters:l.customParameters},i.layers=n,i.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:r.subLayerIds,ue(i,e),e.legendEnabled&&a.legendLayers.push(r)),i}async function ee({layerView:e,printTemplate:t},a){const i=[],r=e.layer;if(null!=r.featureCollections)for(const n of r.featureCollections){const e=await W(n,n.source,t,a);e&&i.push(...e.featureCollection.layers)}else if(null!=r.sublayers)for(const n of r.sublayers){const e=await W(null,n.graphics,t,a);e&&i.push(...e.featureCollection.layers)}return{featureCollection:{layers:i}}}function te(){return{type:"OpenStreetMap"}}async function ae(e,{printTemplate:t,view:a},r){const n={type:"image"},o={format:"png",ignoreBackground:!0,ignorePadding:!0,layers:[e]};0!==a.rotation&&(o.rotation=0);const l=r.ssExtent||a.state.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==a.width%2),null!=e.height&&e.height>0&&(y=e.height%2==a.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===a.scale)&&96===c&&(!u||!y)&&a.state.extent.equals(a.extent)&&(o.area={x:0,y:0,width:a.width,height:a.height},u||(o.area.width-=1),y||(o.area.height-=1),!r.ssExtent)){const e=a.toMap(i(o.area.width,o.area.height));l.ymin=e.y,l.xmax=e.x,r.ssExtent=l}n.extent=l.clone()._normalize(!0).toJSON();const p=await a.takeScreenshot(o);return n.imageData=s(p.dataUrl)?.data,n}async function ie(e,{layerView:t,printTemplate:a},i){e.legendEnabled&&i.legendLayers.push({id:e.id});return W(e,await fe(t),a,i)}async function re(e){const t=[],a=[];for(const r of e.map.allTables)"feature"!==r.type||r.loaded||a.push(r.load());a.length&&await Promise.allSettled(a);for(const r of e.map.allTables)if("feature"===r.type&&r.loaded&&r.isTable&&"feature-layer"===r.source?.type){const e={id:(i=me(r)).id,title:i.title,customParameters:i.customParameters,layerDefinition:{definitionExpression:i.layerDefinition?.definitionExpression},url:i.url};ue(e,r),t.push(e)}var i;return t.length?t:void 0}function ne(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const a={layerType:(i=me(e)).layerType,customParameters:i.customParameters};var i;return ue(a,e),a}async function oe(e,t,a){if(e.serviceUrl&&e.styleUrl){const t=f(e.styleUrl,e.apiKey),i=f(e.serviceUrl,e.apiKey);if(!t&&!i||"2.1.0"!==a.cimVersion){const a={type:"VectorTileLayer"};return a.styleUrl=o(e.styleUrl),a.token=t,i!==t&&(a.additionalTokens=[{url:e.serviceUrl,token:i}]),a}}return ae(e,t,a)}function se(e){const t=e.urlTemplate?.replace(/\${/g,"{"),a={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(a.subDomains=e.subDomains),a}function le(e,t){let a;const i=[],r=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(r):e.name&&i.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(r),i.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:i}),a={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:i,url:o(e.url),version:e.version}),a}function ce(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:o(e.url)}}function ue(e,t){t.url&&(e.url=o(e.url||t.url),e.token=f(e.url,t.apiKey))}async function ye(e,a){a.canvas||(a.canvas=document.createElement("canvas"));const i=1024;a.canvas.width=i,a.canvas.height=i;const o=a.canvas.getContext("2d");let s,l;if(e.path){const t=new Path2D(e.path);t.closePath(),o.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",o.fill(t);const a=D(o);if(!a)return null;o.clearRect(0,0,i,i);const n=r(e.size)/Math.max(a.width,a.height);o.scale(n,n);const c=i/n,u=c/2-a.width/2-a.x,y=c/2-a.height/2-a.y;if(o.translate(u,y),Array.isArray(e.color)&&o.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const i=e.outline;o.lineWidth=r(i.width)/n,o.lineJoin="round",o.strokeStyle=`rgba(${i.color[0]},${i.color[1]},${i.color[2]},${i.color[3]/255})`,o.stroke(t),a.width+=o.lineWidth,a.height+=o.lineWidth}a.width*=n,a.height*=n;const p=o.getImageData(i/2-a.width/2,i/2-a.height/2,Math.ceil(a.width),Math.ceil(a.height));s=p.width,l=p.height,o.canvas.width=s,o.canvas.height=l,o.putImageData(p,0,0)}else{const a="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,i=(await t(a,{responseType:"image"})).data;s=r(e.width),l=r(e.height),o.canvas.width=s,o.canvas.height=l,o.drawImage(i,0,0,o.canvas.width,o.canvas.height)}return{type:"esriPMS",imageData:o.canvas.toDataURL("image/png").substr(22),angle:e.angle,contentType:"image/png",height:n(l),width:n(s),xoffset:e.xoffset,yoffset:e.yoffset}}async function pe(e,t){const a=e.type;if("simple"===a&&ge(e.symbol))e.symbol=await ye(e.symbol,t);else if("uniqueValue"===a||"classBreaks"===a){ge(e.defaultSymbol)&&(e.defaultSymbol=await ye(e.defaultSymbol,t));const i=e["uniqueValue"===a?"uniqueValueInfos":"classBreakInfos"];if(i)for(const e of i)ge(e.symbol)&&(e.symbol=await ye(e.symbol,t))}}async function fe(e){return e.queryFeatures(e.createQuery()).then((e=>e.features))}function me(e,t){return e.write({},{ignorePersistenceEnabled:!0,origin:t})??{}}function de(e){return e.gpMetadata?.executionType?N.fromJSON(e.gpMetadata.executionType):"sync"}function ge(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{J as execute,A as getGpPrintParams,C as getGpServerUrl,j as getMode,k as getTasks,U as printCacheMap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import r from"../../symbols/SimpleFillSymbol.js";import n from"../../symbols/SimpleLineSymbol.js";import t from"../../symbols/SimpleMarkerSymbol.js";import{isInEffectiveScaleRange as o}from"../../views/support/layerViewUtils.js";function i(){return{layerDefinition:{name:"multipointLayer",geometryType:"esriGeometryMultipoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryMultipoint",features:[]}}}function l(){return{layerDefinition:{name:"polygonLayer",geometryType:"esriGeometryPolygon",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolygon",features:[]}}}function f(){return{layerDefinition:{name:"pointLayer",geometryType:"esriGeometryPoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPoint",features:[]}}}function a(){return{layerDefinition:{name:"polylineLayer",geometryType:"esriGeometryPolyline",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolyline",features:[]}}}function y(e,r=15){const n=e.canvas.width,t=e.canvas.height,o=e.getImageData(0,0,n,t).data;let i,l,f,a,y,
|
|
5
|
+
import e from"../../Color.js";import r from"../../symbols/SimpleFillSymbol.js";import n from"../../symbols/SimpleLineSymbol.js";import t from"../../symbols/SimpleMarkerSymbol.js";import{isInEffectiveScaleRange as o}from"../../views/support/layerViewUtils.js";function i(){return{layerDefinition:{name:"multipointLayer",geometryType:"esriGeometryMultipoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryMultipoint",features:[]}}}function l(){return{layerDefinition:{name:"polygonLayer",geometryType:"esriGeometryPolygon",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolygon",features:[]}}}function f(){return{layerDefinition:{name:"pointLayer",geometryType:"esriGeometryPoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPoint",features:[]}}}function a(){return{layerDefinition:{name:"polylineLayer",geometryType:"esriGeometryPolyline",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolyline",features:[]}}}function y(e,r=15){const n=e.canvas.width,t=e.canvas.height,o=e.getImageData(0,0,n,t).data;let i,l,f,a,y,u;e:for(l=t;l--;)for(i=n;i--;)if(o[4*(n*l+i)+3]>r){u=l;break e}if(!u)return null;e:for(i=n;i--;)for(l=u+1;l--;)if(o[4*(n*l+i)+3]>r){y=i;break e}e:for(i=0;i<=y;++i)for(l=u+1;l--;)if(o[4*(n*l+i)+3]>r){f=i;break e}e:for(l=0;l<=u;++l)for(i=f;i<=y;++i)if(o[4*(n*l+i)+3]>r){a=l;break e}return{x:f,y:a,width:y-f,height:u-a}}function u(o,i){const l=i.color?.clone()??new e([0,255,255]),f=i.haloColor?.clone()??l.clone();switch(o){case"envelope":case"polygon":return l.a*=i.fillOpacity??.25,new r({color:l,outline:new n({color:f}),style:"solid"});case"polyline":return new n({color:f});default:return f.a=1,new t({color:f,outline:null})}}function s(e,r){const n=e.allLayerViews.items;if(r===e.scale)return n.filter((e=>!e.suspended));const t=new Array;for(const i of n){const e=i.parent;e&&e!==i.view&&(g(e)||d(e))&&!t.includes(e)||i.visible&&i.visibleAtCurrentTimeExtent&&o(i.layer.effectiveScaleRange,r)&&t.push(i)}return t}function c(e){return"bing-maps"===e?.type}function m(e){return e&&"blendMode"in e&&"effect"in e}function p(e){return"csv"===e?.type}function g(e){return"catalog"===e.layer.type}function d(e){return"group"===e.layer.type}function w(e){const r=e.layer;if(m(r)){const n=r.blendMode;if((!n||"normal"===n)&&(r.effect||"featureEffect"in e&&e.featureEffect))return!0}return!1}export{i as createMultipointLayer,f as createPointLayer,l as createPolygonLayer,a as createPolylineLayer,y as getContextBoundingBox,u as getSelectionSymbol,s as getVisibleLayerViews,c as isBingMapsLayer,m as isBlendLayer,p as isCSVLayer,w as isScreenshotRequired};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../symbols.js";import e from"../../../core/Error.js";import{clone as r}from"../../../core/lang.js";import n from"../../../renderers/visualVariables/support/SizeStop.js";import{PlacementPolygonCenterMethod as
|
|
5
|
+
import"../../../symbols.js";import e from"../../../core/Error.js";import{clone as r}from"../../../core/lang.js";import n from"../../../renderers/visualVariables/support/SizeStop.js";import{PlacementPolygonCenterMethod as t}from"../../../symbols/cim/enums.js";import i from"../../../symbols/CIMSymbol.js";var o;function a(r){if(null!=r.minDataValue&&null!=r.maxDataValue&&null!=r.minSize&&null!=r.maxSize&&"number"==typeof r.minSize&&"number"==typeof r.maxSize)return[new n({value:r.minDataValue,size:r.minSize}),new n({value:r.maxDataValue,size:r.maxSize})];throw new e("create-reference-size-symbol","Invalid size variable")}function l(e){const{view:r,field:n,normalizationField:t,sizeStops:i,sizeByScaleEnabled:a}=e,{value:l,size:s}=i[0],{value:m,size:c}=i[1];let u,y=0;n&&(y=`$feature["${n}"]`,u=`\n if(!HasKey($feature, "${n}")){\n return null;\n }\n $feature["${n}"];\n `),t&&(y=`$feature["${n}"] / $feature["${t}"]`,u=`if(!HasValue($feature, "${n}") || !HasValue($feature, "${t}") || $feature["${t}"] <= 0){\n return 0;\n }\n $feature["${n}"];\n $feature["${t}"];`);const p={type:"CIMExpressionInfo",title:"Size in pixels of outer ring",expression:a?`\n var maxSize = ${c};\n var referenceScale = ${r.scale};\n return (maxSize * (referenceScale / $view.scale));\n `:`${c}`,returnType:"Default"},f={type:"CIMExpressionInfo",title:"Size in pixels of inner ring",expression:`\n ${u}\n var value = ${y};\n\n var referenceScale = ${r.scale};\n var referenceScaleRatio = ${a?"(referenceScale / $view.scale)":1};\n var maxSize = ${c} * referenceScaleRatio;\n var minSize = ${s} * referenceScaleRatio;\n\n var minDataValue = ${l};\n var maxDataValue = ${m};\n\n var ratio = Constrain(( value - minDataValue ) / ( maxDataValue - minDataValue ), 0, 1);\n\n var innerDotSize = Constrain(maxSize * ratio, minSize, maxSize);\n return innerDotSize;\n `,returnType:"Default"};return[{type:"CIMPrimitiveOverride",primitiveName:o.OuterRing,propertyName:"Size",valueExpressionInfo:p},{type:"CIMPrimitiveOverride",primitiveName:o.InnerDot,propertyName:"Size",valueExpressionInfo:f}]}function s(e){switch(e){case"circle":return{rings:[[[8.5,.2],[7.06,.33],[5.66,.7],[4.35,1.31],[3.16,2.14],[2.14,3.16],[1.31,4.35],[.7,5.66],[.33,7.06],[.2,8.5],[.33,9.94],[.7,11.34],[1.31,12.65],[2.14,13.84],[3.16,14.86],[4.35,15.69],[5.66,16.3],[7.06,16.67],[8.5,16.8],[9.94,16.67],[11.34,16.3],[12.65,15.69],[13.84,14.86],[14.86,13.84],[15.69,12.65],[16.3,11.34],[16.67,9.94],[16.8,8.5],[16.67,7.06],[16.3,5.66],[15.69,4.35],[14.86,3.16],[13.84,2.14],[12.65,1.31],[11.34,.7],[9.94,.33],[8.5,.2]]]};case"square":return{rings:[[[.5,.5],[.5,16.5],[16.5,16.5],[16.5,.5],[.5,.5]]]};case"diamond":return{rings:[[[8.5,.5],[.2,8.5],[8.5,16.5],[16.5,8.5],[8.5,.5]]]};case"hexagon-pointy":return{rings:[[[15.86,12.75],[15.86,4.25],[8.5,0],[1.14,4.25],[1.14,12.75],[8.5,17],[15.86,12.75]]]};case"hexagon-flat":return{rings:[[[12.75,15.86],[17,8.5],[12.75,1.14],[4.25,1.14],[0,8.5],[4.25,15.86],[12.75,15.86]]]}}}function m(e){const{type:r,color:n,colorLocked:i}=e;return{type:"CIMVectorMarker",enable:!0,colorLocked:!1,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",primitiveName:o.OuterRing,frame:{xmin:0,ymin:0,xmax:17,ymax:17},markerGraphics:[{type:"CIMMarkerGraphic",geometry:s(r),symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:n.toArray(),colorLocked:!!i,effects:[{type:"CIMGeometricEffectDonut",width:.75}]}]}}],scaleSymbolsProportionally:!1,respectFrame:!0,markerPlacement:{type:"CIMMarkerPlacementPolygonCenter",placePerPart:!1,method:t.OnPolygon,offsetX:0,offsetY:0,clipAtBoundary:!1},size:20}}function c(e){const{type:r,color:n}=e;return{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",primitiveName:o.InnerDot,frame:{xmin:0,ymin:0,xmax:17,ymax:17},markerGraphics:[{type:"CIMMarkerGraphic",geometry:s(r),symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:n.toArray()}]}}],scaleSymbolsProportionally:!0,respectFrame:!0,markerPlacement:{type:"CIMMarkerPlacementPolygonCenter",placePerPart:!1,method:t.OnPolygon,offsetX:0,offsetY:0,clipAtBoundary:!1},size:10}}function u(e){const{primitiveOverrides:r}=e;return new i({data:{type:"CIMSymbolReference",symbol:{type:"CIMPolygonSymbol",symbolLayers:[m(e),c(e)]},primitiveOverrides:r}})}function y(e){return"CIMVectorMarker"===e?.type?e.markerGraphics?.[0]:void 0}function p(e){return"CIMPolygonSymbol"===e?.symbol?.type?e.symbol.symbolLayers?.[0]:void 0}function f(e,r){"CIMVectorMarker"===e?.type&&null!=r&&(e.size=r)}function v(e,r){const n=y(e);n&&null!=r&&(n.geometry=s(r))}function S(e,r){const n=p(y(e));n&&null!=r&&(n.color=r.toArray())}function z(e,r,n){const t=p(y(e));t&&null!=r&&n&&(t.colorLocked=r)}function d(e,n){const{outerRingSize:t,innerDotSize:i,type:a,color:l,colorLocked:s,primitiveOverrides:m}=n,c="CIMPolygonSymbol"===e.data.symbol?.type?e.data.symbol.symbolLayers:null;if(2===c?.length)for(const r of c){const e=r.primitiveName===o.OuterRing;f(r,e?t:i),v(r,a),S(r,l),z(r,s,e)}return null!=t&&null!=i&&(e.data.primitiveOverrides=null),void 0!==m&&(e.data.primitiveOverrides=r(m)),e}!function(e){e.OuterRing="reference-size-outer-ring",e.InnerDot="reference-size-inner-dot"}(o||(o={}));export{l as createPrimitiveOverrides,u as createReferenceSizeSymbol,a as getReferenceSizeStops,d as updateReferenceSizeSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../CSVLayerAdapter.js";import
|
|
5
|
+
import e from"../CSVLayerAdapter.js";import a from"../FeatureLayerAdapter.js";import r from"../FeatureLayerBinningAdapter.js";import t from"../InMemoryLayerAdapter.js";import y from"../LayerAdapter.js";import o from"../PointCloudLayerAdapter.js";import L from"../SceneLayerAdapter.js";import n from"../StreamLayerAdapter.js";var p;!function(e){e[e.CatalogLayer=0]="CatalogLayer",e[e.CatalogFootprintLayer=1]="CatalogFootprintLayer",e[e.CSVLayer=2]="CSVLayer",e[e.FeatureLayer=3]="FeatureLayer",e[e.GeoJSONLayer=4]="GeoJSONLayer",e[e.OGCFeatureLayer=5]="OGCFeatureLayer",e[e.OrientedImageryLayer=6]="OrientedImageryLayer",e[e.PointCloudLayer=7]="PointCloudLayer",e[e.SceneLayer=8]="SceneLayer",e[e.StreamLayer=9]="StreamLayer",e[e.WFSLayer=10]="WFSLayer"}(p||(p={}));const l={[p.CatalogLayer]:{adapter:a,type:"catalog",label:"CatalogLayer"},[p.CatalogFootprintLayer]:{adapter:a,type:"catalog-footprint",label:"CatalogFootprintLayer"},[p.CSVLayer]:{adapter:e,type:"csv",label:"CSVLayer"},[p.FeatureLayer]:{adapter:a,type:"feature",label:"FeatureLayer"},[p.GeoJSONLayer]:{adapter:a,type:"geojson",label:"GeoJSONLayer"},[p.OGCFeatureLayer]:{adapter:t,type:"ogc-feature",label:"OGCFeatureLayer"},[p.OrientedImageryLayer]:{adapter:a,type:"oriented-imagery",label:"OrientedImageryLayer"},[p.PointCloudLayer]:{adapter:o,type:"point-cloud",label:"PointCloudLayer"},[p.SceneLayer]:{adapter:L,type:"scene",label:"SceneLayer"},[p.StreamLayer]:{adapter:n,type:"stream",label:"StreamLayer"},[p.WFSLayer]:{adapter:a,type:"wfs",label:"WFSLayer"}},i=[p.CatalogLayer,p.CatalogFootprintLayer,p.CSVLayer,p.FeatureLayer,p.GeoJSONLayer,p.OGCFeatureLayer,p.OrientedImageryLayer,p.PointCloudLayer,p.SceneLayer,p.StreamLayer,p.WFSLayer],u=[p.CatalogFootprintLayer,p.CSVLayer,p.FeatureLayer,p.GeoJSONLayer,p.OGCFeatureLayer,p.OrientedImageryLayer,p.SceneLayer,p.StreamLayer,p.WFSLayer],m=[p.CSVLayer,p.FeatureLayer,p.GeoJSONLayer,p.OGCFeatureLayer,p.OrientedImageryLayer,p.StreamLayer,p.WFSLayer];function S(e){return e.map((e=>l[e].label))}function d(e){return e.map((e=>l[e].type))}function C(e,a=i,t){if(e instanceof y)return e;const o=F(e,a);return o?t?new r({layer:e}):new o({layer:e}):null}function F(e,a=i){let r=null;return a.some((a=>{const t=e.type===l[a].type;return t&&(r=l[a].adapter),t})),r}export{p as LayerType,m as binningCapableLayerTypes,C as createLayerAdapter,i as defaultSupportedLayerTypes,u as featureCapableLayerTypes,S as getLayerTypeLabels,d as getLayerTypes};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const a="20240523",c="ea20ae8de738c7451d678ba87c6c965a5af6ce49";export{a as buildDate,c as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{GeometryCursor as s}from"../../../geometry/GeometryCursor.js";import{collectMultipath as t}from"../../../geometry/geometryCursorCollectUtils.js";import{setId as i}from"../CIMCursor.js";import{GeometricEffectControlMeasureLineRule as h}from"../enums.js";class e{static local(){return null===e.instance&&(e.instance=new e),e.instance}execute(s,t,i,h,e){return new r(s,t,i)}}e.instance=null;class r{constructor(s,t,i){this._defaultPointSize=20,this._inputGeometries=s,this._geomUnitsPerPoint=i,this._rule=t.rule??h.FullGeometry,this._defaultSize=this._defaultPointSize*i}next(){let i;for(;i=this._inputGeometries.next();){const h=this._processGeom(t(i));if(h?.length)return s.fromJSONCIM({paths:h})}return null}_clone(s){return[s[0],s[1]]}_mid(s,t){return[(s[0]+t[0])/2,(s[1]+t[1])/2]}_mix(s,t,i,h){return[s[0]*t+i[0]*h,s[1]*t+i[1]*h]}_add(s,t){return[s[0]+t[0],s[1]+t[1]]}_add2(s,t,i){return[s[0]+t,s[1]+i]}_sub(s,t){return[s[0]-t[0],s[1]-t[1]]}_dist(s,t){return Math.sqrt((s[0]-t[0])*(s[0]-t[0])+(s[1]-t[1])*(s[1]-t[1]))}_norm(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1])}_normalize(s,t=1){const i=t/this._norm(s);s[0]*=i,s[1]*=i}_leftPerpendicular(s){const t=-s[1],i=s[0];s[0]=t,s[1]=i}_leftPerp(s){return[-s[1],s[0]]}_rightPerpendicular(s){const t=s[1],i=-s[0];s[0]=t,s[1]=i}_rightPerp(s){return[s[1],-s[0]]}_dotProduct(s,t){return s[0]*t[0]+s[1]*t[1]}_crossProduct(s,t){return s[0]*t[1]-s[1]*t[0]}_rotateDirect(s,t,i){const h=s[0]*t-s[1]*i,e=s[0]*i+s[1]*t;s[0]=h,s[1]=e}_makeCtrlPt(s){const t=[s[0],s[1]];return i(t,1),t}_addAngledTicks(s,t,i,h){const e=this._sub(i,t);this._normalize(e);const r=this._crossProduct(e,this._sub(h,t));let _;_=r>0?this._rightPerp(e):this._leftPerp(e);const c=Math.abs(r)/2,u=[];u.push([t[0]+(_[0]-e[0])*c,t[1]+(_[1]-e[1])*c]),u.push(t),u.push(i),u.push([i[0]+(_[0]+e[0])*c,i[1]+(_[1]+e[1])*c]),s.push(u)}_addBezier2(s,t,i,h,e){if(0==e--)return void s.push(h);const r=this._mid(t,i),_=this._mid(i,h),c=this._mid(r,_);this._addBezier2(s,t,r,c,e),this._addBezier2(s,c,_,h,e)}_addBezier3(s,t,i,h,e,r){if(0==r--)return void s.push(e);const _=this._mid(t,i),c=this._mid(i,h),u=this._mid(h,e),o=this._mid(_,c),n=this._mid(c,u),a=this._mid(o,n);this._addBezier3(s,t,_,o,a,r),this._addBezier3(s,a,n,u,e,r)}_add90DegArc(s,t,i,h,e){const r=e??this._crossProduct(this._sub(i,t),this._sub(h,t))>0,_=this._mid(t,i),c=this._sub(_,t);r?this._leftPerpendicular(c):this._rightPerpendicular(c),_[0]+=c[0],_[1]+=c[1],this._addBezier3(s,t,this._mix(t,.33333,_,.66667),this._mix(i,.33333,_,.66667),i,4)}_addArrow(s,t,i){const h=t[0],e=t[1],r=t[t.length-1],_=this._sub(h,e),c=this._norm(_);this._normalize(_);const u=Math.abs(this._crossProduct(_,this._sub(r,e)));let o=this._dotProduct(_,this._sub(r,e));o<.05*c?o=.05*c:o>.95*c&&(o=.95*c);const n=.5*u,a=this._leftPerp(_),p=[e[0]+_[0]*o,e[1]+_[1]*o],d=t.length-1,l=[];l.push(i?[-a[0],-a[1]]:a);let b=[-_[0],-_[1]];for(let P=1;P<d-1;P++){const s=this._sub(t[P+1],t[P]);this._normalize(s);const i=this._dotProduct(s,b),h=this._crossProduct(s,b),e=Math.sqrt((1+i)/2),r=this._sub(s,b);this._normalize(r),r[0]/=e,r[1]/=e,l.push(h<0?[-r[0],-r[1]]:r),b=s}l.push(this._rightPerp(b));for(let P=l.length-1;P>0;P--)s.push([t[P][0]+l[P][0]*n,t[P][1]+l[P][1]*n]);s.push([p[0]+l[0][0]*n,p[1]+l[0][1]*n]),s.push([p[0]+l[0][0]*u,p[1]+l[0][1]*u]),s.push(h),s.push([p[0]-l[0][0]*u,p[1]-l[0][1]*u]),s.push([p[0]-l[0][0]*n,p[1]-l[0][1]*n]);for(let P=1;P<l.length;P++)s.push([t[P][0]-l[P][0]*n,t[P][1]-l[P][1]*n])}_cp2(s,t,i){return s.length>=2?s[1]:this._add2(s[0],t*this._defaultSize,i*this._defaultSize)}_cp3(s,t,i,h){if(s.length>=3)return s[2];const e=this._mix(s[0],1-i,t,i),r=this._sub(t,s[0]);return this._normalize(r),this._rightPerpendicular(r),[e[0]+r[0]*h*this._defaultSize,e[1]+r[1]*h*this._defaultSize]}_arrowPath(s){if(s.length>2)return s;const t=s[0],i=this._cp2(s,-4,0),h=this._sub(t,i);this._normalize(h);const e=this._rightPerp(h);return[t,i,[t[0]+(e[0]-h[0])*this._defaultSize,t[1]+(e[1]-h[1])*this._defaultSize]]}_arrowLastSeg(s){const t=s[0],i=this._cp2(s,-4,0);let h;if(s.length>=3)h=s[s.length-1];else{const s=this._sub(t,i);this._normalize(s);const e=this._rightPerp(s);h=[t[0]+(e[0]-s[0])*this._defaultSize,t[1]+(e[1]-s[1])*this._defaultSize]}return[i,h]}_processGeom(s){if(!s)return null;const t=[];for(const e of s){if(!e||0===e.length)continue;const s=e.length;let r=e[0];switch(this._rule){case h.PerpendicularFromFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=[];h.push(i),h.push(this._mid(r,s)),t.push(h);break}case h.ReversedFirstSegment:{const s=this._cp2(e,0,-1);t.push([s,r]);break}case h.PerpendicularToSecondSegment:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=[];h.push(this._mid(s,i)),h.push(r),t.push(h);break}case h.SecondSegmentWithTicks:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);let _;_=this._crossProduct(h,this._sub(r,s))>0?this._rightPerp(h):this._leftPerp(h);const c=[];c.push([s[0]+(_[0]-h[0])/3,s[1]+(_[1]-h[1])/3]),c.push(s),c.push(i),c.push([i[0]+(_[0]+h[0])/3,i[1]+(_[1]+h[1])/3]),t.push(c);break}case h.DoublePerpendicular:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,3),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push(r),u.push([i[0]+_[0]*c,i[1]+_[1]*c]),t.push(u);const o=[];o.push([i[0]-_[0]*c,i[1]-_[1]*c]),o.push(s),t.push(o);break}case h.OppositeToFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,3),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push([i[0]+_[0]*c,i[1]+_[1]*c]),u.push([i[0]-_[0]*c,i[1]-_[1]*c]),t.push(u);break}case h.TriplePerpendicular:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push([i[0]+_[0]*c*.8,i[1]+_[1]*c*.8]),u.push([h[0]+.8*(r[0]-h[0]),h[1]+.8*(r[1]-h[1])]),t.push(u),t.push([i,h]);const o=[];o.push([i[0]-_[0]*c*.8,i[1]-_[1]*c*.8]),o.push([h[0]+.8*(s[0]-h[0]),h[1]+.8*(s[1]-h[1])]),t.push(o);break}case h.HalfCircleFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=this._mid(r,s);let _=this._sub(s,r);const c=Math.cos(Math.PI/18),u=Math.sin(Math.PI/18),o=Math.sqrt((1+c)/2),n=Math.sqrt((1-c)/2),a=[];let p;this._crossProduct(_,this._sub(i,r))>0?(a.push(r),_=this._sub(r,h),p=s):(a.push(s),_=this._sub(s,h),p=r),this._rotateDirect(_,o,n),_[0]/=o,_[1]/=o;for(let t=1;t<=18;t++)a.push(this._add(h,_)),this._rotateDirect(_,c,u);a.push(p),t.push(a);break}case h.HalfCircleSecondSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,1,-1);let h=this._sub(r,s);this._normalize(h);const _=this._crossProduct(h,this._sub(i,s))/2;this._leftPerpendicular(h);const c=[s[0]+h[0]*_,s[1]+h[1]*_];h=this._sub(s,c);const u=Math.cos(Math.PI/18);let o=Math.sin(Math.PI/18);_>0&&(o=-o);const n=[s];for(let t=1;t<=18;t++)this._rotateDirect(h,u,o),n.push(this._add(c,h));t.push(n);break}case h.HalfCircleExtended:{const i=this._cp2(e,0,-2),h=this._cp3(e,i,1,-1);let _;if(s>=4)_=e[3];else{const s=this._sub(r,i);_=this._add(h,s)}const c=this._dist(i,h)/2/.75,u=this._sub(i,r);this._normalize(u,c);const o=this._sub(h,_);this._normalize(o,c);const n=[_,h];t.push(n);const a=[this._clone(h)];this._addBezier3(a,h,this._add(h,o),this._add(i,u),i,4),a.push(r),t.push(a);break}case h.OpenCircle:{const s=this._cp2(e,-2,0),i=this._sub(s,r),h=Math.cos(Math.PI/18),_=-Math.sin(Math.PI/18),c=[s];for(let t=1;t<=33;t++)this._rotateDirect(i,h,_),c.push(this._add(r,i));t.push(c);break}case h.CoverageEdgesWithTicks:{const i=this._cp2(e,0,-1);let h,_;if(s>=3)h=e[2];else{const s=this._sub(i,r),t=this._leftPerp(s);h=[r[0]+t[0]-.25*s[0],r[1]+t[1]-.25*s[1]]}if(s>=4)_=e[3];else{const s=this._mid(r,i),t=this._sub(r,i);this._normalize(t),this._leftPerpendicular(t);const e=this._crossProduct(t,this._sub(h,s));this._rightPerpendicular(t),_=[h[0]+t[0]*e*2,h[1]+t[1]*e*2]}const c=this._sub(i,r);let u,o;u=this._crossProduct(c,this._sub(h,r))>0?this._rightPerp(c):this._leftPerp(c),o=[],o.push(h),o.push(r),o.push([r[0]+(u[0]-c[0])/3,r[1]+(u[1]-c[1])/3]),t.push(o),u=this._crossProduct(c,this._sub(_,i))>0?this._rightPerp(c):this._leftPerp(c),o=[],o.push([i[0]+(u[0]+c[0])/3,i[1]+(u[1]+c[1])/3]),o.push(i),o.push(_),t.push(o);break}case h.GapExtentWithDoubleTicks:{const i=this._cp2(e,0,2),h=this._cp3(e,i,0,1);let _;if(s>=4)_=e[3];else{const s=this._sub(i,r);_=this._add(h,s)}this._addAngledTicks(t,r,i,this._mid(h,_)),this._addAngledTicks(t,h,_,this._mid(r,i));break}case h.GapExtentMidline:{const i=this._cp2(e,2,0),h=this._cp3(e,i,0,1);let _;if(s>=4)_=e[3];else{const s=this._sub(i,r);_=this._add(h,s)}const c=[];c.push(this._mid(r,h)),c.push(this._mid(i,_)),t.push(c);break}case h.Chevron:{const i=this._cp2(e,-1,-1);let h;if(s>=3)h=e[2];else{const s=this._sub(i,r);this._leftPerpendicular(s),h=this._add(r,s)}t.push([i,this._makeCtrlPt(r),h]);break}case h.PerpendicularWithArc:{const i=this._cp2(e,0,-2),h=this._cp3(e,i,.5,-1),_=this._sub(i,r),c=this._norm(_);_[0]/=c,_[1]/=c;const u=this._crossProduct(_,this._sub(h,r));let o=this._dotProduct(_,this._sub(h,r));o<.05*c?o=.05*c:o>.95*c&&(o=.95*c);const n=[r[0]+_[0]*o,r[1]+_[1]*o];let a=this._leftPerp(_),p=[];if(p.push([n[0]-a[0]*u,n[1]-a[1]*u]),p.push([n[0]+a[0]*u,n[1]+a[1]*u]),t.push(p),s>=4){const s=e[3];let i=this._dotProduct(_,this._sub(s,r));i<.1*c?i=.1*c:i>.9*c&&(i=.9*c);const h=[r[0]+_[0]*i,r[1]+_[1]*i],u=this._crossProduct(_,this._sub(s,r)),o=[];o.push([h[0]-a[0]*u,h[1]-a[1]*u]),o.push([h[0]+a[0]*u,h[1]+a[1]*u]),t.push(o)}const d=[i[0]+a[0]*u,i[1]+a[1]*u];a=this._sub(i,d);const l=Math.cos(Math.PI/18);let b=Math.sin(Math.PI/18);u<0&&(b=-b),p=[r,i];for(let s=1;s<=9;s++)this._rotateDirect(a,l,b),p.push(this._add(d,a));t.push(p);break}case h.ClosedHalfCircle:{const s=this._cp2(e,2,0),i=this._mid(r,s),h=this._sub(s,i),_=Math.cos(Math.PI/18),c=Math.sin(Math.PI/18),u=[r,s];for(let t=1;t<=18;t++)this._rotateDirect(h,_,c),u.push(this._add(i,h));t.push(u);break}case h.TripleParallelExtended:{const s=this._cp2(e,0,-2),h=this._cp3(e,s,1,-2),_=this._mid(r,s),c=this._sub(h,s);this._normalize(c);const u=Math.abs(this._crossProduct(c,this._sub(_,s)))/2,o=this._dist(s,h),n=[s,r];n.push([r[0]+c[0]*o*.5,r[1]+c[1]*o*.5]),t.push(n);const a=[];a.push([_[0]-c[0]*u,_[1]-c[1]*u]),a.push([_[0]+c[0]*o*.375,_[1]+c[1]*o*.375]),i(a[a.length-1],1),a.push([_[0]+c[0]*o*.75,_[1]+c[1]*o*.75]),t.push(a);const p=[s,h];t.push(p);break}case h.ParallelWithTicks:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(i,s);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h),this._addAngledTicks(t,r,s,i),this._addAngledTicks(t,this._mix(r,1,h,_),this._mix(s,1,h,_),this._mid(r,s));break}case h.Parallel:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._leftPerp(h),c=this._crossProduct(h,this._sub(i,r));let u=[r,s];t.push(u),u=[],u.push([r[0]+_[0]*c,r[1]+_[1]*c]),u.push([s[0]+_[0]*c,s[1]+_[1]*c]),t.push(u);break}case h.PerpendicularToFirstSegment:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._mid(r,s),_=this._sub(s,r);this._normalize(_);const c=this._crossProduct(_,this._sub(i,r));this._leftPerpendicular(_);const u=[];u.push([h[0]-_[0]*c*.25,h[1]-_[1]*c*.25]),u.push([h[0]+_[0]*c*1.25,h[1]+_[1]*c*1.25]),t.push(u);break}case h.ParallelOffset:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]-h[0]*_,r[1]-h[1]*_]),c.push([s[0]-h[0]*_,s[1]-h[1]*_]),t.push(c);const u=[];u.push([r[0]+h[0]*_,r[1]+h[1]*_]),u.push([s[0]+h[0]*_,s[1]+h[1]*_]),t.push(u);break}case h.OffsetOpposite:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]-h[0]*_,r[1]-h[1]*_]),c.push([s[0]-h[0]*_,s[1]-h[1]*_]),t.push(c);break}case h.OffsetSame:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]+h[0]*_,r[1]+h[1]*_]),c.push([s[0]+h[0]*_,s[1]+h[1]*_]),t.push(c);break}case h.CircleWithArc:{let h=this._cp2(e,3,0);const _=this._cp3(e,h,.5,-1);let c,u;if(s>=4)c=e[3],u=this._crossProduct(this._sub(c,h),this._sub(_,h))>0;else{c=h,u=this._crossProduct(this._sub(c,r),this._sub(_,r))>0;const s=24*this._geomUnitsPerPoint,t=this._sub(c,r);this._normalize(t,s);const i=Math.sqrt(2)/2;this._rotateDirect(t,i,u?i:-i),h=this._add(r,t)}const o=this._sub(h,r),n=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),p=[h];for(let s=1;s<=36;s++)this._rotateDirect(o,n,a),p.push(this._add(r,o));this._add90DegArc(p,h,c,_,u),i(p[p.length-8],1),t.push(p);break}case h.DoubleJog:{let i,h=this._cp2(e,-3,1),_=this._cp3(e,h,-1,-.5);if(s>=4)i=e[3];else{const s=r;r=h,i=_;const t=this._dist(r,s),e=this._dist(i,s);let c=30*this._geomUnitsPerPoint;.5*t<c&&(c=.5*t),.5*e<c&&(c=.5*e),h=this._mix(r,c/t,s,(t-c)/t),_=this._mix(i,c/e,s,(e-c)/e)}const c=this._mid(r,h),u=this._mid(i,_),o=this._dist(r,h),n=this._dist(_,i);let a=Math.min(o,n)/8;a=Math.min(a,24*this._geomUnitsPerPoint);const p=Math.cos(Math.PI/4);let d=this._sub(r,h);this._normalize(d,a),this._crossProduct(d,this._sub(i,h))>0?this._rotateDirect(d,p,-p):this._rotateDirect(d,p,p);let l=[];l.push(h),l.push(this._add(c,d)),l.push(this._sub(c,d)),l.push(r),t.push(l),d=this._sub(i,_),this._normalize(d,a),this._crossProduct(d,this._sub(r,_))<0?this._rotateDirect(d,p,p):this._rotateDirect(d,p,-p),l=[],l.push(_),l.push(this._add(u,d)),l.push(this._sub(u,d)),l.push(i),t.push(l);break}case h.PerpendicularOffset:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);this._crossProduct(h,this._sub(r,s))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const _=[h[0]/8,h[1]/8],c=this._sub(this._mid(s,i),_);t.push([c,r]);break}case h.LineExcludingLastSegment:{const s=this._arrowPath(e),i=[];let h=s.length-2;for(;h--;)i.push(s[h]);t.push(i);break}case h.MultivertexArrow:{const s=this._arrowPath(e),i=[];this._addArrow(i,s,!1),t.push(i);break}case h.CrossedArrow:{const s=this._arrowPath(e),i=[];this._addArrow(i,s,!0),t.push(i);break}case h.ChevronArrow:{const[s,i]=this._arrowLastSeg(e),h=10*this._geomUnitsPerPoint,_=this._sub(r,s),c=this._norm(_);this._normalize(_);const u=this._crossProduct(_,this._sub(i,s));let o=this._dotProduct(_,this._sub(i,s));o<.05*c?o=.05*c:o>.95*c-h&&(o=.95*c-h);const n=[s[0]+_[0]*o,s[1]+_[1]*o],a=this._leftPerp(_),p=[];p.push([n[0]+a[0]*u+_[0]*h,n[1]+a[1]*u+_[1]*h]),p.push(r),p.push([n[0]-a[0]*u+_[0]*h,n[1]-a[1]*u+_[1]*h]),t.push(p);break}case h.ChevronArrowOffset:{const[s,i]=this._arrowLastSeg(e),h=this._sub(r,s),_=this._norm(h);this._normalize(h);const c=this._crossProduct(h,this._sub(i,s));let u=this._dotProduct(h,this._sub(i,s));u<.05*_?u=.05*_:u>.95*_&&(u=.95*_);const o=[s[0]+h[0]*u,s[1]+h[1]*u];this._leftPerpendicular(h);const n=[];n.push([o[0]+h[0]*c*.5,o[1]+h[1]*c*.5]),n.push(this._mid(o,r)),n.push([o[0]-h[0]*c*.5,o[1]-h[1]*c*.5]),t.push(n);break}case h.PartialFirstSegment:{const[s,i]=this._arrowLastSeg(e),h=this._sub(r,s),_=this._norm(h);this._normalize(h);let c=this._dotProduct(h,this._sub(i,s));c<.05*_?c=.05*_:c>.95*_&&(c=.95*_);const u=[s[0]+h[0]*c,s[1]+h[1]*c];t.push([s,u]);break}case h.Arch:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,1),h=this._sub(r,s),_=this._mix(i,1,h,.55),c=this._mix(i,1,h,-.55),u=[r];this._addBezier2(u,r,_,i,4),this._addBezier2(u,i,c,s,4),t.push(u);break}case h.CurvedParallelTicks:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);this._crossProduct(h,this._sub(r,s))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const _=[h[0]/8,h[1]/8],c=this._sub(this._mid(s,i),_),u=this._sub(this._mix(s,.75,i,.25),_),o=this._sub(this._mix(s,.25,i,.75),_),n=[s];this._addBezier2(n,s,u,c,3),this._addBezier2(n,c,o,i,3),t.push(n);for(let e=0;e<8;e++){const s=n[2*e+1],i=[this._clone(s)];i.push(this._add(s,[h[0]/4,h[1]/4])),t.push(i)}break}case h.Arc90Degrees:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,1),h=[s];this._add90DegArc(h,s,r,i),t.push(h);break}case h.TipWithPerpendicularAndTicks:{const[s,i]=this._arrowLastSeg(e),h=10*this._geomUnitsPerPoint,_=this._sub(r,s),c=this._norm(_);this._normalize(_);let u=this._crossProduct(_,this._sub(i,s)),o=this._dotProduct(_,this._sub(i,s));o<.05*c?o=.05*c:o>.95*c-h&&(o=.95*c-h);const n=this._leftPerp(_),a=[r[0]-_[0]*h,r[1]-_[1]*h],p=.5*Math.max(c-o-h,h);u=Math.abs(u);const d=[];d.push([a[0]+n[0]*(u+p)-_[0]*p,a[1]+n[1]*(u+p)-_[1]*p]),d.push([a[0]+n[0]*u,a[1]+n[1]*u]),d.push([a[0]-n[0]*u,a[1]-n[1]*u]),d.push([a[0]-n[0]*(u+p)-_[0]*p,a[1]-n[1]*(u+p)-_[1]*p]),t.push(d),t.push([a,r]);break}case h.FullGeometry:default:t.push(e)}}return t}}export{e as EffectControlMeasureLine};
|
|
5
|
+
import{GeometryCursor as s}from"../../../geometry/GeometryCursor.js";import{collectMultipath as t}from"../../../geometry/geometryCursorCollectUtils.js";import{setId as i}from"../CIMCursor.js";import{GeometricEffectControlMeasureLineRule as h}from"../enums.js";class e{static local(){return null===e.instance&&(e.instance=new e),e.instance}execute(s,t,i,h,e){return new r(s,t,i)}}e.instance=null;class r{constructor(s,t,i){this._defaultPointSize=20,this._inputGeometries=s,this._geomUnitsPerPoint=i,this._rule=t.rule??h.FullGeometry,this._defaultSize=this._defaultPointSize*i}next(){let i;for(;i=this._inputGeometries.next();){const h=this._processGeom(t(i));if(h?.length)return s.fromJSONCIM({paths:h})}return null}_clone(s){return[s[0],s[1]]}_mid(s,t){return[(s[0]+t[0])/2,(s[1]+t[1])/2]}_mix(s,t,i,h){return[s[0]*t+i[0]*h,s[1]*t+i[1]*h]}_add(s,t){return[s[0]+t[0],s[1]+t[1]]}_add2(s,t,i){return[s[0]+t,s[1]+i]}_sub(s,t){return[s[0]-t[0],s[1]-t[1]]}_dist(s,t){return Math.sqrt((s[0]-t[0])*(s[0]-t[0])+(s[1]-t[1])*(s[1]-t[1]))}_norm(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1])}_normalize(s,t=1){const i=t/this._norm(s);s[0]*=i,s[1]*=i}_leftPerpendicular(s){const t=-s[1],i=s[0];s[0]=t,s[1]=i}_leftPerp(s){return[-s[1],s[0]]}_rightPerpendicular(s){const t=s[1],i=-s[0];s[0]=t,s[1]=i}_rightPerp(s){return[s[1],-s[0]]}_dotProduct(s,t){return s[0]*t[0]+s[1]*t[1]}_crossProduct(s,t){return s[0]*t[1]-s[1]*t[0]}_rotateDirect(s,t,i){const h=s[0]*t-s[1]*i,e=s[0]*i+s[1]*t;s[0]=h,s[1]=e}_makeCtrlPt(s){const t=[s[0],s[1]];return i(t,1),t}_addAngledTicks(s,t,i,h){const e=this._sub(i,t);this._normalize(e);const r=this._crossProduct(e,this._sub(h,t));let _;_=r>0?this._rightPerp(e):this._leftPerp(e);const c=Math.abs(r)/2,u=[];u.push([t[0]+(_[0]-e[0])*c,t[1]+(_[1]-e[1])*c]),u.push(t),u.push(i),u.push([i[0]+(_[0]+e[0])*c,i[1]+(_[1]+e[1])*c]),s.push(u)}_addBezier2(s,t,i,h,e){if(0==e--)return void s.push(h);const r=this._mid(t,i),_=this._mid(i,h),c=this._mid(r,_);this._addBezier2(s,t,r,c,e),this._addBezier2(s,c,_,h,e)}_addBezier3(s,t,i,h,e,r){if(0==r--)return void s.push(e);const _=this._mid(t,i),c=this._mid(i,h),u=this._mid(h,e),o=this._mid(_,c),n=this._mid(c,u),a=this._mid(o,n);this._addBezier3(s,t,_,o,a,r),this._addBezier3(s,a,n,u,e,r)}_add90DegArc(s,t,i,h,e){const r=e??this._crossProduct(this._sub(i,t),this._sub(h,t))>0,_=this._mid(t,i),c=this._sub(_,t);r?this._leftPerpendicular(c):this._rightPerpendicular(c),_[0]+=c[0],_[1]+=c[1],this._addBezier3(s,t,this._mix(t,.33333,_,.66667),this._mix(i,.33333,_,.66667),i,4)}_addArrow(s,t,i){const h=t[0],e=t[1],r=t[t.length-1],_=this._sub(h,e),c=this._norm(_);this._normalize(_);const u=Math.abs(this._crossProduct(_,this._sub(r,e)));let o=this._dotProduct(_,this._sub(r,e));o<.05*c?o=.05*c:o>.95*c&&(o=.95*c);const n=.5*u,a=this._leftPerp(_),p=[e[0]+_[0]*o,e[1]+_[1]*o],d=t.length-1,l=[];l.push(i?[-a[0],-a[1]]:a);let b=[-_[0],-_[1]];for(let P=1;P<d-1;P++){const s=this._sub(t[P+1],t[P]);this._normalize(s);const i=this._dotProduct(s,b),h=this._crossProduct(s,b),e=Math.sqrt((1+i)/2),r=this._sub(s,b);this._normalize(r),r[0]/=e,r[1]/=e,l.push(h<0?[-r[0],-r[1]]:r),b=s}l.push(this._rightPerp(b));for(let P=l.length-1;P>0;P--)s.push([t[P][0]+l[P][0]*n,t[P][1]+l[P][1]*n]);s.push([p[0]+l[0][0]*n,p[1]+l[0][1]*n]),s.push([p[0]+l[0][0]*u,p[1]+l[0][1]*u]),s.push(h),s.push([p[0]-l[0][0]*u,p[1]-l[0][1]*u]),s.push([p[0]-l[0][0]*n,p[1]-l[0][1]*n]);for(let P=1;P<l.length;P++)s.push([t[P][0]-l[P][0]*n,t[P][1]-l[P][1]*n])}_cp2(s,t,i){return s.length>=2?s[1]:this._add2(s[0],t*this._defaultSize,i*this._defaultSize)}_cp3(s,t,i,h){if(s.length>=3)return s[2];const e=this._mix(s[0],1-i,t,i),r=this._sub(t,s[0]);return this._normalize(r),this._rightPerpendicular(r),[e[0]+r[0]*h*this._defaultSize,e[1]+r[1]*h*this._defaultSize]}_arrowPath(s){if(s.length>2)return s;const t=s[0],i=this._cp2(s,-4,0),h=this._sub(t,i);this._normalize(h);const e=this._rightPerp(h);return[t,i,[t[0]+(e[0]-h[0])*this._defaultSize,t[1]+(e[1]-h[1])*this._defaultSize]]}_arrowLastSeg(s){const t=s[0],i=this._cp2(s,-4,0);let h;if(s.length>=3)h=s[s.length-1];else{const s=this._sub(t,i);this._normalize(s);const e=this._rightPerp(s);h=[t[0]+(e[0]-s[0])*this._defaultSize,t[1]+(e[1]-s[1])*this._defaultSize]}return[i,h]}_processGeom(s){if(!s)return null;const t=[];for(const e of s){if(!e||0===e.length)continue;const s=e.length;let r=e[0];switch(this._rule){case h.PerpendicularFromFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=[];h.push(i),h.push(this._mid(r,s)),t.push(h);break}case h.ReversedFirstSegment:{const s=this._cp2(e,0,-1);t.push([s,r]);break}case h.PerpendicularToSecondSegment:{if(e.length<3)return[];const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=[];h.push(this._mid(s,i)),h.push(r),t.push(h);break}case h.SecondSegmentWithTicks:{if(e.length<3)return[];const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);let _;_=this._crossProduct(h,this._sub(r,s))>0?this._rightPerp(h):this._leftPerp(h);const c=[];c.push([s[0]+(_[0]-h[0])/3,s[1]+(_[1]-h[1])/3]),c.push(s),c.push(i),c.push([i[0]+(_[0]+h[0])/3,i[1]+(_[1]+h[1])/3]),t.push(c);break}case h.DoublePerpendicular:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,3),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push(r),u.push([i[0]+_[0]*c,i[1]+_[1]*c]),t.push(u);const o=[];o.push([i[0]-_[0]*c,i[1]-_[1]*c]),o.push(s),t.push(o);break}case h.OppositeToFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,3),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push([i[0]+_[0]*c,i[1]+_[1]*c]),u.push([i[0]-_[0]*c,i[1]-_[1]*c]),t.push(u);break}case h.TriplePerpendicular:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=this._mid(r,s),_=this._sub(h,i);this._normalize(_);const c=this._crossProduct(_,this._sub(r,i));this._leftPerpendicular(_);const u=[];u.push([i[0]+_[0]*c*.8,i[1]+_[1]*c*.8]),u.push([h[0]+.8*(r[0]-h[0]),h[1]+.8*(r[1]-h[1])]),t.push(u),t.push([i,h]);const o=[];o.push([i[0]-_[0]*c*.8,i[1]-_[1]*c*.8]),o.push([h[0]+.8*(s[0]-h[0]),h[1]+.8*(s[1]-h[1])]),t.push(o);break}case h.HalfCircleFirstSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,4),h=this._mid(r,s);let _=this._sub(s,r);const c=Math.cos(Math.PI/18),u=Math.sin(Math.PI/18),o=Math.sqrt((1+c)/2),n=Math.sqrt((1-c)/2),a=[];let p;this._crossProduct(_,this._sub(i,r))>0?(a.push(r),_=this._sub(r,h),p=s):(a.push(s),_=this._sub(s,h),p=r),this._rotateDirect(_,o,n),_[0]/=o,_[1]/=o;for(let t=1;t<=18;t++)a.push(this._add(h,_)),this._rotateDirect(_,c,u);a.push(p),t.push(a);break}case h.HalfCircleSecondSegment:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,1,-1);let h=this._sub(r,s);this._normalize(h);const _=this._crossProduct(h,this._sub(i,s))/2;this._leftPerpendicular(h);const c=[s[0]+h[0]*_,s[1]+h[1]*_];h=this._sub(s,c);const u=Math.cos(Math.PI/18);let o=Math.sin(Math.PI/18);_>0&&(o=-o);const n=[s];for(let t=1;t<=18;t++)this._rotateDirect(h,u,o),n.push(this._add(c,h));t.push(n);break}case h.HalfCircleExtended:{const i=this._cp2(e,0,-2),h=this._cp3(e,i,1,-1);let _;if(s>=4)_=e[3];else{const s=this._sub(r,i);_=this._add(h,s)}const c=this._dist(i,h)/2/.75,u=this._sub(i,r);this._normalize(u,c);const o=this._sub(h,_);this._normalize(o,c);const n=[_,h];t.push(n);const a=[this._clone(h)];this._addBezier3(a,h,this._add(h,o),this._add(i,u),i,4),a.push(r),t.push(a);break}case h.OpenCircle:{const s=this._cp2(e,-2,0),i=this._sub(s,r),h=Math.cos(Math.PI/18),_=-Math.sin(Math.PI/18),c=[s];for(let t=1;t<=33;t++)this._rotateDirect(i,h,_),c.push(this._add(r,i));t.push(c);break}case h.CoverageEdgesWithTicks:{const i=this._cp2(e,0,-1);let h,_;if(s>=3)h=e[2];else{const s=this._sub(i,r),t=this._leftPerp(s);h=[r[0]+t[0]-.25*s[0],r[1]+t[1]-.25*s[1]]}if(s>=4)_=e[3];else{const s=this._mid(r,i),t=this._sub(r,i);this._normalize(t),this._leftPerpendicular(t);const e=this._crossProduct(t,this._sub(h,s));this._rightPerpendicular(t),_=[h[0]+t[0]*e*2,h[1]+t[1]*e*2]}const c=this._sub(i,r);let u,o;u=this._crossProduct(c,this._sub(h,r))>0?this._rightPerp(c):this._leftPerp(c),o=[],o.push(h),o.push(r),o.push([r[0]+(u[0]-c[0])/3,r[1]+(u[1]-c[1])/3]),t.push(o),u=this._crossProduct(c,this._sub(_,i))>0?this._rightPerp(c):this._leftPerp(c),o=[],o.push([i[0]+(u[0]+c[0])/3,i[1]+(u[1]+c[1])/3]),o.push(i),o.push(_),t.push(o);break}case h.GapExtentWithDoubleTicks:{const i=this._cp2(e,0,2),h=this._cp3(e,i,0,1);let _;if(s>=4)_=e[3];else{const s=this._sub(i,r);_=this._add(h,s)}this._addAngledTicks(t,r,i,this._mid(h,_)),this._addAngledTicks(t,h,_,this._mid(r,i));break}case h.GapExtentMidline:{const i=this._cp2(e,2,0),h=this._cp3(e,i,0,1);let _;if(s>=4)_=e[3];else{const s=this._sub(i,r);_=this._add(h,s)}const c=[];c.push(this._mid(r,h)),c.push(this._mid(i,_)),t.push(c);break}case h.Chevron:{const i=this._cp2(e,-1,-1);let h;if(s>=3)h=e[2];else{const s=this._sub(i,r);this._leftPerpendicular(s),h=this._add(r,s)}t.push([i,this._makeCtrlPt(r),h]);break}case h.PerpendicularWithArc:{const i=this._cp2(e,0,-2),h=this._cp3(e,i,.5,-1),_=this._sub(i,r),c=this._norm(_);_[0]/=c,_[1]/=c;const u=this._crossProduct(_,this._sub(h,r));let o=this._dotProduct(_,this._sub(h,r));o<.05*c?o=.05*c:o>.95*c&&(o=.95*c);const n=[r[0]+_[0]*o,r[1]+_[1]*o];let a=this._leftPerp(_),p=[];if(p.push([n[0]-a[0]*u,n[1]-a[1]*u]),p.push([n[0]+a[0]*u,n[1]+a[1]*u]),t.push(p),s>=4){const s=e[3];let i=this._dotProduct(_,this._sub(s,r));i<.1*c?i=.1*c:i>.9*c&&(i=.9*c);const h=[r[0]+_[0]*i,r[1]+_[1]*i],u=this._crossProduct(_,this._sub(s,r)),o=[];o.push([h[0]-a[0]*u,h[1]-a[1]*u]),o.push([h[0]+a[0]*u,h[1]+a[1]*u]),t.push(o)}const d=[i[0]+a[0]*u,i[1]+a[1]*u];a=this._sub(i,d);const l=Math.cos(Math.PI/18);let b=Math.sin(Math.PI/18);u<0&&(b=-b),p=[r,i];for(let s=1;s<=9;s++)this._rotateDirect(a,l,b),p.push(this._add(d,a));t.push(p);break}case h.ClosedHalfCircle:{const s=this._cp2(e,2,0),i=this._mid(r,s),h=this._sub(s,i),_=Math.cos(Math.PI/18),c=Math.sin(Math.PI/18),u=[r,s];for(let t=1;t<=18;t++)this._rotateDirect(h,_,c),u.push(this._add(i,h));t.push(u);break}case h.TripleParallelExtended:{const s=this._cp2(e,0,-2),h=this._cp3(e,s,1,-2),_=this._mid(r,s),c=this._sub(h,s);this._normalize(c);const u=Math.abs(this._crossProduct(c,this._sub(_,s)))/2,o=this._dist(s,h),n=[s,r];n.push([r[0]+c[0]*o*.5,r[1]+c[1]*o*.5]),t.push(n);const a=[];a.push([_[0]-c[0]*u,_[1]-c[1]*u]),a.push([_[0]+c[0]*o*.375,_[1]+c[1]*o*.375]),i(a[a.length-1],1),a.push([_[0]+c[0]*o*.75,_[1]+c[1]*o*.75]),t.push(a);const p=[s,h];t.push(p);break}case h.ParallelWithTicks:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(i,s);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h),this._addAngledTicks(t,r,s,i),this._addAngledTicks(t,this._mix(r,1,h,_),this._mix(s,1,h,_),this._mid(r,s));break}case h.Parallel:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._leftPerp(h),c=this._crossProduct(h,this._sub(i,r));let u=[r,s];t.push(u),u=[],u.push([r[0]+_[0]*c,r[1]+_[1]*c]),u.push([s[0]+_[0]*c,s[1]+_[1]*c]),t.push(u);break}case h.PerpendicularToFirstSegment:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._mid(r,s),_=this._sub(s,r);this._normalize(_);const c=this._crossProduct(_,this._sub(i,r));this._leftPerpendicular(_);const u=[];u.push([h[0]-_[0]*c*.25,h[1]-_[1]*c*.25]),u.push([h[0]+_[0]*c*1.25,h[1]+_[1]*c*1.25]),t.push(u);break}case h.ParallelOffset:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]-h[0]*_,r[1]-h[1]*_]),c.push([s[0]-h[0]*_,s[1]-h[1]*_]),t.push(c);const u=[];u.push([r[0]+h[0]*_,r[1]+h[1]*_]),u.push([s[0]+h[0]*_,s[1]+h[1]*_]),t.push(u);break}case h.OffsetOpposite:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]-h[0]*_,r[1]-h[1]*_]),c.push([s[0]-h[0]*_,s[1]-h[1]*_]),t.push(c);break}case h.OffsetSame:{const s=this._cp2(e,3,0),i=this._cp3(e,s,.5,-1),h=this._sub(s,r);this._normalize(h);const _=this._crossProduct(h,this._sub(i,r));this._leftPerpendicular(h);const c=[];c.push([r[0]+h[0]*_,r[1]+h[1]*_]),c.push([s[0]+h[0]*_,s[1]+h[1]*_]),t.push(c);break}case h.CircleWithArc:{let h=this._cp2(e,3,0);const _=this._cp3(e,h,.5,-1);let c,u;if(s>=4)c=e[3],u=this._crossProduct(this._sub(c,h),this._sub(_,h))>0;else{c=h,u=this._crossProduct(this._sub(c,r),this._sub(_,r))>0;const s=24*this._geomUnitsPerPoint,t=this._sub(c,r);this._normalize(t,s);const i=Math.sqrt(2)/2;this._rotateDirect(t,i,u?i:-i),h=this._add(r,t)}const o=this._sub(h,r),n=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),p=[h];for(let s=1;s<=36;s++)this._rotateDirect(o,n,a),p.push(this._add(r,o));this._add90DegArc(p,h,c,_,u),i(p[p.length-8],1),t.push(p);break}case h.DoubleJog:{let i,h=this._cp2(e,-3,1),_=this._cp3(e,h,-1,-.5);if(s>=4)i=e[3];else{const s=r;r=h,i=_;const t=this._dist(r,s),e=this._dist(i,s);let c=30*this._geomUnitsPerPoint;.5*t<c&&(c=.5*t),.5*e<c&&(c=.5*e),h=this._mix(r,c/t,s,(t-c)/t),_=this._mix(i,c/e,s,(e-c)/e)}const c=this._mid(r,h),u=this._mid(i,_),o=this._dist(r,h),n=this._dist(_,i);let a=Math.min(o,n)/8;a=Math.min(a,24*this._geomUnitsPerPoint);const p=Math.cos(Math.PI/4);let d=this._sub(r,h);this._normalize(d,a),this._crossProduct(d,this._sub(i,h))>0?this._rotateDirect(d,p,-p):this._rotateDirect(d,p,p);let l=[];l.push(h),l.push(this._add(c,d)),l.push(this._sub(c,d)),l.push(r),t.push(l),d=this._sub(i,_),this._normalize(d,a),this._crossProduct(d,this._sub(r,_))<0?this._rotateDirect(d,p,p):this._rotateDirect(d,p,-p),l=[],l.push(_),l.push(this._add(u,d)),l.push(this._sub(u,d)),l.push(i),t.push(l);break}case h.PerpendicularOffset:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);this._crossProduct(h,this._sub(r,s))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const _=[h[0]/8,h[1]/8],c=this._sub(this._mid(s,i),_);t.push([c,r]);break}case h.LineExcludingLastSegment:{const s=this._arrowPath(e),i=[];let h=s.length-2;for(;h--;)i.push(s[h]);t.push(i);break}case h.MultivertexArrow:{const s=this._arrowPath(e),i=[];this._addArrow(i,s,!1),t.push(i);break}case h.CrossedArrow:{const s=this._arrowPath(e),i=[];this._addArrow(i,s,!0),t.push(i);break}case h.ChevronArrow:{const[s,i]=this._arrowLastSeg(e),h=10*this._geomUnitsPerPoint,_=this._sub(r,s),c=this._norm(_);this._normalize(_);const u=this._crossProduct(_,this._sub(i,s));let o=this._dotProduct(_,this._sub(i,s));o<.05*c?o=.05*c:o>.95*c-h&&(o=.95*c-h);const n=[s[0]+_[0]*o,s[1]+_[1]*o],a=this._leftPerp(_),p=[];p.push([n[0]+a[0]*u+_[0]*h,n[1]+a[1]*u+_[1]*h]),p.push(r),p.push([n[0]-a[0]*u+_[0]*h,n[1]-a[1]*u+_[1]*h]),t.push(p);break}case h.ChevronArrowOffset:{const[s,i]=this._arrowLastSeg(e),h=this._sub(r,s),_=this._norm(h);this._normalize(h);const c=this._crossProduct(h,this._sub(i,s));let u=this._dotProduct(h,this._sub(i,s));u<.05*_?u=.05*_:u>.95*_&&(u=.95*_);const o=[s[0]+h[0]*u,s[1]+h[1]*u];this._leftPerpendicular(h);const n=[];n.push([o[0]+h[0]*c*.5,o[1]+h[1]*c*.5]),n.push(this._mid(o,r)),n.push([o[0]-h[0]*c*.5,o[1]-h[1]*c*.5]),t.push(n);break}case h.PartialFirstSegment:{const[s,i]=this._arrowLastSeg(e),h=this._sub(r,s),_=this._norm(h);this._normalize(h);let c=this._dotProduct(h,this._sub(i,s));c<.05*_?c=.05*_:c>.95*_&&(c=.95*_);const u=[s[0]+h[0]*c,s[1]+h[1]*c];t.push([s,u]);break}case h.Arch:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,1),h=this._sub(r,s),_=this._mix(i,1,h,.55),c=this._mix(i,1,h,-.55),u=[r];this._addBezier2(u,r,_,i,4),this._addBezier2(u,i,c,s,4),t.push(u);break}case h.CurvedParallelTicks:{const s=this._cp2(e,-4,1),i=this._cp3(e,s,.882353,-1.94),h=this._sub(i,s);this._crossProduct(h,this._sub(r,s))>0?this._rightPerpendicular(h):this._leftPerpendicular(h);const _=[h[0]/8,h[1]/8],c=this._sub(this._mid(s,i),_),u=this._sub(this._mix(s,.75,i,.25),_),o=this._sub(this._mix(s,.25,i,.75),_),n=[s];this._addBezier2(n,s,u,c,3),this._addBezier2(n,c,o,i,3),t.push(n);for(let e=0;e<8;e++){const s=n[2*e+1],i=[this._clone(s)];i.push(this._add(s,[h[0]/4,h[1]/4])),t.push(i)}break}case h.Arc90Degrees:{const s=this._cp2(e,0,-1),i=this._cp3(e,s,.5,1),h=[s];this._add90DegArc(h,s,r,i),t.push(h);break}case h.TipWithPerpendicularAndTicks:{const[s,i]=this._arrowLastSeg(e),h=10*this._geomUnitsPerPoint,_=this._sub(r,s),c=this._norm(_);this._normalize(_);let u=this._crossProduct(_,this._sub(i,s)),o=this._dotProduct(_,this._sub(i,s));o<.05*c?o=.05*c:o>.95*c-h&&(o=.95*c-h);const n=this._leftPerp(_),a=[r[0]-_[0]*h,r[1]-_[1]*h],p=.5*Math.max(c-o-h,h);u=Math.abs(u);const d=[];d.push([a[0]+n[0]*(u+p)-_[0]*p,a[1]+n[1]*(u+p)-_[1]*p]),d.push([a[0]+n[0]*u,a[1]+n[1]*u]),d.push([a[0]-n[0]*u,a[1]-n[1]*u]),d.push([a[0]-n[0]*(u+p)-_[0]*p,a[1]-n[1]*(u+p)-_[1]*p]),t.push(d),t.push([a,r]);break}case h.FullGeometry:default:t.push(e)}}return t}}export{e as EffectControlMeasureLine};
|
package/views/2d/GoToManager.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{prefersReducedMotion as o}from"../../core/a11yUtils.js";import e from"../../core/Accessor.js";import i from"../../core/Error.js";import r from"../../core/Logger.js";import{throwIfAborted as s,whenOrAbort as a}from"../../core/promiseUtils.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../ViewAnimation.js";import{create as l}from"./viewpointUtils.js";let h=class extends e{constructor(t){super(t),this._gotoTask=null}destroy(){this._gotoTask=null}async goTo(t,e){if(!t)return void r.getLogger(this).error("#goTo()","target cannot be null or undefined");const i=new p;this.view.animation=i,await n((()=>this.view.ready),e);const s={...e,animate
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{prefersReducedMotion as o}from"../../core/a11yUtils.js";import e from"../../core/Accessor.js";import i from"../../core/Error.js";import r from"../../core/Logger.js";import{throwIfAborted as s,whenOrAbort as a}from"../../core/promiseUtils.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../ViewAnimation.js";import{create as l}from"./viewpointUtils.js";let h=class extends e{constructor(t){super(t),this._gotoTask=null}destroy(){this._gotoTask=null}async goTo(t,e){if(!t)return void r.getLogger(this).error("#goTo()","target cannot be null or undefined");const i=new p;this.view.animation=i,await n((()=>this.view.ready),e);const s={...e,animate:e?.animate??!o(),animationMode:e?.animationMode??"auto"},{extent:a,spatialReference:c,size:m,viewpoint:h,constraints:g,padding:w,allLayerViews:d}=this.view,u=l(t,{extent:a,spatialReference:c,size:m,viewpoint:h,constraints:g,padding:w,allLayerViews:d,pickClosestTarget:e?.pickClosestTarget??!0});return i?.update(u),this._gotoTask={},s.animate?this._gotoAnimated(u,s):this._gotoImmediate(u,s)}_gotoImmediate(t,o){const e=this._gotoTask,r=this.view.animation,a=t.then((t=>{if(s(o),e!==this._gotoTask)throw new i("view:goto-interrupted","Goto was interrupted");this.view.viewpoint=r.target=t,r.finish()}));return this._cancellableGoTo(e,r,a,o)}_gotoAnimated(t,o){const e=this._gotoTask,r=this.view.animation;if(!r)return Promise.resolve();const a=t.then((t=>{if(s(o),e!==this._gotoTask)throw new i("view:goto-interrupted","Goto was interrupted");return r.update(t),this.view.animationManager.animate(r,this.view.viewpoint,o),r.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(e,r,a,o)}_cancellableGoTo(t,o,e,i){const r=()=>t===this._gotoTask;return a(e,i).finally((()=>{r()&&(o.done||o.stop())}))}};t([c({constructOnly:!0})],h.prototype,"view",void 0),h=t([m("esri.views.2d.GoToManager")],h);export{h as GoToManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{fromRotation as i}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as s}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{set as r,sub as o,normalize as n,add as a,scale as l}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as c}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{generalizeOptimizedGeometry as h,convertToGeometry as m}from"../../../../../../../layers/graphics/featureConversionUtils.js";import u from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{getXAnchorDirection as d,getYAnchorDirection as f}from"../../../alignmentUtils.js";import{getDisplayIdTexel as g}from"../../../DisplayId.js";import p from"../../../collisions/BoundingBox.js";import{LabelMetric as _}from"../../../collisions/LabelMetric.js";import{smoothPaths as x,pathDivide as y}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as v,processColorInput as P}from"../fill/meshWriterUtils.js";import{TextMeshWriter as M,maxLabelZoom as b}from"../text/TextMeshWriter.js";const w=1,L=0,B=128,S=e((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t}));class I extends M{constructor(){super(...arguments),this._zoomLevel=0}_write(e,t,i,s){if(this._zoomLevel=s||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),s=t.readYForDisplay();return this._writePoint(e,i,s,t)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const i=t.readCentroidForDisplay();if(!i)return;const[s,r]=i.coords;return this._writePoint(e,s,r,t)}case"esriGeometryPolyline":this._writeLines(e,t)}}_writePoint(e,t,i,s){const r=this._getShaping();if(!r)return;let o=this._getPointReferenceBounds();o||(o={offsetX:0,offsetY:0,size:0});const n=r.boundsT,a=d(this.evaluatedMeshParams.horizontalAlignment),l=f(this.evaluatedMeshParams.verticalAlignment),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,h=this.evaluatedMeshParams.scaleInfo?.minScale??0,m=g(s.getDisplayId());e.metricStart(new _(m,t,i,a,l,c,h,o)),e.metricBoxWrite(n),this._writeGlyphs(e,s.getDisplayId(),t,i,r,0,o),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:s}=this.evaluatedMeshParams,r=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,s)=>this._placeSubdivGlyphs(e,t,i,s),a=(o.bounds.width+r)/(1<<w);this._current={out:e,id:t.getDisplayId(),shaping:o,zoomRange:v(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===s?"above":"top"===s?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,i,s){const{repeatLabel:r,fontSize:o}=this.evaluatedMeshParams,{shaping:n}=this._current,a=t(o),l=e.readGeometryForDisplay();if(!l)return;const c=new u;h(c,l,!1,!1,"esriGeometryPolyline",1);const d=A(new u,c,a),f=A(new u,c,-a),g=m(f,"esriGeometryPolyline",!1,!1),p=m(d,"esriGeometryPolyline",!1,!1),_=x(p.paths,n.bounds.width),v=x(g.paths,n.bounds.width);this._current.offsetDirection="above";for(const t of _)y(t,s,i,!!r);this._current.offsetDirection="below";for(const t of v)y(t,s,i,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:s}=this.evaluatedMeshParams,{shaping:r}=this._current,o=x(e.readLegacyGeometryForDisplay().paths,r.bounds.width);for(const n of o)y(n,i,t,!!s)}_placeSubdivGlyphs(e,t,i,s){const{allowOverrun:r,labelPosition:o,repeatLabelDistance:n}=this.evaluatedMeshParams,a=this._current.zoomRange[0],l=S(t),c=this._current.shaping.bounds.width/(1<<w),h=Math.sqrt(n||B)/(1<<w),m=Math.min(i,s-i),u=this._current.shaping.isMultiline?b:Math.log2(m/(h+c/2)),d=0===t?u:Math.min(l,u),f=Math.max(a,this._zoomLevel+w-d),g=this._zoomLevel-f,p=this._current.shaping.bounds.width/2*2**g;this._current.shaping.isMultiline?0===t&&this._placeStraight(e,f):r&&g<0?this._placeStraightAlong(e,a):"parallel"===o?this._placeStraightAlong(e,f):"curved"===o&&this._placeCurved(e,f,p)}_placeStraight(e,t){const{out:i,id:s,shaping:r,referenceBounds:o}=this._current,{x:n,y:a}=e,l=g(s),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,h=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new _(l,e.x,e.y,0,0,c,h,null)),i.metricBoxWrite(r.boundsT);const m=e.angle*(180/Math.PI)%360,u=(e.angle*(180/Math.PI)+180)%360;this._writeGlyphs(i,s,n,a,r,0,o,{clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t}),this._writeGlyphs(i,s,n,a,r,0,o,{clipAngle:u,mapAligned:!0,isLineLabel:!0,minZoom:t}),i.metricEnd()}_placeCurved(e,t,i){const{out:s,id:r}=this._current,o=e.clone(),n=e.angle*(180/Math.PI)%360,a=(e.angle*(180/Math.PI)+180)%360,l=g(r),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,h=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new _(l,e.x,e.y,0,0,c,h,null)),this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(o,t,1,n),this._placeBack(e,o,t,i,1,n),this._placeForward(e,o,t,i,1,n)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(o,t,0,a),this._placeBack(e,o,t,i,0,a),this._placeForward(e,o,t,i,0,a)),s.metricEnd()}_placeStraightAlong(e,t){const{out:r,id:o,shaping:n,zoomRange:a,referenceBounds:l}=this._current,{boxBorderLineColor:c,boxBackgroundColor:h}=this.evaluatedMeshParams,m=e.clone(),u=e.angle*(180/Math.PI)%360,d=(e.angle*(180/Math.PI)+180)%360;if(n.glyphs.length>0&&(c||h)){const c=Math.max(t,a[0],0),h=Math.min(b,a[1]),m=i(s(),-e.angle),[f,g]=n.shapeBackground(m),p={minZoom:c,maxZoom:h,clipAngle:u,mapAligned:!0,isLineLabel:!0};this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(r.recordStart(this.instanceId,this.attributeLayout,n.glyphs[0].textureBinding),this._writeTextBox(r,o,e.x,e.y,g,l,p),r.recordEnd()),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(p.clipAngle=d,r.recordStart(this.instanceId,this.attributeLayout,n.glyphs[0].textureBinding),this._writeTextBox(r,o,e.x,e.y,g,l,p),r.recordEnd())}const f=g(o),p=this.evaluatedMeshParams.scaleInfo?.maxScale??0,x=this.evaluatedMeshParams.scaleInfo?.minScale??0;r.metricStart(new _(f,e.x,e.y,0,0,p,x,null)),this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(m,t,1,u,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(m,t,0,d,!0),r.metricEnd()}_placeBack(e,t,i,s,r,o){const n=e.clone();let a=e.backwardLength+L;for(;n.prev()&&!(a>=s);)this._placeOnSegment(n,t,a,i,-1,r,o),a+=n.length+L}_placeForward(e,t,i,s,r,o){const n=e.clone();let a=e.remainingLength+L;for(;n.next()&&!(a>=s);)this._placeOnSegment(n,t,a,i,1,r,o),a+=n.length+L}_placeFirst(e,t,i,s,r=!1){const o=e,{out:n,id:a,shaping:l,zoomRange:c,referenceBounds:h}=this._current,m=l.glyphs;for(const u of m){const m=u.x>l.bounds.x?i:1-i,d=m*e.remainingLength+(1-m)*e.backwardLength,f=Math.abs(u.x+u.width/2-l.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+L))),p=Math.max(t,r?0:g);u.maxZoom=Math.min(c[1],b),u.angle=e.angle+(1-i)*Math.PI,u.minZoom=Math.max(c[0],p),this._writeLineGlyph(n,a,o.x,o.y,l.bounds,u,s,h,!0),i&&this._isVisible(u.minZoom,u.maxZoom)&&n.metricBoxWrite(u.bounds)}}_placeOnSegment(e,t,i,s,r,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-r*u,y:e.y+i*-r*d};for(const g of m){const m=g.x>c.bounds.x?o:1-o;if(!(m&&1===r||!m&&-1===r))continue;const u=Math.abs(g.x+g.width/2-c.bounds.x),d=Math.max(0,this._zoomLevel+Math.log2(u/i)-.1),_=Math.max(s,this._zoomLevel+Math.log2(u/(i+e.length+L)));if(0!==d&&(g.angle=e.angle+(1-o)*Math.PI,g.minZoom=_,g.maxZoom=d,this._writeLineGlyph(a,l,f.x,f.y,c.bounds,g,n,h,!0),o&&this._isVisible(g.minZoom,g.maxZoom))){const i=g.bounds,s=e.x-t.x,r=e.y-t.y,o=new p(i.center[0]+s,i.center[1]+r,i.width,i.height);a.metricBoxWrite(o)}}}_writeLineGlyph(e,t,i,s,r,o,n,a,l){const c=i+r.x,h=s+r.y,m=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),u=Math.max(r.width,r.height)*m;e.recordStart(this.instanceId,this.attributeLayout,o.textureBinding),e.recordBounds(c,h,u,u);const{texcoords:d,offsets:f}=o,g=this._textMeshTransformProps.fontSize;this._writeQuad(e,t,i,s,{texcoords:d,offsets:f,fontSize:g,color:P(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o.minZoom),maxZoom:Math.min(this._current.zoomRange[1],o.maxZoom),clipAngle:n,mapAligned:l,isLineLabel:!0}),e.recordEnd()}_isVisible(e,t){const i=this._zoomLevel;return e<=i&&i<=t}}function A(e,t,i){const{coords:s,lengths:h}=t,m=c(),u=c(),d=c(),f=c(),g=c(),p=c(),_=2;let x=0;for(let c=0;c<h.length;c++){const t=h[c];for(let c=0;c<t;c++){const h=_*(c+x-1),y=_*(c+x),v=_*(c+x+1);c>0?r(m,s[h],s[h+1]):r(m,0,0),r(u,s[y],s[y+1]),c<t-1?r(d,s[v],s[v+1]):r(d,0,0),0===c?r(f,0,0):(o(f,u,m),n(f,f),r(f,f[1],-f[0])),c===t-1?r(g,0,0):(o(g,d,u),n(g,g),r(g,g[1],-g[0])),a(p,f,g),n(p,p);const P=p[0]*g[0]+p[1]*g[1];0!==P&&l(p,p,P),l(p,p,i),e.coords.push(u[0]+p[0],u[1]+p[1])}e.lengths.push(t),x+=t}return e}export{I as LabelMeshWriter};
|
|
5
|
+
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{fromRotation as i,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as r}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{set as o,sub as n,normalize as a,add as l,scale as h}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as c}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as m}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{generalizeOptimizedGeometry as d,convertToGeometry as u}from"../../../../../../../layers/graphics/featureConversionUtils.js";import f from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{getXAnchorDirection as g,getYAnchorDirection as p}from"../../../alignmentUtils.js";import{getDisplayIdTexel as _}from"../../../DisplayId.js";import x from"../../../collisions/BoundingBox.js";import{LabelMetric as y}from"../../../collisions/LabelMetric.js";import{smoothPaths as v,pathDivide as M}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as P,processColorInput as b}from"../fill/meshWriterUtils.js";import{TextMeshWriter as w,maxLabelZoom as B}from"../text/TextMeshWriter.js";const L=1,S=0,I=128,A=e((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t}));class z extends w{constructor(){super(...arguments),this._zoomLevel=0}_write(e,t,i,s){if(this._zoomLevel=s||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),s=t.readYForDisplay();return this._writePoint(e,i,s,t)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const i=t.readCentroidForDisplay();if(!i)return;const[s,r]=i.coords;return this._writePoint(e,s,r,t)}case"esriGeometryPolyline":this._writeLines(e,t)}}_writePoint(e,t,i,s){const r=this._getShaping();if(!r)return;let o=this._getPointReferenceBounds();o||(o={offsetX:0,offsetY:0,size:0});const n=r.boundsT,a=g(this.evaluatedMeshParams.horizontalAlignment),l=p(this.evaluatedMeshParams.verticalAlignment),h=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,m=_(s.getDisplayId());e.metricStart(new y(m,t,i,a,l,h,c,o)),e.metricBoxWrite(n),this._writeGlyphs(e,s.getDisplayId(),t,i,r,0,o),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:s}=this.evaluatedMeshParams,r=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,s)=>this._placeSubdivGlyphs(e,t,i,s),a=(o.bounds.width+r)/(1<<L);this._current={out:e,id:t.getDisplayId(),shaping:o,zoomRange:P(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===s?"above":"top"===s?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,i,s){const{repeatLabel:r,fontSize:o}=this.evaluatedMeshParams,{shaping:n}=this._current,a=t(o),l=e.readGeometryForDisplay();if(!l)return;const h=new f;d(h,l,!1,!1,"esriGeometryPolyline",1);const c=D(new f,h,a),m=D(new f,h,-a),g=u(m,"esriGeometryPolyline",!1,!1),p=u(c,"esriGeometryPolyline",!1,!1),_=v(p.paths,n.bounds.width),x=v(g.paths,n.bounds.width);this._current.offsetDirection="above";for(const t of _)M(t,s,i,!!r);this._current.offsetDirection="below";for(const t of x)M(t,s,i,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:s}=this.evaluatedMeshParams,{shaping:r}=this._current,o=v(e.readLegacyGeometryForDisplay().paths,r.bounds.width);for(const n of o)M(n,i,t,!!s)}_placeSubdivGlyphs(e,t,i,s){const{allowOverrun:r,labelPosition:o,repeatLabelDistance:n}=this.evaluatedMeshParams,a=this._current.zoomRange[0],l=A(t),h=this._current.shaping.bounds.width/(1<<L),c=Math.sqrt(n||I)/(1<<L),m=Math.min(i,s-i),d=this._current.shaping.isMultiline?B:Math.log2(m/(c+h/2)),u=0===t?d:Math.min(l,d),f=Math.max(a,this._zoomLevel+L-u),g=this._zoomLevel-f,p=this._current.shaping.bounds.width/2*2**g;this._current.shaping.isMultiline?0===t&&this._placeStraight(e,f):r&&g<0?this._placeStraightAlong(e,a):"parallel"===o?this._placeStraightAlong(e,f):"curved"===o&&this._placeCurved(e,f,p)}_placeStraight(e,t){const{out:i,id:s,shaping:r,referenceBounds:o}=this._current,{x:n,y:a}=e,l=_(s),h=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new y(l,e.x,e.y,0,0,h,c,null)),i.metricBoxWrite(r.boundsT);const m=e.angle*(180/Math.PI)%360,d=(e.angle*(180/Math.PI)+180)%360;this._writeGlyphs(i,s,n,a,r,0,o,{clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t}),this._writeGlyphs(i,s,n,a,r,0,o,{clipAngle:d,mapAligned:!0,isLineLabel:!0,minZoom:t}),i.metricEnd()}_placeCurved(e,t,i){const{out:s,id:r}=this._current,o=e.clone(),n=e.angle*(180/Math.PI)%360,a=(e.angle*(180/Math.PI)+180)%360,l=_(r),h=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new y(l,e.x,e.y,0,0,h,c,null)),this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(o,t,1,n),this._placeBack(e,o,t,i,1,n),this._placeForward(e,o,t,i,1,n)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(o,t,0,a),this._placeBack(e,o,t,i,0,a),this._placeForward(e,o,t,i,0,a)),s.metricEnd()}_placeStraightAlong(e,o){const{out:n,id:a,shaping:l,zoomRange:h,referenceBounds:m}=this._current,{boxBorderLineColor:d,boxBackgroundColor:u}=this.evaluatedMeshParams,f=e.clone(),g=e.angle*(180/Math.PI)%360,p=(e.angle*(180/Math.PI)+180)%360;if(l.glyphs.length>0&&!(!d&&!u)){const d=Math.max(o,h[0],0),u=Math.min(B,h[1]),f=i(r(),-e.angle),_={minZoom:d,maxZoom:u,clipAngle:g,mapAligned:!0,isLineLabel:!0},x=t(this.evaluatedMeshParams.offsetX),y=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=c(x,-1*y),[i,o]=l.shapeBackground(s(r(),f,t));n.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding);const h=2*Math.max(i.width,i.height);n.recordBounds(e.x+i.x,e.y+i.y,h,h),this._writeTextBox(n,a,e.x,e.y,o,m,_),n.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=c(x,y),[i,o]=l.shapeBackground(s(r(),f,t));_.clipAngle=p,n.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding);const h=2*Math.max(i.width,i.height);n.recordBounds(e.x+i.x,e.y+i.y,h,h),this._writeTextBox(n,a,e.x,e.y,o,m,_),n.recordEnd()}}const x=_(a),v=this.evaluatedMeshParams.scaleInfo?.maxScale??0,M=this.evaluatedMeshParams.scaleInfo?.minScale??0;n.metricStart(new y(x,e.x,e.y,0,0,v,M,null)),this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(f,o,1,g,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(f,o,0,p,!0),n.metricEnd()}_placeBack(e,t,i,s,r,o){const n=e.clone();let a=e.backwardLength+S;for(;n.prev()&&!(a>=s);)this._placeOnSegment(n,t,a,i,-1,r,o),a+=n.length+S}_placeForward(e,t,i,s,r,o){const n=e.clone();let a=e.remainingLength+S;for(;n.next()&&!(a>=s);)this._placeOnSegment(n,t,a,i,1,r,o),a+=n.length+S}_placeFirst(e,t,i,s,r=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:h}=this._current,c=a.glyphs;for(const m of c){const c=m.x>a.bounds.x?i:1-i,d=c*e.remainingLength+(1-c)*e.backwardLength,u=Math.abs(m.x+m.width/2-a.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(u/(d+S))),g=Math.max(t,r?0:f);m.maxZoom=Math.min(l[1],B),m.angle=e.angle+(1-i)*Math.PI,m.minZoom=Math.max(l[0],g),this._writeLineGlyph(o,n,e.x,e.y,a.bounds,m,s,h,!0),i&&this._isVisible(m.minZoom,m.maxZoom)&&o.metricBoxWrite(m.bounds)}}_placeOnSegment(e,t,i,s,r,o,n){const{out:a,id:l,shaping:h,referenceBounds:c}=this._current,m=h.glyphs,d=e.dx/e.length,u=e.dy/e.length,f={x:e.x+i*-r*d,y:e.y+i*-r*u};for(const g of m){const m=g.x>h.bounds.x?o:1-o;if(!(m&&1===r||!m&&-1===r))continue;const d=Math.abs(g.x+g.width/2-h.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(d/i)-.1),p=Math.max(s,this._zoomLevel+Math.log2(d/(i+e.length+S)));if(0!==u&&(g.angle=e.angle+(1-o)*Math.PI,g.minZoom=p,g.maxZoom=u,this._writeLineGlyph(a,l,f.x,f.y,h.bounds,g,n,c,!0),o&&this._isVisible(g.minZoom,g.maxZoom))){const i=g.bounds,s=e.x-t.x,r=e.y-t.y,o=new x(i.center[0]+s,i.center[1]+r,i.width,i.height);a.metricBoxWrite(o)}}}_writeLineGlyph(e,t,i,s,r,o,n,a,l){const h=i+r.x,c=s+r.y,m=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(r.width,r.height)*m;e.recordStart(this.instanceId,this.attributeLayout,o.textureBinding),e.recordBounds(h,c,d,d);const{texcoords:u,offsets:f}=o,g=this._textMeshTransformProps.fontSize;this._writeQuad(e,t,i,s,{texcoords:u,offsets:f,fontSize:g,color:b(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o.minZoom),maxZoom:Math.min(this._current.zoomRange[1],o.maxZoom),clipAngle:n,mapAligned:l,isLineLabel:!0}),e.recordEnd()}_isVisible(e,t){const i=this._zoomLevel;return e<=i&&i<=t}}function D(e,t,i){const{coords:s,lengths:r}=t,c=m(),d=m(),u=m(),f=m(),g=m(),p=m(),_=2;let x=0;for(let m=0;m<r.length;m++){const t=r[m];for(let r=0;r<t;r++){const m=_*(r+x-1),y=_*(r+x),v=_*(r+x+1);r>0?o(c,s[m],s[m+1]):o(c,0,0),o(d,s[y],s[y+1]),r<t-1?o(u,s[v],s[v+1]):o(u,0,0),0===r?o(f,0,0):(n(f,d,c),a(f,f),o(f,f[1],-f[0])),r===t-1?o(g,0,0):(n(g,u,d),a(g,g),o(g,g[1],-g[0])),l(p,f,g),a(p,p);const M=p[0]*g[0]+p[1]*g[1];0!==M&&h(p,p,M),h(p,p,i),e.coords.push(d[0]+p[0],d[1]+p[1])}e.lengths.push(t),x+=t}return e}export{z as LabelMeshWriter};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{numericHash as e}from"../../../../../../../core/string.js";function t(t){const o=t.map((({name:e,count:t,type:o})=>`${e}.${t}.${o}`)).join(",");return e(o)}function o(e,t,r,i,n,a,c){if(e.primitiveName===t)for(const o in e)if(o===r){let t=i?.readWithDefault(n,a,e[o]&&c);return"text"===e.type&&(t=t.toString()),void(e[o]=t)}if("type"in e&&null!=e.type)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.symbolLayers)for(const
|
|
5
|
+
import{numericHash as e}from"../../../../../../../core/string.js";function t(t){const o=t.map((({name:e,count:t,type:o})=>`${e}.${t}.${o}`)).join(",");return e(o)}function o(e,t,r,i,n,a,c){if(e.primitiveName===t)for(const o in e)if(o===r){let t=i?.readWithDefault(n,a,e[o]&&c);return"text"===e.type&&(t=t.toString()),void(e[o]=t)}if("type"in e&&null!=e.type)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.symbolLayers)for(const s of e.symbolLayers)o(s,t,r,i,n,a,c);break;case"CIMHatchFill":e.lineSymbol&&o(e.lineSymbol,t,r,i,n,a,c);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const s of e.markerGraphics)o(s,t,r,i,n,a,c),o(s.symbol,t,r,i,n,a,c)}}const r=258;function i(e){const t=e.width;return null!=e.effects?r:Math.max(1.25*t,8)}export{o as applyComputedValue,i as getLineClippingMargin,t as vertexLayoutHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{deepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,throwIfNotAbortError as d,isAbortError as y}from"../../../core/promiseUtils.js";import{watch as g,initial as f}from"../../../core/reactiveUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import _ from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as v}from"../../../layers/graphics/featureConversionUtils.js";import b from"../../../layers/support/FeatureFilter.js";import{packFields as F}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as A}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as S}from"../../../layers/support/timeSupport.js";import E from"../../../rest/support/AggregateFeatureSet.js";import x from"../../../rest/support/FeatureSet.js";import j from"../../../rest/support/Query.js";import{getHighlightBits as V}from"../engine/highlightReasons.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{FeatureContainer as R}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as U}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as k}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as q}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as I}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as Q}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as O}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as L}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as H}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as P}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as W}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as T}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import D from"./support/FeatureCommandQueue.js";import{handleNoEngineError as M}from"./support/handleNoEngineError.js";import{HighlightCounter as N}from"./support/HighlightCounter.js";import{toJSONGeometryType as J}from"./support/util.js";import{FeatureTileSubscriptionManager as $}from"../tiling/FeatureTileSubscriptionManager.js";import G from"../../layers/FeatureLayerView.js";import z from"../../layers/LayerView.js";import B from"../../layers/RefreshableLayerView.js";import Z from"../../../geometry/Extent.js";function K(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const X=4294967294;let Y=class extends(G(B(C(z)))){constructor(){super(...arguments),this._commandsQueue=new D({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new N,this._lastAvailableFields=[],this.eventLog=new k,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new _}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===A(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await U(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view.featuresTilingScheme.tileInfo.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){d(r)}this._workerAttached.reject()}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new Q(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new Q(this.layer);case"subtype-group":return new W(this.layer);case"ogc-feature":return new L(this.layer);case"stream":return new P(this.layer);case"oriented-imagery":return new H(this.layer);case"knowledge-graph-sublayer":return new O(this.layer);case"catalog-footprint":return new q(this.layer);default:a(this.layer)}return null}get timeExtent(){return S(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="highlight"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return M(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return M(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return M(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return M(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return M(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return M(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return M(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return M(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return M(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=x.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await M(r,{features:[]}),s=x.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await M(r,{features:[]}),s=E.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return M(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return M(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return M(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return M(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return M(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return M(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await M(r,{count:0,extent:null});return{count:i.count,extent:Z.fromJSON(i.extent)}}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),this._updatingHandles.addPromise(this._workerAttached.promise),this._attachProxy(),this.featureContainer=new R(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new $({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([g((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),f),g((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:t=>Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t)))),fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await T(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=j.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=j.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(d):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%X+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%X+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n){const e=!1,r=!1,i=J(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>v(t,i,e,r))),c=u.map((t=>v(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectIdField:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await this._updateRequiredFields(),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransitions(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){y(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=K(this._lastAvailableFields,e);return this._lastAvailableFields=t,F(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[ee(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._updateHighlights()}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._updateHighlights()}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(i),r=V(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{y(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function ee(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new b,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new b).toJSON(),n.hiddenIds=Array.from(i)),n}e([m()],Y.prototype,"_commandsQueue",void 0),e([m()],Y.prototype,"_sourceRefreshVersion",void 0),e([m()],Y.prototype,"_displayRefreshVersion",void 0),e([m({readOnly:!0})],Y.prototype,"_pipelineUpdating",void 0),e([m({readOnly:!0})],Y.prototype,"hasAllFeatures",null),e([m({readOnly:!0})],Y.prototype,"hasAllFeaturesInView",null),e([m({readOnly:!0})],Y.prototype,"hasFullGeometries",null),e([m()],Y.prototype,"featureEffectView",void 0),e([m()],Y.prototype,"labelingCollisionInfos",null),e([m()],Y.prototype,"layerAdapter",null),e([m({readOnly:!0})],Y.prototype,"timeExtent",null),e([m()],Y.prototype,"updating",void 0),Y=e([w("esri.views.2d.layers.FeatureLayerView2D")],Y);const te=Y;export{te as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{deepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as b}from"../../../layers/graphics/featureConversionUtils.js";import F from"../../../layers/support/FeatureFilter.js";import{packFields as A}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as S}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as E}from"../../../layers/support/timeSupport.js";import x from"../../../rest/support/AggregateFeatureSet.js";import j from"../../../rest/support/FeatureSet.js";import V from"../../../rest/support/Query.js";import{getHighlightBits as C}from"../engine/highlightReasons.js";import{LayerView2DMixin as R}from"./LayerView2D.js";import{FeatureContainer as U}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as k}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as q}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as I}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as Q}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as O}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as L}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as H}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as W}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as T}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as D}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import M from"./support/FeatureCommandQueue.js";import{handleNoEngineError as N}from"./support/handleNoEngineError.js";import{HighlightCounter as J}from"./support/HighlightCounter.js";import{toJSONGeometryType as $}from"./support/util.js";import{FeatureTileSubscriptionManager as G}from"../tiling/FeatureTileSubscriptionManager.js";import z from"../../layers/FeatureLayerView.js";import B from"../../layers/LayerView.js";import Z from"../../layers/RefreshableLayerView.js";import K from"../../../geometry/Extent.js";function X(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const Y=4294967294;let ee=class extends(z(Z(R(B)))){constructor(){super(...arguments),this._commandsQueue=new M({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new J,this._lastAvailableFields=[],this.eventLog=new q,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new v}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===S(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await k(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view.featuresTilingScheme.tileInfo.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){y(r)}this._workerAttached.reject()}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){try{await this._workerAttached.promise}catch(e){console.error("Throw abort")}return this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new O(this.layer):new Q(this.layer);case"geojson":case"csv":case"wfs":return new O(this.layer);case"subtype-group":return new T(this.layer);case"ogc-feature":return new H(this.layer);case"stream":return new W(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new L(this.layer);case"catalog-footprint":return new I(this.layer);default:a(this.layer)}return null}get timeExtent(){return E(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="highlight"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return N(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return N(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return N(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=j.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await N(r,{features:[]}),s=j.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await N(r,{features:[]}),s=x.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return N(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return N(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return N(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return N(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return N(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return N(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await N(r,{count:0,extent:null});return{count:i.count,extent:K.fromJSON(i.extent)}}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new U(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new G({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),d(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:t=>Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t)))),fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await D(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=V.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=V.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(y):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%Y+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%Y+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n){const e=!1,r=!1,i=$(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>b(t,i,e,r))),c=u.map((t=>b(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectIdField:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await this._updateRequiredFields(),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransitions(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=X(this._lastAvailableFields,e);return this._lastAvailableFields=t,A(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[te(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._updateHighlights()}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._updateHighlights()}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(i),r=C(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function te(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new F,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new F).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],ee.prototype,"_commandsQueue",void 0),e([w()],ee.prototype,"_sourceRefreshVersion",void 0),e([w()],ee.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],ee.prototype,"_pipelineUpdating",void 0),e([w({readOnly:!0})],ee.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],ee.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],ee.prototype,"hasFullGeometries",null),e([w()],ee.prototype,"featureEffectView",void 0),e([w()],ee.prototype,"labelingCollisionInfos",null),e([w()],ee.prototype,"layerAdapter",null),e([w({readOnly:!0})],ee.prototype,"timeExtent",null),e([w()],ee.prototype,"updating",void 0),ee=e([_("esri.views.2d.layers.FeatureLayerView2D")],ee);const re=ee;export{re as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r}from"../../../../core/promiseUtils.js";import
|
|
5
|
+
import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import n from"../../../../core/RandomLCG.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{ignoreConnectionErrors as d}from"../../../../core/workers/utils.js";import c from"../../../../layers/support/TileInfo.js";import p from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tileSize as l}from"../../engine/webgl/definitions.js";import{PipelineConnectionHandlers as h}from"./PipelineConnectionHandlers.js";import g from"./Processor.js";import{FeatureSource as _}from"./sources/FeatureSource.js";import{FeatureTileSubscription as b}from"./sources/FeatureTileSubscription.js";import{Tile as f}from"./support/Tile.js";class m{constructor(e){this.inner=e,this.resolver=r()}}class y{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor.destroy(),this._source.destroy(),this._handles.remove(),this._updateLocalEditsRequest=null,this._tileInfoView=null}onAttach(e){has("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const s=this._connection,i=c.fromJSON(e.tileInfoJSON);this._tileInfoView=new p(i),this._source=new _(e.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),s),this._processor=new g(s,this._source),this._handles=t([u((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),o(this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){has("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(e){this._connection=new h(e)}get features(){const t=this._source?.queryEngine;if(!t)throw new e("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new e("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}async updateSchema(e,t){return has("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new m({schema:e,version:t}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(e){const t=new m(e);return this._updateSubscriptionRequests.push(t),this._requestUpdate(),t.resolver.promise}updateHighlight(e){const t=new m(e);return this._updateHighlightRequests.push(t),this._requestUpdate(),t.resolver.promise}async onEdits(t){if(null!=this._updateLocalEditsRequest)throw new e("InternalError - Already processing an edit");this._updateLocalEditsRequest=new m(t);const s=this._updateLocalEditsRequest.resolver.promise;return this._requestUpdate(),s}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round(a(e.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof e.fieldOffset,o=e.fieldOffset??0,n=Array.from(this._subscriptions.values()),u=this._source.chunks(),d=t**2,c=3/(Math.PI*d),p=2*t,h=Math.ceil(l/p);for(const a of n){const t=a.tile,n=new Float64Array(h*h);for(const s of u){const i=s.getTileReader(t);if(!i)continue;const u=i.getCursor();for(;u.next();){let t=1;if(null!=e.field){const s=u.readAttribute(e.field);t=r?-1*+s:+s+o}const s=u.readXForDisplay()/p,i=u.readYForDisplay()/p,a=Math.floor(s),l=Math.floor(i);if(a<0||l<0||a>=h||l>=h)continue;const g=((.5+a-s)*p)**2+((.5+l-i)*p)**2;if(g>d)continue;const _=t*(c*(1-g/d)**2);n[l+a*h]+=_}}for(let e=0;e<n.length;e++)s=Math.min(s,n[e]),i=Math.max(i,n[e])}return{max:i,min:s}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const s=new Set,i=[],r=t.map((e=>e.reader.getCursor())),o=new n,u=3*e.sampleSize;for(let n=0;n<u&&i.length<e.sampleSize;n++){const e=r[o.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const n=o.getIntRange(0,e.getSize()-1);e.setIndex(n);const u=e.getObjectId();s.has(u)||(s.add(u),i.push(e.readLegacyFeatureWorldSpace()))}return i.length>=e.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,s((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=d(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t)){const s=this._subscriptions.get(t);return void(s.paused&&(has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.resume`),s.resume(),s.version=e.version,this._source.onResume(s)))}has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const s=new f(this._tileInfoView,t),i=new b(s,e.version);this._subscriptions.set(t,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id),t.destroy())}_pauseSubscription(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.pause`),t.pause())}async _doUpdate(){if(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t.inner),t.resolver.resolve()}const e=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=e){const{schema:t,version:s}=e.inner;await this._doUpdateSchema(t,s)}const t=this._updateLocalEditsRequest;if(this._updateLocalEditsRequest=null,null!=t){has("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",t.inner);const e=await this._source.getLocalEdit(t.inner);await this._processor.applyLocalEdit(e),this._source.applyLocalEdit(e),has("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",t.inner)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t.inner),t.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(r){i(r)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(e,t){has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e});const s={tileInfo:this._tileInfoView?.tileInfo},i=await this._source.update(e,t),r=Array.from(this._subscriptions.values());await this._processor.update(e,t,s,i,r),has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){has("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e);for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t);if(has("featurelayer-query-pausing-enabled"))for(const t of e.pause)this._pauseSubscription(t)}}export{y as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class
|
|
5
|
+
import{ignoreConnectionErrors as e}from"../../../../core/workers/utils.js";class t{constructor(e){this._client=e,this.layerView=this._client.createInvokeProxy(""),this.container=this._client.createInvokeProxy("container"),this._eventLog=this._client.createInvokeProxy("eventLog")}onEvent(t){e(this._eventLog.onEvent(t))}}export{t as PipelineConnectionHandlers};
|