@vertigis/arcgis-extensions 33.3.1 → 33.5.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 +10 -5
- package/config.d.ts +7 -3
- package/config.js +1 -1
- package/data/Feature.js +1 -1
- package/data/_Relationship.d.ts +1 -1
- package/data/convert.js +1 -1
- package/data/support/DefaultRelationshipFactory.js +1 -1
- package/data/support/DefaultTableExtensionFactory.js +1 -1
- package/declarations/arcgis-js-api-extensions/index.d.ts +49 -21
- package/docs/html/assets/js/search.js +1 -1
- package/docs/html/classes/data__tableextension.tableextension.html +53 -53
- package/docs/html/classes/data__tableextension.tablefeaturesettings.html +5 -5
- package/docs/html/classes/data__tableextension.tableschema.html +4 -4
- package/docs/html/classes/data_arcgisservicetableextension.arcgisservicetableextension.html +47 -47
- package/docs/html/classes/data_attachment.attachment.html +24 -24
- package/docs/html/classes/data_feature.feature.html +27 -27
- package/docs/html/classes/data_featurelist.featurelist.html +17 -17
- package/docs/html/classes/data_featureset.featureset.html +23 -23
- package/docs/html/classes/data_featuresettings.featuresettings.html +5 -5
- package/docs/html/classes/data_featuresourcebase.featuresourcebase.html +61 -61
- package/docs/html/classes/data_featuresourcebase.relationshipcollection.html +4 -4
- package/docs/html/classes/data_featurestream.featurestream.html +30 -30
- package/docs/html/classes/data_fieldextension.fieldextension.html +22 -22
- package/docs/html/classes/data_relationshipbase.relationshipbase.html +36 -36
- package/docs/html/classes/data_schema.schema.html +4 -4
- package/docs/html/classes/data_support_defaultrelationshipfactory.defaultrelationshipfactory.html +2 -2
- package/docs/html/classes/data_tasksettings.tasksettings.html +5 -5
- package/docs/html/classes/entity.entitybase.html +26 -26
- package/docs/html/classes/hyperlink.hyperlink-1.html +6 -6
- package/docs/html/classes/languageresources.languageresources-1.html +14 -14
- package/docs/html/classes/layer_preset_layerpreset.layerpreset.html +24 -24
- package/docs/html/classes/layer_preset_layerpresetsettings.layerpresetsetting.html +6 -6
- package/docs/html/classes/mapping__layerextension.arraywrappedcollection.html +2 -2
- package/docs/html/classes/mapping__layerextension.layerextension.html +45 -45
- package/docs/html/classes/mapping__layerextension.layerextensionschema.html +10 -10
- package/docs/html/classes/mapping__sublayerextension.sublayerextension.html +44 -44
- package/docs/html/classes/mapping__sublayerextension.sublayerschema.html +4 -4
- package/docs/html/classes/mapping__sublayerextension.subsublayerextensioncollection.html +13 -13
- package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerextension.html +42 -42
- package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerfeaturesettings.html +12 -12
- package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerrelationshipcollection.html +11 -11
- package/docs/html/classes/mapping_arcgissublayerextension.arcgissublayerschema.html +17 -17
- package/docs/html/classes/mapping_basemapextension.basemapextension.html +19 -19
- package/docs/html/classes/mapping_bookmark.bookmark.html +24 -24
- package/docs/html/classes/mapping_buildingcomponentsublayerextension.buildingcomponentsublayerextension.html +43 -43
- package/docs/html/classes/mapping_buildingcomponentsublayerextension.buildingcomponentsublayerschema.html +4 -4
- package/docs/html/classes/mapping_buildinggroupsublayerextension.buildinggroupsublayerextension.html +43 -43
- package/docs/html/classes/mapping_buildinggroupsublayerextension.buildinggroupsublayerschema.html +4 -4
- package/docs/html/classes/mapping_buildingscenelayerextension.buildingscenelayerextension.html +44 -44
- package/docs/html/classes/mapping_buildingscenelayerextension.buildingscenelayerreadonlyschema.html +10 -10
- package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerextension.html +43 -43
- package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerfeaturesettings.html +4 -4
- package/docs/html/classes/mapping_buildingsublayerextension.buildingsublayerschema.html +4 -4
- package/docs/html/classes/mapping_csvlayerextension.csvlayerextension.html +43 -43
- package/docs/html/classes/mapping_elevationlayerextension.elevationlayerextension.html +44 -44
- package/docs/html/classes/mapping_featurecollectionlayerextension.featurecollectionlayerextension.html +42 -42
- package/docs/html/classes/mapping_featurelayerextension.featurelayerextension.html +37 -37
- package/docs/html/classes/mapping_featurelayerextensionbase.featurelayerextensionbase.html +42 -42
- package/docs/html/classes/mapping_featurelayerextensionbase.featurelayerschema.html +8 -8
- package/docs/html/classes/mapping_georsslayerextension.georsslayerextension.html +44 -44
- package/docs/html/classes/mapping_graphicslayerextension.graphicslayerextension.html +44 -44
- package/docs/html/classes/mapping_groundextension.groundextension.html +19 -19
- package/docs/html/classes/mapping_grouplayerextension.grouplayerextension.html +45 -45
- package/docs/html/classes/mapping_grouplayerextension.grouplayerextensioncollection.html +14 -14
- package/docs/html/classes/mapping_imagerylayerextension.imagerylayerextension.html +43 -43
- package/docs/html/classes/mapping_imagerytilelayerextension.imagerytilelayerextension.html +44 -44
- package/docs/html/classes/mapping_integratedmeshlayerextension.integratedmeshlayerextension.html +44 -44
- package/docs/html/classes/mapping_kmllayerextension.kmllayerextension.html +44 -44
- package/docs/html/classes/mapping_kmlsublayerextension.kmlsublayerextension.html +44 -44
- package/docs/html/classes/mapping_mapconstraints.mapconstraints.html +5 -5
- package/docs/html/classes/mapping_mapextension.mapextension.html +19 -19
- package/docs/html/classes/mapping_mapimagelayerextension.mapimagelayerextension.html +44 -44
- package/docs/html/classes/mapping_mapimagesublayerextension.mapimagesublayerextension.html +42 -42
- package/docs/html/classes/mapping_openstreetmaplayerextension.openstreetmaplayerextension.html +44 -44
- package/docs/html/classes/mapping_pointcloudlayerextension.pointcloudlayerextension.html +43 -43
- package/docs/html/classes/mapping_scenelayerextension.scenelayerextension.html +43 -43
- package/docs/html/classes/mapping_streamlayerextension.streamlayerextension.html +43 -43
- package/docs/html/classes/mapping_streamlayerextension.streamlayerschema.html +8 -8
- package/docs/html/classes/mapping_support__layerextensioncollection.layerextensioncollectionbase.html +20 -20
- package/docs/html/classes/mapping_support__sublayerextensioncollection.sublayerextensioncollectionbase.html +19 -19
- package/docs/html/classes/mapping_support_layerlistsettings.extensionbaselayerlistsettings.html +6 -6
- package/docs/html/classes/mapping_support_layerlistsettings.layerlistsettings.html +7 -7
- package/docs/html/classes/mapping_tilelayerextension.tilelayerextension.html +44 -44
- package/docs/html/classes/mapping_tilesublayerextension.tilesublayerextension.html +42 -42
- package/docs/html/classes/mapping_vectortilelayerextension.vectortilelayerextension.html +44 -44
- package/docs/html/classes/mapping_webtilelayerextension.webtilelayerextension.html +44 -44
- package/docs/html/classes/mapping_wmslayerextension.wmslayerextension.html +46 -46
- package/docs/html/classes/mapping_wmssublayerextension.wmssublayerextension.html +44 -44
- package/docs/html/classes/mapping_wmtslayerextension.wmtslayerextension.html +44 -44
- package/docs/html/classes/mapping_wmtssublayerextension.wmtssublayerextension.html +44 -44
- package/docs/html/classes/menus_menu.menu.html +22 -22
- package/docs/html/classes/menus_menuitem.menuitem.html +49 -49
- package/docs/html/classes/support_formatsettings.formatsettings.html +5 -5
- package/docs/html/classes/support_initializablebase.initializablebase.html +21 -21
- package/docs/html/classes/support_initializablecollectionproxy.initializablecollectionproxy.html +2 -2
- package/docs/html/classes/support_serializable.serializablebase.html +8 -8
- package/docs/html/classes/support_settings.settings.html +6 -6
- package/docs/html/classes/tasks_geocoding_arcgisgeocoder.arcgisgeocoder.html +94 -59
- package/docs/html/classes/tasks_geocoding_geocoder.geocoder.html +45 -45
- package/docs/html/classes/tasks_identify_buildingcomponentsublayerclientsideidentifyprovider.buildingcomponentsublayerclientsideidentifyprovider.html +20 -20
- package/docs/html/classes/tasks_identify_clientsideidentifyprovider.clientsideidentifyprovider.html +2 -2
- package/docs/html/classes/tasks_identify_featurelayerclientsideidentifyprovider.featurelayerclientsideidentifyprovider.html +2 -2
- package/docs/html/classes/tasks_identify_scenelayerclientsideidentifyprovider.scenelayerclientsideidentifyprovider.html +2 -2
- package/docs/html/classes/tasks_identify_streamlayerclientsidequeryidentifyprovider.streamlayerclientsidequeryidentifyprovider.html +2 -2
- package/docs/html/classes/tasks_query_arcgisrelationship.arcgisrelationship.html +1655 -0
- package/docs/html/classes/tasks_query_buildingcomponentsublayerclientsidequeryprovider.buildingcomponentsublayerclientsidequeryprovider.html +20 -20
- package/docs/html/classes/tasks_query_clientsidequeryprovider.clientsidequeryprovider.html +2 -2
- package/docs/html/classes/tasks_query_querybasedrelationship.querybasedrelationship.html +82 -64
- package/docs/html/classes/tasks_query_scenelayerclientsidequeryprovider.scenelayerclientsidequeryprovider.html +2 -2
- package/docs/html/classes/tasks_query_streamlayerclientsidequeryprovider.streamlayerclientsidequeryprovider.html +2 -2
- package/docs/html/classes/tasks_search_arcgisgeocodersearchprovider.arcgisgeocodersearchprovider.html +470 -0
- package/docs/html/classes/tasks_search_geocodersearchprovider.geocodersearchprovider.html +5 -0
- package/docs/html/classes/tasks_search_querysearchprovider.querysearchprovider.html +6 -6
- package/docs/html/classes/tasks_search_searchservice.searchservice.html +12 -12
- package/docs/html/classes/utilities_date.dateformatter.html +25 -25
- package/docs/html/classes/utilities_geometry.coordinatesystembounds.html +5 -5
- package/docs/html/classes/utilities_number.numberformatter.html +23 -23
- package/docs/html/classes/utilities_uri.uri.html +17 -17
- package/docs/html/enums/support_esri.wellknownbasemap.html +21 -21
- package/docs/html/enums/utilities_number.numberformat.html +7 -7
- package/docs/html/index.html +12 -0
- package/docs/html/interfaces/data__relationship.relationship-1.html +1 -1
- package/docs/html/interfaces/data__relationship.relationshipproperties.html +1 -1
- package/docs/html/interfaces/forked_libs_shp_write.shpfiles.html +6 -6
- package/docs/html/interfaces/portal_classbreaksrenderer.classbreaksrenderer.html +4 -4
- package/docs/html/interfaces/portal_drawinginfo.drawinginfo-1.html +7 -7
- package/docs/html/interfaces/portal_heatmaprenderer.heatmaprenderer.html +4 -4
- package/docs/html/interfaces/portal_imageservicelayer.imageservicelayer-1.html +17 -17
- package/docs/html/interfaces/portal_layerdefinition.fieldoverride.html +6 -3
- package/docs/html/interfaces/portal_layerdefinition.layerdefinition-1.html +70 -47
- package/docs/html/interfaces/portal_layerdefinition.layerdefinitiondefaults.html +11 -8
- package/docs/html/interfaces/portal_layerdefinition.layertimeinfo.html +12 -9
- package/docs/html/interfaces/portal_layerdefinition.orderbyclause.html +244 -0
- package/docs/html/interfaces/portal_layerdefinition.timeinfoexportoptions.html +7 -4
- package/docs/html/interfaces/portal_pointcloudclassbreaksrenderer.pointcloudclassbreaksrenderer.html +4 -4
- package/docs/html/interfaces/portal_pointcloudrenderer.pointcloudrendererbase.html +5 -5
- package/docs/html/interfaces/portal_pointcloudrgbrenderer.pointcloudrgbrenderer.html +4 -4
- package/docs/html/interfaces/portal_pointcloudstretchrenderer.pointcloudstretchrenderer.html +4 -4
- package/docs/html/interfaces/portal_pointclouduniquevaluerenderer.pointclouduniquevaluerenderer.html +4 -4
- package/docs/html/interfaces/portal_predominancerenderer.predominancerenderer.html +4 -4
- package/docs/html/interfaces/portal_renderer.authoringinfo.html +7 -7
- package/docs/html/interfaces/portal_renderer.colorramp.html +5 -5
- package/docs/html/interfaces/portal_renderer.rendererbase.html +8 -5
- package/docs/html/interfaces/portal_simplerenderer.simplerenderer.html +4 -4
- package/docs/html/interfaces/portal_temporalrenderer.temporalrenderer.html +4 -4
- package/docs/html/interfaces/portal_uniquevaluefromstyle.uniquevaluefromstyle.html +4 -4
- package/docs/html/interfaces/portal_uniquevaluerenderer.uniquevaluerenderer.html +4 -4
- package/docs/html/interfaces/portal_vectorfieldrenderer.vectorfieldrenderer.html +394 -0
- package/docs/html/interfaces/portal_webmap.webmap-1.html +16 -16
- package/docs/html/interfaces/portal_webscene.webscene-1.html +16 -16
- package/docs/html/interfaces/support_arcgisrequesthelper.arcgisrequestoptions.html +1 -1
- package/docs/html/interfaces/support_esri.accessorlike.html +4 -4
- package/docs/html/interfaces/support_esri.changeevent.html +4 -4
- package/docs/html/interfaces/support_esri.layerwithsublayers.html +1 -1
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatistics.html +3 -3
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticsfrequentvalues.html +2 -2
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticshistogram.html +3 -3
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticslabel.html +2 -2
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticslabels.html +1 -1
- package/docs/html/interfaces/support_esri.pointcloudlayercachedstatisticsstats.html +9 -9
- package/docs/html/interfaces/support_esri.sublayerlike.html +14 -14
- package/docs/html/interfaces/support_serializable.propertydef.html +5 -5
- package/docs/html/interfaces/tasks_geocoding_arcgisgeocoder.arcgisgeocoderproperties.html +5 -5
- package/docs/html/interfaces/tasks_query_arcgisrelationship.arcgisrelationshipproperties.html +403 -0
- package/docs/html/interfaces/tasks_query_querybasedrelationship.querybasedrelationshipproperties.html +7 -2
- package/docs/html/interfaces/utilities_geometry.geographictransformationjson.html +1 -1
- package/docs/html/interfaces/utilities_geometry.geographictransformationstepjson.html +3 -3
- package/docs/html/interfaces/utilities_geometry.geojsonlinestring.html +2 -2
- package/docs/html/interfaces/utilities_geometry.geojsonmultilinestring.html +2 -2
- package/docs/html/interfaces/utilities_geometry.geojsonmultipoint.html +2 -2
- package/docs/html/interfaces/utilities_geometry.geojsonmultipolygon.html +2 -2
- package/docs/html/interfaces/utilities_geometry.geojsonpoint.html +2 -2
- package/docs/html/interfaces/utilities_geometry.geojsonpolygon.html +2 -2
- package/docs/html/interfaces/utilities_geometry.gmloptions.html +3 -3
- package/docs/html/interfaces/utilities_number.formatoptions.html +4 -4
- package/docs/html/interfaces/utilities_number.numberformatterproperties.html +5 -5
- package/docs/html/interfaces/utilities_number.numbersettings.html +4 -4
- package/docs/html/interfaces/utilities_number.parseoptions.html +2 -2
- package/docs/html/modules/config.html +1 -6
- package/docs/html/modules/data__relationship.html +1 -1
- package/docs/html/modules/data_convert.html +5 -5
- package/docs/html/modules/data_feature.html +3 -3
- package/docs/html/modules/mapping__layerextension.html +1 -1
- package/docs/html/modules/mapping_mapextension.html +1 -1
- package/docs/html/modules/portal_drawinginfo.drawinginfo.html +2 -2
- package/docs/html/modules/portal_imageservicelayer.imageservicelayer.html +2 -2
- package/docs/html/modules/portal_layerdefinition.html +6 -2
- package/docs/html/modules/portal_layerdefinition.layerdefinition.html +1 -1
- package/docs/html/modules/portal_layerdefinition.layerdefinitioncapabilities.html +6 -6
- package/docs/html/modules/portal_renderer.html +10 -10
- package/docs/html/modules/portal_renderer.renderer.html +2 -2
- package/docs/html/modules/portal_vectorfieldrenderer.html +157 -0
- package/docs/html/modules/portal_webmap.webmap.html +1 -1
- package/docs/html/modules/portal_webscene.webscene.html +1 -1
- package/docs/html/modules/support_esri.html +145 -61
- package/docs/html/modules/support_serializable.html +12 -12
- package/docs/html/modules/tasks_geocoding_utilities.html +164 -0
- package/docs/html/modules/tasks_query_arcgisrelationship.html +139 -0
- package/docs/html/modules/tasks_query_querybasedrelationship.html +2 -2
- package/docs/html/modules/tasks_search_arcgisgeocodersearchprovider.html +130 -0
- package/docs/html/modules/tasks_search_searchservice.html +1 -1
- package/docs/html/modules/utilities__layers.html +33 -33
- package/docs/html/modules/utilities_date.html +3 -3
- package/docs/html/modules/utilities_esri.html +2 -2
- package/docs/html/modules/utilities_geometry.html +25 -25
- package/docs/html/modules/utilities_number.html +7 -7
- package/docs/html/modules/utilities_query.html +2 -2
- package/docs/html/modules/utilities_relationships.html +2 -2
- package/docs/html/modules/utilities_uri.html +6 -6
- package/docs/html/modules/version.html +1 -1
- package/docs/html/modules.html +16 -0
- package/forked-libs/shp-write/src/write.js +1 -1
- package/mapping/MapImageLayerExtension.js +1 -1
- package/mapping/MapImageSublayerExtension.js +1 -1
- package/mapping/support/DefaultLayerExtensionFactory.js +1 -1
- package/mapping/support/WfsCapabilities.js +1 -1
- package/package.json +30 -31
- package/portal/DrawingInfo.js +1 -1
- package/portal/ImageServiceLayer.js +1 -1
- package/portal/Layer.js +1 -1
- package/portal/LayerBase.js +1 -1
- package/portal/LayerDefinition.d.ts +24 -0
- package/portal/LayerDefinition.js +1 -1
- package/portal/Renderer.d.ts +3 -2
- package/portal/Renderer.js +1 -1
- package/portal/VectorFieldRenderer.d.ts +41 -0
- package/portal/VectorFieldRenderer.js +1 -0
- package/support/_ArcGISRelationshipCollection.js +1 -1
- package/support/_query.js +1 -1
- package/support/esri.d.ts +9 -3
- package/tasks/geocoding/ArcGISGeocoder.d.ts +9 -1
- package/tasks/geocoding/ArcGISGeocoder.js +1 -1
- package/tasks/geocoding/utilities.d.ts +7 -0
- package/tasks/geocoding/utilities.js +1 -0
- package/tasks/identify/ArcGISSublayerQueryIdentifyProvider.js +1 -1
- package/tasks/identify/BuildingComponentSublayerClientSideIdentifyProvider.d.ts +13 -1
- package/tasks/identify/BuildingComponentSublayerClientSideIdentifyProvider.js +1 -1
- package/tasks/identify/CSVLayerClientSideQueryIdentifyProvider.js +1 -1
- package/tasks/identify/ClientSideIdentifyProvider.d.ts +1 -1
- package/tasks/identify/ClientSideIdentifyProvider.js +1 -1
- package/tasks/identify/FeatureLayerQueryIdentifyProvider.js +1 -1
- package/tasks/identify/ImageryLayerIdentifyProvider.js +1 -1
- package/tasks/identify/SceneLayerClientSideIdentifyProvider.d.ts +1 -1
- package/tasks/identify/SceneLayerClientSideIdentifyProvider.js +1 -1
- package/tasks/identify/StreamLayerClientSideQueryIdentifyProvider.d.ts +1 -1
- package/tasks/identify/WMSSublayerIdentifyProvider.js +1 -1
- package/tasks/query/ArcGISRelationship.d.ts +69 -0
- package/tasks/query/ArcGISRelationship.js +1 -0
- package/tasks/query/ArcGISServiceTableQueryProvider.js +1 -1
- package/tasks/query/ArcGISSublayerQueryProvider.js +1 -1
- package/tasks/query/BuildingComponentSublayerClientSideQueryProvider.d.ts +12 -1
- package/tasks/query/BuildingComponentSublayerClientSideQueryProvider.js +1 -1
- package/tasks/query/CSVLayerClientSideQueryProvider.js +1 -1
- package/tasks/query/ClientSideQueryProvider.d.ts +1 -1
- package/tasks/query/ClientSideQueryProvider.js +1 -1
- package/tasks/query/FeatureLayerQueryProvider.js +1 -1
- package/tasks/query/ImageryLayerQueryProvider.js +1 -1
- package/tasks/query/QueryBasedRelationship.d.ts +3 -3
- package/tasks/query/SceneLayerClientSideQueryProvider.d.ts +1 -1
- package/tasks/query/SceneLayerQueryProvider.js +1 -1
- package/tasks/query/StreamLayerClientSideQueryProvider.d.ts +1 -1
- package/tasks/search/ArcGISGeocoderSearchProvider.d.ts +17 -0
- package/tasks/search/ArcGISGeocoderSearchProvider.js +1 -0
- package/tasks/search/SearchService.js +1 -1
- package/utilities/arcade.js +1 -1
- package/utilities/esri.d.ts +1 -1
- package/utilities/geometry.js +1 -1
- package/utilities/number.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{executeQuery,executeCount}from"../../support/_query.js";import{isSceneLayer}from"../../utilities/_layers.js";import{QueryProviderBase}from"./QueryProviderBase.js";export class SceneLayerQueryProvider extends QueryProviderBase{isSupported(e){const{layer:r}=e;return isSceneLayer(r)&&!!r.associatedLayer&&!e.enableClientSideData}_query(e,r,t){const{layer:a}=e,s=a.associatedLayer.createQuery();return s.where=r,s.outFields=t.outFields,s.returnGeometry=t.returnGeometry,s.outSpatialReference=t.outSpatialReference,s.maxAllowableOffset=t.maxAllowableOffset,t.spatialFilter&&(s.spatialRelationship="intersects",s.geometry=t.spatialFilter),s.
|
|
1
|
+
import{executeQuery,executeCount}from"../../support/_query.js";import{isSceneLayer}from"../../utilities/_layers.js";import{QueryProviderBase}from"./QueryProviderBase.js";export class SceneLayerQueryProvider extends QueryProviderBase{isSupported(e){const{layer:r}=e;return isSceneLayer(r)&&!!r.associatedLayer&&!e.enableClientSideData}_query(e,r,t){const{layer:a}=e,s=a.associatedLayer.createQuery();return s.where=r,s.outFields=t.outFields,s.returnGeometry=t.returnGeometry,s.outSpatialReference=t.outSpatialReference,s.maxAllowableOffset=t.maxAllowableOffset,t.spatialFilter&&(s.spatialRelationship="intersects",s.geometry=t.spatialFilter),s.num=t.maxResults,s.returnZ=!0,executeQuery(s,e,a.associatedLayer,t.cancelToken)}async _count(e,r,t){const{layer:a}=e,s=a.associatedLayer.createQuery();return s.where=r,s.outFields=t.outFields,s.returnGeometry=t.returnGeometry,t.spatialFilter&&(s.spatialRelationship="intersects",s.geometry=t.spatialFilter),s.num=t.maxResults,executeCount(s,e,a.associatedLayer,t.cancelToken)}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Query from "@arcgis/core/
|
|
1
|
+
import type Query from "@arcgis/core/rest/support/Query";
|
|
2
2
|
import type { FeatureSource } from "../../data/FeatureSource.js";
|
|
3
3
|
import { ClientSideQueryProvider, ClientSideQueryableLayerExtension } from "./ClientSideQueryProvider.js";
|
|
4
4
|
import type { QueryOptions } from "./QueryOptions.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Feature } from "../../data/Feature.js";
|
|
2
|
+
import type { FeatureSource } from "../../data/FeatureSource.js";
|
|
3
|
+
import { GeocoderSearchProvider } from "./GeocoderSearchProvider.js";
|
|
4
|
+
import type { SearchOptions } from "./SearchOptions.js";
|
|
5
|
+
/**
|
|
6
|
+
* A search provider for geocoders.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ArcGISGeocoderSearchProvider extends GeocoderSearchProvider {
|
|
9
|
+
/**
|
|
10
|
+
* @inheritdoc
|
|
11
|
+
*/
|
|
12
|
+
isSupported(source: FeatureSource): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @inheritdoc
|
|
15
|
+
*/
|
|
16
|
+
protected _search(sources: FeatureSource[], searchText: string, options: SearchOptions): AsyncIterable<Feature>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SCORE_FIELD,SCORE_FIELD_ORIGINAL}from"../../data/Feature.js";import{isArcGISGeocoder}from"../geocoding/utilities.js";import{GeocoderSearchProvider}from"./GeocoderSearchProvider.js";const SCORE_DECREMENT_UNIT=.001,SCORE_EXACT_MATCH=100,SCORE_NON_MATCH_MAX=99,MATCH_ADDR_FIELD="Match_addr";export class ArcGISGeocoderSearchProvider extends GeocoderSearchProvider{isSupported(e){return isArcGISGeocoder(e)}async*_search(e,t,r){var o;const[a]=e,{cancelToken:s,currentScale:i,initialSearchArea:c,outSpatialReference:E,maxResults:d}=null!=r?r:{},S={cancelToken:s,searchPoint:i&&(null===(o=null==c?void 0:c.extent)||void 0===o?void 0:o.center),searchArea:!i&&c,outFields:a.featureSettings.outFields,outSpatialReference:E,maxResults:d};if(!t)return;const _=t.replace(/^"*|"*$/g,"");let n=0,u=.001;for await(const e of a.geocode(_,S)){if(e.attributes.get("Match_addr")===_)e.attributes.set(SCORE_FIELD,100),e.attributes.set(SCORE_FIELD_ORIGINAL,100);else{let t=e.attributes.get(SCORE_FIELD);t=t>99?99:t,e.attributes.set(SCORE_FIELD,t),e.attributes.set(SCORE_FIELD_ORIGINAL,t),t===n?(e.attributes.set(SCORE_FIELD,n-u),e.attributes.set(SCORE_FIELD_ORIGINAL,n-u),u+=.001):(n=t,u=.001)}yield e}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Point from"@arcgis/core/geometry/Point";import{distance}from"@arcgis/core/geometry/geometryEngine";import{isLayerExtension,isMapExtension,isSublayerExtension}from"../../ItemType.js";import{SCORE_FIELD,SCORE_FIELD_ORIGINAL}from"../../data/Feature.js";import{MapExtension}from"../../mapping/MapExtension.js";import{cancelify}from"../../support/Cancellable.js";import{isCancellation}from"../../support/utilities.js";import{groupBy}from"../../utilities/array.js";import{AsyncQueue}from"../../utilities/asyncIterable.js";import{checkArg}from"../../utilities/checkArg.js";import{Collection}from"../../utilities/collection.js";import{isMap}from"../../utilities/mapping.js";import{parallelEach}from"../../utilities/promise.js";import{GeocoderSearchProvider}from"./GeocoderSearchProvider.js";import{QuerySearchProvider}from"./QuerySearchProvider.js";import{SearchError}from"./SearchError.js";import{SearchOptions}from"./SearchOptions.js";export class SearchService{constructor(){this.providers=new Collection,this.providers.add(new QuerySearchProvider),this.providers.add(new GeocoderSearchProvider)}isSupported(e){return!!this.providers.find((
|
|
1
|
+
import Point from"@arcgis/core/geometry/Point";import{distance}from"@arcgis/core/geometry/geometryEngine";import{isLayerExtension,isMapExtension,isSublayerExtension}from"../../ItemType.js";import{SCORE_FIELD,SCORE_FIELD_ORIGINAL}from"../../data/Feature.js";import{MapExtension}from"../../mapping/MapExtension.js";import{cancelify}from"../../support/Cancellable.js";import{isCancellation}from"../../support/utilities.js";import{groupBy}from"../../utilities/array.js";import{AsyncQueue}from"../../utilities/asyncIterable.js";import{checkArg}from"../../utilities/checkArg.js";import{Collection}from"../../utilities/collection.js";import{isMap}from"../../utilities/mapping.js";import{parallelEach}from"../../utilities/promise.js";import{ArcGISGeocoderSearchProvider}from"./ArcGISGeocoderSearchProvider.js";import{GeocoderSearchProvider}from"./GeocoderSearchProvider.js";import{QuerySearchProvider}from"./QuerySearchProvider.js";import{SearchError}from"./SearchError.js";import{SearchOptions}from"./SearchOptions.js";export class SearchService{constructor(){this.providers=new Collection,this.providers.add(new QuerySearchProvider),this.providers.add(new ArcGISGeocoderSearchProvider),this.providers.add(new GeocoderSearchProvider)}isSupported(e){return!!this.providers.find((r=>r.isSupported(e)))}search(e,r,i){checkArg("sources",e).isNotMissing();const t={...SearchOptions.DEFAULTS,...i},a=_getMaxDistanceFromPointOfInterest(t);let o,n=[];Collection.isCollection(e)?n=e.toArray():isMapExtension(e)?o=e:isMap(e)?o=new MapExtension({map:e}):n=[...e];let s=0;const c=new AsyncQueue,l=new Map,p=(e,o)=>{o&&0!==e.length&&(s++,c.isDone||(async()=>{const n=[];try{await parallelEach(e,(e=>e.initialize()));for await(const s of o.search(e,r,i)){if(c.isDone)return;t.outSpatialReference&&(s.schema.spatialReference=t.outSpatialReference),_adjustScoreByDistance(s,a,i);let e=!1;n.push(s.attributes.on("change",(()=>{e||(e=!0,_adjustScoreByDistance(s,a,i),e=!1)}))),c.add(s)}}catch(r){if(isCancellation(r))return void c.reject(r);l.set(e,r)}finally{n.forEach((e=>e.remove()))}0==--s&&(l.size?c.reject(new SearchError(l)):c.done())})())};return(async()=>{try{o&&(await o.initialize(),n=o.getAllFeatureSources(isSearchable))}catch(e){c.reject(new Error(`Map failed to initialize: ${e}`))}groupBy(n,(e=>this.providers.find((r=>r.isSupported(e))))).forEach(p),0===s&&c.done()})(),c}count(e,r,i){checkArg("sources",e).isNotMissing();const t={...i,returnGeometry:!1};let a,o=[];Collection.isCollection(e)?o=e.toArray():isMapExtension(e)?a=e:isMap(e)?a=new MapExtension({map:e}):o=[...e];let n=0;const s=new AsyncQueue,c=new Map,l=(e,i)=>{i&&(n++,(async()=>{if(!s.isDone){try{if(await parallelEach(e,(e=>e.initialize())),s.isDone)return;s.addMany(await i.count(e,r,t))}catch(r){if(isCancellation(r))return void s.reject(r);c.set(e,r)}0==--n&&(c.size?s.reject(new SearchError(c)):s.done())}})())};return(async()=>{try{a&&(await a.initialize(),o=a.getAllFeatureSources(isSearchable))}catch(e){s.reject(new Error(`Map failed to initialize: ${e}`))}groupBy(o,(e=>this.providers.find((r=>r.isSupported(e))))).forEach(l),0===n&&s.done()})(),s}async suggest(e,r,i){checkArg("sources",e).isNotMissing();const t={...SearchOptions.DEFAULTS,...i};return cancelify(this._suggest(e,r,t),t.cancelToken)}async _suggest(e,r,i){let t,a=[];Collection.isCollection(e)?a=e.toArray():isMapExtension(e)?t=e:isMap(e)?t=new MapExtension({map:e}):a=[...e];const o=[];if(t)try{await t.initialize(),a=t.getAllFeatureSources(isSearchable)}catch(e){throw new Error(`Map failed to initialize: ${e}`)}const n=groupBy(a,(e=>this.providers.find((r=>r.isSupported(e)))));return await parallelEach(n.entries(),(async([e,t])=>{if(e)try{const a=await e.suggest(t,r,i);for(const e of a){const r=o.findIndex((r=>r.suggestion===e.suggestion));r>=0?e.score>o[r].score&&(o[r]=e):o.push(e)}}catch(e){throw isCancellation(e)?e:new SearchError([[t,e]])}})),o.sort(((e,r)=>r.score-e.score)).slice(0,i.maxSuggestions)}}export function isSearchable(e){var r,i;return!!e.taskSettings.enableSearch&&(isLayerExtension(e)?null===(r=e.layer)||void 0===r?void 0:r.visible:!isSublayerExtension(e)||(null===(i=e.sublayer)||void 0===i?void 0:i.visible))}function _getMaxDistanceFromPointOfInterest(e){if(!(e.near&&e.initialSearchArea&&e.initialSearchArea.extent&&e.initialSearchArea.extent.spatialReference.equals(e.near.spatialReference)))return;const{extent:r}=e.initialSearchArea,{spatialReference:i}=r,t=distance(new Point({x:r.xmin,y:r.ymin,spatialReference:i}),e.near,void 0),a=distance(new Point({x:r.xmin,y:r.ymax,spatialReference:i}),e.near,void 0),o=distance(new Point({x:r.xmax,y:r.ymin,spatialReference:i}),e.near,void 0),n=distance(new Point({x:r.xmax,y:r.ymax,spatialReference:i}),e.near,void 0);return Math.max(t,a,o,n)}function _adjustScoreByDistance(e,r,i){if(!(r&&i.near&&i.initialSearchArea&&e.geometry&&i.near.spatialReference.equals(e.geometry.spatialReference)&&e.attributes.has(SCORE_FIELD)))return;const t=(r-distance(e.geometry,i.near,void 0))/r,a=(2*e.attributes.get(SCORE_FIELD_ORIGINAL)+t)/3;e.attributes.set(SCORE_FIELD,a)}
|
package/utilities/arcade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as Arcade from"@arcgis/core/arcade/arcade";import*as arcadeUtils from"@arcgis/core/support/arcadeUtils";import{toGraphic}from"../data/Feature.js";import{checkArg}from"./checkArg.js";const arcadeScriptCache=new Map;export function isArcadeScriptAsync(e,r){const a=_getArcadeScriptForExpression(e,r);return["$datastore","$map","$layer"].some((e=>arcadeUtils.hasVariable(a,e)))||Arcade.scriptIsAsync({...a,isAsync:void 0,usesFeatureSet:void 0,usesGeometry:void 0},void 0)}export function arcadeScriptUsesGeometry(e,r){return!!_getArcadeScriptForExpression(e,r).usesGeometry}export async function enableGeometrySupportIfNeeded(e){var r,a,t,s;const{spatialReference:c}=e.geometry,i=null===(s=null===(t=null===(a=null===(r=e.source)||void 0===r?void 0:r.layer)||void 0===a?void 0:a.elevationInfo)||void 0===t?void 0:t.featureExpressionInfo)||void 0===s?void 0:s.expression;i&&arcadeScriptUsesGeometry(i,c)&&await Arcade.enableGeometrySupport()}export function runArcadeExpression(e,r){const{map:a,layer:t,vars:s,feature:c,spatialReference:i}=r;checkArg("$map and $layer parameters are not supported in synchronous arcade",r).satisfies((()=>!a&&!t));const o=arcadeUtils.getViewInfo({spatialReference:i}),n=arcadeUtils.createExecContext(c&&toGraphic(c),o);if(s)for(const e of Object.keys(s))n.vars[e]=s[e];const p=_getArcadeScriptForExpression(e,i);return arcadeUtils.hasVariable(p,"$feature")&&checkArg("params.feature",c).isNotMissing(),Arcade.executeScript(p,n)}export async function runAsyncArcadeExpression(e,r){const{map:a,layer:t,vars:s,feature:c,spatialReference:i}=r,o={..._getArcadeScriptForExpression(e,i)},n=["$datastore","$map","$layer"].filter((e=>arcadeUtils.hasVariable(o,e)));await arcadeUtils.loadScriptDependencies(o,!0,n);const p=arcadeUtils.getViewInfo({spatialReference:i}),d=arcadeUtils.createExecContext(c&&toGraphic(c),p);if(o.isAsync=!0,o.usesFeatureSet=!0,await Arcade.
|
|
1
|
+
import*as Arcade from"@arcgis/core/arcade/arcade";import*as arcadeUtils from"@arcgis/core/support/arcadeUtils";import{toGraphic}from"../data/Feature.js";import{checkArg}from"./checkArg.js";const arcadeScriptCache=new Map;export function isArcadeScriptAsync(e,r){const a=_getArcadeScriptForExpression(e,r);return["$datastore","$map","$layer"].some((e=>arcadeUtils.hasVariable(a,e)))||Arcade.scriptIsAsync({...a,isAsync:void 0,usesFeatureSet:void 0,usesGeometry:void 0},void 0)}export function arcadeScriptUsesGeometry(e,r){return!!_getArcadeScriptForExpression(e,r).usesGeometry}export async function enableGeometrySupportIfNeeded(e){var r,a,t,s;const{spatialReference:c}=e.geometry,i=null===(s=null===(t=null===(a=null===(r=e.source)||void 0===r?void 0:r.layer)||void 0===a?void 0:a.elevationInfo)||void 0===t?void 0:t.featureExpressionInfo)||void 0===s?void 0:s.expression;i&&arcadeScriptUsesGeometry(i,c)&&await Arcade.enableGeometrySupport()}export function runArcadeExpression(e,r){const{map:a,layer:t,vars:s,feature:c,spatialReference:i}=r;checkArg("$map and $layer parameters are not supported in synchronous arcade",r).satisfies((()=>!a&&!t));const o=arcadeUtils.getViewInfo({spatialReference:i}),n=arcadeUtils.createExecContext(c&&toGraphic(c),o);if(s)for(const e of Object.keys(s))n.vars[e]=s[e];const p=_getArcadeScriptForExpression(e,i);return arcadeUtils.hasVariable(p,"$feature")&&checkArg("params.feature",c).isNotMissing(),Arcade.executeScript(p,n)}export async function runAsyncArcadeExpression(e,r){const{map:a,layer:t,vars:s,feature:c,spatialReference:i}=r,o={..._getArcadeScriptForExpression(e,i)},n=["$datastore","$map","$layer"].filter((e=>arcadeUtils.hasVariable(o,e)));await arcadeUtils.loadScriptDependencies(o,!0,n);const p=arcadeUtils.getViewInfo({spatialReference:i}),d=arcadeUtils.createExecContext(c&&toGraphic(c),p);if(o.isAsync=!0,o.usesFeatureSet=!0,await Arcade.enableAsyncSupport(),await Arcade.enableFeatureSetSupport(),o.usesGeometry&&await Arcade.enableGeometrySupport(),arcadeUtils.hasVariable(o,"$feature")&&checkArg("params.feature",c).isNotMissing(),n.includes("$map")&&(checkArg("params.map",a).isNotMissing(),d.vars.$map=arcadeUtils.convertMapToFeatureSetCollection({map:a,spatialReference:i})),n.includes("$layer")&&(checkArg("params.layer",t).isNotMissing(),d.vars.$layer=arcadeUtils.convertFeatureLayerToFeatureSet(t,i)),n.includes("$datastore")&&(checkArg("params.layer",t).isNotMissing(),d.vars.$datastore=arcadeUtils.convertServiceUrlToWorkspace({url:t.url,spatialReference:i})),s)for(const e of Object.keys(s))d.vars[e]=s[e];return arcadeUtils.createFunction(o,d)(d)}function _getArcadeScriptForExpression(e,r){if(arcadeScriptCache.has(e))return arcadeScriptCache.get(e);const a=Arcade.parseScript(e,r);return arcadeScriptCache.set(e,a),a}
|
package/utilities/esri.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type Field from "@arcgis/core/layers/support/Field";
|
|
|
9
9
|
import type EsriFieldInfo from "@arcgis/core/popup/FieldInfo";
|
|
10
10
|
import type ImageMediaInfo from "@arcgis/core/popup/content/ImageMediaInfo";
|
|
11
11
|
import type PortalItem from "@arcgis/core/portal/PortalItem";
|
|
12
|
-
import type FeatureSet from "@arcgis/core/
|
|
12
|
+
import type FeatureSet from "@arcgis/core/rest/support/FeatureSet";
|
|
13
13
|
/**
|
|
14
14
|
* Loads the given Esri API object and returns a promise that is fulfilled when
|
|
15
15
|
* the object is loaded.
|
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{isSupported,isLoaded,load,getTransformation,project as projectionEngineProject}from"@arcgis/core/geometry/projection";import{canProject,project as webMercatorProject}from"@arcgis/core/geometry/support/webMercatorUtils";import GeometryService from"@arcgis/core/tasks/GeometryService";import BufferParameters from"@arcgis/core/tasks/support/BufferParameters";import ProjectParameters from"@arcgis/core/tasks/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{parse}from"./number.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),l=e=>{const r=c(e)?denormalize([e.points],s)[0]:e.points;for(const e of r)a(e[0],e[1])},m=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":l(r);break;case"extent":m(Polygon.fromExtent(r));break;case"polyline":g(r);break;case"polygon":m(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 l=Math.min(o,i),m=Math.max(n,t);m-l<a-s&&(e=c,s=l,a=m)}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){var t,n;checkArg("geometry",e).isNotMissing();const o=e.match(wktRegex);if(o){const e=null===(t=o[2])||void 0===t?void 0:t.includes("Z"),i=null===(n=o[2])||void 0===n?void 0:n.includes("M");switch(o[1]){case"POINT":{const t=_parseWktPoint(o[3],o[2]);return new Point({x:t[0],y:t[1],z:e?t[2]:void 0,m:!e&&i?t[2]:i?t[3]:void 0,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"MULTIPOINT":{const t=_parseWktPointArray(o[3],o[2]);return new Multipoint({points:t,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"LINESTRING":{const t=_parseWktPointArray(o[3],o[2]);return new Polyline({paths:[t],hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"MULTILINESTRING":{const t=_parseWkt2DPointArray(o[3],o[2]);return new Polyline({paths:t,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"POLYGON":{const t=_parseWkt2DPointArray(o[3],o[2]);return new Polygon({rings:t,hasZ:e,hasM:i,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);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(null==n?void 0: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(isSupported()&&(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){void 0!==config.geometryService&&null!==config.geometryService||(config.geometryService=new GeometryService({url:DEFAULT_GEOMETRY_SERVICE_URL}));const s=new BufferParameters({geometries:o?e:[e],distances:i?r:[r],unit:t,unionResults:n});return config.geometryService.buffer(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=null!=r?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});(null==t?void 0: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),void 0!==config.geometryService&&null!==config.geometryService||(config.geometryService=new GeometryService({url:DEFAULT_GEOMETRY_SERVICE_URL}));try{return await config.geometryService.project(n)}catch(e){throw new GeometryServiceError(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!==(null==r?void 0:r.spatialReference))return r.spatialReference;return SpatialReference.WebMercator}function _getProjectOptions(e,r,t){return(null==t?void 0: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 _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 _parseGmlCoordPairFromString(e){const r=e.replace(/,/g,"").split(" ").map(Number);if(2===r.length)return[r[0],r[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(" ").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(" ")}export function isGeometry(e){return isPoint(e)||isMultipoint(e)||isPolyline(e)||isPolygon(e)||isExtent(e)||isMesh(e)}export function isPoint(e){return"point"===(null==e?void 0:e.type)}export function isMultipoint(e){return"multipoint"===(null==e?void 0:e.type)}export function isPolyline(e){return"polyline"===(null==e?void 0:e.type)}export function isPolygon(e){return"polygon"===(null==e?void 0:e.type)}export function isExtent(e){return"extent"===(null==e?void 0:e.type)}export function isMesh(e){return"mesh"===(null==e?void 0: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{isSupported,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{parse}from"./number.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),l=e=>{const r=c(e)?denormalize([e.points],s)[0]:e.points;for(const e of r)a(e[0],e[1])},m=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":l(r);break;case"extent":m(Polygon.fromExtent(r));break;case"polyline":g(r);break;case"polygon":m(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 l=Math.min(o,i),m=Math.max(n,t);m-l<a-s&&(e=c,s=l,a=m)}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){var t,n;checkArg("geometry",e).isNotMissing();const o=e.match(wktRegex);if(o){const e=null===(t=o[2])||void 0===t?void 0:t.includes("Z"),i=null===(n=o[2])||void 0===n?void 0:n.includes("M");switch(o[1]){case"POINT":{const t=_parseWktPoint(o[3],o[2]);return new Point({x:t[0],y:t[1],z:e?t[2]:void 0,m:!e&&i?t[2]:i?t[3]:void 0,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"MULTIPOINT":{const t=_parseWktPointArray(o[3],o[2]);return new Multipoint({points:t,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"LINESTRING":{const t=_parseWktPointArray(o[3],o[2]);return new Polyline({paths:[t],hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"MULTILINESTRING":{const t=_parseWkt2DPointArray(o[3],o[2]);return new Polyline({paths:t,hasZ:e,hasM:i,spatialReference:r||SpatialReference.WGS84})}case"POLYGON":{const t=_parseWkt2DPointArray(o[3],o[2]);return new Polygon({rings:t,hasZ:e,hasM:i,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);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(null==n?void 0: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(isSupported()&&(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=null!=r?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});(null==t?void 0: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 new GeometryServiceError(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!==(null==r?void 0:r.spatialReference))return r.spatialReference;return SpatialReference.WebMercator}function _getProjectOptions(e,r,t){return(null==t?void 0: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 _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 _parseGmlCoordPairFromString(e){const r=e.replace(/,/g,"").split(" ").map(Number);if(2===r.length)return[r[0],r[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(" ").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(){var e,r,t;return null!==(t=null!==(e=config.geometryServiceUrl)&&void 0!==e?e:null===(r=config._geometryService)||void 0===r?void 0:r.url)&&void 0!==t?t: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"point"===(null==e?void 0:e.type)}export function isMultipoint(e){return"multipoint"===(null==e?void 0:e.type)}export function isPolyline(e){return"polyline"===(null==e?void 0:e.type)}export function isPolygon(e){return"polygon"===(null==e?void 0:e.type)}export function isExtent(e){return"extent"===(null==e?void 0:e.type)}export function isMesh(e){return"mesh"===(null==e?void 0:e.type)}
|
package/utilities/number.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{getMatchingLocales,get}from"../locale.js";import{serializable,SerializableBase}from"../support/Serializable.js";import{settings as formatSettings}from"./FormatSettings.js";import{checkArg}from"./checkArg.js";export{isNumeric}from"./_number.js";const WHITESPACE_SEPARATORS=[" ",String.fromCharCode(160),String.fromCharCode(8239)],PERCENT_SIGN_REGEX=/[%٪%٪]/g,CURRENCY_REGEX=/₩|¥|元|レイ|₾|₽|₼|₺|₹|₸|₴|₲|₱|₮|₭|€|₫|₪|₩|₧|₦|₤IT|₡|CN¥|PTE||៛|የቻይና ዩዋን|ብር|ლ|฿|සිෆ්එ|රු\.|ಲೀ|રૂ\.|৳|लेई|रू|नेरू|ل\.ل\.|ل\.س\.|ریال|ر\.ي\.|ر\.ق\.|ر\.ع\.|ر\.س\.|ر\.إ\.|د\.م\.|د\.ل\.|د\.ك\.|د\.ع\.|د\.س\.|د\.ج\.|د\.ت\.|د\.ب\.|د\.إ\.|د\.أ\.|ج\.م\.|ج\.س\.|أ\.م\.|؋|ל״י|֏|щ\.д\.|сом|руб\.|руб|р\.|лв\.|крб\.|кр|ден|ТМТ|КМ|Δρχ|öS|Íkr|¥CN|¥|£MT|£LB|£L|£IL|£IE|£GI|£GB|£FK|£E|£CY|£|zł|zl|soʻm|rb|r\.|p\.|mk|ley|leu|lej|lei|kr\.|kr|kn|din\.|den|Zł|ZWR|ZWL|ZWD|ZRZ|ZRN|ZMW|ZMK|ZK|ZAR|ZAL|YUR|YUN|YUM|YUD|YER|YDD|XXXX|XXX|XUA|XTS|XSU|XRE|XPT|XPF|XPD|XOF|XFU|XFO|XEU|XDR|XCD|XBD|XBC|XBB|XBA|XAU|XAG|XAF|WST|WS\$|VUV|VT|VNN|VND|VEF|VEB|UZS|UYU|UYP|UYI|UY\$|USh|USS|USN|USD|US\$|UM|UK£|UGX|UGS|UAK|UAH|Tk|TZS|TWD|TTD|TT\$|TSh|TRY|TRL|TPE|TOP|TND|TMT|TMM|TK|TJS|TJR|THB|T\$|S£|SZL|SYP|SVC|SUR|STN|STD|SSP|SRG|SRD|SR\$|SR|SOS|SLL|SKK|SIT|SI\$|SHP|SGD|SEK|SD£|SDP|SDG|SDD|SCR|SBD|SB\$|SAR|S\/|S\$|S|Rs\.|Rs|Rp|RWF|RUR|RUB|RSD|RON|ROL|RM|RHD|RF|RD\$|R\$|R|QAR|Q|PYG|PTE|PLZ|PLN|PKR|PHP|PGK|PES|PEN|PEI|PAB|P\.|P|OMR|Nkr|Nfk|NZD\$|NZD|NZ\$|NT\$|NPR|NOK|NLG|NKr|NIS|NIO|NIC|NGN|NAf\.|NAf|NAD|N\$|MZN|MZM|MZE|MYR|MXV|MXP|MXN|MX\$|MWK|MVR|MVP|MUR|MTn|MTP|MTL|MRO|MOP\$|MOP|MNT|MMK|MLF|MKN|MKD|MK|MGF|MGA|MDL|MDC|MCF|MAF|MAD|L£|Lt|Ls|Lekë|Le|LYD|LVR|LVL|LUL|LUF|LUC|LTT|LTL|LSL|LS|LRD|LKR|LE|LBP|LAK|L\$|L|Kčs|Kč|Kz|Kw|Ksh|Kr|Kn|KZT|KYD|KY\$|KWD|KRW|KRO|KRH|KPW|KMF|KM|KHR|KGS|KES|K|JP¥|JPY|JOD|JMD|JM\$|J\$|Ikr|ITL|ISK|ISJ|IRR|IQD|INR|ILS|ILR|ILP|IE£|IEP|IDR|HUF|HTG|HRK|HRD|HNL|HKD|HK\$|Gs\.|Gs|GYD|GY\$|GWP|GWE|GTQ|GRD|GQE|GNS|GNF|GMD|GIP|GH₵|GHS|GHC|GEL|GEK|GB£|GBP|G\$|G|Ft|Fl£|Fdj|FRF|FR|FK£|FKP|FJD|FJ\$|FIM|FG|FCFP|FCFA|FC|FBu|FB|F\.Rw|F\.G\.|F|E£|Esc\.|Ekr|EUR|ETB|ESP|ESB|ESA|ERN|EG£|EGP|EEK|ECV|ECU|ECS|EC\$|E|Dkr|Db|DZD|DT|DOP|DO\$|DM|DKK|DJF|DEM|DDM|DA|D|Cub\$|CZK|CYP|CVE|CUP|CUC\$|CUC|CU\$|CSK|CSD|CRC|COU|COP|CO\$|CN¥|CNY|CNX|CNH|CLP|CLF|CLE|CL\$|CI\$|CHW|CHF|CHE|CFPF|CFP|CFA|CF|CDF|CAD|CA\$|C\$|BsF|Bs\.|Bs|Br|Bds\$|BZD|BZ\$|BYR|BYN|BYB|BWP|BUK|BTN|BSD|BS\$|BRZ|BRR|BRN|BRL|BRE|BRC|BRB|BR\$|BOV|BOP|BOL|BOB|BND|BN\$|BMD|BM\$|BIF|BHD|BGO|BGN|BGM|BGL|BGK|BGJ|BEL|BEF|BEC|BDT|BD\$|BBD|BB\$|BAN|BAM|BAD|B\/\.|B\$|Ar|Afl\.|Afl|AZN|AZM|AWG|AUD\$|AUD|AU\$|ATS|ARS|ARP|ARM|ARL|ARA|AR\$|AOR|AON|AOK|AOA|ANG|AMD|ALL|ALK|AFN|AFA|AED|ADP|A\$|\*\*\*|\$ US|\$ SG|\$ NZ|\$ HK|\$ AU|\$b|\$UY|\$US|\$U|\$TT|\$SR|\$SG|\$SB|\$RH|\$NZ|\$NA|\$MX|\$MN|\$HK|\$FJ|\$EC|\$CO|\$CL|\$CA|\$C|\$BZ|\$BS|\$BN|\$BM|\$AU|\$AR|\$/g;export var NumberFormat;!function(t){t.NUMBER="n",t.FIXED_POINT="f",t.CURRENCY="c",t.ACCOUNTING="a",t.PERCENT="p",t.ROUND_TRIP="r",t.DEFAULT="f"}(NumberFormat||(NumberFormat={}));export function format(...t){return globalFormatter.format(...t)}export function parse(...t){return globalFormatter.parse(...t)}let NumberFormatter=class extends SerializableBase{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}get defaultParseFormat(){return this._defaultParseFormat}set defaultParseFormat(t){this._defaultParseFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}format(...t){var r,e,a,i;let o,n;if(1===t.length?(o=t[0],n={}):arguments.length>=2&&(o=t[1],n="string"==typeof t[0]?{format:t[0]}:t[0],checkArg("options",n).isNotMissing()),null==o||isNaN(o))return"";let m=n.format||this.defaultFormat||NumberFormat.DEFAULT;if(m===NumberFormat.ROUND_TRIP)return o.toString();const s=m.toLowerCase();if(s===NumberFormat.CURRENCY||s===NumberFormat.ACCOUNTING){const t=n.currency||this.currency||"USD";m=s,m+=null!==(e=null!==(r=n.fractionalDigits)&&void 0!==r?r:this.fractionalDigits)&&void 0!==e?e:"",m+=t?`$${t}`:""}else s!==NumberFormat.NUMBER&&s!==NumberFormat.FIXED_POINT&&s!==NumberFormat.PERCENT||(m=s,m+=null!==(i=null!==(a=n.fractionalDigits)&&void 0!==a?a:this.fractionalDigits)&&void 0!==i?i:"");n.locale=n.locale||this.locale;const l=getMatchingLocales(n.locale||get()),u=`${l.join(";")}|${m}`;let N=numberFormatters.get(u);if(!N){N=[];const t=m.split(";",3);1===t.length?(N[0]=this._createNumberFormatter(l,t[0]),N[1]=N[0],N[2]=N[0]):2===t.length?(N[0]=this._createNumberFormatter(l,t[0]),N[1]=this._createNumberFormatter(l,t[1]),N[2]=N[0]):3===t.length&&(N[0]=this._createNumberFormatter(l,t[0]),N[1]=this._createNumberFormatter(l,t[1]),N[2]=this._createNumberFormatter(l,t[2])),numberFormatters.set(u,N)}return o>0?N[0](o):o<0?N[1](o):N[2](o)}parse(...t){var r;let e,a;if(1===t.length?(e=t[0],a={}):t.length>=2&&(e=t[1],a="string"==typeof t[0]||Array.isArray(t[0])?{format:t[0]}:t[0]),"number"==typeof e)return e;if("boolean"==typeof e)return e?1:0;if(null==e)return NaN;let i=e.toString().trim();a.locale=a.locale||this.locale;const o=getMatchingLocales(a.locale||get()),n=o.join(";");let m=numberParsers.get(n);m||(m=this._createNumberParser(o),numberParsers.set(n,m));let s,l=1;(null==i?void 0:i.startsWith("("))&&i.endsWith(")")&&(l=-1,i=i.slice(1,-1));let u=!1;const N="string"==typeof i&&!!i.match(PERCENT_SIGN_REGEX);N?s=i.replace(PERCENT_SIGN_REGEX,"").trim():(null===(r=a.format)||void 0===r?void 0:r.includes(NumberFormat.CURRENCY))&&(s=i.replace(CURRENCY_REGEX,"").replace(/\s/g,""),u=s!==i);let c=m(null!=s?s:i);if(isNaN(c)&&(c=parseFloat(null!=s?s:i)),isNaN(c))return c;if(N&&(c/=100),c*=l,u)return c;const F=a.format||this.defaultParseFormat,R=[].concat(F||[])
|
|
1
|
+
import{__decorate}from"tslib";import{getMatchingLocales,get}from"../locale.js";import{serializable,SerializableBase}from"../support/Serializable.js";import{settings as formatSettings}from"./FormatSettings.js";import{checkArg}from"./checkArg.js";export{isNumeric}from"./_number.js";const WHITESPACE_SEPARATORS=[" ",String.fromCharCode(160),String.fromCharCode(8239)],PERCENT_SIGN_REGEX=/[%٪%٪]/g,CURRENCY_REGEX=/₩|¥|元|レイ|₾|₽|₼|₺|₹|₸|₴|₲|₱|₮|₭|€|₫|₪|₩|₧|₦|₤IT|₡|CN¥|PTE||៛|የቻይና ዩዋን|ብር|ლ|฿|සිෆ්එ|රු\.|ಲೀ|રૂ\.|৳|लेई|रू|नेरू|ل\.ل\.|ل\.س\.|ریال|ر\.ي\.|ر\.ق\.|ر\.ع\.|ر\.س\.|ر\.إ\.|د\.م\.|د\.ل\.|د\.ك\.|د\.ع\.|د\.س\.|د\.ج\.|د\.ت\.|د\.ب\.|د\.إ\.|د\.أ\.|ج\.م\.|ج\.س\.|أ\.م\.|؋|ל״י|֏|щ\.д\.|сом|руб\.|руб|р\.|лв\.|крб\.|кр|ден|ТМТ|КМ|Δρχ|öS|Íkr|¥CN|¥|£MT|£LB|£L|£IL|£IE|£GI|£GB|£FK|£E|£CY|£|zł|zl|soʻm|rb|r\.|p\.|mk|ley|leu|lej|lei|kr\.|kr|kn|din\.|den|Zł|ZWR|ZWL|ZWD|ZRZ|ZRN|ZMW|ZMK|ZK|ZAR|ZAL|YUR|YUN|YUM|YUD|YER|YDD|XXXX|XXX|XUA|XTS|XSU|XRE|XPT|XPF|XPD|XOF|XFU|XFO|XEU|XDR|XCD|XBD|XBC|XBB|XBA|XAU|XAG|XAF|WST|WS\$|VUV|VT|VNN|VND|VEF|VEB|UZS|UYU|UYP|UYI|UY\$|USh|USS|USN|USD|US\$|UM|UK£|UGX|UGS|UAK|UAH|Tk|TZS|TWD|TTD|TT\$|TSh|TRY|TRL|TPE|TOP|TND|TMT|TMM|TK|TJS|TJR|THB|T\$|S£|SZL|SYP|SVC|SUR|STN|STD|SSP|SRG|SRD|SR\$|SR|SOS|SLL|SKK|SIT|SI\$|SHP|SGD|SEK|SD£|SDP|SDG|SDD|SCR|SBD|SB\$|SAR|S\/|S\$|S|Rs\.|Rs|Rp|RWF|RUR|RUB|RSD|RON|ROL|RM|RHD|RF|RD\$|R\$|R|QAR|Q|PYG|PTE|PLZ|PLN|PKR|PHP|PGK|PES|PEN|PEI|PAB|P\.|P|OMR|Nkr|Nfk|NZD\$|NZD|NZ\$|NT\$|NPR|NOK|NLG|NKr|NIS|NIO|NIC|NGN|NAf\.|NAf|NAD|N\$|MZN|MZM|MZE|MYR|MXV|MXP|MXN|MX\$|MWK|MVR|MVP|MUR|MTn|MTP|MTL|MRO|MOP\$|MOP|MNT|MMK|MLF|MKN|MKD|MK|MGF|MGA|MDL|MDC|MCF|MAF|MAD|L£|Lt|Ls|Lekë|Le|LYD|LVR|LVL|LUL|LUF|LUC|LTT|LTL|LSL|LS|LRD|LKR|LE|LBP|LAK|L\$|L|Kčs|Kč|Kz|Kw|Ksh|Kr|Kn|KZT|KYD|KY\$|KWD|KRW|KRO|KRH|KPW|KMF|KM|KHR|KGS|KES|K|JP¥|JPY|JOD|JMD|JM\$|J\$|Ikr|ITL|ISK|ISJ|IRR|IQD|INR|ILS|ILR|ILP|IE£|IEP|IDR|HUF|HTG|HRK|HRD|HNL|HKD|HK\$|Gs\.|Gs|GYD|GY\$|GWP|GWE|GTQ|GRD|GQE|GNS|GNF|GMD|GIP|GH₵|GHS|GHC|GEL|GEK|GB£|GBP|G\$|G|Ft|Fl£|Fdj|FRF|FR|FK£|FKP|FJD|FJ\$|FIM|FG|FCFP|FCFA|FC|FBu|FB|F\.Rw|F\.G\.|F|E£|Esc\.|Ekr|EUR|ETB|ESP|ESB|ESA|ERN|EG£|EGP|EEK|ECV|ECU|ECS|EC\$|E|Dkr|Db|DZD|DT|DOP|DO\$|DM|DKK|DJF|DEM|DDM|DA|D|Cub\$|CZK|CYP|CVE|CUP|CUC\$|CUC|CU\$|CSK|CSD|CRC|COU|COP|CO\$|CN¥|CNY|CNX|CNH|CLP|CLF|CLE|CL\$|CI\$|CHW|CHF|CHE|CFPF|CFP|CFA|CF|CDF|CAD|CA\$|C\$|BsF|Bs\.|Bs|Br|Bds\$|BZD|BZ\$|BYR|BYN|BYB|BWP|BUK|BTN|BSD|BS\$|BRZ|BRR|BRN|BRL|BRE|BRC|BRB|BR\$|BOV|BOP|BOL|BOB|BND|BN\$|BMD|BM\$|BIF|BHD|BGO|BGN|BGM|BGL|BGK|BGJ|BEL|BEF|BEC|BDT|BD\$|BBD|BB\$|BAN|BAM|BAD|B\/\.|B\$|Ar|Afl\.|Afl|AZN|AZM|AWG|AUD\$|AUD|AU\$|ATS|ARS|ARP|ARM|ARL|ARA|AR\$|AOR|AON|AOK|AOA|ANG|AMD|ALL|ALK|AFN|AFA|AED|ADP|A\$|\*\*\*|\$ US|\$ SG|\$ NZ|\$ HK|\$ AU|\$b|\$UY|\$US|\$U|\$TT|\$SR|\$SG|\$SB|\$RH|\$NZ|\$NA|\$MX|\$MN|\$HK|\$FJ|\$EC|\$CO|\$CL|\$CA|\$C|\$BZ|\$BS|\$BN|\$BM|\$AU|\$AR|\$/g;export var NumberFormat;!function(t){t.NUMBER="n",t.FIXED_POINT="f",t.CURRENCY="c",t.ACCOUNTING="a",t.PERCENT="p",t.ROUND_TRIP="r",t.DEFAULT="f"}(NumberFormat||(NumberFormat={}));export function format(...t){return globalFormatter.format(...t)}export function parse(...t){return globalFormatter.parse(...t)}let NumberFormatter=class extends SerializableBase{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}get defaultParseFormat(){return this._defaultParseFormat}set defaultParseFormat(t){this._defaultParseFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}format(...t){var r,e,a,i;let o,n;if(1===t.length?(o=t[0],n={}):arguments.length>=2&&(o=t[1],n="string"==typeof t[0]?{format:t[0]}:t[0],checkArg("options",n).isNotMissing()),null==o||isNaN(o))return"";let m=n.format||this.defaultFormat||NumberFormat.DEFAULT;if(m===NumberFormat.ROUND_TRIP)return o.toString();const s=m.toLowerCase();if(s===NumberFormat.CURRENCY||s===NumberFormat.ACCOUNTING){const t=n.currency||this.currency||"USD";m=s,m+=null!==(e=null!==(r=n.fractionalDigits)&&void 0!==r?r:this.fractionalDigits)&&void 0!==e?e:"",m+=t?`$${t}`:""}else s!==NumberFormat.NUMBER&&s!==NumberFormat.FIXED_POINT&&s!==NumberFormat.PERCENT||(m=s,m+=null!==(i=null!==(a=n.fractionalDigits)&&void 0!==a?a:this.fractionalDigits)&&void 0!==i?i:"");n.locale=n.locale||this.locale;const l=getMatchingLocales(n.locale||get()),u=`${l.join(";")}|${m}`;let N=numberFormatters.get(u);if(!N){N=[];const t=m.split(";",3);1===t.length?(N[0]=this._createNumberFormatter(l,t[0]),N[1]=N[0],N[2]=N[0]):2===t.length?(N[0]=this._createNumberFormatter(l,t[0]),N[1]=this._createNumberFormatter(l,t[1]),N[2]=N[0]):3===t.length&&(N[0]=this._createNumberFormatter(l,t[0]),N[1]=this._createNumberFormatter(l,t[1]),N[2]=this._createNumberFormatter(l,t[2])),numberFormatters.set(u,N)}return o>0?N[0](o):o<0?N[1](o):N[2](o)}parse(...t){var r;let e,a;if(1===t.length?(e=t[0],a={}):t.length>=2&&(e=t[1],a="string"==typeof t[0]||Array.isArray(t[0])?{format:t[0]}:t[0]),"number"==typeof e)return e;if("boolean"==typeof e)return e?1:0;if(null==e)return NaN;let i=e.toString().trim();a.locale=a.locale||this.locale;const o=getMatchingLocales(a.locale||get()),n=o.join(";");let m=numberParsers.get(n);m||(m=this._createNumberParser(o),numberParsers.set(n,m));let s,l=1;(null==i?void 0:i.startsWith("("))&&i.endsWith(")")&&(l=-1,i=i.slice(1,-1));let u=!1;const N="string"==typeof i&&!!i.match(PERCENT_SIGN_REGEX);N?s=i.replace(PERCENT_SIGN_REGEX,"").trim():(null===(r=a.format)||void 0===r?void 0:r.includes(NumberFormat.CURRENCY))&&(s=i.replace(CURRENCY_REGEX,"").replace(/\s/g,""),u=s!==i);let c=m(null!=s?s:i);if(isNaN(c)&&(c=parseFloat(null!=s?s:i)),isNaN(c))return c;if(N&&(c/=100),c*=l,u)return c;const F=a.format||this.defaultParseFormat,R=[].concat(F||[]),D=!R.length||R.some((t=>{if(t===NumberFormat.ROUND_TRIP)return c===parseFloat(c.toString());const r=this._createNumberFormatter(o,t,{minimumFractionDigits:0,maximumFractionDigits:20});if(i===r(c))return!0;const e=t.match(standardFormatPattern);if(e&&""===e[2])for(let r=0;r<=20;r++){const e=this._createNumberFormatter(o,t,{minimumFractionDigits:r,maximumFractionDigits:r});if(i===e(c))return!0}return!1}));return D?c:NaN}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",fractionalDigits:"initial",currency:"initial",locale:"initial"}}_createNumberFormatter(t,r,e){const a=e||{};let i=r.match(standardFormatPattern);if(i){const r=i[1].toLowerCase(),e=Math.min(20,parseInt(i[2]));let o=i[3];r===NumberFormat.CURRENCY||r===NumberFormat.ACCOUNTING?o=(o||this.currency||"USD").toUpperCase():(o="",void 0===a.minimumFractionDigits&&(a.minimumFractionDigits=0),void 0===a.maximumFractionDigits&&(a.maximumFractionDigits=Math.max(4,a.minimumFractionDigits))),r===NumberFormat.PERCENT?a.style="percent":r===NumberFormat.ACCOUNTING?a.currencySign="accounting":r===NumberFormat.FIXED_POINT&&(a.useGrouping=!1),isNaN(e)||(a.minimumFractionDigits=e,a.maximumFractionDigits=e);const n=o?new Intl.NumberFormat(t,{style:"currency",currency:o,...a}):new Intl.NumberFormat(t,a);return t=>n.format(t)}i=r.match(/[0#]+|\.|,|%|\\.|(["'])[^\1]+\1|[^0#.,\\'"]+/g);let o=!1,n="",m="",s="",l="";a.minimumFractionDigits=0,a.maximumFractionDigits=0,a.useGrouping=!1;for(let t of i)switch(t[0]){case".":o=!0;break;case",":a.useGrouping=!0;break;case"%":a.style="percent";break;case"0":case"#":o?m+=t:n+=t;break;default:t.startsWith('"')||t.startsWith("'")?t=t.slice(1,-1):t.startsWith("\\")&&(t=t.slice(1)),n||m?l+=t:s+=t}if(n){const t=n.indexOf("0");t>=0&&(a.minimumIntegerDigits=n.length-t)}if(m){const t=m.lastIndexOf("0");a.minimumFractionDigits=t>=0?t+1:0,a.maximumFractionDigits=Math.min(20,m.length)}if(n||m){const r=new Intl.NumberFormat(t,a);return t=>`${s}${r.format(t)}${l}`}return()=>s+l}_createNumberParser(t){const r=new Intl.NumberFormat(t),e=r.formatToParts(12345.6),a=[...new Intl.NumberFormat(t,{useGrouping:!1}).format(9876543210)].reverse(),i=new Map(a.map(((t,r)=>[t,r]))),o=t=>i.get(t).toString();let n=e.find((t=>"group"===t.type)).value;WHITESPACE_SEPARATORS.some((t=>t===n))&&(n=`${WHITESPACE_SEPARATORS.join("|")}`);const m=new RegExp(`[${n}]`,"g"),s=new RegExp(`[${e.find((t=>"decimal"===t.type)).value}]`),l=new RegExp(`[${a.join("")}]`,"g"),u=r.format(-1/0),N=r.format(1/0);return t=>{if(t===N)return Number.POSITIVE_INFINITY;if(t===u)return Number.NEGATIVE_INFINITY;const r=t.trim().replace(m,"").replace(s,".").replace(l,o);return r?+r:NaN}}};NumberFormatter=__decorate([serializable],NumberFormatter);export{NumberFormatter};let GlobalFormatter=class extends NumberFormatter{get defaultFormat(){return formatSettings.numberFormat}set defaultFormat(t){formatSettings.numberFormat=t}get currency(){return formatSettings.currency}set currency(t){formatSettings.currency=t}get fractionalDigits(){return formatSettings.fractionalDigits}set fractionalDigits(t){formatSettings.fractionalDigits=t}};GlobalFormatter=__decorate([serializable],GlobalFormatter);const numberFormatters=new Map,numberParsers=new Map,standardFormatPattern=/^([acfnp])(\d*)(?:\$([a-zA-Z]{3}))?$/i,globalFormatter=new GlobalFormatter;export const settings=globalFormatter;
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="33.
|
|
1
|
+
export const version="33.5.0";
|