@arcgis/core 4.30.0-next.20240611 → 4.30.0-next.20240613
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/6ae4a5e81fd398d2ebca.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -4
- package/assets/esri/themes/base/widgets/_Print.scss +4 -30
- package/assets/esri/themes/base/widgets/_SnappingControls.scss +5 -0
- 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/chunks/ShadowHighlight.glsl.js +4 -29
- package/chunks/Viewshed.glsl.js +145 -84
- package/interfaces.d.ts +210 -76
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/package.json +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/svgUtils.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/pointToPoint/Camera.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js +23 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ViewshedTechniqueConfiguration.js +5 -0
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/reshapeTooltipUtils.js +1 -1
- package/widgets/Compass/CompassViewModel.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/css.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
- package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
- package/widgets/support/SnappingControls/SnappingListItem.js +1 -1
- package/widgets/support/SnappingControls/snappingLayerListUtils.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/assets/esri/core/workers/chunks/17e8791bad1e2c3a0bb1.js +0 -1
|
@@ -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 t}from"../../kernel.js";import{symbolTypesRenderer as e}from"../../symbols.js";import{resultOrAbort as r}from"../../core/asyncUtils.js";import n from"../../core/Error.js";import{JSONMap as o}from"../../core/jsonMap.js";import{parseWhereClause as a}from"../../core/sql.js";import{createTypeReader as s}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import{queryAllJSON as i}from"./featureQueryAll.js";import{getOwningPortalUrl as u}from"./layerUtils.js";import l from"../../renderers/SimpleRenderer.js";import c from"../../renderers/UniqueValueRenderer.js";import p from"../../rest/support/AttachmentQuery.js";import d from"../../rest/support/Query.js";import f from"../../rest/support/RelationshipQuery.js";const y=new o({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"});async function m(t,e,r,o){const a=await L(t);if(await h(t,e,o),!a.addAttachment)throw new n(o,"Layer source does not support addAttachment capability");return a.addAttachment(e,r)}function h(t,e,r){const{attributes:o}=e,{objectIdField:a}=t;return t.capabilities?.data?.supportsAttachment?e?o?a&&o[a]?Promise.resolve():Promise.reject(new n(r,`feature is missing the identifying attribute ${a}`)):Promise.reject(new n(r,"'attributes' are required on a feature to query attachments")):Promise.reject(new n(r,"A feature is required to add/delete/update attachments")):Promise.reject(new n(r,"this layer doesn't support attachments"))}async function w(t,e,r,o,a){const s=await L(t);if(await h(t,e,a),!s.updateAttachment)throw new n(a,"Layer source does not support updateAttachment capability");return s.updateAttachment(e,r,o)}async function b(t,e,r){const{applyEdits:n}=await import("../graphics/editingSupport.js"),o=await t.load();let a=r;return"feature"===o.type&&o.infoFor3D&&null!=e.deleteFeatures&&null!=o.globalIdField&&(a={...a,globalIdToObjectId:await J(o,e.deleteFeatures,o.globalIdField)}),n(o,o.source,e,r)}async function g(t,e,r){const{uploadAssets:n}=await import("../graphics/editingSupport.js"),o=await t.load();return n(o,o.source,e,r)}async function j(t,e,r,o){const a=await L(t);if(await h(t,e,o),!a.deleteAttachments)throw new n(o,"Layer source does not support deleteAttachments capability");return a.deleteAttachments(e,r)}async function I(t,e,r){const o=(await t.load({signal:e?.signal})).source;if(!o.fetchRecomputedExtents)throw new n(r,"Layer source does not support fetchUpdates capability");return o.fetchRecomputedExtents(e)}async function q(t,e,r,o){e=p.from(e),await t.load();const a=t.source,s=t.capabilities;if(!s?.data?.supportsAttachment)throw new n(o,"this layer doesn't support attachments");const{attachmentTypes:i,objectIds:u,globalIds:l,num:c,size:d,start:f,where:y}=e;if(!s?.operations?.supportsQueryAttachments){if(i?.length>0||l?.length>0||d?.length>0||c||f||y)throw new n(o,"when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(u?.length||l?.length||y))throw new n(o,"'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);if(!a.queryAttachments)throw new n(o,"Layer source does not support queryAttachments capability",e);return a.queryAttachments(e)}async function F(t,e,r,o){const a=await L(t);if(!a.queryObjectIds)throw new n(o,"Layer source does not support queryObjectIds capability");return a.queryObjectIds(d.from(e)??t.createQuery(),r)}async function A(t,e,r,o){const a=await L(t);if(!a.queryFeatureCount)throw new n(o,"Layer source does not support queryFeatureCount capability");return a.queryFeatureCount(d.from(e)??t.createQuery(),r)}async function O(t,e,r,o){const a=await L(t);if(!a.queryExtent)throw new n(o,"Layer source does not support queryExtent capability");return a.queryExtent(d.from(e)??t.createQuery(),r)}async function P(t,e,r,o){const a=await L(t);if(!a.queryRelatedFeatures)throw new n(o,"Layer source does not support queryRelatedFeatures capability");return a.queryRelatedFeatures(f.from(e),r)}async function S(t,e,r,o){const a=await L(t);if(!a.queryRelatedFeaturesCount)throw new n(o,"Layer source does not support queryRelatedFeaturesCount capability");return a.queryRelatedFeaturesCount(f.from(e),r)}async function E(t){const e=t.source;if(e?.refresh)try{const{dataChanged:r,updates:n}=await e.refresh();if(null!=n&&(t.sourceJSON={...t.sourceJSON,...n},t.read(n,{origin:"service",url:t.parsedUrl})),r)return!0}catch{}if(t.definitionExpression)try{return(await a(t.definitionExpression,t.fieldsIndex)).hasDateFunctions}catch{}return!1}function x(t){const e=new d,r=t.capabilities?.data,n=t.capabilities?.query;e.historicMoment=t.historicMoment,e.gdbVersion=t.gdbVersion,e.returnGeometry=!0,n&&(e.compactGeometryEnabled=n.supportsCompactGeometry,e.defaultSpatialReferenceEnabled=n.supportsDefaultSpatialReference),r&&(r.supportsZ&&null!=t.returnZ&&(e.returnZ=t.returnZ),r.supportsM&&null!=t.returnM&&(e.returnM=t.returnM)),e.outFields=["*"];const{timeOffset:o,timeExtent:a}=t;return e.timeExtent=null!=o&&null!=a?a.offset(-o.value,o.unit):a||null,e.multipatchOption="multipatch"===t.geometryType?"xyFootprint":null,e}function R(t){const{globalIdField:e,fields:r}=t;if(e)return e;if(r)for(const n of r)if("esriFieldTypeGlobalID"===n.type)return n.name}function M(t){const{objectIdField:e,fields:r}=t;if(e)return e;if(r)for(const n of r)if("esriFieldTypeOID"===n.type)return n.name}function C(t){return t.currentVersion?t.currentVersion:t.hasOwnProperty("capabilities")||t.hasOwnProperty("drawingInfo")||t.hasOwnProperty("hasAttachments")||t.hasOwnProperty("htmlPopupType")||t.hasOwnProperty("relationships")||t.hasOwnProperty("timeInfo")||t.hasOwnProperty("typeIdField")||t.hasOwnProperty("types")?10:9.3}function G(t,e){const{subtypes:r,subtypeField:n}=t;if(!e||!r?.length||!n)return null;const o=e.attributes[n];return null==o?null:r.find((t=>t.code===o))}async function L(t){return(await t.load()).source}async function Q(e,r){if(!t)return;if(t.findCredential(e))return;let n;try{const o=await u(e,r);o&&(n=await t.checkSignInStatus(`${o}/sharing`))}catch(o){}if(n)try{const n=null!=r?r.signal:null;await t.getCredential(e,{signal:n})}catch(o){}}async function T(t,e,r){const n=t.parsedUrl?.path;n&&t.authenticationTriggerEvent===e&&await Q(n,r)}function v(t){return!t.sourceJSON?.isMultiServicesView&&(t.userHasUpdateItemPrivileges||t.editingEnabled)}const D=s({types:e});function U(t,e){if(t.defaultSymbol)return t.types?.length?new c({defaultSymbol:D(t.defaultSymbol,t,e),field:t.typeIdField,uniqueValueInfos:t.types.map((t=>({id:t.id,symbol:D(t.symbol,t,e)})))}):new l({symbol:D(t.defaultSymbol,t,e)})}function V(t){let e=t.sourceJSON?.cacheMaxAge;if(!e)return!1;const r=t.editingInfo?.lastEditDate?.getTime();return null==r||(e*=1e3,Date.now()-r<e)}async function J(t,e,n){if(null==e)return null;const o=[],{objectIdField:a}=t;if(e.forEach((t=>{let e=null;if("attributes"in t){const{attributes:r}=t;e={globalId:r[n],objectId:null!=r[a]&&-1!==r[a]?r[a]:null}}else e={globalId:t.globalId,objectId:null!=t.objectId&&-1!==t.objectId?t.objectId:null};null!=e.globalId&&(null!=e.objectId&&-1!==e.objectId||o.push(e.globalId))})),0===o.length)return null;const s=t.createQuery();s.where=o.map((t=>`${n}='${t}'`)).join(" OR "),s.returnGeometry=!1,s.outFields=[a,n],s.cacheHint=!1;const u=await r(i(t,s));if(!u.ok)return null;const l=new Map,c=u.value.features;for(const r of c){const t=r.attributes[n],e=r.attributes[a];null!=t&&null!=e&&-1!==e&&l.set(t,e)}return l}function N(t,e,r){if(!e||!r||!t)return null;const n=r.getAttribute(e);return null==n?null:t.find((t=>{const{id:e}=t;return null!=e&&e.toString()===n.toString()}))??null}export{m as addAttachment,b as applyEdits,v as computeEffectiveEditingEnabled,U as createDefaultRenderer,x as createQuery,j as deleteAttachments,T as ensureLayerCredential,I as fetchRecomputedExtents,y as geometryTypeKebabDict,G as getFeatureSubtype,N as getFeatureType,J as getGlobalIdToObjectIdMap,E as hasDataChanged,V as isLayerCacheStale,q as queryAttachments,O as queryExtent,A as queryFeatureCount,F as queryObjectIds,P as queryRelatedFeatures,S as queryRelatedFeaturesCount,R as readGlobalIdField,M as readObjectIdField,C as readVersion,w as updateAttachment,g as uploadAssets};
|
|
5
|
+
import{id as t}from"../../kernel.js";import{symbolTypesRenderer as e}from"../../symbols.js";import{resultOrAbort as r}from"../../core/asyncUtils.js";import n from"../../core/Error.js";import{JSONMap as o}from"../../core/jsonMap.js";import{parseWhereClause as a}from"../../core/sql.js";import{createTypeReader as s}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import{queryAllJSON as i}from"./featureQueryAll.js";import{getOwningPortalUrl as u}from"./layerUtils.js";import l from"../../renderers/SimpleRenderer.js";import c from"../../renderers/UniqueValueRenderer.js";import p from"../../rest/support/AttachmentQuery.js";import d from"../../rest/support/Query.js";import f from"../../rest/support/RelationshipQuery.js";const y=new o({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"});async function m(t,e,r,o){const a=await L(t);if(await h(t,e,o),!a.addAttachment)throw new n(o,"Layer source does not support addAttachment capability");return a.addAttachment(e,r)}function h(t,e,r){const{attributes:o}=e,{objectIdField:a}=t;return t.capabilities?.data?.supportsAttachment?e?o?a&&o[a]?Promise.resolve():Promise.reject(new n(r,`feature is missing the identifying attribute ${a}`)):Promise.reject(new n(r,"'attributes' are required on a feature to query attachments")):Promise.reject(new n(r,"A feature is required to add/delete/update attachments")):Promise.reject(new n(r,"this layer doesn't support attachments"))}async function w(t,e,r,o,a){const s=await L(t);if(await h(t,e,a),!s.updateAttachment)throw new n(a,"Layer source does not support updateAttachment capability");return s.updateAttachment(e,r,o)}async function b(t,e,r){const{applyEdits:n}=await import("../graphics/editingSupport.js"),o=await t.load();let a=r;return"feature"===o.type&&o.infoFor3D&&null!=e.deleteFeatures&&null!=o.globalIdField&&(a={...a,globalIdToObjectId:await J(o,e.deleteFeatures,o.globalIdField)}),n(o,o.source,e,r)}async function g(t,e,r){const{uploadAssets:n}=await import("../graphics/editingSupport.js"),o=await t.load();return n(o,o.source,e,r)}async function j(t,e,r,o){const a=await L(t);if(await h(t,e,o),!a.deleteAttachments)throw new n(o,"Layer source does not support deleteAttachments capability");return a.deleteAttachments(e,r)}async function I(t,e,r){const o=(await t.load({signal:e?.signal})).source;if(!o.fetchRecomputedExtents)throw new n(r,"Layer source does not support fetchUpdates capability");return o.fetchRecomputedExtents(e)}async function q(t,e,r,o){e=p.from(e),await t.load();const a=t.source,s=t.capabilities;if(!s?.data?.supportsAttachment)throw new n(o,"this layer doesn't support attachments");const{attachmentTypes:i,objectIds:u,globalIds:l,num:c,size:d,start:f,where:y}=e;if(!s?.operations?.supportsQueryAttachments){if(i?.length>0||l?.length>0||d?.length>0||c||f||y)throw new n(o,"when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(u?.length||l?.length||y))throw new n(o,"'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);if(!a.queryAttachments)throw new n(o,"Layer source does not support queryAttachments capability",e);return a.queryAttachments(e)}async function F(t,e,r,o){const a=await L(t);if(!a.queryObjectIds)throw new n(o,"Layer source does not support queryObjectIds capability");return a.queryObjectIds(d.from(e)??t.createQuery(),r)}async function A(t,e,r,o){const a=await L(t);if(!a.queryFeatureCount)throw new n(o,"Layer source does not support queryFeatureCount capability");return a.queryFeatureCount(d.from(e)??t.createQuery(),r)}async function O(t,e,r,o){const a=await L(t);if(!a.queryExtent)throw new n(o,"Layer source does not support queryExtent capability");return a.queryExtent(d.from(e)??t.createQuery(),r)}async function P(t,e,r,o){const a=await L(t);if(!a.queryRelatedFeatures)throw new n(o,"Layer source does not support queryRelatedFeatures capability");return a.queryRelatedFeatures(f.from(e),r)}async function S(t,e,r,o){const a=await L(t);if(!a.queryRelatedFeaturesCount)throw new n(o,"Layer source does not support queryRelatedFeaturesCount capability");return a.queryRelatedFeaturesCount(f.from(e),r)}async function E(t){const e=t.source;if(e?.refresh)try{const{dataChanged:r,updates:n}=await e.refresh();if(null!=n&&(t.sourceJSON={...t.sourceJSON,...n},t.read(n,{origin:"service",url:t.parsedUrl})),r)return!0}catch{}if(t.definitionExpression)try{return(await a(t.definitionExpression,t.fieldsIndex)).hasDateFunctions}catch{}return!1}function x(t){const e=new d,r=t.capabilities?.data,n=t.capabilities?.query;e.historicMoment=t.historicMoment,e.gdbVersion=t.gdbVersion,e.returnGeometry=!0,n&&(e.compactGeometryEnabled=n.supportsCompactGeometry,e.defaultSpatialReferenceEnabled=n.supportsDefaultSpatialReference),r&&(r.supportsZ&&null!=t.returnZ&&(e.returnZ=t.returnZ),r.supportsM&&null!=t.returnM&&(e.returnM=t.returnM)),e.outFields=["*"];const{timeOffset:o,timeExtent:a}=t;return e.timeExtent=null!=o&&null!=a?a.offset(-o.value,o.unit):a||null,e.multipatchOption="multipatch"===t.geometryType?"xyFootprint":null,e}function R(t){const{globalIdField:e,fields:r}=t;if(e)return e;if(r)for(const n of r)if("esriFieldTypeGlobalID"===n.type)return n.name}function M(t){const{objectIdField:e,fields:r}=t;if(e)return e;if(r)for(const n of r)if("esriFieldTypeOID"===n.type)return n.name}function C(t){return t.currentVersion?t.currentVersion:t.hasOwnProperty("capabilities")||t.hasOwnProperty("drawingInfo")||t.hasOwnProperty("hasAttachments")||t.hasOwnProperty("htmlPopupType")||t.hasOwnProperty("relationships")||t.hasOwnProperty("timeInfo")||t.hasOwnProperty("typeIdField")||t.hasOwnProperty("types")?10:9.3}function G(t,e){const{subtypes:r,subtypeField:n}=t;if(!e||!r?.length||!n)return null;const o=e.attributes[n];return null==o?null:r.find((t=>t.code===o))}async function L(t){return(await t.load()).source}async function Q(e,r){if(!t)return;if(t.findCredential(e))return;let n;try{const o=await u(e,r);o&&(n=await t.checkSignInStatus(`${o}/sharing`))}catch(o){}if(n)try{const n=null!=r?r.signal:null;await t.getCredential(e,{signal:n})}catch(o){}}async function T(t,e,r){const n=t.parsedUrl?.path;n&&t.authenticationTriggerEvent===e&&await Q(n,r)}function v(t){return!t.sourceJSON?.isMultiServicesView&&(t.userHasUpdateItemPrivileges||t.editingEnabled)}const D=s({types:e});function U(t,e){if(t.defaultSymbol)return t.types?.length?new c({defaultSymbol:D(t.defaultSymbol,t,e),field:t.typeIdField,uniqueValueInfos:t.types.map((t=>({id:t.id,symbol:D(t.symbol,t,e)})))}):new l({symbol:D(t.defaultSymbol,t,e)})}function V(t){let e=t.sourceJSON?.cacheMaxAge;if(!e)return!1;const r=t.editingInfo?.lastEditDate?.getTime();return null==r||(e*=1e3,Date.now()-r<e)}async function J(t,e,n){if(null==e)return null;const o=[],{objectIdField:a}=t;if(e.forEach((t=>{let e=null;if("attributes"in t){const{attributes:r}=t;e={globalId:r[n],objectId:null!=r[a]&&-1!==r[a]?r[a]:null}}else e={globalId:t.globalId,objectId:null!=t.objectId&&-1!==t.objectId?t.objectId:null};null!=e.globalId&&(null!=e.objectId&&-1!==e.objectId||o.push(e.globalId))})),0===o.length)return null;const s=t.createQuery();s.where=o.map((t=>`${n}='${t}'`)).join(" OR "),s.returnGeometry=!1,s.outFields=[a,n],s.cacheHint=!1;const u=await r(i(t,s));if(!u.ok)return null;const l=new Map,c=u.value.features;for(const r of c){const t=r.attributes[n],e=r.attributes[a];null!=t&&null!=e&&-1!==e&&l.set(t,e)}return l}function N(t,e,r){if(!e||!r||!t)return null;const n=r.getAttribute(e);return null==n?null:t.find((t=>{const{id:e}=t;return null!=e&&e.toString()===n.toString()}))??null}export{m as addAttachment,b as applyEdits,v as computeEffectiveEditingEnabled,U as createDefaultRenderer,x as createQuery,j as deleteAttachments,Q as ensureCredentialIfSignedIn,T as ensureLayerCredential,I as fetchRecomputedExtents,y as geometryTypeKebabDict,G as getFeatureSubtype,N as getFeatureType,J as getGlobalIdToObjectIdMap,E as hasDataChanged,V as isLayerCacheStale,q as queryAttachments,O as queryExtent,A as queryFeatureCount,F as queryObjectIds,P as queryRelatedFeatures,S as queryRelatedFeaturesCount,R as readGlobalIdField,M as readObjectIdField,C as readVersion,w as updateAttachment,g as uploadAssets};
|
|
@@ -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{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";const
|
|
5
|
+
import{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";import{DateTime as o,FixedOffsetZone as l}from"luxon";const u={84:4326,83:4269,27:4267};function a(n){if(!n)return null;const i={idCounter:-1};if("string"==typeof n){n=(new DOMParser).parseFromString(n,"text/xml")}const s=n.documentElement;if("ServiceExceptionReport"===s.nodeName){const e=Array.prototype.slice.call(s.childNodes).map((e=>e.textContent)).join("\r\n");throw new t("wmslayer:wms-capabilities-xml-is-not-valid","The server returned errors when the WMS capabilities were requested.",e)}const o=x("Capability",s),l=x("Service",s),u=o&&x("Request",o);if(!o||!l||!u)return null;const a=x("Layer",o);if(!a)return null;const c="WMS_Capabilities"===s.nodeName||"WMT_MS_Capabilities"===s.nodeName?s.getAttribute("version"):"1.3.0",d=g("Title",l,"")||g("Name",l,""),p=g("AccessConstraints",l,""),h=/^none$/i.test(p)?"":p,N=g("Abstract",l,""),A=parseInt(g("MaxWidth",l,"5000"),10),w=parseInt(g("MaxHeight",l,"5000"),10),L=b(u,"GetMap"),F=y(u,"GetMap"),M=S(a,c,i);if(!M)return null;let T,I=0;const v=Array.prototype.slice.call(o.childNodes),R=M.sublayers??[],U=e=>{null!=e&&R.push(e)};v.forEach((e=>{"Layer"===e.nodeName&&(0===I?T=e:1===I?(M.name&&(M.name="",U(S(T,c,i))),U(S(e,c,i))):U(S(e,c,i)),I++)}));let V=M.sublayers,O=M.extent;const _=M.fullExtents??[];if(V||(V=[]),0===V.length&&V.push(M),!O){const e=new r(V[0].extent);M.extent=e.toJSON(),O=M.extent}const B=M.spatialReferences.length>0?M.spatialReferences:m(M),j=y(u,"GetFeatureInfo"),k=j?b(u,"GetFeatureInfo"):null,q=f(V),X=M.minScale||0,D=M.maxScale||0,$=M.dimensions??[],G=q.reduce(((e,t)=>e.concat(t.dimensions??[])),[]),W=$.concat(G).filter(C);let P=null;if(W.length){const t=W.map((e=>{const{extent:t}=e;return E(t)?t.map((e=>e.getTime())):t?.map((e=>[e.min.getTime(),e.max.getTime()]))})).flat(2).filter(e);P={startTimeField:null,endTimeField:null,trackIdField:void 0,timeExtent:[Math.min(...t),Math.max(...t)]}}return{copyright:h,description:N,dimensions:$,extent:O,fullExtents:_,featureInfoFormats:k,featureInfoUrl:j,mapUrl:F,maxWidth:A,maxHeight:w,maxScale:D,minScale:X,layers:q,spatialReferences:B,supportedImageFormatTypes:L,timeInfo:P,title:d,version:c}}function c(e){const t=e.filter((e=>e.popupEnabled&&e.name&&e.queryable));return t.length?t.map((({name:e})=>e)).join():null}function m(e){if(e.spatialReferences.length>0)return e.spatialReferences;if(e.sublayers)for(const t of e.sublayers){const e=m(t);if(e.length>0)return e}return[]}function f(e){let t=[];for(const n of e)t.push(n),n.sublayers?.length&&(t=t.concat(f(n.sublayers)),delete n.sublayers);return t}function d(e,t,n){return t.getAttribute(e)??n}function p(e,t,n,r){const i=x(e,n);return i?d(t,i,r):r}function x(e,t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(w(r)&&r.nodeName===e)return r}return null}function h(e,t){if(null==t)return[];const n=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];w(i)&&i.nodeName===e&&n.push(i)}return n}function g(e,t,n){return x(e,t)?.textContent??n}function N(e,t,n){if(!e)return null;const s=parseFloat(e.getAttribute("minx")),o=parseFloat(e.getAttribute("miny")),l=parseFloat(e.getAttribute("maxx")),u=parseFloat(e.getAttribute("maxy"));let a,c,m,f;n?(a=isNaN(o)?-Number.MAX_VALUE:o,c=isNaN(s)?-Number.MAX_VALUE:s,m=isNaN(u)?Number.MAX_VALUE:u,f=isNaN(l)?Number.MAX_VALUE:l):(a=isNaN(s)?-Number.MAX_VALUE:s,c=isNaN(o)?-Number.MAX_VALUE:o,m=isNaN(l)?Number.MAX_VALUE:l,f=isNaN(u)?Number.MAX_VALUE:u);const d=new i({wkid:t});return new r({xmin:a,ymin:c,xmax:m,ymax:f,spatialReference:d})}function y(e,t){const n=x(t,e);if(n){const e=x("DCPType",n);if(e){const t=x("HTTP",e);if(t){const e=x("Get",t);if(e){let t=p("OnlineResource","xlink:href",e,null);if(t)return t.indexOf("&")===t.length-1&&(t=t.substring(0,t.length-1)),T(t,["service","request"])}}}}return null}function b(t,n){const r=h("Operation",t);if(!r.length){return h("Format",x(n,t)).map((({textContent:e})=>e)).filter(e)}const i=[];for(const e of r)if(e.getAttribute("name")===n){const t=h("Format",e);for(const{textContent:e}of t)null!=e&&i.push(e)}return i}function A(e,t,n){const r=x(t,e);if(!r)return n;const{textContent:i}=r;if(null==i||""===i)return n;const s=Number(i);return isNaN(s)?n:s}function S(e,t,n){if(!e)return null;const o={id:n.idCounter++,fullExtents:[],parentLayerId:null,queryable:"1"===e.getAttribute("queryable"),spatialReferences:[],sublayers:null},l=x("LatLonBoundingBox",e),a=x("EX_GeographicBoundingBox",e);let c=null;l&&(c=N(l,4326)),a&&(c=new r(0,0,0,0,new i({wkid:4326})),c.xmin=parseFloat(g("westBoundLongitude",a,"0")),c.ymin=parseFloat(g("southBoundLatitude",a,"0")),c.xmax=parseFloat(g("eastBoundLongitude",a,"0")),c.ymax=parseFloat(g("northBoundLatitude",a,"0"))),l||a||(c=new r(-180,-90,180,90,new i({wkid:4326}))),o.minScale=A(e,"MaxScaleDenominator",0),o.maxScale=A(e,"MinScaleDenominator",0);const m=["1.0.0","1.1.0","1.1.1"].includes(t)?"SRS":"CRS";return Array.prototype.slice.call(e.childNodes).forEach((e=>{if("Name"===e.nodeName)o.name=e.textContent||"";else if("Title"===e.nodeName)o.title=e.textContent||"";else if("Abstract"===e.nodeName)o.description=e.textContent||"";else if("BoundingBox"===e.nodeName){const n=e.getAttribute(m);if(n&&0===n.indexOf("EPSG:")){const r=parseInt(n.substring(5),10);0===r||isNaN(r)||c||(c="1.3.0"===t?N(e,r,s(r)):N(e,r))}const r=n?.indexOf(":");if(r&&r>-1){let i=parseInt(n.substring(r+1,n.length),10);0===i||isNaN(i)||(i=u[i]??i);const l="1.3.0"===t?N(e,i,s(i)):N(e,i);l&&o.fullExtents&&o.fullExtents.push(l)}}else if(e.nodeName===m){(e.textContent?.split(" ")??[]).forEach((e=>{const t=e.includes(":")?parseInt(e.split(":")[1],10):parseInt(e,10);if(0!==t&&!isNaN(t)){const e=u[t]??t;o.spatialReferences.includes(e)||o.spatialReferences.push(e)}}))}else if("Style"!==e.nodeName||o.legendUrl){if("Layer"===e.nodeName){const r=S(e,t,n);r&&(r.parentLayerId=o.id,o.sublayers||(o.sublayers=[]),o.sublayers.push(r))}}else{const t=x("LegendURL",e);if(t){const e=x("OnlineResource",t);e&&(o.legendUrl=e.getAttribute("xlink:href"))}}})),o.extent=c?.toJSON(),o.dimensions=h("Dimension",e).filter((e=>e.getAttribute("name")&&e.getAttribute("units")&&e.textContent)).map((e=>{const t=e.getAttribute("name"),n=e.getAttribute("units"),r=e.textContent,i=e.getAttribute("unitSymbol")??void 0,s=e.getAttribute("default")??void 0,o="0"!==d("default",e,"0"),l="0"!==d("nearestValue",e,"0"),u="0"!==d("current",e,"0");if(C({name:t,units:n})){return{name:"time",units:"ISO8601",extent:R(r),default:R(s),multipleValues:o,nearestValue:l,current:u}}if(F({name:t,units:n})){return{name:"elevation",units:n,extent:I(r),unitSymbol:i,default:I(s),multipleValues:o,nearestValue:l}}return{name:t,units:n,extent:v(r),unitSymbol:i,default:v(s),multipleValues:o,nearestValue:l}})),o}function E(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof Date}function w(e){return e.nodeType===Node.ELEMENT_NODE}function L(e){return void 0!==e.min&&void 0!==e.max}function F(e){return/^elevation$/i.test(e.name)&&/^(epsg|crs):\d+$/i.test(e.units)}function M(e){return!C(e)&&!F(e)}function C(e){return/^time$/i.test(e.name)&&/^iso8601$/i.test(e.units)}function T(e,t){const r=[],i=n(e);for(const n in i.query)i.query.hasOwnProperty(n)&&(t.includes(n.toLowerCase())||r.push(n+"="+i.query[n]));return i.path+(r.length?"?"+r.join("&"):"")}function I(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:parseFloat(t[0]),max:parseFloat(t[1]),resolution:t.length>=3&&"0"!==t[2]?parseFloat(t[2]):void 0}})).filter(e):r.map((e=>parseFloat(e)))}function v(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:t[0],max:t[1],resolution:t.length>=3&&"0"!==t[2]?t[2]:void 0}})).filter(e):r}function R(t){if(!t)return;const n=t.includes("/"),r=t.split(",");return n?r.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:U(t[0]),max:U(t[1]),resolution:t.length>=3&&"0"!==t[2]?V(t[2]):void 0}})).filter(e):r.map((e=>U(e)))}function U(e){return o.fromISO(e,{zone:l.utcInstance}).toJSDate()}function V(e){const t=/(?:p(\d+y|\d+(?:\.|,)\d+y)?(\d+m|\d+(?:\.|,)\d+m)?(\d+d|\d+(?:\.|,)\d+d)?)?(?:t(\d+h|\d+(?:\.|,)\d+h)?(\d+m|\d+(?:\.|,)\d+m)?(\d+s|\d+(?:\.|,)\d+s)?)?/i,n=e.match(t);if(!n)return null;return{years:O(n[1]),months:O(n[2]),days:O(n[3]),hours:O(n[4]),minutes:O(n[5]),seconds:O(n[6])}}function O(e){if(!e)return 0;const t=/(?:\d+(?:\.|,)\d+|\d+)/,n=e.match(t);if(!n)return 0;const r=n[0].replace(",",".");return Number(r)}function _(e){return e.toISOString().replace(/\.[0-9]{3}/,"")}const B="0000-01-01T00:00:00Z",j="9999-12-31T23:59:59Z";function k(e){if(!e||e.isAllTime||e.isEmpty)return;const{start:t,end:n}=e;if(t&&n&&t.getTime()===n.getTime())return`${_(t)}`;return`${t?_(t):B}/${n?_(n):j}`}const q=new Set([102100,3857,102113,900913]),X=new Set([3395,54004]);function D(e,t){let n=e.wkid;return null==t?n:(null!=n&&t.includes(n)||!e.latestWkid||(n=e.latestWkid),null!=n&&q.has(n)?t.find((e=>q.has(e)))||t.find((e=>X.has(e)))||102100:n)}export{V as fromISODuration,c as getPopupLayers,L as isDimensionInterval,F as isElevationDimension,M as isGenericDimension,C as isTimeDimension,D as normalizeWKID,a as parseCapabilities,k as toTimeQueryParameter};
|
package/package.json
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 e}from"../../chunks/tslib.es6.js";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Loadable.js";import{throwIfAbortError as p}from"../../core/promiseUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as c}from"../../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../geometry/SpatialReference.js";import{getFeatureJSON as f,getFeatureIds as h,getAttachmentEditsJSON as g,isProtectedOrPrivateVersionError as v,unpackEditResultData as S,createEditedFeatures as E}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as b,normalizeEdits as j,normalizeGeometries as R}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as w}from"../../layers/mixins/EditBusLayer.js";import{getOwningPortalUrl as F}from"../../layers/support/layerUtils.js";import I from"../../portal/PortalItem.js";import{getUserPrivileges as A}from"../../portal/support/portalItemUtils.js";import{parseUrl as U,asValidOptions as P,encode as C}from"../utils.js";import{unapplyEditsZUnitScaling as O}from"../query/operations/editsZScale.js";import{readBoolean as k,readNumber as V}from"../support/jsonUtils.js";import{isSafeToEditVersion as D,isVersionInEditSession as M,currentSessionId as N}from"../../versionManagement/support/versionManagementUtils.js";function _(e){return{data:x(e),sync:H(e),operations:J(e.capabilities,e),query:Q(e),editing:q(e)}}function x(e){return{isDataVersioned:k(e,"hasVersionedData",!1)}}function J(e,t){const s=e?e.toLowerCase().split(",").map((e=>e.trim())):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:k(t,"supportsQueryDataElements",!1),supportsQueryDomains:k(t,"supportsQueryDomains",!1),supportsQueryContingentValues:k(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function Q(e){return{maxRecordCountFactor:V(e,"maxRecordCountFactor",void 0),maxRecordCount:V(e,"maxRecordCount",void 0)}}function q(e){const t=e?.advancedEditingCapabilities;return{supportsGlobalId:k(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:k(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSplit:k(t,"supportsSplit",!1),supportsAsyncApplyEdits:k(t,"supportsAsyncApplyEdits",!1)}}function H(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:k(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let T=class extends(n(o(u))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=[],this.tableInfos=[],this.capabilities=null}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON.hasBranchVersionedData?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readCapabilities(e,t){return _(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then((()=>this._setUserPrivileges(e)))),Promise.resolve(this)}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter((e=>!e.error)).map(l);let n=0;return r.map((e=>{s=w(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null})),r}catch(r){throw s&&s.reject(r),r}}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){p(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await F(this.url,t)}catch(u){p(u)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(u){p(u)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new I({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return A(l)}catch(u){p(u)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){const s=t?.globalIdUsed??!1,a=y.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map((async e=>{const t=e.addFeatures?.map((e=>f({spatialReference:a},e,null)))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map((e=>f({spatialReference:a},e,null)))??[],l=(await Promise.all(n)).filter(i),u=l.length>0?l:null,p=h(e.identifierFields,e.deleteFeatures,s),d=p.length>0?p:null;O(o,u,a);const c=await g(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}return{id:e.id,adds:o,updates:u,deletes:d,attachments:m}}))),u={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:n?.returnServiceEditsInSourceSR,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await D(this.url,t?.gdbVersion,!0);const p=M(this.url,t?.gdbVersion||null);u.edits=JSON.stringify(l);const d=U(this.url),c=P(d.query,{query:C({...u,f:"json"}),method:"post"});let m;p&&(c.authMode="immediate",c.query.sessionId=N);try{m=await r(this.url+"/applyEdits",c)}catch(S){if(!v(S))throw S;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...W(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t};return{edits:await Promise.all(e.map((async e=>{const s=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(b(e,s,t,!!r,!!i,"feature-service"),!s.data.isDataVersioned&&t?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");const o=j(e,s,"feature-service");return{...await R(o),id:e.id,identifierFields:e.identifierFields}}))),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{origin:"service",url:U(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data)}};function W(e){const t=e.data,s=[];return{results:t.map((e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=S(t),i=e.editedFeatures,a=i?.spatialReference?new y({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?E(i,a):null;return o&&s.push({layerId:e.id,editedFeatures:o}),{id:e.id,editedFeatures:o,...r}})),editedFeatures:s}}e([d()],T.prototype,"url",void 0),e([d()],T.prototype,"sourceJSON",void 0),e([d()],T.prototype,"userHasFullEditingPrivileges",void 0),e([d()],T.prototype,"userHasUpdateItemPrivileges",void 0),e([d({readOnly:!0})],T.prototype,"utilityNetworkUrl",null),e([d({readOnly:!0})],T.prototype,"versionManagementServiceUrl",null),e([d()],T.prototype,"userTypeExtensions",void 0),e([d({json:{read:{source:"layers"}}})],T.prototype,"layerInfos",void 0),e([d({json:{read:{source:"tables"}}})],T.prototype,"tableInfos",void 0),e([d({readOnly:!0,json:{read:{source:["hasVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],T.prototype,"capabilities",void 0),e([c("service","capabilities")],T.prototype,"readCapabilities",null),e([d({readOnly:!0})],T.prototype,"effectiveCapabilities",null),T=e([m("esri.rest.featureService.FeatureService")],T);const L=T;export{L as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Loadable.js";import{throwIfAborted as p,throwIfAbortError as d}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/SpatialReference.js";import{getFeatureJSON as h,getFeatureIds as g,getAttachmentEditsJSON as v,isProtectedOrPrivateVersionError as b,unpackEditResultData as S,createEditedFeatures as E}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as j,normalizeEdits as w,normalizeGeometries as I}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as R}from"../../layers/mixins/EditBusLayer.js";import{ensureCredentialIfSignedIn as F}from"../../layers/support/featureLayerUtils.js";import{getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{getFeatureLayerCapabilities as C}from"../../layers/support/serviceCapabilitiesUtils.js";import U from"../../portal/PortalItem.js";import{getUserPrivileges as P}from"../../portal/support/portalItemUtils.js";import{parseUrl as O,asValidOptions as k,encode as T}from"../utils.js";import{unapplyEditsZUnitScaling as V}from"../query/operations/editsZScale.js";import{readBoolean as D,readNumber as N}from"../support/jsonUtils.js";import{isSafeToEditVersion as L,isVersionInEditSession as M,currentSessionId as _}from"../../versionManagement/support/versionManagementUtils.js";function x(e,t){const s=t.id;return{id:s,name:t.name,url:`${e}/${s}`,type:t.type||"Table"}}function Q(e){return{data:J(e),sync:$(e),operations:q(e.capabilities,e),query:W(e),editing:H(e)}}function J(e){return{isDataVersioned:D(e,"hasVersionedData",!1)}}function q(e,t){const s=e?e.toLowerCase().split(",").map((e=>e.trim())):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:D(t,"supportsQueryDataElements",!1),supportsQueryDomains:D(t,"supportsQueryDomains",!1),supportsQueryContingentValues:D(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function W(e){return{maxRecordCountFactor:N(e,"maxRecordCountFactor",void 0),maxRecordCount:N(e,"maxRecordCount",void 0)}}function H(e){const t=e?.advancedEditingCapabilities;return{supportsGlobalId:D(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:D(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSplit:D(t,"supportsSplit",!1),supportsAsyncApplyEdits:D(t,"supportsAsyncApplyEdits",!1)}}function $(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:D(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let G=class extends(n(o(u))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=null,this.tableInfos=null,this.capabilities=null}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){if(this.sourceJSON)for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON?.hasBranchVersionedData?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readLayerInfos(e,t){return(t.layers||[]).map((e=>{const{type:t,geometryType:s}=e;return{...x(this.url,e),type:t||"Feature Layer",geometryType:s}}))}readTableInfos(e,t){return(t.tables||[]).map((e=>x(this.url,e)))}readCapabilities(e,t){return Q(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then((()=>this._setUserPrivileges(e)))),Promise.resolve(this)}async fetchAllLayersAndTables(e){return await this.load(e),this._fetchLayersAndTablesPromise||=this._fetchLayersAndTables(this.url),p(e),this._fetchLayersAndTablesPromise}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter((e=>!e.error)).map(l);let n=0;return r.map((e=>{s=R(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null})),r}catch(r){throw s&&s.reject(r),r}}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){d(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await A(this.url,t)}catch(u){d(u)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(u){d(u)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new U({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return P(l)}catch(u){d(u)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){await F(this.url);const s=t?.globalIdUsed??!1,a=f.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map((async e=>{const t=e.addFeatures?.map((e=>h({spatialReference:a},e,null)))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map((e=>h({spatialReference:a},e,null)))??[],l=(await Promise.all(n)).filter(i),u=l.length>0?l:null,p=g(e.identifierFields,e.deleteFeatures,s),d=p.length>0?p:null;V(o,u,a);const c=await v(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}return{id:e.id,adds:o,updates:u,deletes:d,attachments:m}}))),u={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:n?.returnServiceEditsInSourceSR,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await L(this.url,t?.gdbVersion,!0);const p=M(this.url,t?.gdbVersion||null);u.edits=JSON.stringify(l);const d=O(this.url),c=k(d.query,{query:T({...u,f:"json"}),method:"post"});let m;p&&(c.authMode="immediate",c.query.sessionId=_);try{m=await r(this.url+"/applyEdits",c)}catch(y){if(!b(y))throw y;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...z(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t};return{edits:await Promise.all(e.map((async e=>{const s=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(j(e,s,t,!!r,!!i,"feature-service"),!s.data.isDataVersioned&&t?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");const o=w(e,s,"feature-service");return{...await I(o),id:e.id,identifierFields:e.identifierFields}}))),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{url:O(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data,{url:O(e)})}async _fetchLayersAndTables(e){const t=`${e}/layers`,s=await r(t,{responseType:"json",query:{f:"json"}});return{layers:s.data.layers.map((e=>{const{type:t,geometryType:s}=e,r=x(this.url,e),i=C(e,r.url);return{...r,type:t||"Feature Layer",geometryType:s,capabilities:i}})),tables:s.data.tables.map((e=>{const t=x(this.url,e),s=C(e,t.url);return{...t,capabilities:s}}))}}};function z(e){const t=e.data,s=[];return{results:t.map((e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=S(t),i=e.editedFeatures,a=i?.spatialReference?new f({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?E(i,a):null;return o&&s.push({layerId:e.id,editedFeatures:o}),{id:e.id,editedFeatures:o,...r}})),editedFeatures:s}}e([c()],G.prototype,"url",void 0),e([c()],G.prototype,"sourceJSON",void 0),e([c()],G.prototype,"userHasFullEditingPrivileges",void 0),e([c()],G.prototype,"userHasUpdateItemPrivileges",void 0),e([c({readOnly:!0})],G.prototype,"utilityNetworkUrl",null),e([c({readOnly:!0})],G.prototype,"versionManagementServiceUrl",null),e([c()],G.prototype,"userTypeExtensions",void 0),e([c({json:{read:{source:["layers"]}}})],G.prototype,"layerInfos",void 0),e([m("layerInfos",["layers"])],G.prototype,"readLayerInfos",null),e([c({json:{read:{source:["tables"]}}})],G.prototype,"tableInfos",void 0),e([m("tableInfos",["tables"])],G.prototype,"readTableInfos",null),e([c({readOnly:!0,json:{read:{source:["hasVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],G.prototype,"capabilities",void 0),e([m("capabilities",["hasVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"])],G.prototype,"readCapabilities",null),e([c({readOnly:!0})],G.prototype,"effectiveCapabilities",null),G=e([y("esri.rest.featureService.FeatureService")],G);const B=G;export{B as default};
|
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 c="20240613",a="33982be2234c621ab4a83dd7cc83a52523089798";export{c as buildDate,a 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 t from"../../Color.js";import has from"../../core/has.js";import{assertIsSome as e}from"../../core/maybe.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/mat2df32.js";import{multiply as r,translate as n,identity as o,scale as s,rotate as a}from"../../core/libs/gl-matrix-2/math/mat2d.js";import{getDashArray as l}from"./gfxUtils.js";import"../../widgets/support/widgetUtils.js";import{tsx as h}from"../../widgets/support/jsxFactory.js";const f="http://www.w3.org/2000/svg";let c=0,u=0;const d=has("android"),y=has("chrome")||d&&d>=4?"auto":"optimizeLegibility",p={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},g=/([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g;let m={},x={};const w=Math.PI;let k=1;function b(t,e){const i=t*(w/180);return Math.abs(e*Math.sin(i))+Math.abs(e*Math.cos(i))}function j(t){return t.map((t=>`${t.command} ${t.values.join(" ")}`)).join(" ").trim()}function v(t,i,r,n,o){if(t){if("circle"===t.type)return h("circle",{cx:t.cx,cy:t.cy,fill:i,"fill-rule":"evenodd",r:t.r,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-dashoffset":r.dashOffset,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width});if("ellipse"===t.type)return h("ellipse",{cx:t.cx,cy:t.cy,fill:i,"fill-rule":"evenodd",rx:t.rx,ry:t.ry,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width});if("rect"===t.type)return h("rect",{fill:i,"fill-rule":"evenodd",height:t.height,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width,width:t.width,x:t.x,y:t.y});if("image"===t.type)return h("image",{alt:o||"image",height:t.height,href:t.src,preserveAspectRatio:"none",width:t.width,x:t.x,y:t.y});if("path"===t.type){const e="string"!=typeof t.path?j(t.path):t.path;return h("path",{d:e,fill:i,"fill-rule":"evenodd",stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width})}if("text"===t.type)return e(n),h("text",{"dominant-baseline":n.dominantBaseline,fill:i,"fill-rule":"evenodd","font-family":n.font.family,"font-size":n.font.size,"font-style":n.font.style,"font-variant":n.font.variant,"font-weight":n.font.weight,kerning:n.kerning,rotate:n.rotate,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width,"text-anchor":n.align,"text-decoration":n.decoration,"text-rendering":y,x:t.x,y:t.y},t.text)}return null}function M(e){const i={fill:"none",pattern:null,linearGradient:null};if(e)if("type"in e&&"pattern"===e.type){const t="patternId-"+ ++c;i.fill=`url(#${t})`,i.pattern={id:t,x:e.x,y:e.y,width:e.width,height:e.height,image:{x:0,y:0,width:e.width,height:e.height,href:e.src}}}else if("type"in e&&"linear"===e.type){const r="linearGradientId-"+ ++u;i.fill=`url(#${r})`,i.linearGradient={id:r,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stops:e.colors.map((e=>({offset:e.offset,color:e.color&&new t(e.color).toString()})))}}else if(e){const r=new t(e);i.fill=r.toString()}return i}function A(e){const i={color:"none",width:1,cap:"butt",join:"4",dashArray:"none",dashOffset:"0"};return e&&(null!=e.width&&(i.width=e.width),e.cap&&(i.cap=e.cap),e.join&&(i.join=e.join.toString()),e.color&&(i.color=new t(e.color).toString()),e.dashArray&&(i.dashArray=e.dashArray),e.dashoffset&&(i.dashOffset=e.dashoffset),e.style&&!e.dashArray&&(i.dashArray=l(e).join(",")||"none")),i}function S(t,i){const r={align:null,decoration:null,kerning:null,rotate:null,font:{style:null,variant:null,weight:null,size:null,family:null}};if(t){const n=t.alignBaseline,o="baseline"===n?"auto":"top"===n?"text-top":"bottom"===n?"hanging":n;r.align=t.align,r.dominantBaseline=o,r.decoration=t.decoration,r.kerning=t.kerning?"auto":"0",r.rotate=t.rotated?"90":"0",e(i),r.font.style=i.style||"normal",r.font.variant=i.variant||"normal",r.font.weight=i.weight||"normal",r.font.size=i.size&&i.size.toString()||"10pt",r.font.family=i.family||"serif"}return r}function $(t){const{pattern:e,linearGradient:i}=t;if(e)return h("pattern",{height:e.height,id:e.id,patternUnits:"userSpaceOnUse",width:e.width,x:e.x,y:e.y},h("image",{height:e.image.height,href:e.image.href,width:e.image.width,x:e.image.x,y:e.image.y}));if(i){const t=i.stops.map(((t,e)=>h("stop",{key:`${e}-stop`,offset:t.offset,"stop-color":t.color})));return h("linearGradient",{gradientUnits:"userSpaceOnUse",id:i.id,x1:i.x1,x2:i.x2,y1:i.y1,y2:i.y2},t)}return null}function N(t,e){if(!t||0===t.length)return null;const i=[];for(const r of t){const{shape:t,fill:e,stroke:n,font:o}=r,s=M(e),a=A(n),l="text"===t.type?S(t,o):null,h=v(t,s.fill,a,l);h&&i.push(h)}return h("mask",{id:e,maskUnits:"userSpaceOnUse"},h("g",null,i))}function G(t,e,i){return n(t,o(t),[e,i])}function I(t,e,i,r,n){return s(t,o(t),[e,i]),t[4]=t[4]*e-r*e+r,t[5]=t[5]*i-n*i+n,t}function z(t,e,i,r){const n=e%360*Math.PI/180;a(t,o(t),n);const s=Math.cos(n),l=Math.sin(n),h=t[4],f=t[5];return t[4]=h*s-f*l+r*l-i*s+i,t[5]=f*s+h*l-i*l-r*s+r,t}function B(t,e){m&&"left"in m?(null!=m.left&&m.left>t&&(m.left=t),(null==m.right||m.right<t)&&(m.right=t),(null==m.top||m.top>e)&&(m.top=e),(null==m.bottom||m.bottom<e)&&(m.bottom=e)):m={left:t,bottom:e,right:t,top:e}}function U(t){const e=t.args,i=e.length;let r;switch(t.action){case"M":case"L":case"C":case"S":case"Q":case"T":for(r=0;r<i;r+=2)B(e[r],e[r+1]);x.x=e[i-2],x.y=e[i-1];break;case"H":for(r=0;r<i;++r)B(e[r],x.y);x.x=e[i-1];break;case"V":for(r=0;r<i;++r)B(x.x,e[r]);x.y=e[i-1];break;case"m":{let t=0;"x"in x||(B(x.x=e[0],x.y=e[1]),t=2);for(r=t;r<i;r+=2)B(x.x+=e[r],x.y+=e[r+1]);break}case"l":case"t":for(r=0;r<i;r+=2)B(x.x+=e[r],x.y+=e[r+1]);break;case"h":for(r=0;r<i;++r)B(x.x+=e[r],x.y);break;case"v":for(r=0;r<i;++r)B(x.x,x.y+=e[r]);break;case"c":for(r=0;r<i;r+=6)B(x.x+e[r],x.y+e[r+1]),B(x.x+e[r+2],x.y+e[r+3]),B(x.x+=e[r+4],x.y+=e[r+5]);break;case"s":case"q":for(r=0;r<i;r+=4)B(x.x+e[r],x.y+e[r+1]),B(x.x+=e[r+2],x.y+=e[r+3]);break;case"A":for(r=0;r<i;r+=7)B(e[r+5],e[r+6]);x.x=e[i-2],x.y=e[i-1];break;case"a":for(r=0;r<i;r+=7)B(x.x+=e[r+5],x.y+=e[r+6])}}function F(t,e,i){const r=p[t.toLowerCase()];let n;"number"==typeof r&&(r?e.length>=r&&(n={action:t,args:e.slice(0,e.length-e.length%r)},i.push(n),U(n)):(n={action:t,args:[]},i.push(n),U(n)))}function O(t){const e=("string"!=typeof t.path?j(t.path):t.path).match(g),i=[];if(m={},x={},!e)return null;let r="",n=[];const o=e.length;for(let a=0;a<o;++a){const t=e[a],o=parseFloat(t);isNaN(o)?(r&&F(r,n,i),n=[],r=t):n.push(o)}F(r,n,i);const s={x:0,y:0,width:0,height:0};return m&&"left"in m&&(s.x=m.left,s.y=m.top,s.width=m.right-m.left,s.height=m.bottom-m.top),s}function T(t){const e={x:0,y:0,width:0,height:0};if("circle"===t.type)e.x=t.cx-t.r,e.y=t.cy-t.r,e.width=2*t.r,e.height=2*t.r;else if("ellipse"===t.type)e.x=t.cx-t.rx,e.y=t.cy-t.ry,e.width=2*t.rx,e.height=2*t.ry;else if("image"===t.type||"rect"===t.type)e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height;else if("path"===t.type){const i=O(t);e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height}return e}function E(t){const e={x:0,y:0,width:0,height:0};let i=null,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const o of t)i?(i.x=Math.min(i.x,o.x),i.y=Math.min(i.y,o.y),r=Math.max(r,o.x+o.width),n=Math.max(n,o.y+o.height)):(i=e,i.x=o.x,i.y=o.y,r=o.x+o.width,n=o.y+o.height);return i&&(i.width=r-i.x,i.height=n-i.y),i}function L(t,e,n,o,s,a,l,h,f){let c=(l&&a?b(a,e):e)/2,u=(l&&a?b(a,n):n)/2;if(f){const t=f[0],e=f[1];c=(l&&a?b(a,t):t)/2,u=(l&&a?b(a,e):e)/2}const d=t.width+o,y=t.height+o,p=i(),g=i();let m=!1;if(s&&0!==d&&0!==y){const t=e!==n?e/n:d/y,i=e>n?e:n;let o=1,s=1;isNaN(i)||(t>1?(o=i/d,s=i/t/y):(s=i/y,o=i*t/d)),r(g,g,I(p,o,s,c,u)),m=!0}const x=t.x+(d-o)/2,w=t.y+(y-o)/2;if(r(g,g,G(p,c-x,u-w)),!m&&(d>e||y>n)){const t=d/e>y/n,i=(t?e:n)/(t?d:y);r(g,g,I(p,i,i,x,w))}return a&&r(g,g,z(p,a,x,w)),h&&r(g,g,G(p,h[0],h[1])),`matrix(${g[0]},${g[1]},${g[2]},${g[3]},${g[4]},${g[5]})`}function V(t,e,i){const r=t?.effects.find((t=>"bloom"===t.type));if(!r)return null;const{strength:n,radius:o}=r,s=n>0?o:0,a=(n+s)*e,l=4*n+1;return h("filter",{filterUnits:"userSpaceOnUse",height:"300%",id:`bloom${i}`,width:"300%",x:"-100%",y:"-100%"},h("feMorphology",{in:"SourceGraphic",operator:"dilate",radius:(n+.5*s)*(5**(e/100)*(.4+e/100)),result:"dilate"}),h("feGaussianBlur",{in:"dilate",result:"blur",stdDeviation:a/25}),h("feGaussianBlur",{in:"blur",result:"intensityBlur",stdDeviation:a/50}),h("feComponentTransfer",{in:"SourceGraphic",result:"intensityBrightness"},h("feFuncR",{slope:l,type:"linear"}),h("feFuncG",{slope:l,type:"linear"}),h("feFuncB",{slope:l,type:"linear"})),h("feMerge",null,h("feMergeNode",{in:"intensityBlur"}),h("feMergeNode",{in:"intensityBrightness"}),h("feGaussianBlur",{stdDeviation:n/10})))}function C(t,i,r,n={}){const o=[],s=[],a=++k,l=V(n.effectView,i,a);let c=null;if(l){const t=n.effectView?.effects.find((t=>"bloom"===t.type)),e=(t.strength?t.strength+t.radius/2:0)/3,o=i+i*e,s=r+r*e;c=[Math.max(o,10),Math.max(s,10)]}for(let e=0;e<t.length;e++){const a=t[e],l=[],f=[];let u=0,d=0,y=0;for(const t of a){const{shape:e,fill:i,stroke:r,font:s,offset:a}=t;n.ignoreStrokeWidth||"text"===e.type||(u+=r?.width||0);const h=M(i),c=A(r),p="text"===e.type?S(e,s):null;o.push($(h)),l.push(v(e,h.fill,c,p,n.ariaLabel)),f.push(T(e)),a&&(d+=a[0],y+=a[1])}const p=L(E(f),i,r,u,n.scale??!1,n.rotation,n.useRotationSize??!1,[d,y],c);let g=null;if(n.masking){const t=`mask-${e}`,i=n.masking[e];o.push(N(i,t)),g=`url(#${t})`}s.push(g?h("g",{mask:g},h("g",{transform:p},l)):h("g",{transform:p},l))}n.useRotationSize&&n.rotation&&(i=b(n.rotation,i),r=b(n.rotation,r)),l&&(e(c),i=c[0],r=c[1]);const u="display: block;";return h("svg",{"aria-labelledby":n.ariaLabel,focusable:!1,height:r,role:"img",style:u,width:i,xmlns:f},l,h("defs",null,o),l?h("g",{filter:`url(#bloom${a})`},s):s)}export{E as computeBBox,M as generateFillAttributes,A as generateStrokeAttributes,S as generateTextAttributes,T as getBoundingBox,L as getTransformMatrix,$ as renderDef,C as renderSVG,v as renderShape};
|
|
5
|
+
import t from"../../Color.js";import has from"../../core/has.js";import{assertIsSome as e}from"../../core/maybe.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/mat2df32.js";import{multiply as r,translate as n,identity as o,scale as s,rotate as a}from"../../core/libs/gl-matrix-2/math/mat2d.js";import{getDashArray as l}from"./gfxUtils.js";import"../../widgets/support/widgetUtils.js";import{tsx as h}from"../../widgets/support/jsxFactory.js";const f="http://www.w3.org/2000/svg";let c=0,u=0;const d=has("android"),y=has("chrome")||d&&d>=4?"auto":"optimizeLegibility",p={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},g=/([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g;let m={},x={};const w=Math.PI;let k=1;function b(t,e){const i=t*(w/180);return Math.abs(e*Math.sin(i))+Math.abs(e*Math.cos(i))}function j(t){return t.map((t=>`${t.command} ${t.values.join(" ")}`)).join(" ").trim()}function v(t,i,r,n,o){if(t){if("circle"===t.type)return h("circle",{cx:t.cx,cy:t.cy,fill:i,"fill-rule":"evenodd",r:t.r,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-dashoffset":r.dashOffset,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width});if("ellipse"===t.type)return h("ellipse",{cx:t.cx,cy:t.cy,fill:i,"fill-rule":"evenodd",rx:t.rx,ry:t.ry,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width});if("rect"===t.type)return h("rect",{fill:i,"fill-rule":"evenodd",height:t.height,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width,width:t.width,x:t.x,y:t.y});if("image"===t.type)return h("image",{alt:o||"image",height:t.height,href:t.src,preserveAspectRatio:"none",width:t.width,x:t.x,y:t.y});if("path"===t.type){const e="string"!=typeof t.path?j(t.path):t.path;return h("path",{d:e,fill:i,"fill-rule":"evenodd",stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width})}if("text"===t.type)return e(n),h("text",{"dominant-baseline":n.dominantBaseline,fill:i,"fill-rule":"evenodd","font-family":n.font.family,"font-size":n.font.size,"font-style":n.font.style,"font-variant":n.font.variant,"font-weight":n.font.weight,kerning:n.kerning,rotate:n.rotate,stroke:r.color,"stroke-dasharray":r.dashArray,"stroke-linecap":r.cap,"stroke-linejoin":r.join,"stroke-miterlimit":"4","stroke-width":r.width,"text-anchor":n.align,"text-decoration":n.decoration,"text-rendering":y,x:t.x,y:t.y},t.text)}return null}function M(e){const i={fill:"none",pattern:null,linearGradient:null};if(e)if("type"in e&&"pattern"===e.type){const t="patternId-"+ ++c;i.fill=`url(#${t})`,i.pattern={id:t,x:e.x,y:e.y,width:e.width,height:e.height,image:{x:0,y:0,width:e.width,height:e.height,href:e.src}}}else if("type"in e&&"linear"===e.type){const r="linearGradientId-"+ ++u;i.fill=`url(#${r})`,i.linearGradient={id:r,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stops:e.colors.map((e=>({offset:e.offset,color:e.color&&new t(e.color).toString()})))}}else if(e){const r=new t(e);i.fill=r.toString()}return i}function A(e){const i={color:"none",width:1,cap:"butt",join:"4",dashArray:"none",dashOffset:"0"};return e&&(null!=e.width&&(i.width=e.width),e.cap&&(i.cap=e.cap),e.join&&(i.join=e.join.toString()),e.color&&(i.color=new t(e.color).toString()),e.dashArray&&(i.dashArray=e.dashArray),e.dashoffset&&(i.dashOffset=e.dashoffset),e.style&&!e.dashArray&&(i.dashArray=l(e).join(",")||"none")),i}function S(t,i){const r={align:null,decoration:null,kerning:null,rotate:null,font:{style:null,variant:null,weight:null,size:null,family:null}};if(t){const n=t.alignBaseline,o="baseline"===n?"auto":"top"===n?"text-top":"bottom"===n?"hanging":n;r.align=t.align,r.dominantBaseline=o,r.decoration=t.decoration,r.kerning=t.kerning?"auto":"0",r.rotate=t.rotated?"90":"0",e(i),r.font.style=i.style||"normal",r.font.variant=i.variant||"normal",r.font.weight=i.weight||"normal",r.font.size=i.size&&i.size.toString()||"10pt",r.font.family=i.family||"serif"}return r}function $(t){const{pattern:e,linearGradient:i}=t;if(e)return h("pattern",{height:e.height,id:e.id,patternUnits:"userSpaceOnUse",width:e.width,x:e.x,y:e.y},h("image",{height:e.image.height,href:e.image.href,width:e.image.width,x:e.image.x,y:e.image.y}));if(i){const t=i.stops.map(((t,e)=>h("stop",{key:`${e}-stop`,offset:t.offset,"stop-color":t.color})));return h("linearGradient",{gradientUnits:"userSpaceOnUse",id:i.id,x1:i.x1,x2:i.x2,y1:i.y1,y2:i.y2},t)}return null}function N(t,e){if(!t||0===t.length)return null;const i=[];for(const r of t){const{shape:t,fill:e,stroke:n,font:o}=r,s=M(e),a=A(n),l="text"===t.type?S(t,o):null,h=v(t,s.fill,a,l);h&&i.push(h)}return h("mask",{id:e,maskUnits:"userSpaceOnUse"},h("g",null,i))}function G(t,e,i){return n(t,o(t),[e,i])}function I(t,e,i,r,n){return s(t,o(t),[e,i]),t[4]=t[4]*e-r*e+r,t[5]=t[5]*i-n*i+n,t}function z(t,e,i,r){const n=e%360*Math.PI/180;a(t,o(t),n);const s=Math.cos(n),l=Math.sin(n),h=t[4],f=t[5];return t[4]=h*s-f*l+r*l-i*s+i,t[5]=f*s+h*l-i*l-r*s+r,t}function B(t,e){m&&"left"in m?(null!=m.left&&m.left>t&&(m.left=t),(null==m.right||m.right<t)&&(m.right=t),(null==m.top||m.top>e)&&(m.top=e),(null==m.bottom||m.bottom<e)&&(m.bottom=e)):m={left:t,bottom:e,right:t,top:e}}function U(t){const e=t.args,i=e.length;let r;switch(t.action){case"M":case"L":case"C":case"S":case"Q":case"T":for(r=0;r<i;r+=2)B(e[r],e[r+1]);x.x=e[i-2],x.y=e[i-1];break;case"H":for(r=0;r<i;++r)B(e[r],x.y);x.x=e[i-1];break;case"V":for(r=0;r<i;++r)B(x.x,e[r]);x.y=e[i-1];break;case"m":{let t=0;"x"in x||(B(x.x=e[0],x.y=e[1]),t=2);for(r=t;r<i;r+=2)B(x.x+=e[r],x.y+=e[r+1]);break}case"l":case"t":for(r=0;r<i;r+=2)B(x.x+=e[r],x.y+=e[r+1]);break;case"h":for(r=0;r<i;++r)B(x.x+=e[r],x.y);break;case"v":for(r=0;r<i;++r)B(x.x,x.y+=e[r]);break;case"c":for(r=0;r<i;r+=6)B(x.x+e[r],x.y+e[r+1]),B(x.x+e[r+2],x.y+e[r+3]),B(x.x+=e[r+4],x.y+=e[r+5]);break;case"s":case"q":for(r=0;r<i;r+=4)B(x.x+e[r],x.y+e[r+1]),B(x.x+=e[r+2],x.y+=e[r+3]);break;case"A":for(r=0;r<i;r+=7)B(e[r+5],e[r+6]);x.x=e[i-2],x.y=e[i-1];break;case"a":for(r=0;r<i;r+=7)B(x.x+=e[r+5],x.y+=e[r+6])}}function F(t,e,i){const r=p[t.toLowerCase()];let n;"number"==typeof r&&(r?e.length>=r&&(n={action:t,args:e.slice(0,e.length-e.length%r)},i.push(n),U(n)):(n={action:t,args:[]},i.push(n),U(n)))}function O(t){const e=("string"!=typeof t.path?j(t.path):t.path).match(g),i=[];if(m={},x={},!e)return null;let r="",n=[];const o=e.length;for(let a=0;a<o;++a){const t=e[a],o=parseFloat(t);isNaN(o)?(r&&F(r,n,i),n=[],r=t):n.push(o)}F(r,n,i);const s={x:0,y:0,width:0,height:0};return m&&"left"in m&&(s.x=m.left,s.y=m.top,s.width=m.right-m.left,s.height=m.bottom-m.top),s}function T(t){const e={x:0,y:0,width:0,height:0};if("circle"===t.type)e.x=t.cx-t.r,e.y=t.cy-t.r,e.width=2*t.r,e.height=2*t.r;else if("ellipse"===t.type)e.x=t.cx-t.rx,e.y=t.cy-t.ry,e.width=2*t.rx,e.height=2*t.ry;else if("image"===t.type||"rect"===t.type)e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height;else if("path"===t.type){const i=O(t);e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height}return e}function E(t){const e={x:0,y:0,width:0,height:0};let i=null,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const o of t)i?(i.x=Math.min(i.x,o.x),i.y=Math.min(i.y,o.y),r=Math.max(r,o.x+o.width),n=Math.max(n,o.y+o.height)):(i=e,i.x=o.x,i.y=o.y,r=o.x+o.width,n=o.y+o.height);return i&&(i.width=r-i.x,i.height=n-i.y),i}function L(t,e,n,o,s,a,l,h,f){let c=(l&&a?b(a,e):e)/2,u=(l&&a?b(a,n):n)/2;if(f){const t=f[0],e=f[1];c=(l&&a?b(a,t):t)/2,u=(l&&a?b(a,e):e)/2}const d=t.width+o,y=t.height+o,p=i(),g=i();let m=!1;if(s&&0!==d&&0!==y){const t=e!==n?e/n:d/y,i=e>n?e:n;let o=1,s=1;isNaN(i)||(t>1?(o=i/d,s=i/t/y):(s=i/y,o=i*t/d)),r(g,g,I(p,o,s,c,u)),m=!0}const x=t.x+(d-o)/2,w=t.y+(y-o)/2;if(r(g,g,G(p,c-x,u-w)),!m&&(d>e||y>n)){const t=d/e>y/n,i=(t?e:n)/(t?d:y);r(g,g,I(p,i,i,x,w))}return a&&r(g,g,z(p,a,x,w)),h&&r(g,g,G(p,h[0],h[1])),`matrix(${g[0]},${g[1]},${g[2]},${g[3]},${g[4]},${g[5]})`}function V(t,e,i){const r=t?.effects.find((t=>"bloom"===t.type));if(!r)return null;const{strength:n,radius:o}=r,s=n>0?o:0,a=(n+s)*e,l=4*n+1;return h("filter",{filterUnits:"userSpaceOnUse",height:"300%",id:`bloom${i}`,width:"300%",x:"-100%",y:"-100%"},h("feMorphology",{in:"SourceGraphic",operator:"dilate",radius:(n+.5*s)*(5**(e/100)*(.4+e/100)),result:"dilate"}),h("feGaussianBlur",{in:"dilate",result:"blur",stdDeviation:a/25}),h("feGaussianBlur",{in:"blur",result:"intensityBlur",stdDeviation:a/50}),h("feComponentTransfer",{in:"SourceGraphic",result:"intensityBrightness"},h("feFuncR",{slope:l,type:"linear"}),h("feFuncG",{slope:l,type:"linear"}),h("feFuncB",{slope:l,type:"linear"})),h("feMerge",null,h("feMergeNode",{in:"intensityBlur"}),h("feMergeNode",{in:"intensityBrightness"}),h("feGaussianBlur",{stdDeviation:n/10})))}function C(t,i,r,n={}){const o=[],s=[],a=++k,l=V(n.effectView,i,a);let c=null;if(l){const t=n.effectView?.effects.find((t=>"bloom"===t.type)),e=(t.strength?t.strength+t.radius/2:0)/3,o=i+i*e,s=r+r*e;c=[Math.max(o,10),Math.max(s,10)]}for(let e=0;e<t.length;e++){const a=t[e],l=[],f=[];let u=0,d=0,y=0;for(const t of a){const{shape:e,fill:i,stroke:r,font:s,offset:a}=t;n.ignoreStrokeWidth||"text"===e.type||(u+=r?.width||0);const h=M(i),c=A(r),p="text"===e.type?S(e,s):null;o.push($(h)),l.push(v(e,h.fill,c,p,n.ariaLabel)),f.push(T(e)),a&&(d+=a[0],y+=a[1])}const p=L(E(f),i,r,u,n.scale??!1,n.rotation,n.useRotationSize??!1,[d,y],c);let g=null;if(n.masking){const t=`mask-${e}`,i=n.masking[e];o.push(N(i,t)),g=`url(#${t})`}s.push(g?h("g",{mask:g},h("g",{transform:p},l)):h("g",{transform:p},l))}n.useRotationSize&&n.rotation&&(i=b(n.rotation,i),r=b(n.rotation,r)),l&&(e(c),i=c[0],r=c[1]);const u="display: block;";return h("svg",{"aria-label":n.ariaLabel,focusable:!1,height:r,role:"img",style:u,width:i,xmlns:f},l,h("defs",null,o),l?h("g",{filter:`url(#bloom${a})`},s):s)}export{E as computeBBox,M as generateFillAttributes,A as generateStrokeAttributes,S as generateTextAttributes,T as getBoundingBox,L as getTransformMatrix,$ as renderDef,C as renderSVG,v as renderShape};
|
|
@@ -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"../../../../geometry.js";import t from"../../../../Graphic.js";import"../../../../symbols.js";import{getContrast as i}from"../../../../core/colorUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as r}from"../../../../core/unitUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{subtract as c,normalize as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as l,UNIT_X as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as m,l as d,n as _,g,o as u,f as y}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as v,initializeProjection as G}from"../../../../geometry/projection.js";import{a as w,c as R}from"../../../../chunks/boundedPlane.js";import{equals as b}from"../../../../geometry/support/spatialReferenceUtils.js";import j from"../../../../layers/GraphicsLayer.js";import{ViewingMode as C}from"../../../ViewingMode.js";import{DragManipulation as A}from"./manipulations/DragManipulation.js";import{RotateManipulation as k}from"./manipulations/RotateManipulation.js";import{ScaleManipulation as S}from"./manipulations/ScaleManipulation.js";import{PreserveAspectRatio as P,SnapRotation as T}from"./manipulations/utils.js";import{primaryKey as M}from"../../../input/keys.js";import{InteractiveToolBase as x}from"../../../interactive/InteractiveToolBase.js";import{mediaKeys as D,KeyBindings as O}from"../../../interactive/keybindings.js";import{EditGeometry as U}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as L}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehavior as E}from"../../../interactive/editGeometry/interfaces.js";import{AccumulationType as B}from"../../../interactive/editGeometry/operations/UpdateVertices.js";import{calculateOrientedBounds as H}from"../../../interactive/editGeometry/support/editPlaneUtils.js";import{findFirstGraphicHit as I}from"../../../support/hitTestSelectUtils.js";import{createScreenPointFromEvent as V}from"../../../support/screenUtils.js";import z from"../../../../geometry/Polygon.js";import N from"../../../../geometry/Point.js";import W from"../../../../symbols/SimpleFillSymbol.js";import q from"../../../../symbols/SimpleMarkerSymbol.js";const F={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",plus:"+",minus:"-",toggleOpacity:"t",shift:"Shift",primaryKey:M},K=80,J=10,Q=30,X=[[1,1],[1,-1],[-1,-1],[-1,1],[1,0],[0,-1],[-1,0],[0,1]],Y=1,Z=10;let $=class extends x{constructor(e){super(e),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._planeCache=w(),this._displayPlaneCache=w(),this._mainAxisCache=l(),this._rotationHandleCache=f(),this._cornerA=f(),this._cornerB=f(),this._cornerC=f(),this._cornerD=f(),this._avgAB=f(),this._avgBC=f(),this._avgCD=f(),this._avgDA=f(),this._preserveAspectRatio=new P,this._snapRotation=new T,this._graphicsLayer=new j({internal:!0,listMode:"hide",visible:!1}),this._sharedUndoStack=[],this._sharedRedoStack=[],this._isOpacityToggled=!1,this._factor=Y,this.preserveAspectRatio=null,this.snapRotation=null}initialize(){this._initialize()}destroy(){const{map:e}=this.view;this._dragManipulation.destroy(),this._rotateManipulation.destroy(),this._scaleManipulations.forEach((e=>e.destroy())),this._editGeometryOperations.destroy(),e.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=s(this._graphicsLayer),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._preserveAspectRatio=null,this._snapRotation=null,this._planeCache=null,this._displayPlaneCache=null,this._rotationHandleCache=null,this._mainAxisCache=null,this._cornerA=null,this._cornerB=null,this._cornerC=null,this._cornerD=null,this._avgAB=null,this._avgBC=null,this._avgCD=null,this._avgDA=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _plane(){const e=this._graphic.geometry;if(null==e)return null;const t=this._editGeometryOperations.data,i=t.components[0].edges[0],s=c(this._mainAxisCache,i.leftVertex.pos,i.rightVertex.pos);h(s,s);let o=K*this.view.resolution;const a=this.view.spatialReference;return b(a,e.spatialReference)&&(o*=r(a)/r(e.spatialReference)),H(s,t,o,this._planeCache)}get _displayPlane(){const e=this._plane;if(!e)return null;const t=this._displayPlaneCache;R(e,t);const i=J*this.view.resolution;return m(t.basis1,t.basis1,1+i/d(t.basis1)),m(t.basis2,t.basis2,1+i/d(t.basis2)),t}get _backgroundGraphicGeometry(){const e=this._displayPlane;if(!e)return null;const t=this.view.spatialReference;return this._updateDisplayPlaneConrers(e),new z({spatialReference:t,rings:[[this._cornerA,this._cornerB,this._cornerC,this._cornerD,this._cornerA]]})}get _rotateGraphicGeometry(){const e=this._plane;if(!e)return null;const t=this._rotationHandleCache;return _(t,e.basis1),m(t,t,Q*this.view.resolution),g(t,t,e.origin),g(t,t,e.basis1),new N({x:t[0],y:t[1],spatialReference:this.view.spatialReference})}get _scaleGraphicGeometries(){const e=this._displayPlane;if(!e)return[];const t=this.view.spatialReference;this._updateDisplayPlaneConrers(e);const{_cornerA:i,_cornerB:s,_cornerC:o,_cornerD:r}=this,a=u(this._avgAB,i,s,.5),n=u(this._avgBC,s,o,.5),c=u(this._avgCD,o,r,.5),h=u(this._avgDA,r,i,.5);return[new N({x:i[0],y:i[1],spatialReference:t}),new N({x:s[0],y:s[1],spatialReference:t}),new N({x:o[0],y:o[1],spatialReference:t}),new N({x:r[0],y:r[1],spatialReference:t}),new N({x:a[0],y:a[1],spatialReference:t}),new N({x:n[0],y:n[1],spatialReference:t}),new N({x:c[0],y:c[1],spatialReference:t}),new N({x:h[0],y:h[1],spatialReference:t})]}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this._editGeometryOperations.undo(),this.updateGraphics()}redo(){this._editGeometryOperations.redo(),this.updateGraphics()}refresh(){const{view:e,target:t}=this,i="georeference"in t?t.georeference.coords:t.geometry,s=this._editGeometryOperations,o=s.data.components[0].vertices,r=U.fromGeometry(v(i,e.spatialReference),C.Local).components[0].vertices;o.forEach(((e,t)=>{s.setVertexPosition(e,r[t].pos)})),this.updateGraphics()}reset(){const{target:e}=this;if("georeference"in e){const t=e.georeference;"control-points"===t.type&&(t.controlPoints=this._initialControlPoints)}else e.geometry=this._initialGeometry;this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const e=this._editGeometryOperations.data.geometry;if("georeference"in this.target){this.target.georeference.coords=e}this._graphic.geometry=e,this._backgroundGraphic.geometry=this._backgroundGraphicGeometry,this._rotateGraphic.geometry=this._rotateGraphicGeometry,this._scaleGraphicGeometries.forEach(((e,t)=>{this._scaleGraphics[t].geometry=e}))}setSharedUndoStack(e){this._sharedUndoStack=e}setSharedRedoStack(e){this._sharedRedoStack=e}async _initialize(){const{view:e,target:s}=this;if("georeference"in s){const e=s.georeference;this._graphic=new t({geometry:e.coords}),this._initialControlPoints="control-points"===e.type?e.controlPoints:null}else this._graphic=s,this._initialGeometry=s.geometry;e.map.addMany([this._graphicsLayer]),e.focus(),this.visible=!1,this.finishToolCreation(),await this._loadProjectionEngine(),this._editGeometryOperations=L.fromGeometry(v(this._graphic.geometry,e.spatialReference),C.Local),this._backgroundGraphic=new t({symbol:new W({color:"transparent",outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:2}}),geometry:this._backgroundGraphicGeometry}),this._rotateGraphic=new t({symbol:new q({color:i(e.effectiveTheme.accentColor),outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:1}}),geometry:this._rotateGraphicGeometry}),this._scaleGraphics=this._scaleGraphicGeometries.map((s=>new t({symbol:new q({size:6,style:"square",color:i(e.effectiveTheme.accentColor),outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:1}}),geometry:s}))),this._graphicsLayer.graphics.addMany([this._backgroundGraphic,this._rotateGraphic,...this._scaleGraphics]),this._dragManipulation=new A({tool:this,view:e,graphic:this._graphic}),this._rotateManipulation=new k({tool:this,view:e,graphic:this._rotateGraphic,snapRotation:this._snapRotation}),this._scaleManipulations=this._scaleGraphics.map(((t,i)=>new S({tool:this,view:e,graphic:t,direction:X[i],preserveAspectRatio:this._preserveAspectRatio}))),this.addHandles([this._dragManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),this._rotateManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),...this._scaleManipulations.map((e=>e.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)))),o((()=>this.view.scale),(()=>this.active?this.updateGraphics():null)),e.on("click",(async t=>{if(null!=e.activeTool&&e.activeTool!==this)return;const i=V(t),o=[];e.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const r=await this.view.hitTest(i,{exclude:o}),a=r.results;if(0===a.length)e.activeTool=null;else{const t=I(r.results),i="georeference"in s,o=a.map((e=>"media"===e.type?e.element:null)).filter(Boolean),n=new Set([...this._graphicsLayer.graphics,i?null:s].filter(Boolean));i&&o.includes(s)||null!=t&&n.has(t.graphic)?null==e.activeTool&&(e.activeTool=this):e.activeTool=null}}))]);const r=e=>{this.addHandles(e.events.on("grab-changed",(e=>{"georeference"in s&&("start"===e.action?s.opacity*=.5:"end"===e.action&&(s.opacity*=2))})))};this._dragManipulation.forEachManipulator(r),this._rotateManipulation.forEachManipulator(r),this._scaleManipulations.forEach((e=>e.forEachManipulator(r)));const a=new O;a.addToggle(D.preserveAspectRatio,(()=>{null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled)})),a.addToggle(D.rotateIncrements,(()=>{null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled)})),a.add(D.toggleOpacity,(()=>{"georeference"in s&&(s.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled)})),a.addToggle(D.factorModifier,(e=>this._factor="key-down"===e.type?Z:Y)),a.add(D.scaleUp,(()=>this._scale(this._factor))),a.add(D.scaleDown,(()=>this._scale(-this._factor))),a.add(D.moveUp,(()=>this._move(0,this._factor))),a.add(D.moveDown,(()=>this._move(0,-this._factor))),a.add(D.moveLeft,(()=>this._move(-this._factor,0))),a.add(D.moveRight,(()=>this._move(this._factor,0))),this.addHandles([e.on("key-down",(t=>{e.activeTool===this&&a.dispatch(e.inputManager,t)})),e.on("key-up",(t=>{e.activeTool===this&&a.dispatch(e.inputManager,t)}))])}async _loadProjectionEngine(){const e=this._graphic.geometry;return G(e.spatialReference,this.view.spatialReference)}_updateDisplayPlaneConrers(e){const{basis1:t,basis2:i,origin:s}=e,o=this._cornerA;g(o,s,t),g(o,o,i);const r=this._cornerB;g(r,s,t),y(r,r,i);const a=this._cornerC;y(a,s,t),y(a,a,i);const n=this._cornerD;y(n,s,t),g(n,n,i)}_getInfo(){return{editGeometryOperations:this._editGeometryOperations,plane:this._plane,displayPlane:this._displayPlane}}_updateGraphics(e,t){"start"===e.action&&(this._sharedUndoStack.push({tool:this,operation:t}),this._sharedRedoStack.length=0),this.updateGraphics()}_scale(e){const t=this._editGeometryOperations,i=t.data.geometry.extent?.width,s=(i+e*this.view.resolution)/i,o=t.scale(this._plane.origin,p,s,s,E.NEW_STEP,B.REPLACE);this._sharedUndoStack.push({tool:this,operation:o}),this._sharedRedoStack.length=0,this.updateGraphics()}_move(e,t){const i=this._editGeometryOperations.move(e*this.view.resolution,t*this.view.resolution,0,E.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:i}),this._sharedRedoStack.length=0,this.updateGraphics()}};e([a()],$.prototype,"_plane",null),e([a()],$.prototype,"_backgroundGraphicGeometry",null),e([a()],$.prototype,"_rotateGraphicGeometry",null),e([a()],$.prototype,"_scaleGraphicGeometries",null),e([a()],$.prototype,"preserveAspectRatio",void 0),e([a()],$.prototype,"snapRotation",void 0),e([a({constructOnly:!0,nonNullable:!0})],$.prototype,"target",void 0),e([a({constructOnly:!0})],$.prototype,"view",void 0),$=e([n("esri.views.2d.interactive.editingTools.TransformTool")],$);export{$ as TransformTool,F as keys};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../Graphic.js";import"../../../../symbols.js";import{getContrast as i}from"../../../../core/colorUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as r}from"../../../../core/unitUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{subtract as c,normalize as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as l,UNIT_X as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as m,l as d,n as _,g,o as u,f as y}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as v,initializeProjection as G}from"../../../../geometry/projection.js";import{a as w,c as R}from"../../../../chunks/boundedPlane.js";import{equals as b}from"../../../../geometry/support/spatialReferenceUtils.js";import j from"../../../../layers/GraphicsLayer.js";import{ViewingMode as C}from"../../../ViewingMode.js";import{DragManipulation as k}from"./manipulations/DragManipulation.js";import{RotateManipulation as A}from"./manipulations/RotateManipulation.js";import{ScaleManipulation as S}from"./manipulations/ScaleManipulation.js";import{PreserveAspectRatio as P,SnapRotation as T}from"./manipulations/utils.js";import{primaryKey as M}from"../../../input/keys.js";import{InteractiveToolBase as x}from"../../../interactive/InteractiveToolBase.js";import{mediaKeys as D,KeyBindings as O}from"../../../interactive/keybindings.js";import{EditGeometry as U}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as L}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehavior as E}from"../../../interactive/editGeometry/interfaces.js";import{AccumulationType as B}from"../../../interactive/editGeometry/operations/UpdateVertices.js";import{calculateOrientedBounds as H}from"../../../interactive/editGeometry/support/editPlaneUtils.js";import{findFirstGraphicHit as I}from"../../../support/hitTestSelectUtils.js";import{createScreenPointFromEvent as V}from"../../../support/screenUtils.js";import z from"../../../../geometry/Polygon.js";import N from"../../../../geometry/Point.js";import W from"../../../../symbols/SimpleFillSymbol.js";import q from"../../../../symbols/SimpleMarkerSymbol.js";const F={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",plus:"+",minus:"-",toggleOpacity:"t",shift:"Shift",primaryKey:M},K=80,J=10,Q=30,X=[[1,1],[1,-1],[-1,-1],[-1,1],[1,0],[0,-1],[-1,0],[0,1]],Y=1,Z=10;let $=class extends x{constructor(e){super(e),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._planeCache=w(),this._displayPlaneCache=w(),this._mainAxisCache=l(),this._rotationHandleCache=f(),this._cornerA=f(),this._cornerB=f(),this._cornerC=f(),this._cornerD=f(),this._avgAB=f(),this._avgBC=f(),this._avgCD=f(),this._avgDA=f(),this._preserveAspectRatio=new P,this._snapRotation=new T,this._graphicsLayer=new j({internal:!0,listMode:"hide",visible:!1}),this._sharedUndoStack=[],this._sharedRedoStack=[],this._isOpacityToggled=!1,this._factor=Y,this.preserveAspectRatio=null,this.snapRotation=null}initialize(){this._initialize()}destroy(){const{map:e}=this.view;this._dragManipulation.destroy(),this._rotateManipulation.destroy(),this._scaleManipulations.forEach((e=>e.destroy())),this._editGeometryOperations.destroy(),e.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=s(this._graphicsLayer),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._preserveAspectRatio=null,this._snapRotation=null,this._planeCache=null,this._displayPlaneCache=null,this._rotationHandleCache=null,this._mainAxisCache=null,this._cornerA=null,this._cornerB=null,this._cornerC=null,this._cornerD=null,this._avgAB=null,this._avgBC=null,this._avgCD=null,this._avgDA=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _plane(){const e=this._graphic.geometry;if(null==e)return null;const t=this._editGeometryOperations.data,i=t.components[0].edges[0],s=c(this._mainAxisCache,i.leftVertex.pos,i.rightVertex.pos);h(s,s);let o=K*this.view.resolution;const a=this.view.spatialReference;return b(a,e.spatialReference)&&(o*=r(a)/r(e.spatialReference)),H(s,t,o,this._planeCache)}get _displayPlane(){const e=this._plane;if(!e)return null;const t=this._displayPlaneCache;R(e,t);const i=J*this.view.resolution;return m(t.basis1,t.basis1,1+i/d(t.basis1)),m(t.basis2,t.basis2,1+i/d(t.basis2)),t}get _backgroundGraphicGeometry(){const e=this._displayPlane;if(!e)return null;const t=this.view.spatialReference;return this._updateDisplayPlaneConrers(e),new z({spatialReference:t,rings:[[this._cornerA,this._cornerB,this._cornerC,this._cornerD,this._cornerA]]})}get _rotateGraphicGeometry(){const e=this._plane;if(!e)return null;const t=this._rotationHandleCache;return _(t,e.basis1),m(t,t,Q*this.view.resolution),g(t,t,e.origin),g(t,t,e.basis1),new N({x:t[0],y:t[1],spatialReference:this.view.spatialReference})}get _scaleGraphicGeometries(){const e=this._displayPlane;if(!e)return[];const t=this.view.spatialReference;this._updateDisplayPlaneConrers(e);const{_cornerA:i,_cornerB:s,_cornerC:o,_cornerD:r}=this,a=u(this._avgAB,i,s,.5),n=u(this._avgBC,s,o,.5),c=u(this._avgCD,o,r,.5),h=u(this._avgDA,r,i,.5);return[new N({x:i[0],y:i[1],spatialReference:t}),new N({x:s[0],y:s[1],spatialReference:t}),new N({x:o[0],y:o[1],spatialReference:t}),new N({x:r[0],y:r[1],spatialReference:t}),new N({x:a[0],y:a[1],spatialReference:t}),new N({x:n[0],y:n[1],spatialReference:t}),new N({x:c[0],y:c[1],spatialReference:t}),new N({x:h[0],y:h[1],spatialReference:t})]}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this._editGeometryOperations.undo(),this.updateGraphics()}redo(){this._editGeometryOperations.redo(),this.updateGraphics()}refresh(){const{view:e,target:t}=this,i="georeference"in t?t.georeference.coords:t.geometry,s=this._editGeometryOperations,o=s.data.components[0].vertices,r=U.fromGeometry(v(i,e.spatialReference),C.Local).components[0].vertices;o.forEach(((e,t)=>{s.setVertexPosition(e,r[t].pos)})),this.updateGraphics()}reset(){const{target:e}=this;if("georeference"in e){const t=e.georeference;"control-points"===t.type&&(t.controlPoints=this._initialControlPoints)}else e.geometry=this._initialGeometry;this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const e=this._editGeometryOperations.data.geometry;if("georeference"in this.target){this.target.georeference.coords=e}this._graphic.geometry=e,this._backgroundGraphic.geometry=this._backgroundGraphicGeometry,this._rotateGraphic.geometry=this._rotateGraphicGeometry,this._scaleGraphicGeometries.forEach(((e,t)=>{this._scaleGraphics[t].geometry=e}))}setSharedUndoStack(e){this._sharedUndoStack=e}setSharedRedoStack(e){this._sharedRedoStack=e}async _initialize(){const{view:e,target:s}=this;if("georeference"in s){const e=s.georeference;this._graphic=new t({geometry:e.coords}),this._initialControlPoints="control-points"===e.type?e.controlPoints:null}else this._graphic=s,this._initialGeometry=s.geometry;e.map.addMany([this._graphicsLayer]),e.focus(),this.visible=!1,this.finishToolCreation(),await this._loadProjectionEngine(),this._editGeometryOperations=L.fromGeometry(v(this._graphic.geometry,e.spatialReference),C.Local),this._backgroundGraphic=new t({symbol:new W({color:"transparent",outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:2}}),geometry:this._backgroundGraphicGeometry}),this._rotateGraphic=new t({symbol:new q({color:i(e.effectiveTheme.accentColor),outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:1}}),geometry:this._rotateGraphicGeometry}),this._scaleGraphics=this._scaleGraphicGeometries.map((s=>new t({symbol:new q({size:6,style:"square",color:i(e.effectiveTheme.accentColor),outline:{type:"simple-line",color:e.effectiveTheme.accentColor,width:1}}),geometry:s}))),this._graphicsLayer.graphics.addMany([this._backgroundGraphic,this._rotateGraphic,...this._scaleGraphics]),this._dragManipulation=new k({tool:this,view:e,graphic:this._graphic}),this._rotateManipulation=new A({tool:this,view:e,graphic:this._rotateGraphic,snapRotation:this._snapRotation}),this._scaleManipulations=this._scaleGraphics.map(((t,i)=>new S({tool:this,view:e,graphic:t,direction:X[i],preserveAspectRatio:this._preserveAspectRatio}))),this.addHandles([this._dragManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),this._rotateManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),...this._scaleManipulations.map((e=>e.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)))),o((()=>this.view.scale),(()=>this.active?this.updateGraphics():null)),e.on("click",(async t=>{if(null!=e.activeTool&&e.activeTool!==this)return;const i=V(t),o=[];e.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const r=await this.view.hitTest(i,{exclude:o}),a=r.results;if(0===a.length)e.activeTool=null;else{const t=I(r.results),i="georeference"in s,o=a.map((e=>"media"===e.type?e.element:null)).filter(Boolean),n=new Set([...this._graphicsLayer.graphics,i?null:s].filter(Boolean));i&&o.includes(s)||null!=t&&n.has(t.graphic)?null==e.activeTool&&(e.activeTool=this):e.activeTool=null}}))]);const r=e=>{this.addHandles(e.events.on("grab-changed",(e=>{"georeference"in s&&("start"===e.action?s.opacity*=.5:"end"===e.action&&(s.opacity*=2))})))};this._dragManipulation.forEachManipulator(r),this._rotateManipulation.forEachManipulator(r),this._scaleManipulations.forEach((e=>e.forEachManipulator(r)));const a=new O;a.addToggle(D.preserveAspectRatio,(()=>{null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled)})),a.addToggle(D.rotateIncrements,(()=>{null==this.snapRotation&&(this._snapRotation.enabled=!this._snapRotation.enabled)})),a.add(D.toggleOpacity,(()=>{"georeference"in s&&(s.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled)})),a.addToggle(D.factorModifier,(e=>this._factor="key-down"===e.type?Z:Y)),a.add(D.scaleUp,(()=>this._scale(this._factor))),a.add(D.scaleDown,(()=>this._scale(-this._factor))),a.add(D.moveUp,(()=>this._move(0,this._factor))),a.add(D.moveDown,(()=>this._move(0,-this._factor))),a.add(D.moveLeft,(()=>this._move(-this._factor,0))),a.add(D.moveRight,(()=>this._move(this._factor,0))),this.addHandles([e.on("key-down",(t=>{e.activeTool===this&&a.dispatch(e.inputManager,t)})),e.on("key-up",(t=>{e.activeTool===this&&a.dispatch(e.inputManager,t)}))])}async _loadProjectionEngine(){const e=this._graphic.geometry;return G(e.spatialReference,this.view.spatialReference)}_updateDisplayPlaneConrers(e){const{basis1:t,basis2:i,origin:s}=e,o=this._cornerA;g(o,s,t),g(o,o,i);const r=this._cornerB;g(r,s,t),y(r,r,i);const a=this._cornerC;y(a,s,t),y(a,a,i);const n=this._cornerD;y(n,s,t),g(n,n,i)}_getInfo(){return{editGeometryOperations:this._editGeometryOperations,plane:this._plane,displayPlane:this._displayPlane}}_updateGraphics(e,t){"start"===e.action&&(this._sharedUndoStack.push({tool:this,operation:t}),this._sharedRedoStack.length=0),this.updateGraphics()}_scale(e){const t=this._editGeometryOperations,i=t.data.geometry.extent?.width,s=(i+e*this.view.resolution)/i,o=t.scale(this._plane.origin,p,s,s,E.NEW_STEP,B.REPLACE);this._sharedUndoStack.push({tool:this,operation:o}),this._sharedRedoStack.length=0,this.updateGraphics()}_move(e,t){const i=this._editGeometryOperations.move(e*this.view.resolution,t*this.view.resolution,0,E.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:i}),this._sharedRedoStack.length=0,this.updateGraphics()}};e([a()],$.prototype,"_plane",null),e([a()],$.prototype,"_backgroundGraphicGeometry",null),e([a()],$.prototype,"_rotateGraphicGeometry",null),e([a()],$.prototype,"_scaleGraphicGeometries",null),e([a()],$.prototype,"preserveAspectRatio",void 0),e([a()],$.prototype,"snapRotation",void 0),e([a({constructOnly:!0,nonNullable:!0})],$.prototype,"target",void 0),e([a({constructOnly:!0})],$.prototype,"view",void 0),$=e([n("esri.views.2d.interactive.editingTools.TransformTool")],$);export{$ as TransformTool,F as keys};
|
|
@@ -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 t from"../../../Viewpoint.js";import{lerp as
|
|
5
|
+
import"../../../geometry.js";import t from"../../../Viewpoint.js";import{deg2rad as e,lerp as o}from"../../../core/mathUtils.js";import{distance as i}from"../../../geometry/support/pointUtils.js";import{getScaleToResolutionFactor as r,copy as s}from"../viewpointUtils.js";import n from"../../../geometry/Point.js";class a{constructor(e){this._view=e,this.viewpoint=new t({targetGeometry:new n,scale:0,rotation:0})}get view(){return this._view}get size(){const[t,e]=this._view.size;return Math.sqrt(t*t+e*e)}get scale(){return this.viewpoint.scale}get rotation(){return this.viewpoint.rotation}get center(){return this.viewpoint.targetGeometry}get scaleToResolutionFactor(){return r(this.center.spatialReference)}pixelsPerPanAtZoom(t){return 1/(t*this.scaleToResolutionFactor)}zoomAtPixelsPerPan(t){return 1/(t*this.scaleToResolutionFactor)}pixelsPerRotateAtZoom(t){return this.size/2}compareTo(t,o){o.pan=i(this.center,t.center);let r=Math.abs(t.rotation-this.rotation);r=r>=180?360-r:r,o.rotate=e(r),o.sourceZoom=this.scale,o.targetZoom=t.scale}interpolate(t,e,i){const{pan:r,rotate:s,zoom:n,zoomOffset:a}=i,{center:c}=this;c.spatialReference=t.center.spatialReference,c.x=o(t.center.x,e.center.x,r),c.y=o(t.center.y,e.center.y,r),this.viewpoint.scale=o(t.scale,e.scale+a,n);let p=t.rotation;const l=e.rotation;Math.abs(l-p)>=180&&(p+=360*(p<l?1:-1)),this.viewpoint.rotation=o(p,l,s)}copyFrom(t){s(this.viewpoint,t.viewpoint),this._view=t.view}}export{a as Camera};
|
|
@@ -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"../../../core/Error.js";import has from"../../../core/has.js";import{disposeMaybe as i,abortMaybe as l,destroyMaybe as r}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as a,watch as o,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{SchemaHelper as m}from"../../2d/engine/vectorTiles/SchemaHelper.js";import d from"../../2d/engine/vectorTiles/TileHandler3D.js";import p from"../../2d/engine/vectorTiles/VTLPainter3D.js";import y from"../../2d/engine/vectorTiles/style/StyleRepository.js";import{LayerView3D as g}from"./LayerView3D.js";import{TiledLayerView3D as f}from"./TiledLayerView3D.js";import{vtlAssumes256PixelSizeAsDefault as u,test as v}from"../terrain/terrainUtils.js";import S from"../../layers/LayerView.js";let _=class extends(f(g(S))){constructor(){super(...arguments),this._tileHandlerController=null,this.type="vector-tile-3d",this.levelShift=has("disable-feature:vtl-level-shift")?0:1}initialize(){if(null==this.layer.fullExtent)return void this.addResolvingPromise(Promise.reject(new t("vectortilelayerview:full-extent-undefined","This layer view's layer does not define a fullExtent.")));const{basemapTerrain:e,spatialReference:i,state:l,viewingMode:r}=this.view,h="local"===r&&!u(i)||v.force512VTL?this.layer.tileInfo:this.layer.tileInfo.getCompatibleForVTL(256),c=this._getTileInfoSupportError(h,this.layer.fullExtent);if(null!=c)return this.addResolvingPromise(Promise.reject(c));const g=a((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const t=e.tilingScheme,i=t.pixelSize,l=256===i?1:2,r=e.spatialReference?.isGeographic&&256===i?1:0,s=e.spatialReference?.isGeographic||256!==i?0:1;let a;this.schemaHelper=new m(l,r,this.levelShift+s),a=256===i||512===i?this.layer.tileInfo.getCompatibleForVTL(i):this.layer.tileInfo;const o=this._getTileInfoCompatibilityError(a,t);if(o)throw o;this.tileInfo=a}));this._tileHandlerController=new AbortController;const f=this.view.resourceController;this._memCache=f.memoryController.newCache(`vtl-${this.layer.uid}`,(e=>{e.release()})),this.addHandles(o((()=>this.view.qualitySettings.memoryLimit),(e=>this._memCache.maxSize=Math.ceil(e/10*1048576)),n));const S=new y(this.layer.currentStyleInfo.style);this._tileHandler=new d(this.layer,S,l.contentPixelRatio,this._memCache);const _=this._tileHandlerController.signal,C=H(f),w=this._tileHandler.start({signal:_,schedule:C}),R=this._tileHandler.spriteMosaic;R.then((e=>{!s(_)&&this._tileHandler&&(this.painter=new p(e,this._tileHandler.glyphMosaic))})),w.then((()=>this._tileHandlerController=null));const L=()=>{this._tileHandlerController&&this._tileHandlerController.abort(),this._tileHandlerController=new AbortController,this._memCache.clear();const e=this.layer.currentStyleInfo.style,t=this.view.state?.contentPixelRatio??1,i=new y(e),l=new d(this.layer,i,t,this._memCache),r=l.start({signal:this._tileHandlerController.signal,schedule:C}),s=l.spriteMosaic;r.then((()=>this._tileHandlerController=null)),this._updatingHandles.addPromise(Promise.all([r,s]).then((([,e])=>{const t=this._tileHandler,i=this.painter;this.painter=new p(e,l.glyphMosaic),this._tileHandler=l,this.emit("data-changed"),t.destroy(),i&&i.dispose()})))};this._updatingHandles.add((()=>({style:this.layer.currentStyleInfo.style,pixelRatio:this.view.state?.contentPixelRatio})),
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import{disposeMaybe as i,abortMaybe as l,destroyMaybe as r}from"../../../core/maybe.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{whenOnce as a,watch as o,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{SchemaHelper as m}from"../../2d/engine/vectorTiles/SchemaHelper.js";import d from"../../2d/engine/vectorTiles/TileHandler3D.js";import p from"../../2d/engine/vectorTiles/VTLPainter3D.js";import y from"../../2d/engine/vectorTiles/style/StyleRepository.js";import{LayerView3D as g}from"./LayerView3D.js";import{TiledLayerView3D as f}from"./TiledLayerView3D.js";import{vtlAssumes256PixelSizeAsDefault as u,test as v}from"../terrain/terrainUtils.js";import S from"../../layers/LayerView.js";let _=class extends(f(g(S))){constructor(){super(...arguments),this._tileHandlerController=null,this.type="vector-tile-3d",this.levelShift=has("disable-feature:vtl-level-shift")?0:1}initialize(){if(null==this.layer.fullExtent)return void this.addResolvingPromise(Promise.reject(new t("vectortilelayerview:full-extent-undefined","This layer view's layer does not define a fullExtent.")));const{basemapTerrain:e,spatialReference:i,state:l,viewingMode:r}=this.view,h="local"===r&&!u(i)||v.force512VTL?this.layer.tileInfo:this.layer.tileInfo.getCompatibleForVTL(256),c=this._getTileInfoSupportError(h,this.layer.fullExtent);if(null!=c)return this.addResolvingPromise(Promise.reject(c));const g=a((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const t=e.tilingScheme,i=t.pixelSize,l=256===i?1:2,r=e.spatialReference?.isGeographic&&256===i?1:0,s=e.spatialReference?.isGeographic||256!==i?0:1;let a;this.schemaHelper=new m(l,r,this.levelShift+s),a=256===i||512===i?this.layer.tileInfo.getCompatibleForVTL(i):this.layer.tileInfo;const o=this._getTileInfoCompatibilityError(a,t);if(o)throw o;this.tileInfo=a}));this._tileHandlerController=new AbortController;const f=this.view.resourceController;this._memCache=f.memoryController.newCache(`vtl-${this.layer.uid}`,(e=>{e.release()})),this.addHandles(o((()=>this.view.qualitySettings.memoryLimit),(e=>this._memCache.maxSize=Math.ceil(e/10*1048576)),n));const S=new y(this.layer.currentStyleInfo.style);this._tileHandler=new d(this.layer,S,l.contentPixelRatio,this._memCache);const _=this._tileHandlerController.signal,C=H(f),w=this._tileHandler.start({signal:_,schedule:C}),R=this._tileHandler.spriteMosaic;R.then((e=>{!s(_)&&this._tileHandler&&(this.painter=new p(e,this._tileHandler.glyphMosaic))})),w.then((()=>this._tileHandlerController=null));const L=()=>{this._tileHandlerController&&this._tileHandlerController.abort(),this._tileHandlerController=new AbortController,this._memCache.clear();const e=this.layer.currentStyleInfo.style,t=this.view.state?.contentPixelRatio??1,i=new y(e),l=new d(this.layer,i,t,this._memCache),r=l.start({signal:this._tileHandlerController.signal,schedule:C}),s=l.spriteMosaic;r.then((()=>this._tileHandlerController=null)),this._updatingHandles.addPromise(Promise.all([r,s]).then((([,e])=>{const t=this._tileHandler,i=this.painter;this.painter=new p(e,l.glyphMosaic),this._tileHandler=l,this.emit("data-changed"),t.destroy(),i&&i.dispose()})))};this._updatingHandles.add((()=>({style:this.layer.currentStyleInfo.style,pixelRatio:this.view.state?.contentPixelRatio})),L),this.addHandles([this.layer.on("paint-change",(()=>this.emit("data-changed"))),this.layer.on("style-layer-change",L),this.layer.on("delete-style-layer",L),this.layer.on("spriteSource-change",(()=>this.emit("data-changed"))),this.layer.on("layout-change",(()=>this.emit("data-changed"))),this.layer.on("style-layer-visibility-change",(()=>this.emit("data-changed")))]);const j=Promise.all([g,w,R]);this.addResolvingPromise(j)}destroy(){this.painter=i(this.painter),this._tileHandlerController=l(this._tileHandlerController),this._tileHandler=r(this._tileHandler),this._memCache=r(this._memCache)}get contentZoom(){return has("disable-feature:vtl-level-shift")?1:this.view.qualitySettings.tiledSurface.vtlContentZoom}get displayLevelRange(){const e=this.tileInfo.lods,t=this.layer.minScale||e[0].scale,i=this.layer.maxScale||e[e.length-1].scale,l=this.levelRangeFromScaleRange(t,i);return this.layer.maxScale?l.maxLevel++:l.maxLevel+=this.levelShift,l}get dataScaleRange(){const e=this.tileInfo.lods;return{minScale:e[0].scale,maxScale:e[e.length-1].scale}}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange,i=this.levelRangeFromScaleRange(e,t);return 1===i.minLevel&&256===this.tileInfo.size[0]&&(i.minLevel=0),i.maxLevel+=this.levelShift,i}async fetchTile(e,t){const i=this.schemaHelper.getLevelRowColumn(e);return this._tileHandler.getVectorTile(i,t)}};e([h()],_.prototype,"layer",void 0),e([h()],_.prototype,"levelShift",void 0),e([h()],_.prototype,"contentZoom",null),e([h()],_.prototype,"displayLevelRange",null),e([h()],_.prototype,"tileInfo",void 0),e([h()],_.prototype,"dataScaleRange",null),e([h()],_.prototype,"dataLevelRange",null),e([h()],_.prototype,"updatingProgressValue",void 0),_=e([c("esri.views.3d.layers.VectorTileLayerView3D")],_);const C=_;function H(e){return t=>e.immediate.schedule(t)}export{C as default};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ReadDepth as e}from"./output/ReadDepth.glsl.js";import{CameraSpace as o}from"./util/CameraSpace.glsl.js";import{glsl as t}from"../shaderModules/interfaces.js";function i(i){const r=i.fragment;i.include(o),r.include(e),r.code.add(t`vec3 normalFromDepth(sampler2D depthMap, vec3 pixelPos, vec2 fragCoord, vec2 uv) {
|
|
6
|
+
ivec2 iuv = ivec2(uv * vec2(textureSize(depthMap, 0)));
|
|
7
|
+
float leftPixelDepth = linearizeDepth(texelFetch(depthMap, iuv + ivec2(-1, 0), 0).r);
|
|
8
|
+
float rightPixelDepth = linearizeDepth(texelFetch(depthMap, iuv + ivec2(1, 0), 0).r);
|
|
9
|
+
float bottomPixelDepth = linearizeDepth(texelFetch(depthMap, iuv + ivec2(0, -1), 0).r);
|
|
10
|
+
float topPixelDepth = linearizeDepth(texelFetch(depthMap, iuv + ivec2(0, 1), 0).r);
|
|
11
|
+
bool pickLeft = abs(pixelPos.z - leftPixelDepth) < abs(pixelPos.z - rightPixelDepth);
|
|
12
|
+
bool pickBottom = abs(pixelPos.z - bottomPixelDepth) < abs(pixelPos.z - topPixelDepth);
|
|
13
|
+
vec3 fragCoordHorizontal = pickLeft
|
|
14
|
+
? vec3(fragCoord + vec2(-1.0, 0.0), leftPixelDepth)
|
|
15
|
+
: vec3(fragCoord + vec2(1.0, 0.0), rightPixelDepth);
|
|
16
|
+
vec3 fragCoordVertical = pickBottom
|
|
17
|
+
? vec3(fragCoord + vec2(0.0, -1.0), bottomPixelDepth)
|
|
18
|
+
: vec3(fragCoord + vec2(0.0, 1.0), topPixelDepth);
|
|
19
|
+
vec3 verticalPixelPos = reconstructPosition(fragCoordHorizontal.xy, fragCoordHorizontal.z);
|
|
20
|
+
vec3 horizontalPixelPos = reconstructPosition(fragCoordVertical.xy, fragCoordVertical.z);
|
|
21
|
+
vec3 normal = normalize(cross(verticalPixelPos - pixelPos, horizontalPixelPos - pixelPos));
|
|
22
|
+
return pickLeft == pickBottom ? normal : -normal;
|
|
23
|
+
}`)}export{i as NormalFromDepth};
|