@vertigis/arcgis-extensions 37.7.1 → 38.0.0
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/AppConfig.schema.json +24 -11
- package/data/Feature.js +1 -1
- package/data/FeatureList.d.ts +1 -1
- package/data/FeatureList.js +1 -1
- package/data/FeatureSettings.js +1 -1
- package/data/FeatureSourceBase.d.ts +1 -1
- package/data/FeatureSourceBase.js +1 -1
- package/data/PopupContentExtension.js +1 -1
- package/data/Schema.js +1 -1
- package/declarations/arcgis-js-api-extensions/index.d.ts +12 -10
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/data_FeatureList.FeatureList.html +8 -8
- package/docs/html/classes/data_FeatureSourceBase.RelationshipCollection.html +8 -8
- package/docs/html/classes/data_FeatureStream.FeatureStream.html +1 -1
- package/docs/html/classes/mapping_ArcGISSublayerExtension.ArcGISSublayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping_GroupLayerExtension.GroupLayerExtensionCollection.html +8 -8
- package/docs/html/classes/mapping_SubtypeGroupLayerExtension.SubtypeGroupLayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping_SubtypeSublayerExtension.SubtypeSublayerRelationshipCollection.html +8 -8
- package/docs/html/classes/mapping__SublayerExtension.SubSublayerExtensionCollection.html +8 -8
- package/docs/html/classes/mapping_support_ArrayWrappedCollection.ArrayWrappedCollection.html +8 -8
- package/docs/html/classes/mapping_support__LayerExtensionCollection.LayerExtensionCollectionBase.html +8 -8
- package/docs/html/classes/mapping_support__SublayerExtensionCollection.SublayerExtensionCollectionBase.html +8 -8
- package/docs/html/classes/support_InitializableCollectionProxy.InitializableCollectionProxy.html +8 -8
- package/docs/html/classes/support_ReadOnlyInitializableCollection.ReadOnlyInitializableCollection.html +8 -8
- package/docs/html/classes/support__ArcGISRelationshipCollection.ArcGISRelationshipCollection.html +8 -8
- package/docs/html/classes/utilities_CollectionProxy.CollectionProxy.html +8 -8
- package/docs/html/classes/utilities_CopyOnWriteCollection.CopyOnWriteCollection.html +8 -8
- package/docs/html/classes/utilities_MapTransformCollection.MapTransformCollection.html +8 -8
- package/docs/html/classes/utilities_ReadOnlyCollection.ReadOnlyCollection.html +8 -8
- package/docs/html/classes/utilities_asyncIterable.AsyncQueue.html +1 -1
- package/docs/html/functions/portal_ElevationInfo.ElevationInfo.fromEsriApiElevationInfo.html +2 -2
- package/docs/html/functions/portal_Lighting.Lighting.fromEsriApiLighting.html +2 -2
- package/docs/html/functions/utilities_esri.getAllFieldInfos.html +1 -0
- package/docs/html/functions/utilities_esri.getAllReferencedFieldNames.html +1 -0
- package/docs/html/functions/utilities_esri.isAttachmentsContent.html +1 -0
- package/docs/html/functions/utilities_esri.isCodedValueDomain.html +1 -0
- package/docs/html/functions/utilities_esri.isColor.html +1 -0
- package/docs/html/functions/utilities_esri.isCustomContent.html +1 -0
- package/docs/html/functions/utilities_esri.isEsriObject.html +1 -0
- package/docs/html/functions/utilities_esri.isExpressionContent.html +1 -0
- package/docs/html/functions/utilities_esri.isFeatureSet.html +1 -0
- package/docs/html/functions/utilities_esri.isFeatureType.html +1 -0
- package/docs/html/functions/utilities_esri.isField.html +1 -0
- package/docs/html/functions/utilities_esri.isFieldsContent.html +1 -0
- package/docs/html/functions/utilities_esri.isGraphic.html +1 -0
- package/docs/html/functions/utilities_esri.isImageMediaInfo.html +1 -0
- package/docs/html/functions/utilities_esri.isMediaContent.html +1 -0
- package/docs/html/functions/utilities_esri.isPopupContent.html +1 -0
- package/docs/html/functions/utilities_esri.isPopupTemplate.html +1 -0
- package/docs/html/functions/utilities_esri.isPortalItem.html +1 -0
- package/docs/html/functions/utilities_esri.isRelationshipContent.html +626 -0
- package/docs/html/functions/utilities_esri.isSpatialReference.html +1 -0
- package/docs/html/functions/utilities_esri.isTextContent.html +1 -0
- package/docs/html/functions/utilities_esri.isViewpoint.html +1 -0
- package/docs/html/functions/utilities_esri.load.html +1 -0
- package/docs/html/functions/utilities_esri.ready.html +1 -0
- package/docs/html/interfaces/data_PopupContentExtension.ContentProperties.html +33 -3
- package/docs/html/interfaces/data_support_attachments.AttachmentEnabledLayer.html +1 -13
- package/docs/html/interfaces/portal_PopupInfo.PopupElement.html +30 -3
- package/docs/html/interfaces/portal_SubtypeGroupLayer.SubtypeGroupLayer-1.html +1 -1
- package/docs/html/interfaces/portal_SubtypeGroupLayer.SubtypeSubtypeGroupLayer.html +1 -1
- package/docs/html/interfaces/portal_WMSLayer.WMSLayer-1.html +1 -1
- package/docs/html/modules/utilities_esri.html +2 -0
- package/docs/html/types/portal_PopupInfo.PopupElementType.html +1 -1
- package/docs/html/types/portal__LayerBase.LayerType.html +1 -1
- package/docs/html/types/support_esri.FeatureLayerElevationInfo.html +1 -1
- package/docs/html/variables/version.version.html +1 -1
- package/mapping/BasemapExtension.js +1 -1
- package/mapping/BuildingGroupSublayerExtension.js +1 -1
- package/mapping/BuildingSceneLayerExtension.js +1 -1
- package/mapping/GroundExtension.js +1 -1
- package/mapping/GroupLayerExtension.d.ts +1 -1
- package/mapping/GroupLayerExtension.js +1 -1
- package/mapping/ImageryLayerExtension.js +1 -1
- package/mapping/KMLLayerExtension.js +1 -1
- package/mapping/KMLSublayerExtension.js +1 -1
- package/mapping/MapExtension.js +1 -1
- package/mapping/SubtypeGroupLayerExtension.js +1 -1
- package/mapping/SubtypeSublayerExtension.js +1 -1
- package/mapping/WMSLayerExtension.js +1 -1
- package/mapping/WMSSublayerExtension.js +1 -1
- package/mapping/WMTSLayerExtension.js +1 -1
- package/mapping/_LayerExtension.js +1 -1
- package/mapping/_SublayerExtension.d.ts +1 -1
- package/mapping/_SublayerExtension.js +1 -1
- package/mapping/support/ArrayWrappedCollection.d.ts +1 -1
- package/mapping/support/ArrayWrappedCollection.js +1 -1
- package/mapping/support/DefaultLayerExtensionFactory.js +1 -1
- package/mapping/support/_LayerExtensionCollection.d.ts +2 -2
- package/mapping/support/_LayerExtensionCollection.js +1 -1
- package/mapping/support/_SublayerExtensionCollection.d.ts +2 -2
- package/mapping/support/_SublayerExtensionCollection.js +1 -1
- package/menus/Menu.js +1 -1
- package/package.json +3 -3
- package/portal/LayerBase.js +1 -1
- package/portal/PopupInfo.d.ts +22 -4
- package/portal/PopupInfo.js +1 -1
- package/portal/SubtypeGroupLayer.d.ts +2 -2
- package/portal/SubtypeGroupLayer.js +1 -1
- package/portal/SubtypeSublayer.js +1 -1
- package/portal/WMSLayer.d.ts +1 -1
- package/portal/WMSLayer.js +1 -1
- package/portal/_LayerBase.d.ts +1 -1
- package/support/esri.d.ts +1 -1
- package/tasks/identify/CSVLayerClientSideQueryIdentifyProvider.js +1 -1
- package/tasks/identify/ImageryLayerIdentifyProvider.js +1 -1
- package/utilities/CollectionProxy.d.ts +4 -4
- package/utilities/CollectionProxy.js +1 -1
- package/utilities/CopyOnWriteCollection.d.ts +2 -2
- package/utilities/CopyOnWriteCollection.js +1 -1
- package/utilities/ReadOnlyCollection.d.ts +3 -4
- package/utilities/esri.d.ts +7 -0
- package/utilities/esri.js +1 -1
- package/utilities/extensions.js +1 -1
- package/utilities/geometry.js +1 -1
- package/utilities/symbol.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -25,7 +25,7 @@ export declare class CopyOnWriteCollection<T> extends CollectionProxy<T> {
|
|
|
25
25
|
/**
|
|
26
26
|
* @inheritDoc
|
|
27
27
|
*/
|
|
28
|
-
add(item: T, index?: number):
|
|
28
|
+
add(item: T, index?: number): this;
|
|
29
29
|
/**
|
|
30
30
|
* @inheritDoc
|
|
31
31
|
*/
|
|
@@ -41,7 +41,7 @@ export declare class CopyOnWriteCollection<T> extends CollectionProxy<T> {
|
|
|
41
41
|
/**
|
|
42
42
|
* @inheritDoc
|
|
43
43
|
*/
|
|
44
|
-
sort(compareFunction?: (a: T, b: T) => number):
|
|
44
|
+
sort(compareFunction?: (a: T, b: T) => number): this;
|
|
45
45
|
/**
|
|
46
46
|
* Forks the collection by making a copy of the original.
|
|
47
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Collection}from"../utilities/collection.js";import{CollectionProxy}from"./CollectionProxy.js";import{checkArg}from"./checkArg.js";export class CopyOnWriteCollection extends CollectionProxy{constructor(o){super(o),checkArg("collection",o).isNotMissing(),this._originalCollection=o}get originalCollection(){return this._originalCollection}set originalCollection(o){checkArg("value",o).isNotMissing(),this.isModified||(this._collection=o),this._originalCollection=o}get isModified(){return this._collection!==this.originalCollection}clone(){const o=new CopyOnWriteCollection(this.originalCollection);return this.isModified&&(o._collection=this._cloneCollection(this._collection)),o}add(o,i){this._copy(),super.add(o,i)}removeAt(o){return this._copy(),super.removeAt(o)}reorder(o,i){return this._copy(),super.reorder(o,i)}reset(){this.isModified&&(this._collection=this._originalCollection)}sort(o){this._copy(),super.sort(o)}_copy(){this.isModified||(this._collection=this._cloneCollection(this.originalCollection))}_cloneCollection(o){return new Collection(o.toArray())}}
|
|
1
|
+
import{Collection}from"../utilities/collection.js";import{CollectionProxy}from"./CollectionProxy.js";import{checkArg}from"./checkArg.js";export class CopyOnWriteCollection extends CollectionProxy{constructor(o){super(o),checkArg("collection",o).isNotMissing(),this._originalCollection=o}get originalCollection(){return this._originalCollection}set originalCollection(o){checkArg("value",o).isNotMissing(),this.isModified||(this._collection=o),this._originalCollection=o}get isModified(){return this._collection!==this.originalCollection}clone(){const o=new CopyOnWriteCollection(this.originalCollection);return this.isModified&&(o._collection=this._cloneCollection(this._collection)),o}add(o,i){return this._copy(),super.add(o,i)}removeAt(o){return this._copy(),super.removeAt(o)}reorder(o,i){return this._copy(),super.reorder(o,i)}reset(){this.isModified&&(this._collection=this._originalCollection)}sort(o){return this._copy(),super.sort(o)}_copy(){this.isModified||(this._collection=this._cloneCollection(this.originalCollection))}_cloneCollection(o){return new Collection(o.toArray())}}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CollectionProxy } from "./CollectionProxy.js";
|
|
2
|
-
import type { Collection } from "./collection.js";
|
|
3
2
|
/**
|
|
4
3
|
* A read-only collection.
|
|
5
4
|
*/
|
|
@@ -7,7 +6,7 @@ export declare class ReadOnlyCollection<T> extends CollectionProxy<T> {
|
|
|
7
6
|
/**
|
|
8
7
|
* @inheritDoc
|
|
9
8
|
*/
|
|
10
|
-
add(_item: T, _index?: number):
|
|
9
|
+
add(_item: T, _index?: number): this;
|
|
11
10
|
/**
|
|
12
11
|
* @inheritDoc
|
|
13
12
|
*/
|
|
@@ -23,11 +22,11 @@ export declare class ReadOnlyCollection<T> extends CollectionProxy<T> {
|
|
|
23
22
|
/**
|
|
24
23
|
* @inheritDoc
|
|
25
24
|
*/
|
|
26
|
-
reverse():
|
|
25
|
+
reverse(): this;
|
|
27
26
|
/**
|
|
28
27
|
* @inheritDoc
|
|
29
28
|
*/
|
|
30
|
-
sort(_compareFunction?: (a: T, b: T) => number):
|
|
29
|
+
sort(_compareFunction?: (a: T, b: T) => number): this;
|
|
31
30
|
/**
|
|
32
31
|
* @inheritDoc
|
|
33
32
|
*/
|
package/utilities/esri.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type EsriExpressionContent from "@arcgis/core/popup/content/ExpressionCon
|
|
|
14
14
|
import type EsriFieldsContent from "@arcgis/core/popup/content/FieldsContent";
|
|
15
15
|
import type ImageMediaInfo from "@arcgis/core/popup/content/ImageMediaInfo";
|
|
16
16
|
import type EsriMediaContent from "@arcgis/core/popup/content/MediaContent";
|
|
17
|
+
import type EsriRelationshipContent from "@arcgis/core/popup/content/RelationshipContent";
|
|
17
18
|
import type EsriTextContent from "@arcgis/core/popup/content/TextContent";
|
|
18
19
|
import type PortalItem from "@arcgis/core/portal/PortalItem";
|
|
19
20
|
import type FeatureSet from "@arcgis/core/rest/support/FeatureSet";
|
|
@@ -114,6 +115,12 @@ export declare function isMediaContent(content: unknown): content is EsriMediaCo
|
|
|
114
115
|
* @param content The content to check.
|
|
115
116
|
*/
|
|
116
117
|
export declare function isTextContent(content: unknown): content is EsriTextContent;
|
|
118
|
+
/**
|
|
119
|
+
* Returns true if content is an Esri RelationshipContent.
|
|
120
|
+
*
|
|
121
|
+
* @param content The content to check.
|
|
122
|
+
*/
|
|
123
|
+
export declare function isRelationshipContent(content: unknown): content is EsriRelationshipContent;
|
|
117
124
|
/**
|
|
118
125
|
* Returns true if content is an Esri PopupContent.
|
|
119
126
|
*
|
package/utilities/esri.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function load(e){e&&"function"==typeof e.load&&await e.load(),await ready(e)}export async function ready(e){e&&"function"==typeof e.when&&await e.when()}export function getAllFieldInfos(e){if(!e)return;const t=Array.isArray(e.content)?e.content.filter((e=>"fields"===e.type)).map((e=>e.fieldInfos||[])):[];return(e.fieldInfos||[]).concat(...t)}const FIELD_TOKEN_REGEX=/\{(expression[\\/])?[\w.]+\}/g,RELATIONSHIP_TOKEN_REGEX=/\{relationships[\\/][\w.]+[\\/][\w.]+\}/g,FIELD_ARCADE_REGEX=/\$feature\.([\w.]+)|\$feature\["([\w.]+)"\]/g;export function getAllReferencedFieldNames(e){if(!e)return;const t=new Set,n=[],r=[];return n.push(e.title),e.expressionInfos&&e.expressionInfos.forEach((e=>{r.push(e.expression,e.title)})),Array.isArray(e.content)?e.content.forEach((e=>{if("text"===e.type)n.push(e.text);else if("media"===e.type){let r=e.mediaInfos||[];r=Array.isArray(r)?r:[r],r.forEach((e=>{n.push(e.title,e.caption),isImageMediaInfo(e)?e.value&&n.push(e.value.linkURL,e.value.sourceURL):e.value&&(t.add(e.value.tooltipField),t.add(e.value.normalizeField),(e.value.fields||[]).forEach((e=>t.add(e))))}))}})):"string"==typeof e.content&&n.push(e.content),r.filter((e=>!!e)).forEach((e=>{const n=e.matchAll(FIELD_ARCADE_REGEX);for(const e of n)t.add(e[1]??e[2])})),n.filter((e=>!!e)).forEach((e=>{let n;const r=new RegExp(FIELD_TOKEN_REGEX),o=new RegExp(RELATIONSHIP_TOKEN_REGEX),s=r=>{const o=new RegExp(r);for(n=o.exec(e);n&&"string"==typeof n[0]&&void 0===n[1];)t.add(n[0].replace(/\{|\}/g,"").split(":")[0]),n=o.exec(e)};s(r),s(o)})),Array.from(t.values()).filter((e=>!!e))}export function isCodedValueDomain(e){return"esri.layers.support.CodedValueDomain"===e?.declaredClass}export function isColor(e){return"esri.Color"===e?.declaredClass}export function isImageMediaInfo(e){return"esri.popup.content.ImageMediaInfo"===e?.declaredClass}export function isPopupTemplate(e){return"esri.PopupTemplate"===e?.declaredClass}export function isField(e){return"esri.layers.support.Field"===e?.declaredClass}export function isAttachmentsContent(e){return"esri.popup.content.AttachmentsContent"===e?.declaredClass}export function isCustomContent(e){return"esri.popup.content.CustomContent"===e?.declaredClass}export function isExpressionContent(e){return"esri.popup.content.ExpressionContent"===e?.declaredClass}export function isFieldsContent(e){return"esri.popup.content.FieldsContent"===e?.declaredClass}export function isMediaContent(e){return"esri.popup.content.MediaContent"===e?.declaredClass}export function isTextContent(e){return"esri.popup.content.TextContent"===e?.declaredClass}export function isPopupContent(e){return isAttachmentsContent(e)||isExpressionContent(e)||isCustomContent(e)||isFieldsContent(e)||isTextContent(e)||isMediaContent(e)}export function isFeatureSet(e){return"esri.rest.support.FeatureSet"===e?.declaredClass}export function isFeatureType(e){return"esri.layers.support.FeatureType"===e?.declaredClass}export function isViewpoint(e){return"esri.Viewpoint"===e?.declaredClass}export function isPortalItem(e){return"esri.portal.PortalItem"===e?.declaredClass}export function isGraphic(e){return"esri.Graphic"===e?.declaredClass}export function isSpatialReference(e){return"esri.geometry.SpatialReference"===e?.declaredClass}export function isEsriObject(e){return!!e?.declaredClass}
|
|
1
|
+
export async function load(e){e&&"function"==typeof e.load&&await e.load(),await ready(e)}export async function ready(e){e&&"function"==typeof e.when&&await e.when()}export function getAllFieldInfos(e){if(!e)return;const t=Array.isArray(e.content)?e.content.filter((e=>"fields"===e.type)).map((e=>e.fieldInfos||[])):[];return(e.fieldInfos||[]).concat(...t)}const FIELD_TOKEN_REGEX=/\{(expression[\\/])?[\w.]+\}/g,RELATIONSHIP_TOKEN_REGEX=/\{relationships[\\/][\w.]+[\\/][\w.]+\}/g,FIELD_ARCADE_REGEX=/\$feature\.([\w.]+)|\$feature\["([\w.]+)"\]/g;export function getAllReferencedFieldNames(e){if(!e)return;const t=new Set,n=[],r=[];return n.push(e.title),e.expressionInfos&&e.expressionInfos.forEach((e=>{r.push(e.expression,e.title)})),Array.isArray(e.content)?e.content.forEach((e=>{if("text"===e.type)n.push(e.text);else if("media"===e.type){let r=e.mediaInfos||[];r=Array.isArray(r)?r:[r],r.forEach((e=>{n.push(e.title,e.caption),isImageMediaInfo(e)?e.value&&n.push(e.value.linkURL,e.value.sourceURL):e.value&&(t.add(e.value.tooltipField),t.add(e.value.normalizeField),(e.value.fields||[]).forEach((e=>t.add(e))))}))}})):"string"==typeof e.content&&n.push(e.content),r.filter((e=>!!e)).forEach((e=>{const n=e.matchAll(FIELD_ARCADE_REGEX);for(const e of n)t.add(e[1]??e[2])})),n.filter((e=>!!e)).forEach((e=>{let n;const r=new RegExp(FIELD_TOKEN_REGEX),o=new RegExp(RELATIONSHIP_TOKEN_REGEX),s=r=>{const o=new RegExp(r);for(n=o.exec(e);n&&"string"==typeof n[0]&&void 0===n[1];)t.add(n[0].replace(/\{|\}/g,"").split(":")[0]),n=o.exec(e)};s(r),s(o)})),Array.from(t.values()).filter((e=>!!e))}export function isCodedValueDomain(e){return"esri.layers.support.CodedValueDomain"===e?.declaredClass}export function isColor(e){return"esri.Color"===e?.declaredClass}export function isImageMediaInfo(e){return"esri.popup.content.ImageMediaInfo"===e?.declaredClass}export function isPopupTemplate(e){return"esri.PopupTemplate"===e?.declaredClass}export function isField(e){return"esri.layers.support.Field"===e?.declaredClass}export function isAttachmentsContent(e){return"esri.popup.content.AttachmentsContent"===e?.declaredClass}export function isCustomContent(e){return"esri.popup.content.CustomContent"===e?.declaredClass}export function isExpressionContent(e){return"esri.popup.content.ExpressionContent"===e?.declaredClass}export function isFieldsContent(e){return"esri.popup.content.FieldsContent"===e?.declaredClass}export function isMediaContent(e){return"esri.popup.content.MediaContent"===e?.declaredClass}export function isTextContent(e){return"esri.popup.content.TextContent"===e?.declaredClass}export function isRelationshipContent(e){return"esri.popup.content.RelationshipContent"===e?.declaredClass}export function isPopupContent(e){return isAttachmentsContent(e)||isExpressionContent(e)||isCustomContent(e)||isFieldsContent(e)||isTextContent(e)||isMediaContent(e)||isRelationshipContent(e)}export function isFeatureSet(e){return"esri.rest.support.FeatureSet"===e?.declaredClass}export function isFeatureType(e){return"esri.layers.support.FeatureType"===e?.declaredClass}export function isViewpoint(e){return"esri.Viewpoint"===e?.declaredClass}export function isPortalItem(e){return"esri.portal.PortalItem"===e?.declaredClass}export function isGraphic(e){return"esri.Graphic"===e?.declaredClass}export function isSpatialReference(e){return"esri.geometry.SpatialReference"===e?.declaredClass}export function isEsriObject(e){return!!e?.declaredClass}
|
package/utilities/extensions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isLayerExtension,isSublayerExtension,isTableExtension}from"../ItemType.js";import{isBuildingComponentSublayer,isMapImageSublayer,isSubtypeSublayer,isWMSSublayer}from"./layers.js";export function isArcGISServiceTableExtension(e){return isTableExtension(e)&&"ArcGISServiceTable"===e.getDefaults().table.$tableType}export function isGroupLayerExtension(e){return isLayerExtension(e)&&!!e.layerExtensions}export function isFeatureLayerExtension(e){return isLayerExtension(e)&&"ArcGISFeatureLayer"===e.getDefaults().layer?.layerType}export function isSubtypeSublayerExtension(e){return isSublayerExtension(e)&&(isSubtypeSublayer(e.sublayer)||"SubtypeSublayer"===e._deferredSublayerProperties?.$sublayerType)}export function isSubtypeGroupLayerExtension(e){return isLayerExtension(e)&&"
|
|
1
|
+
import{isLayerExtension,isSublayerExtension,isTableExtension}from"../ItemType.js";import{isBuildingComponentSublayer,isMapImageSublayer,isSubtypeSublayer,isWMSSublayer}from"./layers.js";export function isArcGISServiceTableExtension(e){return isTableExtension(e)&&"ArcGISServiceTable"===e.getDefaults().table.$tableType}export function isGroupLayerExtension(e){return isLayerExtension(e)&&!!e.layerExtensions}export function isFeatureLayerExtension(e){return isLayerExtension(e)&&"ArcGISFeatureLayer"===e.getDefaults().layer?.layerType}export function isSubtypeSublayerExtension(e){return isSublayerExtension(e)&&(isSubtypeSublayer(e.sublayer)||"SubtypeSublayer"===e._deferredSublayerProperties?.$sublayerType)}export function isSubtypeGroupLayerExtension(e){return isLayerExtension(e)&&"SubtypeGroupLayer"===e.getDefaults().layer?.layerType}export function isFeatureCollectionLayerExtension(e){return isLayerExtension(e)&&"feature-collection-layer"===e._getSerializableLayerType?.()}export function isCSVLayerExtension(e){return isLayerExtension(e)&&"CSV"===e.getDefaults().layer.layerType}export function isGeoRssLayerExtension(e){return isLayerExtension(e)&&"GeoRSS"===e.getDefaults().layer.layerType}export function isImageryLayerExtension(e){return isLayerExtension(e)&&"ArcGISImageServiceLayer"===e.getDefaults().layer.layerType}export function isSceneLayerExtension(e){return isLayerExtension(e)&&"ArcGISSceneServiceLayer"===e.getDefaults().layer.layerType}export function isStreamLayerExtension(e){return isLayerExtension(e)&&"ArcGISStreamLayer"===e.getDefaults().layer.layerType}export function isMapImageLayerExtension(e){return isLayerExtension(e)&&"ArcGISMapServiceLayer"===e.getDefaults().layer.layerType}export function isTileLayerExtension(e){return isLayerExtension(e)&&"ArcGISTiledMapServiceLayer"===e.getDefaults().layer.layerType}export function isWMSLayerExtension(e){return isLayerExtension(e)&&"WMS"===e.getDefaults().layer.layerType}export function isWMSSublayerExtension(e){return isSublayerExtension(e)&&(isWMSSublayer(e.sublayer)||"WMSSublayer"===e._deferredSublayerProperties?.$sublayerType)}export function isMapImageSublayerExtension(e){return isSublayerExtension(e)&&(isMapImageSublayer(e.sublayer)||"ArcGISMapServiceSublayer"===e._deferredSublayerProperties?.$sublayerType)}export function isWMTSLayerExtension(e){if(!isLayerExtension(e))return!1;const r=e.getDefaults().layer;return"WebTiledLayer"===r.layerType&&!!r.wmtsInfo}export function isKMLLayerExtension(e){return isLayerExtension(e)&&"KML"===e.getDefaults().layer.layerType}export function isBuildingSceneLayerExtension(e){return isLayerExtension(e)&&"BuildingSceneLayer"===e.getDefaults().layer.layerType}export function isPointCloudLayerExtension(e){return isLayerExtension(e)&&"PointCloudLayer"===e.getDefaults().layer.layerType}export function isBuildingComponentSublayerExtension(e){return isSublayerExtension(e)&&(isBuildingComponentSublayer(e.sublayer)||"BuildingComponentSublayer"===e._deferredSublayerProperties?.$sublayerType)}
|
package/utilities/geometry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Extent from"@arcgis/core/geometry/Extent";import Multipoint from"@arcgis/core/geometry/Multipoint";import Point from"@arcgis/core/geometry/Point";import Polygon from"@arcgis/core/geometry/Polygon";import Polyline from"@arcgis/core/geometry/Polyline";import SpatialReference from"@arcgis/core/geometry/SpatialReference";import{buffer as esriBuffer,difference,geodesicBuffer as esriGeodesicBuffer,union}from"@arcgis/core/geometry/geometryEngine";import{isLoaded,load,getTransformation,project as projectionEngineProject}from"@arcgis/core/geometry/projection";import{canProject,project as webMercatorProject}from"@arcgis/core/geometry/support/webMercatorUtils";import{buffer as esriGeometryServiceBuffer,project as esriGeometryServiceProject}from"@arcgis/core/rest/geometryService";import BufferParameters from"@arcgis/core/rest/support/BufferParameters";import ProjectParameters from"@arcgis/core/rest/support/ProjectParameters";import{ArgumentError}from"../ArgumentError.js";import{config}from"../config.js";import{GeometryServiceError}from"./GeometryServiceError.js";import{getGmlNS,ogcSrsToEsriSr}from"./_ogc.js";import{groupBy}from"./array.js";import{checkArg}from"./checkArg.js";import{isEsriObject}from"./esri.js";import{parse}from"./number.js";export{}from"./transformation.js";const wktRegex=/^(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON)\s(?:(ZM|Z|M)\s)?(\(.+\))$/,wktPointRegex=/^\(?([-\d.]+)\s([-\d.]+)(?:\s([-\d.]+))?(?:\s([-\d.]+))?\)?$/,wktArrayRegex=/^\(([-\d.\s(),]+)\)$/,gmlToEsriParseError="Unable to convert the GML geometry into an Esri geometry.",DEFAULT_GEOMETRY_SERVICE_URL="https://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer",wktNameRegex=/^(PROJCS|GEOGCS|VERTCS|GEOGTRAN|VERTTRAN)\s?\[\s?"(\w+)",.*/,commonWktStrings={4326:{name:"GCS_WGS_1984",wkt:'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'},102100:{name:"WGS_1984_Web_Mercator_Auxiliary_Sphere",wkt:'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]'}},wktModules={PROJCS:"projected",GEOGCS:"geographic",VERTCS:"vertical",GEOGTRAN:"transformations",VERTTRAN:"vertical-transformations"},wktData={};export class CoordinateSystemBounds{constructor(e){this.limit=e}get min(){return-this.limit}get max(){return this.limit}get range(){return 2*this.limit}}export const WEB_MERCATOR_BOUNDS=new CoordinateSystemBounds(20037508.342788905);export const GEOGRAPHIC_BOUNDS=new CoordinateSystemBounds(180);export function getBounds(e){return e.isWebMercator?WEB_MERCATOR_BOUNDS:e.isGeographic?GEOGRAPHIC_BOUNDS:void 0}export function getScreenExtent(e){if(!e||0===e.length)return;let r,t,n,o;const{spatialReference:i}=e[0];let s;i.isWebMercator?s=WEB_MERCATOR_BOUNDS:i.isGeographic&&(s=GEOGRAPHIC_BOUNDS);const a=(e,i)=>{(!t||e>t)&&(t=e),(!r||e<r)&&(r=e),(!o||i>o)&&(o=i),(!n||i<n)&&(n=i)},c=e=>s&&Math.sign(e.extent.xmax)!==Math.sign(e.extent.xmin),m=e=>{const r=c(e)?denormalize([e.points],s)[0]:e.points;for(const e of r)a(e[0],e[1])},l=e=>{const r=c(e)?denormalize(e.rings,s):e.rings;for(const e of r)for(const r of e)a(r[0],r[1])},g=e=>{const r=c(e)?denormalize(e.paths,s):e.paths;for(const e of r)for(const r of e)a(r[0],r[1])};for(const r of e.filter((e=>e.spatialReference.equals(i))))switch(r.type){case"point":a(r.x,r.y);break;case"multipoint":m(r);break;case"extent":l(Polygon.fromExtent(r));break;case"polyline":g(r);break;case"polygon":l(r);break;default:throw new Error(`Cannot determine a valid screen extent for geometry type ${r.type}`)}return new Extent({xmin:r>t?t:r,xmax:t<r?r:t,ymin:n,ymax:o,spatialReference:i})}function denormalize(e,r){if(!r)return e;const t=[...e];let n=-1/0,o=1/0;for(let e of t){let t=-1/0,i=1/0;for(const n of e){for(;n[0]<r.min;)n[0]+=r.range;for(;n[0]>r.max;)n[0]-=r.range;i=Math.min(i,n[0]),t=Math.max(t,n[0])}let s=Math.min(o,i),a=Math.max(n,t);if(a-s>r.limit){t=-1/0,i=1/0;const c=[...e];for(const e of c)e[0]<0?e[0]+=r.range:e[0]-=r.range,i=Math.min(i,e[0]),t=Math.max(t,e[0]);const m=Math.min(o,i),l=Math.max(n,t);l-m<a-s&&(e=c,s=m,a=l)}o=Math.min(s,i),n=Math.max(a,t)}return t}export function denormalizeExtent(e,r){if(!r)return e;const t=Polygon.fromExtent(e);return t.rings=denormalize(t.rings,r),t.extent}export function esriToWKT(e){checkArg("geometry",e).isNotMissing();const r=`${e.hasZ?"Z":""}${e.hasM?"M":""}${e.hasM||e.hasZ?" ":""}`;if(isPoint(e)){const{x:t,y:n,z:o,m:i}=e,s=[t,n];return e.hasZ&&s.push(o),e.hasM&&s.push(i),`POINT ${r}(${_createWktPoint(s)})`}if(isMultipoint(e))return`MULTIPOINT ${r}(${_createWktPointArray(e.points)})`;if(isPolyline(e))return e.paths.length>1?`MULTILINESTRING ${r}(${_createWkt2DPointArray(e.paths)})`:`LINESTRING ${r}(${_createWktPointArray(e.paths[0])})`;if(isPolygon(e))return`POLYGON ${r}(${_createWkt2DPointArray(e.rings)})`;if(isExtent(e)){const t=[e.xmin,e.ymax];return`POLYGON ${r}(${_createWkt2DPointArray([[t,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],t]])})`}throw new ArgumentError("Cannot determine what type of WKT geometry to create")}export function wktToEsri(e,r){checkArg("geometry",e).isNotMissing();const t=e.match(wktRegex);if(t){const e=t[2]?.includes("Z"),n=t[2]?.includes("M");switch(t[1]){case"POINT":{const o=_parseWktPoint(t[3],t[2]);return new Point({x:o[0],y:o[1],z:e?o[2]:void 0,m:!e&&n?o[2]:n?o[3]:void 0,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"MULTIPOINT":{const o=_parseWktPointArray(t[3],t[2]);return new Multipoint({points:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"LINESTRING":{const o=_parseWktPointArray(t[3],t[2]);return new Polyline({paths:[o],hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"MULTILINESTRING":{const o=_parseWkt2DPointArray(t[3],t[2]);return new Polyline({paths:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"POLYGON":{const o=_parseWkt2DPointArray(t[3],t[2]);return new Polygon({rings:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}}}throw new ArgumentError("Cannot determine what type of esri geometry to create")}export function esriToGeoJSON(e){if(checkArg("geometry",e).isNotMissing(),isPoint(e)){const{x:r,y:t}=e;return{type:"Point",coordinates:[r,t]}}if(isMultipoint(e))return{type:"MultiPoint",coordinates:e.points};if(isPolyline(e))return e.paths.length>1?{type:"MultiLineString",coordinates:e.paths}:{type:"LineString",coordinates:e.paths[0]};if(isPolygon(e))return{type:"Polygon",coordinates:e.rings};if(isExtent(e)){const r=[e.xmin,e.ymax];return{type:"Polygon",coordinates:[[r,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],r]]}}throw new ArgumentError("Cannot determine what type of WKT geometry to create")}export function geoJSONToEsri(e){switch(checkArg("geometry",e).isNotMissing(),checkArg("geometry.type",e.type).isNotMissing(),e.type){case"Point":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPoint),new Point({x:e.coordinates[0],y:e.coordinates[1],spatialReference:SpatialReference.WGS84});case"MultiPoint":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPointArray),new Multipoint({points:e.coordinates,spatialReference:SpatialReference.WGS84});case"LineString":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPointArray),new Polyline({paths:[e.coordinates],spatialReference:SpatialReference.WGS84});case"MultiLineString":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArray),new Polyline({paths:e.coordinates,spatialReference:SpatialReference.WGS84});case"Polygon":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArray),new Polygon({rings:e.coordinates,spatialReference:SpatialReference.WGS84});case"MultiPolygon":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArrayArray),new Polygon({rings:e.coordinates.flat(),spatialReference:SpatialReference.WGS84})}throw new ArgumentError("Cannot determine what type of esri geometry to create")}export function gmlToEsri(e){switch(checkArg("geometry",e).isNotMissing(),e.localName){case"Point":return _createEsriPoint(e);case"MultiPoint":return _createEsriMultiPoint(e);case"LineString":case"Curve":case"MultiLineString":case"MultiCurve":return _createEsriPolyline(e);case"Polygon":case"MultiPolygon":return _createEsriPolygon(e);case"Envelope":return _createEsriExtent(e);default:throw new ArgumentError("Unrecognized geometry type.")}}export function esriToGml(e,r){switch(checkArg("geometry",e).isNotMissing(),checkArg("geometry type",e.type).isNotMissing(),checkArg("gmlVersion",r.gmlVersion).isNotMissing(),e.type){case"point":return _createGmlPointElement(e,r);case"polyline":return _createGmlLineStringElement(e,r);case"polygon":case"extent":return _createGmlPolygonElement(e,r);default:throw new ArgumentError(`Unrecognized geometry type: ${e.type}. Must be one of point, polyline or polygon.`)}}export async function esriWkidToWkt(e){checkArg("wkid",e).isNotMissing();let r=commonWktStrings[`${e}`];if(!r)for(const t of Object.keys(wktModules)){const n=wktModules[t];if(r=(await fetchEsriProjCodes(n))[e],r){const t=r.wkt.match(wktNameRegex);commonWktStrings[e]={name:t[2],wkt:r.wkt};break}}if(!r)throw new Error(`Failed to find Wkt for id ${e}`);return r.wkt}export async function esriWktToWkid(e){checkArg("wkt",e).isNotMissing();const r=e.match(wktNameRegex);if(r){let e=Object.keys(commonWktStrings).find((e=>commonWktStrings[e].name===r[2]));if(!e){const t=wktModules[r[1]];if(t){const n=await fetchEsriProjCodes(t);e=Object.keys(n).find((e=>n[e].name===r[2])),e&&(commonWktStrings[e]={name:r[2],wkt:n[e].wkt})}}if(e)return parseInt(e)}throw new Error(`Failed to find Wkid for ${e}`)}export function createCrossTypeUnion(e){const r=[],t=groupBy(e,(e=>e.type));for(const e of GEOM_ORDER){const n=t.get(e);let o;if(n?.length){o=n.length>1?union(n):n[0];for(const e of r)o=difference(o,e);o&&r.push(o)}}return r}const GEOM_ORDER=["mesh","extent","polygon","polyline","multipoint","point"];async function fetchEsriProjCodes(e){if(void 0===wktData[e])switch(e){case wktModules.GEOGCS:wktData[e]=(await import("esri-proj-codes/geographic.json")).default;break;case wktModules.PROJCS:wktData[e]=(await import("esri-proj-codes/projected.json")).default;break;case wktModules.GEOGTRAN:wktData[e]=(await import("esri-proj-codes/transformations.json")).default;break;case wktModules.VERTCS:wktData[e]=(await import("esri-proj-codes/vertical.json")).default;break;case wktModules.VERTTRAN:wktData[e]=(await import("esri-proj-codes/vertical-transformations.json")).default}const r=wktData[e];if(!r)throw new Error(`Invalid esri-proj-codes module: ${e}`);return r}export async function project(e,r,t){checkArg("geometries",e).isNotMissing().satisfies(_geometriesAreUniform,"All geometries must have the same type and spatial reference."),checkArg("outSpatialReference",r).isNotMissing();const n=Array.from(e);if(n.length<=0)return n;const o=_getInputSpatialReference(e),i=_getProjectOptions(o,r,t);if(void 0===i){if(o.equals(r))return n;if(canProject(o,r))return n.map((e=>webMercatorProject(e,r)));if(isLoaded()||await load(),null!==getTransformation(o,r)){const e=projectionEngineProject(n,r);return Array.isArray(e)?e:[e]}}if(i&&i.steps.length>1)throw new ArgumentError("GeographicTransformation","Geometry Service can't handle a two step transformation");return _projectWithGeometryService(n,r,i)}export async function buffer(e,r,t,n=!1){const o=Array.isArray(e),i=Array.isArray(r);if(o!==i)throw new ArgumentError("Geometries and distances must be the same type.");const s=Array.isArray(e)?e[0].spatialReference:e.spatialReference;if(s.isWebMercator||s.isWGS84)return esriGeodesicBuffer(e,r,t,n);if(s.isGeographic){const s=new BufferParameters({geometries:o?e:[e],distances:i?r:[r],unit:t,unionResults:n});return esriGeometryServiceBuffer(getGeometryServiceUrl(),s)}return esriBuffer(e,r,t,n)}export function removeZValues(e){const r=e;switch(r.type){case"point":r.z=void 0;break;case"polyline":case"polygon":_removeZCoords(r.paths||r.rings,r.hasM).forEach(((e,t)=>e.forEach(((e,n)=>r.setPoint(t,n,e)))));break;case"extent":r.zmax=void 0,r.zmin=void 0}return r}function _removeZCoords(e,r=!1){const t=r?3:2;return e.map((e=>e.map((e=>e.slice(0,t)))))}function _createWktPoint(e){return e.join(" ")}function _createWktPointArray(e){return e.map(_createWktPoint).join(", ")}function _createWkt2DPointArray(e){return e.map((e=>`(${_createWktPointArray(e)})`)).join(", ")}function _parseInvariant(e){return parse({locale:"inv"},e)}function _parseWktPoint(e,r){const t=r??"",n=e.match(wktPointRegex);if(n){const e=[_parseInvariant(n[1]),_parseInvariant(n[2])];return(t.includes("Z")||!t.includes("Z")&&t.includes("M"))&&n[3]&&e.push(_parseInvariant(n[3])),t.includes("M")&&n[4]&&e.push(_parseInvariant(n[4])),e}throw new ArgumentError(`Detected invalid WKT point: ${e}`)}function _parseWktPointArray(e,r){const t=e.match(wktArrayRegex);if(t)return _parseWktArray(t[1]).map((e=>_parseWktPoint(e,r)));throw new ArgumentError(`Detected invalid WKT point array: ${e}`)}function _parseWkt2DPointArray(e,r){const t=e.match(wktArrayRegex);if(t)return _parseWktArray(t[1]).map((e=>_parseWktPointArray(e,r)));throw new ArgumentError(`Detected invalid WKT 2D point array: ${e}`)}function _parseWktArray(e){let r=e.trim().replace(/\s*,\s*/g,","),t=0;for(let e=0;e<r.length;e++)switch(r.charAt(e)){case"(":t++;break;case")":t--;break;case",":0===t&&(r=`${r.substr(0,e)}&${r.substr(e+1)}`)}return r.split("&")}function _isGeoJSONPoint(e){return!!Array.isArray(e)&&!e.some((e=>"number"!=typeof e))}function _isGeoJSONPointArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSONPoint(e)))}function _isGeoJSON2DPointArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSONPointArray(e)))}function _isGeoJSON2DPointArrayArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSON2DPointArray(e)))}async function _projectWithGeometryService(e,r,t){const n=new ProjectParameters({geometries:e,outSpatialReference:r});t?.hasOwnProperty("transformation")&&(n.transformation=t.steps[0].wkid?{wkid:t.steps[0].wkid}:{wkt:t.steps[0].wkt},n.transformForward=!t.hasOwnProperty("transformForward")||!t.steps[0].isInverse);try{return await esriGeometryServiceProject(getGeometryServiceUrl(),n)}catch(e){throw e instanceof Error?new GeometryServiceError(e):e}}function _geometriesAreUniform(e){const r=[...e];if(!(r.length>0))return!0;const t=r[0].type,n=r[0].spatialReference;return r.every((e=>e.type===t&&e.spatialReference.equals(n)))}function _getInputSpatialReference(e){for(const r of e)if(null!==r?.spatialReference)return r.spatialReference;return SpatialReference.WebMercator}function _getProjectOptions(e,r,t){return t?.hasOwnProperty("steps")?{...t}:_getTransformProjectOptions(e,r)}function _getTransformProjectOptions(e,r){if(checkArg("inSr",e).isNotMissing(),checkArg("outSR",r).isNotMissing(),0===config.autoTransformations.length)return;const t=config.autoTransformations.filter((r=>r.inSpatialReference.equals(e))).filter((e=>e.outSpatialReference.equals(r)));if(t.length>0)return{...t[0].transformation};const n=config.autoTransformations.filter((e=>e.inSpatialReference.equals(r))).filter((r=>r.outSpatialReference.equals(e)));return n.length>0?{...n[0].transformation}:void 0}function _createEsriExtent(e){const r=_getEsriSpatialReference(e),t=_parseGmlCorners(e);if(2===t.length){const[e,n]=t;return new Extent({spatialReference:r,xmin:e[0],xmax:n[0],ymin:e[1],ymax:n[1]})}throw new ArgumentError(gmlToEsriParseError)}function _createEsriPoint(e){const r=_getEsriSpatialReference(e),t=_parseGmlCoordPair(e);if(t&&t.length>1)return new Point({x:t[0],y:t[1],spatialReference:r});throw new ArgumentError(gmlToEsriParseError)}function _createEsriMultiPoint(e){const r=new Array,t=_getEsriSpatialReference(e);if(e.childElementCount>0){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"pointMember")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"pointMembers")),o=t.concat(...n);for(const e of o){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"Point"));for(const e of t)r.push(_parseGmlCoordPair(e))}}if(r&&r.length>0)return new Multipoint({points:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _createEsriPolyline(e){let r;const t=_getEsriSpatialReference(e);if("LineString"===e.localName?r=_parseGmlLineString(e):"Curve"===e.localName&&e.childElementCount>0?r=_parseGmlCurve(e):"MultiLineString"===e.localName&&e.childElementCount>0?r=_parseGmlMultiLineString(e):"MultiCurve"===e.localName&&e.childElementCount>0&&(r=_parseGmlMultiCurve(e)),r&&r.length>0)return new Polyline({paths:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _createEsriPolygon(e){let r;const t=_getEsriSpatialReference(e);if("Polygon"===e.localName?r=_parseGmlPolygon(e):"MultiPolygon"===e.localName&&(r=_parseGmlMultiPolygon(e)),r&&r.length>0)return new Polygon({rings:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _parseGmlLineString(e){return[_parseGmlCoords(e)]}function _parseGmlCurve(e){const r=new Array,t=e.getElementsByTagNameNS(e.namespaceURI,"segments");if(t.length>0){const n=Array.from(t[0].getElementsByTagNameNS(e.namespaceURI,"LineStringSegment"));for(const e of n){const t=_parseGmlCoords(e);r.push(t)}}return r}function _parseGmlMultiLineString(e){const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"lineStringMember"));for(const e of t){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LineString"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlMultiCurve(e){const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"curveMember")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"curveMembers")),o=t.concat(...n);for(const e of o){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LineString"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlPolygon(e){checkArg("geometry",e).isNotMissing();const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"outerBoundaryIs")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"innerBoundaryIs")),o=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"exterior")),i=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"interior")),s=t.concat(...n).concat(...o).concat(...i);for(const e of s){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LinearRing"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlMultiPolygon(e){checkArg("geometry",e).isNotMissing();const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"polygonMember"));for(const e of t){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"Polygon"));for(const e of t){const t=_parseGmlPolygon(e);r.push(...t)}}return r}function _parseGmlCoordPair(e){if(checkArg("geometry",e).isNotMissing(),"Point"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates"),t=e.getElementsByTagNameNS(e.namespaceURI,"pos");if(r.length>0&&r[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseGmlCoordPairFromString(r[0].childNodes[0].data)}if(t.length>0&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseGmlCoordPairFromString(t[0].childNodes[0].data)}throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoordinates(e){const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates");if(0===r.length)return;const t=r[1],n=t.getAttribute("cs")??",",o=t.getAttribute("ts")??" ",{data:i}=t.childNodes[0];return i.split(n).map((e=>_parseGmlCoordPairFromString(e,o)))}function _parseGmlCorners(e){if(checkArg("geometry",e).isNotMissing(),"Envelope"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=_parseGmlCoordinates(e);if(r)return r;const t=e.getElementsByTagNameNS(e.namespaceURI,"pos");if(2===t.length&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){const e=t[0].childNodes[0].data,r=t[0].childNodes[0].data;return[_parseGmlCoordPairFromString(e),_parseGmlCoordPairFromString(r)]}const n=e.getElementsByTagNameNS(e.namespaceURI,"lowerCorner"),o=e.getElementsByTagNameNS(e.namespaceURI,"upperCorner");if(n.length>0&&n[0].childNodes[0].nodeType===Node.TEXT_NODE&&o.length>0&&o[0].childNodes[0].nodeType===Node.TEXT_NODE){const e=n[0].childNodes[0].data,r=o[0].childNodes[0].data;return[_parseGmlCoordPairFromString(e),_parseGmlCoordPairFromString(r)]}throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoordPairFromString(e,r=" "){const t=e.replace(/,/g,"").split(r).map(Number);if(2===t.length)return[t[0],t[1]];throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoords(e){if(checkArg("geometry",e).isNotMissing(),"LineString"!==e.localName&&"LinearRing"!==e.localName&&"LineStringSegment"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates"),t=e.getElementsByTagNameNS(e.namespaceURI,"posList");if(r.length>0&&r[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseCoordsFromString(r[0].childNodes[0].data)}if(t.length>0&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseCoordsFromString(t[0].childNodes[0].data)}throw new ArgumentError(gmlToEsriParseError)}function _parseCoordsFromString(e){const r=e.replace(/,/g,"").split(" ").filter((e=>!!e)).map(Number),t=new Array;for(let e=0;e<r.length;e+=2){if(void 0===r[e+1])throw new ArgumentError(gmlToEsriParseError);t.push([r[e],r[e+1]])}if(t.length>0)return t;throw new ArgumentError(gmlToEsriParseError)}function _getEsriSpatialReference(e){return checkArg("geometry",e).isNotMissing(),e.hasAttribute("srsName")?ogcSrsToEsriSr(e.getAttribute("srsName")):SpatialReference.WebMercator}function _createGmlPointElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"Point","gml");let o,i;_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(o=_createElementWithNS(t,"coordinates","gml"),i=_esriPointToString(", ",e)):(o=_createElementWithNS(t,"pos","gml"),i=_esriPointToString(" ",e)),n.appendChild(o);const s=_createTextNode(i);return o.appendChild(s),n}function _createGmlLineStringElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"LineString","gml");let o,i;_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(o=_createElementWithNS(t,"coordinates","gml"),i=_esriPolylineToString(", ",e)):(o=_createElementWithNS(t,"posList","gml"),i=_esriPolylineToString(" ",e)),n.appendChild(o);const s=_createTextNode(i);return o.appendChild(s),n}function _createGmlPolygonElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"Polygon","gml");_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0);const o="2.0"===r.gmlVersion?_createElementWithNS(t,"outerBoundaryIs","gml"):_createElementWithNS(t,"exterior","gml");n.appendChild(o);const i=_createElementWithNS(t,"LinearRing","gml");let s,a;o.appendChild(i),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(s=_createElementWithNS(t,"coordinates","gml"),a=_esriPolygonToString(", ",e)):(s=_createElementWithNS(t,"posList","gml"),a=_esriPolygonToString(" ",e)),i.appendChild(s);const c=_createTextNode(a);return s.appendChild(c),n}function _getSrsName(e,r){if(r.hasOwnProperty("srsName"))return r.srsName;if(void 0!==e.spatialReference.wkid&&null!==e.spatialReference.wkid){if(e.spatialReference.wkid<32767)return`EPSG:${e.spatialReference.wkid}`;if(102100===e.spatialReference.wkid||900913===e.spatialReference.wkid||102113===e.spatialReference.wkid)return"EPSG:3857"}throw new ArgumentError("Unable to convert Esri WKT spatial reference to an OGC spatial reference")}function _applySrsAttributes(e,r,t){if(null!=r&&(e.setAttribute("srsName",r),null!=t)){const r=t<1?2:t;e.setAttribute("srsDimension",r.toString())}}function _createElementWithNS(e,r,t){checkArg("namespace",e).isNotMissing(),checkArg("name",r).isNotMissing();return document.implementation.createDocument(void 0,"temp",void 0).createElementNS(e,t?`${t}:${r}`:r)}function _createTextNode(e){return document.implementation.createDocument(void 0,"temp",void 0).createTextNode(e)}function _esriPointToString(e,r){const t=r;return" "===e?`${t.x} ${t.y}`:`${t.x}, ${t.y}`}function _esriPolylineToString(e,r){return r.paths[0].map((r=>r.join(e))).join(" ")}function _esriPolygonToString(e,r){let t;if(isPolygon(r))t=r.rings[0];else if(isExtent(r)){const{xmin:e,xmax:n,ymin:o,ymax:i}=r;t=[[e,i],[n,i],[n,o],[e,o],[e,i]]}return t.map((r=>r.join(e))).join(" ")}function getGeometryServiceUrl(){return config.geometryServiceUrl??DEFAULT_GEOMETRY_SERVICE_URL}export function isGeometry(e){return isPoint(e)||isMultipoint(e)||isPolyline(e)||isPolygon(e)||isExtent(e)||isMesh(e)}export function isPoint(e){return isEsriObject(e)&&"point"===e?.type}export function isMultipoint(e){return isEsriObject(e)&&"multipoint"===e?.type}export function isPolyline(e){return isEsriObject(e)&&"polyline"===e?.type}export function isPolygon(e){return isEsriObject(e)&&"polygon"===e?.type}export function isExtent(e){return isEsriObject(e)&&"extent"===e?.type}export function isMesh(e){return isEsriObject(e)&&"mesh"===e?.type}
|
|
1
|
+
import Extent from"@arcgis/core/geometry/Extent";import Multipoint from"@arcgis/core/geometry/Multipoint";import Point from"@arcgis/core/geometry/Point";import Polygon from"@arcgis/core/geometry/Polygon";import Polyline from"@arcgis/core/geometry/Polyline";import SpatialReference from"@arcgis/core/geometry/SpatialReference";import{buffer as esriBuffer,difference,geodesicBuffer as esriGeodesicBuffer,union}from"@arcgis/core/geometry/geometryEngine";import{isLoaded,load,getTransformation,project as projectionEngineProject}from"@arcgis/core/geometry/projection";import{canProject,project as webMercatorProject}from"@arcgis/core/geometry/support/webMercatorUtils";import{buffer as esriGeometryServiceBuffer,project as esriGeometryServiceProject}from"@arcgis/core/rest/geometryService";import BufferParameters from"@arcgis/core/rest/support/BufferParameters";import ProjectParameters from"@arcgis/core/rest/support/ProjectParameters";import{ArgumentError}from"../ArgumentError.js";import{config}from"../config.js";import{GeometryServiceError}from"./GeometryServiceError.js";import{getGmlNS,ogcSrsToEsriSr}from"./_ogc.js";import{groupBy}from"./array.js";import{checkArg}from"./checkArg.js";import{isEsriObject}from"./esri.js";import{parse}from"./number.js";export{}from"./transformation.js";const wktRegex=/^(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON)\s(?:(ZM|Z|M)\s)?(\(.+\))$/,wktPointRegex=/^\(?([-\d.]+)\s([-\d.]+)(?:\s([-\d.]+))?(?:\s([-\d.]+))?\)?$/,wktArrayRegex=/^\(([-\d.\s(),]+)\)$/,gmlToEsriParseError="Unable to convert the GML geometry into an Esri geometry.",DEFAULT_GEOMETRY_SERVICE_URL="https://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer",wktNameRegex=/^(PROJCS|GEOGCS|VERTCS|GEOGTRAN|VERTTRAN)\s?\[\s?"(\w+)",.*/,commonWktStrings={4326:{name:"GCS_WGS_1984",wkt:'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'},102100:{name:"WGS_1984_Web_Mercator_Auxiliary_Sphere",wkt:'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]'}},wktModules={PROJCS:"projected",GEOGCS:"geographic",VERTCS:"vertical",GEOGTRAN:"transformations",VERTTRAN:"vertical-transformations"},wktData={};export class CoordinateSystemBounds{constructor(e){this.limit=e}get min(){return-this.limit}get max(){return this.limit}get range(){return 2*this.limit}}export const WEB_MERCATOR_BOUNDS=new CoordinateSystemBounds(20037508.342788905);export const GEOGRAPHIC_BOUNDS=new CoordinateSystemBounds(180);export function getBounds(e){return e.isWebMercator?WEB_MERCATOR_BOUNDS:e.isGeographic?GEOGRAPHIC_BOUNDS:void 0}export function getScreenExtent(e){if(!e||0===e.length)return;let r,t,n,o;const{spatialReference:i}=e[0];let s;i.isWebMercator?s=WEB_MERCATOR_BOUNDS:i.isGeographic&&(s=GEOGRAPHIC_BOUNDS);const a=(e,i)=>{(!t||e>t)&&(t=e),(!r||e<r)&&(r=e),(!o||i>o)&&(o=i),(!n||i<n)&&(n=i)},c=e=>s&&Math.sign(e.extent.xmax)!==Math.sign(e.extent.xmin),m=e=>{const r=c(e)?denormalize([e.points],s)[0]:e.points;for(const e of r)a(e[0],e[1])},l=e=>{const r=c(e)?denormalize(e.rings,s):e.rings;for(const e of r)for(const r of e)a(r[0],r[1])},g=e=>{const r=c(e)?denormalize(e.paths,s):e.paths;for(const e of r)for(const r of e)a(r[0],r[1])};for(const r of e.filter((e=>e.spatialReference.equals(i))))switch(r.type){case"point":a(r.x,r.y);break;case"multipoint":m(r);break;case"extent":l(Polygon.fromExtent(r));break;case"polyline":g(r);break;case"polygon":l(r);break;default:throw new Error(`Cannot determine a valid screen extent for geometry type ${r.type}`)}return new Extent({xmin:r>t?t:r,xmax:t<r?r:t,ymin:n,ymax:o,spatialReference:i})}function denormalize(e,r){if(!r)return e;const t=[...e];let n=-1/0,o=1/0;for(let e of t){let t=-1/0,i=1/0;for(const n of e){for(;n[0]<r.min;)n[0]+=r.range;for(;n[0]>r.max;)n[0]-=r.range;i=Math.min(i,n[0]),t=Math.max(t,n[0])}let s=Math.min(o,i),a=Math.max(n,t);if(a-s>r.limit){t=-1/0,i=1/0;const c=[...e];for(const e of c)e[0]<0?e[0]+=r.range:e[0]-=r.range,i=Math.min(i,e[0]),t=Math.max(t,e[0]);const m=Math.min(o,i),l=Math.max(n,t);l-m<a-s&&(e=c,s=m,a=l)}o=Math.min(s,i),n=Math.max(a,t)}return t}export function denormalizeExtent(e,r){if(!r)return e;const t=Polygon.fromExtent(e);return t.rings=denormalize(t.rings,r),t.extent}export function esriToWKT(e){checkArg("geometry",e).isNotMissing();const r=`${e.hasZ?"Z":""}${e.hasM?"M":""}${e.hasM||e.hasZ?" ":""}`;if(isPoint(e)){const{x:t,y:n,z:o,m:i}=e,s=[t,n];return e.hasZ&&s.push(o),e.hasM&&s.push(i),`POINT ${r}(${_createWktPoint(s)})`}if(isMultipoint(e))return`MULTIPOINT ${r}(${_createWktPointArray(e.points)})`;if(isPolyline(e))return e.paths.length>1?`MULTILINESTRING ${r}(${_createWkt2DPointArray(e.paths)})`:`LINESTRING ${r}(${_createWktPointArray(e.paths[0])})`;if(isPolygon(e))return`POLYGON ${r}(${_createWkt2DPointArray(e.rings)})`;if(isExtent(e)){const t=[e.xmin,e.ymax];return`POLYGON ${r}(${_createWkt2DPointArray([[t,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],t]])})`}throw new ArgumentError("Cannot determine what type of WKT geometry to create")}export function wktToEsri(e,r){checkArg("geometry",e).isNotMissing();const t=e.match(wktRegex);if(t){const e=t[2]?.includes("Z"),n=t[2]?.includes("M");switch(t[1]){case"POINT":{const o=_parseWktPoint(t[3],t[2]);return new Point({x:o[0],y:o[1],z:e?o[2]:void 0,m:!e&&n?o[2]:n?o[3]:void 0,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"MULTIPOINT":{const o=_parseWktPointArray(t[3],t[2]);return new Multipoint({points:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"LINESTRING":{const o=_parseWktPointArray(t[3],t[2]);return new Polyline({paths:[o],hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"MULTILINESTRING":{const o=_parseWkt2DPointArray(t[3],t[2]);return new Polyline({paths:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}case"POLYGON":{const o=_parseWkt2DPointArray(t[3],t[2]);return new Polygon({rings:o,hasZ:e,hasM:n,spatialReference:r||SpatialReference.WGS84})}}}throw new ArgumentError("Cannot determine what type of esri geometry to create")}export function esriToGeoJSON(e){if(checkArg("geometry",e).isNotMissing(),isPoint(e)){const{x:r,y:t}=e;return{type:"Point",coordinates:[r,t]}}if(isMultipoint(e))return{type:"MultiPoint",coordinates:e.points};if(isPolyline(e))return e.paths.length>1?{type:"MultiLineString",coordinates:e.paths}:{type:"LineString",coordinates:e.paths[0]};if(isPolygon(e))return{type:"Polygon",coordinates:e.rings};if(isExtent(e)){const r=[e.xmin,e.ymax];return{type:"Polygon",coordinates:[[r,[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin],r]]}}throw new ArgumentError("Cannot determine what type of WKT geometry to create")}export function geoJSONToEsri(e){switch(checkArg("geometry",e).isNotMissing(),checkArg("geometry.type",e.type).isNotMissing(),e.type){case"Point":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPoint),new Point({x:e.coordinates[0],y:e.coordinates[1],spatialReference:SpatialReference.WGS84});case"MultiPoint":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPointArray),new Multipoint({points:e.coordinates,spatialReference:SpatialReference.WGS84});case"LineString":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSONPointArray),new Polyline({paths:[e.coordinates],spatialReference:SpatialReference.WGS84});case"MultiLineString":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArray),new Polyline({paths:e.coordinates,spatialReference:SpatialReference.WGS84});case"Polygon":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArray),new Polygon({rings:e.coordinates,spatialReference:SpatialReference.WGS84});case"MultiPolygon":return checkArg("geometry.coordinates",e.coordinates).satisfies(_isGeoJSON2DPointArrayArray),new Polygon({rings:e.coordinates.flat(),spatialReference:SpatialReference.WGS84})}throw new ArgumentError("Cannot determine what type of esri geometry to create")}export function gmlToEsri(e){switch(checkArg("geometry",e).isNotMissing(),e.localName){case"Point":return _createEsriPoint(e);case"MultiPoint":return _createEsriMultiPoint(e);case"LineString":case"Curve":case"MultiLineString":case"MultiCurve":return _createEsriPolyline(e);case"Polygon":case"MultiPolygon":return _createEsriPolygon(e);case"Envelope":return _createEsriExtent(e);default:throw new ArgumentError("Unrecognized geometry type.")}}export function esriToGml(e,r){switch(checkArg("geometry",e).isNotMissing(),checkArg("geometry type",e.type).isNotMissing(),checkArg("gmlVersion",r.gmlVersion).isNotMissing(),e.type){case"point":return _createGmlPointElement(e,r);case"polyline":return _createGmlLineStringElement(e,r);case"polygon":case"extent":return _createGmlPolygonElement(e,r);default:throw new ArgumentError(`Unrecognized geometry type: ${e.type}. Must be one of point, polyline or polygon.`)}}export async function esriWkidToWkt(e){checkArg("wkid",e).isNotMissing();let r=commonWktStrings[`${e}`];if(!r)for(const t of Object.keys(wktModules)){const n=wktModules[t];if(r=(await fetchEsriProjCodes(n))[e],r){const t=r.wkt.match(wktNameRegex);commonWktStrings[e]={name:t[2],wkt:r.wkt};break}}if(!r)throw new Error(`Failed to find Wkt for id ${e}`);return r.wkt}export async function esriWktToWkid(e){checkArg("wkt",e).isNotMissing();const r=e.match(wktNameRegex);if(r){let e=Object.keys(commonWktStrings).find((e=>commonWktStrings[e].name===r[2]));if(!e){const t=wktModules[r[1]];if(t){const n=await fetchEsriProjCodes(t);e=Object.keys(n).find((e=>n[e].name===r[2])),e&&(commonWktStrings[e]={name:r[2],wkt:n[e].wkt})}}if(e)return parseInt(e)}throw new Error(`Failed to find Wkid for ${e}`)}export function createCrossTypeUnion(e){const r=[],t=groupBy(e,(e=>e.type));for(const e of GEOM_ORDER){const n=t.get(e);let o;if(n?.length){o=n.length>1?union(n):n[0];for(const e of r)o=difference(o,e);o&&r.push(o)}}return r}const GEOM_ORDER=["mesh","extent","polygon","polyline","multipoint","point"];async function fetchEsriProjCodes(e){if(void 0===wktData[e])switch(e){case wktModules.GEOGCS:wktData[e]=(await import("esri-proj-codes/geographic.json")).default;break;case wktModules.PROJCS:wktData[e]=(await import("esri-proj-codes/projected.json")).default;break;case wktModules.GEOGTRAN:wktData[e]=(await import("esri-proj-codes/transformations.json")).default;break;case wktModules.VERTCS:wktData[e]=(await import("esri-proj-codes/vertical.json")).default;break;case wktModules.VERTTRAN:wktData[e]=(await import("esri-proj-codes/vertical-transformations.json")).default}const r=wktData[e];if(!r)throw new Error(`Invalid esri-proj-codes module: ${e}`);return r}export async function project(e,r,t){checkArg("geometries",e).isNotMissing().satisfies(_geometriesAreUniform,"All geometries must have the same type and spatial reference."),checkArg("outSpatialReference",r).isNotMissing();const n=Array.from(e);if(n.length<=0)return n;const o=_getInputSpatialReference(e),i=_getProjectOptions(o,r,t);if(void 0===i){if(o.equals(r))return n;if(canProject(o,r))return n.map((e=>webMercatorProject(e,r)));if(isLoaded()||await load(),null!==getTransformation(o,r)){const e=projectionEngineProject(n,r);return Array.isArray(e)?e:[e]}}if(i&&i.steps.length>1)throw new ArgumentError("GeographicTransformation","Geometry Service can't handle a two step transformation");return _projectWithGeometryService(n,r,i)}export async function buffer(e,r,t,n=!1){const o=Array.isArray(e),i=Array.isArray(r);if(o!==i)throw new ArgumentError("Geometries and distances must be the same type.");const s=Array.isArray(e)?e[0].spatialReference:e.spatialReference;if(s.isWebMercator||s.isWGS84)return esriGeodesicBuffer(e,r,t,n);if(s.isGeographic){const s=new BufferParameters({geometries:o?e:[e],distances:i?r:[r],unit:t,unionResults:n});return esriGeometryServiceBuffer(getGeometryServiceUrl(),s)}return esriBuffer(e,r,t,n)}export function removeZValues(e){const r=e;switch(r.type){case"point":r.z=void 0;break;case"polyline":case"polygon":_removeZCoords(r.paths||r.rings,r.hasM).forEach(((e,t)=>e.forEach(((e,n)=>r.setPoint(t,n,e)))));break;case"extent":r.zmax=void 0,r.zmin=void 0}return r}function _removeZCoords(e,r=!1){const t=r?3:2;return e.map((e=>e.map((e=>e.slice(0,t)))))}function _createWktPoint(e){return e.join(" ")}function _createWktPointArray(e){return e.map(_createWktPoint).join(", ")}function _createWkt2DPointArray(e){return e.map((e=>`(${_createWktPointArray(e)})`)).join(", ")}function _parseInvariant(e){return parse({locale:"inv"},e)}function _parseWktPoint(e,r){const t=r??"",n=e.match(wktPointRegex);if(n){const e=[_parseInvariant(n[1]),_parseInvariant(n[2])];return(t.includes("Z")||!t.includes("Z")&&t.includes("M"))&&n[3]&&e.push(_parseInvariant(n[3])),t.includes("M")&&n[4]&&e.push(_parseInvariant(n[4])),e}throw new ArgumentError(`Detected invalid WKT point: ${e}`)}function _parseWktPointArray(e,r){const t=e.match(wktArrayRegex);if(t)return _parseWktArray(t[1]).map((e=>_parseWktPoint(e,r)));throw new ArgumentError(`Detected invalid WKT point array: ${e}`)}function _parseWkt2DPointArray(e,r){const t=e.match(wktArrayRegex);if(t)return _parseWktArray(t[1]).map((e=>_parseWktPointArray(e,r)));throw new ArgumentError(`Detected invalid WKT 2D point array: ${e}`)}function _parseWktArray(e){let r=e.trim().replace(/\s*,\s*/g,","),t=0;for(let e=0;e<r.length;e++)switch(r.charAt(e)){case"(":t++;break;case")":t--;break;case",":0===t&&(r=`${r.substr(0,e)}&${r.substr(e+1)}`)}return r.split("&")}function _isGeoJSONPoint(e){return!!Array.isArray(e)&&!e.some((e=>"number"!=typeof e))}function _isGeoJSONPointArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSONPoint(e)))}function _isGeoJSON2DPointArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSONPointArray(e)))}function _isGeoJSON2DPointArrayArray(e){return!!Array.isArray(e)&&!e.some((e=>!_isGeoJSON2DPointArray(e)))}async function _projectWithGeometryService(e,r,t){const n=new ProjectParameters({geometries:e,outSpatialReference:r});t?.hasOwnProperty("transformation")&&(n.transformation=t.steps[0].wkid?{wkid:t.steps[0].wkid}:{wkt:t.steps[0].wkt},n.transformForward=!t.hasOwnProperty("transformForward")||!t.steps[0].isInverse);try{return await esriGeometryServiceProject(getGeometryServiceUrl(),n)}catch(e){throw e instanceof Error?new GeometryServiceError(e):e}}function _geometriesAreUniform(e){const r=[...e];if(!(r.length>0))return!0;const t=r[0].type,n=r[0].spatialReference;return r.every((e=>e.type===t&&e.spatialReference.equals(n)))}function _getInputSpatialReference(e){for(const r of e)if(null!==r?.spatialReference)return r.spatialReference;return SpatialReference.WebMercator}function _getProjectOptions(e,r,t){return t?.hasOwnProperty("steps")?t:_getTransformProjectOptions(e,r)}function _getTransformProjectOptions(e,r){if(checkArg("inSr",e).isNotMissing(),checkArg("outSR",r).isNotMissing(),0===config.autoTransformations.length)return;const t=config.autoTransformations.filter((r=>r.inSpatialReference.equals(e))).filter((e=>e.outSpatialReference.equals(r)));if(t.length>0)return t[0].transformation;const n=config.autoTransformations.filter((e=>e.inSpatialReference.equals(r))).filter((r=>r.outSpatialReference.equals(e)));return n.length>0?n[0].transformation:void 0}function _createEsriExtent(e){const r=_getEsriSpatialReference(e),t=_parseGmlCorners(e);if(2===t.length){const[e,n]=t;return new Extent({spatialReference:r,xmin:e[0],xmax:n[0],ymin:e[1],ymax:n[1]})}throw new ArgumentError(gmlToEsriParseError)}function _createEsriPoint(e){const r=_getEsriSpatialReference(e),t=_parseGmlCoordPair(e);if(t&&t.length>1)return new Point({x:t[0],y:t[1],spatialReference:r});throw new ArgumentError(gmlToEsriParseError)}function _createEsriMultiPoint(e){const r=new Array,t=_getEsriSpatialReference(e);if(e.childElementCount>0){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"pointMember")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"pointMembers")),o=t.concat(...n);for(const e of o){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"Point"));for(const e of t)r.push(_parseGmlCoordPair(e))}}if(r&&r.length>0)return new Multipoint({points:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _createEsriPolyline(e){let r;const t=_getEsriSpatialReference(e);if("LineString"===e.localName?r=_parseGmlLineString(e):"Curve"===e.localName&&e.childElementCount>0?r=_parseGmlCurve(e):"MultiLineString"===e.localName&&e.childElementCount>0?r=_parseGmlMultiLineString(e):"MultiCurve"===e.localName&&e.childElementCount>0&&(r=_parseGmlMultiCurve(e)),r&&r.length>0)return new Polyline({paths:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _createEsriPolygon(e){let r;const t=_getEsriSpatialReference(e);if("Polygon"===e.localName?r=_parseGmlPolygon(e):"MultiPolygon"===e.localName&&(r=_parseGmlMultiPolygon(e)),r&&r.length>0)return new Polygon({rings:r,spatialReference:t});throw new ArgumentError(gmlToEsriParseError)}function _parseGmlLineString(e){return[_parseGmlCoords(e)]}function _parseGmlCurve(e){const r=new Array,t=e.getElementsByTagNameNS(e.namespaceURI,"segments");if(t.length>0){const n=Array.from(t[0].getElementsByTagNameNS(e.namespaceURI,"LineStringSegment"));for(const e of n){const t=_parseGmlCoords(e);r.push(t)}}return r}function _parseGmlMultiLineString(e){const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"lineStringMember"));for(const e of t){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LineString"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlMultiCurve(e){const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"curveMember")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"curveMembers")),o=t.concat(...n);for(const e of o){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LineString"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlPolygon(e){checkArg("geometry",e).isNotMissing();const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"outerBoundaryIs")),n=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"innerBoundaryIs")),o=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"exterior")),i=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"interior")),s=t.concat(...n).concat(...o).concat(...i);for(const e of s){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"LinearRing"));for(const e of t)r.push(_parseGmlCoords(e))}return r}function _parseGmlMultiPolygon(e){checkArg("geometry",e).isNotMissing();const r=new Array,t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"polygonMember"));for(const e of t){const t=Array.from(e.getElementsByTagNameNS(e.namespaceURI,"Polygon"));for(const e of t){const t=_parseGmlPolygon(e);r.push(...t)}}return r}function _parseGmlCoordPair(e){if(checkArg("geometry",e).isNotMissing(),"Point"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates"),t=e.getElementsByTagNameNS(e.namespaceURI,"pos");if(r.length>0&&r[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseGmlCoordPairFromString(r[0].childNodes[0].data)}if(t.length>0&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseGmlCoordPairFromString(t[0].childNodes[0].data)}throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoordinates(e){const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates");if(0===r.length)return;const t=r[1],n=t.getAttribute("cs")??",",o=t.getAttribute("ts")??" ",{data:i}=t.childNodes[0];return i.split(n).map((e=>_parseGmlCoordPairFromString(e,o)))}function _parseGmlCorners(e){if(checkArg("geometry",e).isNotMissing(),"Envelope"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=_parseGmlCoordinates(e);if(r)return r;const t=e.getElementsByTagNameNS(e.namespaceURI,"pos");if(2===t.length&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){const e=t[0].childNodes[0].data,r=t[0].childNodes[0].data;return[_parseGmlCoordPairFromString(e),_parseGmlCoordPairFromString(r)]}const n=e.getElementsByTagNameNS(e.namespaceURI,"lowerCorner"),o=e.getElementsByTagNameNS(e.namespaceURI,"upperCorner");if(n.length>0&&n[0].childNodes[0].nodeType===Node.TEXT_NODE&&o.length>0&&o[0].childNodes[0].nodeType===Node.TEXT_NODE){const e=n[0].childNodes[0].data,r=o[0].childNodes[0].data;return[_parseGmlCoordPairFromString(e),_parseGmlCoordPairFromString(r)]}throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoordPairFromString(e,r=" "){const t=e.replace(/,/g,"").split(r).map(Number);if(2===t.length)return[t[0],t[1]];throw new ArgumentError(gmlToEsriParseError)}function _parseGmlCoords(e){if(checkArg("geometry",e).isNotMissing(),"LineString"!==e.localName&&"LinearRing"!==e.localName&&"LineStringSegment"!==e.localName)throw new ArgumentError(gmlToEsriParseError);const r=e.getElementsByTagNameNS(e.namespaceURI,"coordinates"),t=e.getElementsByTagNameNS(e.namespaceURI,"posList");if(r.length>0&&r[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseCoordsFromString(r[0].childNodes[0].data)}if(t.length>0&&t[0].childNodes[0].nodeType===Node.TEXT_NODE){return _parseCoordsFromString(t[0].childNodes[0].data)}throw new ArgumentError(gmlToEsriParseError)}function _parseCoordsFromString(e){const r=e.replace(/,/g,"").split(" ").filter((e=>!!e)).map(Number),t=new Array;for(let e=0;e<r.length;e+=2){if(void 0===r[e+1])throw new ArgumentError(gmlToEsriParseError);t.push([r[e],r[e+1]])}if(t.length>0)return t;throw new ArgumentError(gmlToEsriParseError)}function _getEsriSpatialReference(e){return checkArg("geometry",e).isNotMissing(),e.hasAttribute("srsName")?ogcSrsToEsriSr(e.getAttribute("srsName")):SpatialReference.WebMercator}function _createGmlPointElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"Point","gml");let o,i;_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(o=_createElementWithNS(t,"coordinates","gml"),i=_esriPointToString(", ",e)):(o=_createElementWithNS(t,"pos","gml"),i=_esriPointToString(" ",e)),n.appendChild(o);const s=_createTextNode(i);return o.appendChild(s),n}function _createGmlLineStringElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"LineString","gml");let o,i;_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(o=_createElementWithNS(t,"coordinates","gml"),i=_esriPolylineToString(", ",e)):(o=_createElementWithNS(t,"posList","gml"),i=_esriPolylineToString(" ",e)),n.appendChild(o);const s=_createTextNode(i);return o.appendChild(s),n}function _createGmlPolygonElement(e,r){const t=getGmlNS(r.gmlVersion),n=_createElementWithNS(t,"Polygon","gml");_applySrsAttributes(n,_getSrsName(e,r),r.hasOwnProperty("srsDimension")?r.srsDimension:void 0);const o="2.0"===r.gmlVersion?_createElementWithNS(t,"outerBoundaryIs","gml"):_createElementWithNS(t,"exterior","gml");n.appendChild(o);const i=_createElementWithNS(t,"LinearRing","gml");let s,a;o.appendChild(i),"2.0"===r.gmlVersion||"3.0"===r.gmlVersion?(s=_createElementWithNS(t,"coordinates","gml"),a=_esriPolygonToString(", ",e)):(s=_createElementWithNS(t,"posList","gml"),a=_esriPolygonToString(" ",e)),i.appendChild(s);const c=_createTextNode(a);return s.appendChild(c),n}function _getSrsName(e,r){if(r.hasOwnProperty("srsName"))return r.srsName;if(void 0!==e.spatialReference.wkid&&null!==e.spatialReference.wkid){if(e.spatialReference.wkid<32767)return`EPSG:${e.spatialReference.wkid}`;if(102100===e.spatialReference.wkid||900913===e.spatialReference.wkid||102113===e.spatialReference.wkid)return"EPSG:3857"}throw new ArgumentError("Unable to convert Esri WKT spatial reference to an OGC spatial reference")}function _applySrsAttributes(e,r,t){if(null!=r&&(e.setAttribute("srsName",r),null!=t)){const r=t<1?2:t;e.setAttribute("srsDimension",r.toString())}}function _createElementWithNS(e,r,t){checkArg("namespace",e).isNotMissing(),checkArg("name",r).isNotMissing();return document.implementation.createDocument(void 0,"temp",void 0).createElementNS(e,t?`${t}:${r}`:r)}function _createTextNode(e){return document.implementation.createDocument(void 0,"temp",void 0).createTextNode(e)}function _esriPointToString(e,r){const t=r;return" "===e?`${t.x} ${t.y}`:`${t.x}, ${t.y}`}function _esriPolylineToString(e,r){return r.paths[0].map((r=>r.join(e))).join(" ")}function _esriPolygonToString(e,r){let t;if(isPolygon(r))t=r.rings[0];else if(isExtent(r)){const{xmin:e,xmax:n,ymin:o,ymax:i}=r;t=[[e,i],[n,i],[n,o],[e,o],[e,i]]}return t.map((r=>r.join(e))).join(" ")}function getGeometryServiceUrl(){return config.geometryServiceUrl??DEFAULT_GEOMETRY_SERVICE_URL}export function isGeometry(e){return isPoint(e)||isMultipoint(e)||isPolyline(e)||isPolygon(e)||isExtent(e)||isMesh(e)}export function isPoint(e){return isEsriObject(e)&&"point"===e?.type}export function isMultipoint(e){return isEsriObject(e)&&"multipoint"===e?.type}export function isPolyline(e){return isEsriObject(e)&&"polyline"===e?.type}export function isPolygon(e){return isEsriObject(e)&&"polygon"===e?.type}export function isExtent(e){return isEsriObject(e)&&"extent"===e?.type}export function isMesh(e){return isEsriObject(e)&&"mesh"===e?.type}
|
package/utilities/symbol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function isVolumetric(e){return isSymbol3D(e)&&e.symbolLayers.some((e=>"object"===e.type||"path"===e.type||"extrude"===e.type))}const SYMBOL_CLASS_REGEX=/^esri\.symbols\.\w+Symbol
|
|
1
|
+
export function isVolumetric(e){return isSymbol3D(e)&&e.symbolLayers.some((e=>"object"===e.type||"path"===e.type||"extrude"===e.type))}const SYMBOL_CLASS_REGEX=/^esri\.symbols\.\w+Symbol(3D)?$/;export function isSymbol(e){return SYMBOL_CLASS_REGEX.test(e?.declaredClass)}export function isCimSymbol(e){return"esri.symbols.CimSymbol"===e?.declaredClass}export function isLabelSymbol3D(e){return"esri.symbols.LabelSymbol3D"===e?.declaredClass}export function isLineSymbol3D(e){return"esri.symbols.LineSymbol3D"===e?.declaredClass}export function isMeshSymbol3D(e){return"esri.symbols.MeshSymbol3D"===e?.declaredClass}export function isPictureFillSymbol(e){return"esri.symbols.PictureFillSymbol"===e?.declaredClass}export function isPictureMarkerSymbol(e){return"esri.symbols.PictureMarkerSymbol"===e?.declaredClass}export function isPointSymbol3D(e){return"esri.symbols.PointSymbol3D"===e?.declaredClass}export function isPolygonSymbol3D(e){return"esri.symbols.PolygonSymbol3D"===e?.declaredClass}export function isSimpleFillSymbol(e){return"esri.symbols.SimpleFillSymbol"===e?.declaredClass}export function isSimpleLineSymbol(e){return"esri.symbols.SimpleLineSymbol"===e?.declaredClass}export function isSimpleMarkerSymbol(e){return"esri.symbols.SimpleMarkerSymbol"===e?.declaredClass}export function isWebStyleSymbol(e){return"esri.symbols.WebStyleSymbol"===e?.declaredClass}export function isTextSymbol(e){return"esri.symbols.TextSymbol"===e?.declaredClass}export function isSymbol3D(e){return isPointSymbol3D(e)||isLineSymbol3D(e)||isPolygonSymbol3D(e)||isMeshSymbol3D(e)||isLabelSymbol3D(e)}export function isPointGeometrySymbol(e){return isSimpleMarkerSymbol(e)||isPictureMarkerSymbol(e)||isWebStyleSymbol(e)||isTextSymbol(e)||isCimSymbol(e)||isPointSymbol3D(e)||isLabelSymbol3D(e)}export function isMeshGeometrySymbol(e){return isMeshSymbol3D(e)||isLabelSymbol3D(e)}export function isPolylineGeometrySymbol(e){return isSimpleLineSymbol(e)||isTextSymbol(e)||isCimSymbol(e)||isLineSymbol3D(e)||isLabelSymbol3D(e)}export function isPolygonGeometrySymbol(e){return isSimpleFillSymbol(e)||isPictureFillSymbol(e)||isSimpleMarkerSymbol(e)||isTextSymbol(e)||isCimSymbol(e)||isPolygonSymbol3D(e)||isLabelSymbol3D(e)}export function isIconSymbol3DLayer(e){return"esri.symbols.IconSymbol3DLayer"===e.declaredClass}export function isObjectSymbol3DLayer(e){return"esri.symbols.ObjectSymbol3DLayer"===e.declaredClass}export function isPathSymbol3DLayer(e){return"esri.symbols.PathSymbol3DLayer"===e.declaredClass}export function isLineSymbol3DLayer(e){return"esri.symbols.LineSymbol3DLayer"===e.declaredClass}export function isFillSymbol3DLayer(e){return"esri.symbols.FillSymbol3DLayer"===e.declaredClass}export function isExtrudeSymbol3DLayer(e){return"esri.symbols.ExtrudeSymbol3DLayer"===e.declaredClass}
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="
|
|
1
|
+
export const version="38.0.0";
|