@arcgis/core 4.32.0-next.20241021 → 4.32.0-next.20241023
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/applications/MapViewer/templateUtils.d.ts +4 -0
- package/applications/MapViewer/templateUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0b7ee57bec7ffac312f2.js +1 -0
- package/assets/esri/core/workers/chunks/{1ba1d9c867ec6a492af9.js → 0f3912bca9fe25eea75c.js} +1 -1
- package/assets/esri/core/workers/chunks/{842ebde78db9bfcaf07b.js → 1678d1d0ecb9b2af69a8.js} +1 -1
- package/assets/esri/core/workers/chunks/1d16ca7791f64dd7c7fb.js +1 -0
- package/assets/esri/core/workers/chunks/1d4be734ff961e313257.js +1 -0
- package/assets/esri/core/workers/chunks/{b292758308dfac4ba8ee.js → 2d8aa31dc96bbd014036.js} +1 -1
- package/assets/esri/core/workers/chunks/{53f648321c5fde26bfe4.js → 319e06888467f9f460ab.js} +1 -1
- package/assets/esri/core/workers/chunks/33cae7ece52a77394b05.js +1 -0
- package/assets/esri/core/workers/chunks/{210a954f5299fe105e0b.js → 539060ffb7f230fb1bd0.js} +1 -1
- package/assets/esri/core/workers/chunks/545441dcc8e915e63ff1.js +1 -0
- package/assets/esri/core/workers/chunks/{303f39b9b7bd33109df8.js → 587df97288a83721d251.js} +1 -1
- package/assets/esri/core/workers/chunks/5caa02a7a85d05e253b4.js +1 -0
- package/assets/esri/core/workers/chunks/5cfecb320e1dcd258b2e.js +1 -0
- package/assets/esri/core/workers/chunks/67018ef25736f0722f6e.js +1 -0
- package/assets/esri/core/workers/chunks/89f74819ac1b5884c149.js +1 -0
- package/assets/esri/core/workers/chunks/92b2d81ef16877341f97.js +1 -0
- package/assets/esri/core/workers/chunks/{e6e77cbdeb99d90caad1.js → 97f62fad6d416a666319.js} +1 -1
- package/assets/esri/core/workers/chunks/98c1956b2e27058c8a51.js +1 -0
- package/assets/esri/core/workers/chunks/9c8a910b6261a4d5da77.js +1 -0
- package/assets/esri/core/workers/chunks/ab6eaa3ae2e233f91a5e.js +1 -0
- package/assets/esri/core/workers/chunks/{63719f892a7d1025c7d3.js → b42c1ab7579a3c464f72.js} +1 -1
- package/assets/esri/core/workers/chunks/{03eba36affe6ed1f5a11.js → bc4ef18d0a02354186e3.js} +7 -7
- package/assets/esri/core/workers/chunks/{c71304c88fce556340ef.js → c859f73b57a764e99b02.js} +1 -1
- package/assets/esri/core/workers/chunks/cb3038ec3ef0d86bf2a0.js +1 -0
- package/assets/esri/core/workers/chunks/{ae20ca2008a2ea6a46b2.js → d8f4bd2b4366388f8a28.js} +1 -1
- package/assets/esri/core/workers/chunks/e71fa25ed45bae5a1adb.js +320 -0
- package/assets/esri/core/workers/chunks/{9c9a8a529494c6d1dfa3.js → ec9d5af8887854e821c8.js} +1 -1
- package/assets/esri/libs/parquet/pkg/arcgis_parquet_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +14 -0
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/Bufferer-BhkgvSV4.js +5 -0
- package/chunks/{Distance2DCalculator-DM4OojiI.js → Distance2DCalculator-BX0Ep7eP.js} +1 -1
- package/chunks/{GeodeticDistanceCalculator-DzvUOSaR.js → GeodeticDistanceCalculator-B5uO-Y_z.js} +1 -1
- package/chunks/OperatorCrosses.js +5 -0
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticDistance.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntersects.js +5 -0
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorOverlaps.js +5 -0
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorTouches.js +5 -0
- package/chunks/OperatorWithin.js +5 -0
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/SSAOBlur.glsl.js +5 -5
- package/chunks/SideCalculator2D-CoWc8Oe3.js +1 -1
- package/chunks/Transformation2D.js +1 -1
- package/core/MemCache.js +1 -1
- package/core/MemCachePool.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/operators/affineTransformOperator.js +1 -1
- package/geometry/operators/alphaShapeOperator.js +1 -1
- package/geometry/operators/areaOperator.js +1 -1
- package/geometry/operators/autoCompleteOperator.js +1 -1
- package/geometry/operators/boundaryOperator.js +1 -1
- package/geometry/operators/bufferOperator.js +1 -1
- package/geometry/operators/centroidOperator.js +1 -1
- package/geometry/operators/clipOperator.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/convexHullOperator.js +1 -1
- package/geometry/operators/crossesOperator.js +1 -1
- package/geometry/operators/cutOperator.js +1 -1
- package/geometry/operators/densifyOperator.js +1 -1
- package/geometry/operators/differenceOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/distanceOperator.js +1 -1
- package/geometry/operators/equalsOperator.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/generalizeOperator.js +1 -1
- package/geometry/operators/geodesicBufferOperator.js +1 -1
- package/geometry/operators/geodesicProximityOperator.js +1 -1
- package/geometry/operators/geodeticAreaOperator.js +1 -1
- package/geometry/operators/geodeticDensifyOperator.js +1 -1
- package/geometry/operators/geodeticDistanceOperator.js +1 -1
- package/geometry/operators/geodeticLengthOperator.js +1 -1
- package/geometry/operators/graphicBufferOperator.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBoundary.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorConvexHull.js +1 -1
- package/geometry/operators/gx/operatorDifference.js +1 -1
- package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
- package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
- package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorLocateBetween.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/gx/operatorProject.js +1 -1
- package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/integrateOperator.js +1 -1
- package/geometry/operators/intersectionOperator.js +1 -1
- package/geometry/operators/intersectsOperator.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/json/containsOperator.js +5 -0
- package/geometry/operators/json/crossesOperator.js +5 -0
- package/geometry/operators/json/disjointOperator.js +5 -0
- package/geometry/operators/json/intersectsOperator.js +5 -0
- package/geometry/operators/json/offsetOperator.js +5 -0
- package/geometry/operators/json/overlapsOperator.js +5 -0
- package/geometry/operators/json/touchesOperator.js +5 -0
- package/geometry/operators/json/withinOperator.js +5 -0
- package/geometry/operators/labelPointOperator.js +1 -1
- package/geometry/operators/lengthOperator.js +1 -1
- package/geometry/operators/linesToPolygonsOperator.js +1 -1
- package/geometry/operators/locateBetweenOperator.js +1 -1
- package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
- package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
- package/geometry/operators/offsetOperator.js +1 -1
- package/geometry/operators/overlapsOperator.js +1 -1
- package/geometry/operators/polygonOverlayOperator.js +1 -1
- package/geometry/operators/polygonSlicerOperator.js +1 -1
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/proximityOperator.js +1 -1
- package/geometry/operators/relateOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/simplifyOperator.js +1 -1
- package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
- package/geometry/operators/support/apiConverter.js +5 -0
- package/geometry/operators/support/initNoPeFactory.js +5 -0
- package/geometry/operators/support/jsonConverter.js +5 -0
- package/geometry/operators/support/proximityResult.js +1 -1
- package/geometry/operators/symmetricDifferenceOperator.js +1 -1
- package/geometry/operators/touchesOperator.js +1 -1
- package/geometry/operators/unionOperator.js +1 -1
- package/geometry/operators/withinOperator.js +1 -1
- package/geometry/support/MeshVertexAttributes.js +1 -1
- package/interfaces.d.ts +134 -0
- package/layers/LinkChartLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/knowledgeGraph/supportUtils.js +1 -1
- package/layers/support/ElevationQueryTileCache.js +1 -1
- package/layers/support/ElevationTileData.js +1 -1
- package/layers/support/mediaUtils.js +1 -1
- package/layers/support/parquetLayerUtils.js +1 -1
- package/layers/support/rasterFunctions/ClipFunction.js +1 -1
- package/layers/support/rasterFunctions/clipUtils.js +1 -1
- package/layers/support/rasterFunctions/localUtils.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/linkChart/LinkChartProperties.js +1 -1
- package/package.json +1 -1
- package/smartMapping/raster/renderers/classBreaks.js +1 -1
- package/smartMapping/raster/renderers/rgb.js +1 -1
- package/smartMapping/raster/renderers/stretch.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
- package/smartMapping/raster/support/adapters/RasterLayerAdapter.js +1 -1
- package/smartMapping/renderers/support/rendererUtils.d.ts +4 -0
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
- package/views/2d/grid/GridView2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/CachedMeshData.js +5 -0
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOPool.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/ProceduralTextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +1 -1
- package/views/input/BrowserEventSource.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/css.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLine2D.js +5 -0
- package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
- package/widgets/ElevationProfile/support/constants.js +1 -1
- package/widgets/ElevationProfile/support/visualizationUtils.js +5 -0
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/support/columnUtils.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable/support/templateUtils.js +5 -0
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/assets/esri/core/workers/chunks/03d0394fff1463c224f9.js +0 -1
- package/assets/esri/core/workers/chunks/0c40cac18711f79f0a7d.js +0 -1
- package/assets/esri/core/workers/chunks/1a97f98facfc62a9fc69.js +0 -1
- package/assets/esri/core/workers/chunks/1e3ed3ee48c2977cff6f.js +0 -1
- package/assets/esri/core/workers/chunks/1fc064e37d030e449d5e.js +0 -1
- package/assets/esri/core/workers/chunks/4daab36de5efa03a8cbb.js +0 -1
- package/assets/esri/core/workers/chunks/77d129134c2a66cd86d8.js +0 -1
- package/assets/esri/core/workers/chunks/88bd9e023764da377aa7.js +0 -1
- package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +0 -1
- package/assets/esri/core/workers/chunks/a5675c989d00b7400f98.js +0 -1
- package/assets/esri/core/workers/chunks/c06c5c815b5e37717fa1.js +0 -1
- package/assets/esri/core/workers/chunks/ca1385e165aae8a32ca2.js +0 -1
- package/assets/esri/core/workers/chunks/ce8c1208916f54af7e68.js +0 -320
- package/assets/esri/core/workers/chunks/df51c93b2dbcc89efc23.js +0 -1
- package/assets/esri/core/workers/chunks/efa3c919261672871f2f.js +0 -1
- package/chunks/Bufferer-fr1_Nc47.js +0 -5
- package/geometry/operators/support/converterAPI.js +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{b as e,c as t}from"./tslib.es6.js";import{t as s,a as i,G as n,m as r,d as m,l as o,b as a,n as h,h as l,c,e as u,g as f}from"./Geometry.js";import{S as _,G as g}from"./SimpleGeometryCursor.js";import{aD as d,aE as p,aF as b,L as y,aG as P,a as x,v as C,j as D,b as w,P as T,H as v,z as S,aH as I,E as M,V,k as E,o as k,a7 as R}from"./QuadraticBezier.js";import{i as A,P as B,T as X,d as Y,m as F,c as G,k as z}from"./Transformation2D.js";import{c as L}from"./GeometryCleaner-k94LXQsr.js";import{O as q}from"./OperatorGeneralize.js";class N{getOperatorType(){return 10104}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimple(e,t,s,i,n){return 5===d(e,t,s,i,n)}executeMany(e,t,s,i){return new j(e,t,s,i)}execute(e,t,s,i){const n=new _([e]);return this.executeMany(n,t,s,i).next()}}class j extends g{constructor(e,t,i,n){super(),e||s(""),this.m_progressTracker=n,this.m_bForceSimplify=i,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(i(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){e||s("");return p(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}var O;function U(e,t,s,i,n,r){return{m_from:e.clone(),m_to:t.clone(),m_center:s.clone(),m_next:n,m_type:i}}function J(e,t,s,i,n){return{m_from:e.clone(),m_to:t.clone(),m_next:s,m_type:4,m_center:new B}}!function(e){e[e.enumDummy=256]="enumDummy",e[e.enumLine=1]="enumLine",e[e.enumArc=2]="enumArc",e[e.enumMiter=8]="enumMiter",e[e.enumBevel=16]="enumBevel",e[e.enumJoinMask=26]="enumJoinMask",e[e.enumConnectionMask=27]="enumConnectionMask"}(O||(O={}));class H extends g{constructor(e,t,s,i,n,r,m,o,a,h){super(),this.m_index=0,this.m_bufferedPolygon=null,this.m_x=0,this.m_y=0,this.m_progressTracker=h,this.m_parent=e,this.m_mp=t,this.m_distance=s,this.m_spatialReference=i,this.m_densifyDist=o,this.m_maxVertexInCompleteCircle=a,this.m_joins=n,this.m_caps=r,this.m_miterLimit=m}next(){const e=new T;for(;;){if(this.m_index===this.m_mp.getPointCount())return null;if(1===this.m_caps)return this.m_index=this.m_mp.getPointCount(),new x({vd:this.m_mp.getDescription()});if(this.m_mp.getPointByVal(this.m_index,e),this.m_index++,!e.isEmpty())break}let t,s=!1;if(null===this.m_bufferedPolygon&&(this.m_x=e.getX(),this.m_y=e.getY(),this.m_bufferedPolygon=this.m_parent.buffer(e,this.m_distance,this.m_spatialReference,this.m_joins,this.m_caps,this.m_miterLimit,this.m_densifyDist,this.m_maxVertexInCompleteCircle),s=!0),t=this.m_index<this.m_mp.getPointCount()?this.m_bufferedPolygon.clone():this.m_bufferedPolygon,!s){const s=new X,i=e.getX()-this.m_x,n=e.getY()-this.m_y;s.setShiftCoords(i,n),t.applyTransformation(s)}return R(t,0),t}getGeometryID(){return 0}getRank(){return f(0),-1}tock(){return!0}}class Q extends g{constructor(e){super(),this.m_currentPathIndex=0,this.m_polyline=e}next(){if(!this.m_polyline)return null;const e=this.m_polyline.getImpl(),t=e.getPathCount();if(this.m_currentPathIndex<t){const t=this.m_currentPathIndex;if(this.m_currentPathIndex++,!e.isClosedPathInXYPlane(t)){let s=e.getXY(e.getPathEnd(t)-1);for(;this.m_currentPathIndex<e.getPathCount();){const t=e.getXY(e.getPathStart(this.m_currentPathIndex));if(e.isClosedPathInXYPlane(this.m_currentPathIndex))break;if(!t.equals(s))break;s=e.getXY(e.getPathEnd(this.m_currentPathIndex)-1),this.m_currentPathIndex++}}if(0===t&&this.m_currentPathIndex===this.m_polyline.getPathCount()){const e=this.m_polyline;return this.m_polyline=null,e}const s=new w({vd:this.m_polyline.getDescription()});s.addPath(this.m_polyline,t,!0);for(let i=t+1;i<this.m_currentPathIndex;i++)s.addSegmentsFromPath(this.m_polyline,i,0,e.getSegmentCountPath(i),!1);return this.m_currentPathIndex===this.m_polyline.getPathCount()&&(this.m_polyline=null),s}return null}getGeometryID(){return 0}getRank(){return f(0),-1}tock(){return!0}}class K extends g{constructor(e,t,s){super(),this.m_geometry=null,this.m_index=0,this.m_bufferer=e,this.m_geoms=t,this.m_index=0,this.m_bFilter=s}next(){if(null===this.m_geometry&&(this.m_index=0,this.m_geometry=this.m_geoms.next(),!this.m_geometry))return null;const e=this.m_geometry.getImpl();if(this.m_index<e.getPathCount()){const e=this.m_index;this.m_index++;return this.m_bufferer.bufferPolylinePath(this.m_geometry,e,this.m_bFilter)}return this.m_geometry=null,this.next()}getGeometryID(){return 0}getRank(){return f(0),-1}tock(){return!0}}class W extends g{constructor(e){super(),this.m_index=0,this.m_bufferer=e}next(){const e=this.m_bufferer.m_geometry;if(this.m_index<e.getPathCount()){const t=this.m_index,s=e.calculateRingArea2D(this.m_index);for(f(s>0),this.m_index++;this.m_index<e.getPathCount();){if(e.calculateRingArea2D(this.m_index)>0)break;this.m_index++}let i;return i=0===t&&this.m_index===e.getPathCount()?this.m_bufferer.bufferPolygonImpl(e,0,e.getPathCount()):this.m_bufferer.bufferPolygonImpl(e,t,this.m_index),i}return null}getGeometryID(){return 0}getRank(){return f(0),-1}tock(){return!0}}class Z{constructor(e){this.m_geometry=null,this.m_bufferCommands=[],this.m_originalGeomType=n.enumUnknown,this.m_maxVertexInCompleteCircle=-1,this.m_circleTemplateSize=-1,this.m_oldCircleTemplateSize=0,this.m_spatialReference=null,this.m_tolerance=new b(0,0),this.m_smallTolerance=new b(0,0),this.m_filterTolerance=0,this.m_densifyDist=-1,this.m_distance=Number.NaN,this.m_absDistance=0,this.m_absDistanceReversed=0,this.m_dA=-1,this.m_miterLimit=4,this.m_joins=0,this.m_caps=0,this.m_bRoundBuffer=!0,this.m_bOutputLoops=!0,this.m_bFilter=!0,this.m_circleTemplate=[],this.m_leftStack=[],this.m_middleStack=[],this.m_helperLine1=new y,this.m_helperLine2=new y,this.m_helperArray=[],this.m_progressCounter=0,this.m_densificator=P.constructDefault(e),this.m_progressTracker=e}buffer(e,t,i,n,c,u,f,_){if(e||s("Geometry.Bufferer.Impl.Buffer"),f<0&&s("Geometry.Bufferer.Impl.Buffer"),r(e.getGeometryType())&&m("Unsupported geometry type."),e.isEmpty())return new x({vd:e.getDescription()});if(this.m_joins=n,this.m_caps=c,this.m_bRoundBuffer=!1,this.m_miterLimit=u,this.m_originalGeomType=e.getGeometryType(),o(this.m_originalGeomType)?this.m_bRoundBuffer=0===this.m_joins:a(this.m_originalGeomType)?this.m_bRoundBuffer=0===this.m_caps:h(this.m_originalGeomType)&&(this.m_bRoundBuffer=0===this.m_joins&&0===this.m_caps),this.m_bFilter=this.m_bRoundBuffer,this.m_geometry=L(e),this.m_geometry.isEmpty())return new x({vd:e.getDescription()});const g=new C;this.m_geometry.queryLooseEnvelope(g),t>0&&g.inflateCoords(t,t),this.m_tolerance=D(i,g,!0),this.m_smallTolerance=D(null,g,!0),_<=0&&(_=96),this.m_spatialReference=i,this.m_distance=t,this.m_absDistance=Math.abs(this.m_distance),this.m_absDistanceReversed=0!==this.m_absDistance?1/this.m_absDistance:0,Number.isNaN(f)||0===f?f=1e-5*this.m_absDistance:f>.5*this.m_absDistance&&(f=.5*this.m_absDistance),_<12&&(_=12);const d=Math.abs(t)*(1-Math.cos(Math.PI/_));if(d>f)f=d;else if(0!==t){const e=Math.PI/Math.acos(1-f/Math.abs(t));e<_-1&&(_=Math.trunc(e))<12&&(_=12,f=Math.abs(t)*(1-Math.cos(Math.PI/_)))}this.m_densifyDist=f,this.m_maxVertexInCompleteCircle=_,this.m_filterTolerance=this.m_bRoundBuffer?Math.min(this.m_smallTolerance.total(),.25*this.m_densifyDist):0,this.m_circleTemplateSize=this.calcN(),this.m_circleTemplateSize!==this.m_oldCircleTemplateSize&&(this.m_circleTemplate.length=0,this.m_oldCircleTemplateSize=this.m_circleTemplateSize),this.m_densifyDist>0&&l(this.m_geometry)&&(this.m_geometry=this.m_densificator.densifyEx(this.m_geometry,0,this.m_densifyDist,0,0!==this.m_joins,A()));const p=this.bufferImpl();return this.m_geometry=null,p}generateCircleTemplate(){if(this.m_circleTemplate.length)return;const e=this.m_circleTemplateSize,t=Math.trunc((e+3)/4),s=.5*Math.PI/t;this.m_dA=s,this.m_circleTemplate.length=4*t;const i=Math.cos(s),n=Math.sin(s),r=B.construct(0,1);for(let m=0;m<t;m++)this.m_circleTemplate[m+0*t]=B.construct(r.y,-r.x),this.m_circleTemplate[m+1*t]=B.construct(-r.x,-r.y),this.m_circleTemplate[m+2*t]=B.construct(-r.y,r.x),this.m_circleTemplate[m+3*t]=r.clone(),r.rotateReverse(i,n)}bufferImpl(){const e=this.m_geometry.getGeometryType();if(c(e)){const e=new w({vd:this.m_geometry.getDescription()});return e.addSegment(this.m_geometry,!0),this.m_geometry=e,this.bufferImpl()}if(this.m_distance<=this.m_tolerance.total()){if(!o(e))return new x({vd:this.m_geometry.getDescription()});if(this.m_distance<0){const e=new C;if(this.m_geometry.queryEnvelope(e),e.width()<=2*this.m_absDistance||e.height()<=2*this.m_absDistance)return new x({vd:this.m_geometry.getDescription()})}}switch(this.m_geometry.getGeometryType()){case n.enumPoint:return this.bufferPoint();case n.enumMultiPoint:return this.bufferMultiPoint();case n.enumPolyline:return this.bufferPolyline();case n.enumPolygon:return this.bufferPolygon();case n.enumEnvelope:return this.bufferEnvelope();default:u("")}}bufferPolyline(){if(this.isDegenerateGeometry(this.m_geometry)){const e=new T;this.m_geometry.getPointByVal(0,e);const t=new C;return this.m_geometry.queryEnvelope(t),e.setXY(t.getCenter()),this.bufferDegeneratePath(e,!0)}const e=this.m_geometry,t=this.m_geometry.getDescription();this.m_geometry=null;const s=new Q(e);let i,n;i=0===this.m_joins?(new q).executeMany(s,.25*this.m_densifyDist,!1,this.m_progressTracker):s,n=this.m_bRoundBuffer?(new N).executeMany(i,null,!0,this.m_progressTracker):i;const r=new K(this,n,this.m_bFilter),m=(new v).executeMany(r,this.m_spatialReference,this.m_progressTracker,2),o=(new S).executeMany(m,this.m_spatialReference,!1,this.m_progressTracker).next();return null!==o?o:new x({vd:t})}bufferPolygon(){if(0===this.m_distance)return this.m_geometry;this.generateCircleTemplate();const e=(new S).execute(this.m_geometry,null,!1,this.m_progressTracker);if(this.m_distance<0){if(this.m_geometry=e,this.m_geometry.isEmpty())return this.m_geometry;const t=this.m_geometry,s=this.bufferPolygonImpl(t,0,t.getPathCount());return(new S).execute(s,this.m_spatialReference,!1,this.m_progressTracker)}{if(this.m_geometry=e,this.isDegenerateGeometry(this.m_geometry)){const e=new T;this.m_geometry.getPointByVal(0,e);const t=new C;return this.m_geometry.queryEnvelope(t),e.setXY(t.getCenter()),this.bufferDegeneratePath(e,!0)}const t=new W(this),s=(new v).executeMany(t,this.m_spatialReference,this.m_progressTracker,2),i=(new S).executeMany(s,this.m_spatialReference,!1,this.m_progressTracker).next();return null!==i?i:new x({vd:this.m_geometry.getDescription()})}}bufferPolygonImpl(e,t,s){const i=e,n=i.getImpl();let r=new x({vd:e.getDescription()});for(let m=t;m<s;m++){if(n.getPathSize(m)<1)continue;const t=n.calculateRingArea2D(m),s=new C;if(n.queryPathEnvelope(m,s),this.m_distance>0)if(t>0)if(this.isDegeneratePath(n,m)){const e=new T;n.getPointByVal(n.getPathStart(m),e),e.setXY(s.getCenter()),r.add(this.bufferDegeneratePath(e,!0),!1)}else{const t=new w({vd:e.getDescription()}),s=t.getImpl();if(I(this.m_geometry,m)){const e=this.bufferConvexPath(i,m);r.add(e,!1)}else{this.bufferClosedPath(this.m_geometry,m,s,this.m_bRoundBuffer,1);const e=this.bufferCleanup(t);r.add(e,!1)}}else{if(s.width()+this.m_tolerance.total()<=2*this.m_absDistance||s.height()+this.m_tolerance.total()<=2*this.m_absDistance)continue;const t=new w({vd:e.getDescription()}),i=t.getImpl();if(this.bufferClosedPath(this.m_geometry,m,i,this.m_bRoundBuffer,1),!t.isEmpty()){const e=s,n=Math.max(1,this.m_absDistance),m=e.clone();m.inflateCoords(n,n),i.addEnvelope(m,!1);const o=this.bufferCleanup(t);r.reserve(r.getPointCount()+o.getPointCount()-4),re(o,r,m,!0)}}else if(t>0){if(s.width()+this.m_tolerance.total()<=2*this.m_absDistance||s.height()+this.m_tolerance.total()<=2*this.m_absDistance)continue;const t=new w({vd:e.getDescription()}),i=t.getImpl();if(this.bufferClosedPath(this.m_geometry,m,i,this.m_bRoundBuffer,-1),!t.isEmpty()){const e=new C;i.queryLooseEnvelope(e);const s=Math.max(1,this.m_absDistance),n=e.clone();n.inflateCoords(s,s),i.addEnvelope(n,!1);re(this.bufferCleanup(t),r,n,!0)}}else{const t=new w({vd:e.getDescription()}),s=t.getImpl();this.bufferClosedPath(this.m_geometry,m,s,this.m_bRoundBuffer,-1);const i=this.bufferCleanup(t);for(let e=0,n=i.getPathCount();e<n;e++)r.addPath(i,e,!0)}}if(this.m_distance>0){if(r.getPathCount()>1){return this.bufferCleanup(r)}return $(r)}{const e=new C;if(r.queryLooseEnvelope(e),r.isEmpty())return $(r);{const t=Math.max(1,this.m_absDistance),s=e.clone();s.inflateCoords(t,t),r.addEnvelope(s,!1);const i=this.bufferCleanup(r);r=new x;const n=new x({vd:i.getDescription()});return re(i,n,s,!1),$(n)}}}bufferPoint(){return this.bufferPointImpl(this.m_geometry)}bufferPointImpl(e){const t=new x({vd:e.getDescription()});return 0===this.m_caps?(this.addCircle(t.getImpl(),e),this.setStrongSimple(t)):2===this.m_caps?(this.addSquare(t.getImpl(),e),this.setStrongSimple(t)):t}bufferDegeneratePath(e,t){const s=new x({vd:e.getDescription()});return t&&0===this.m_joins||!t&&0===this.m_caps?(this.addCircle(s.getImpl(),e),this.setStrongSimple(s)):t||2!==this.m_caps?s:(this.addSquare(s.getImpl(),e),this.setStrongSimple(s))}bufferMultiPoint(){const e=new H(this,this.m_geometry,this.m_distance,this.m_spatialReference,this.m_joins,this.m_caps,this.m_miterLimit,this.m_densifyDist,this.m_maxVertexInCompleteCircle,this.m_progressTracker);return(new v).executeMany(e,this.m_spatialReference,this.m_progressTracker,2).next()}bufferEnvelope(){let e=new x({vd:this.m_geometry.getDescription()});if(this.m_distance<=0){if(0===this.m_distance)e.addEnvelope(this.m_geometry,!1),ee(this.m_geometry,this.m_tolerance.total())&&(e=this.setStrongSimple(e));else{const t=new M;this.m_geometry.queryEnvelope(t),t.inflateCoords(this.m_distance,this.m_distance),e.addEnvelope(t,!1),ee(t,this.m_tolerance.total())&&(e=this.setStrongSimple(e))}return e}if(1===this.m_joins){const t=new M({copy:this.m_geometry});return t.inflateCoords(this.m_absDistance,this.m_absDistance),e.addEnvelope(t,!1),e}const t=this.m_geometry.clone();if(0===t.width()||0===t.height()){if(0===t.width()&&0===t.height()){const e=new T({vd:this.m_geometry.getDescription()});return t.queryCornerByVal(0,e),this.m_geometry=e,this.bufferImpl()}const e=new w({vd:this.m_geometry.getDescription()}),s=new T;return t.queryCornerByVal(0,s),e.startPathPoint(s),t.queryCornerByVal(2,s),e.lineToPoint(s),this.m_geometry=e,this.bufferImpl()}return e.addEnvelope(this.m_geometry,!1),this.m_geometry=e,this.bufferConvexPath(e,0)}bufferConvexPath(e,t){this.generateCircleTemplate();const s=e.hasAttribute(10),i=new x({vd:e.getDescription()}),n=i.getImpl();i.reserve((this.m_circleTemplate.length/10+4)*e.getPathSize(t));const r=new B,m=new B,o=new B,a=new B(0,0),h=new B,l=new B,c=e.getImpl(),f=e.getPathSize(t),_=e.getPathStart(t);for(let g=0,d=e.getPathSize(t);g<d;g++){const e=c.getXY(_+g),t=c.getXY(_+(g+1)%f),i=c.getXY(_+(g+2)%f);h.setSub(t,e),0===h.length()&&u("");const d=s&&!!(1&c.getAttributeAsInt(10,(g+1)%f,0));h.normalize();const p=h.clone();h.leftPerpendicularThis(),h.scale(this.m_absDistance),r.setAdd(h,e),m.setAdd(h,t),0===g?n.startPath(r):n.lineTo(r),n.lineTo(m),l.setSub(i,t),0===l.length()&&u(""),l.normalize();const b=l.clone();l.leftPerpendicularThis(),l.scale(this.m_absDistance),o.setAdd(l,t);let y=O.enumArc;const P=d?0:this.m_joins;if(2===P)y=O.enumBevel;else if(1===P){const e=-p.crossProduct(b);a.setSub(p,b),a.scale(this.m_absDistance/e),a.length()<this.m_miterLimit*this.m_absDistance?(a.addThis(t),y=O.enumMiter):y=O.enumBevel}else a.assign(t);this.addJoin(y,n,a,m,o,!1,!1)}return $(i)}bufferPolylinePath(e,t,s){this.generateCircleTemplate();const i=e,n=i.getImpl();if(n.getPathSize(t)<1)return null;let r;if(r=this.m_bRoundBuffer?n.isClosedPathInXYPlane(t):n.isClosedPath(t),this.isDegeneratePath(n,t)&&this.m_distance>0){const e=new T;n.getPointByVal(n.getPathStart(t),e);const s=new C;return n.queryPathEnvelope(t,s),e.setXY(s.getCenter()),this.bufferDegeneratePath(e,r)}const m=new w({vd:e.getDescription()});m.reserve((Math.trunc(this.m_circleTemplate.length/10)+4)*n.getPathSize(t));const o=m.getImpl();return r?2!==this.bufferClosedPath(i,t,o,s,1)&&this.bufferClosedPath(i,t,o,s,-1):this.bufferOpenPath(i,t,o,s),this.bufferCleanup(m)}progress_(){}bufferCleanup(e,t=!1){const s=t?this.m_tolerance:this.m_smallTolerance;return V(e,s,!0,!t,-1,this.m_progressTracker,0,!1)}calcN(){const e=4;if(0===this.m_densifyDist)return this.m_maxVertexInCompleteCircle;const t=1-this.m_densifyDist*Math.abs(this.m_absDistanceReversed);let s=e;return s=t<-1?e:2*Math.PI/Math.acos(t)+.5,s<e?s=e:s>this.m_maxVertexInCompleteCircle&&(s=this.m_maxVertexInCompleteCircle),Math.trunc(s)}addJoin(e,t,s,i,n,r,m){if(this.generateCircleTemplate(),r&&(t.startPath(i),r=!1),e===O.enumBevel)return void(m&&t.lineTo(n));if(e===O.enumMiter){const e=s.clone();return t.lineTo(e),void(m&&t.lineTo(n))}const o=new B;o.setSub(i,s),o.scale(this.m_absDistanceReversed);const a=new B;a.setSub(n,s),a.scale(this.m_absDistanceReversed);let h=Math.atan2(o.y,o.x)/this.m_dA;h<0&&(h=this.m_circleTemplate.length+h),h=this.m_circleTemplate.length-h;let l=Math.atan2(a.y,a.x)/this.m_dA;l<0&&(l=this.m_circleTemplate.length+l),l=this.m_circleTemplate.length-l,l<h&&(l+=this.m_circleTemplate.length);let c=Math.trunc(l),u=Math.ceil(h),f=this.m_circleTemplate[u%this.m_circleTemplate.length].clone();f.scaleAddThis(this.m_absDistance,s);const _=10*this.m_tolerance.total();f.sub(i).length()<_&&(u+=1),f=this.m_circleTemplate[c%this.m_circleTemplate.length].clone(),f.scaleAddThis(this.m_absDistance,s),f.sub(n).length()<_&&(c-=1);let g=c-u;g++;for(let d=0,p=u%this.m_circleTemplate.length;d<g;d++,p=(p+1)%this.m_circleTemplate.length)f=this.m_circleTemplate[p].clone(),f.scaleAddThis(this.m_absDistance,s),t.lineTo(f),this.progress_();m&&t.lineTo(n)}bufferClosedPath(e,t,s,i,n){const r=new E,m=r.addPathFromMultiPath(e,t,!0);return this.bufferClosedPathImpl(r,m,s,i,n)}bufferClosedPathImpl(e,t,s,i,n){const r=e.getFirstVertex(e.getFirstPath(t)),m=new T;e.queryPoint(r,m),e.filterClosePoints(this.m_filterTolerance,!1,!1,!1,-1);if(e.getPointCount(t)<2)return n<0?0:(this.m_bRoundBuffer&&this.addCircle(s,m),2);f(e.getFirstPath(t)!==k),f(e.getFirstVertex(e.getFirstPath(t))!==k);const o=e.getXY(e.getFirstVertex(e.getFirstPath(t))),a=new X;if(a.setShift(o.negate()),e.applyTransformation(a),i){const i=ne(e,t,n,!0,this.m_absDistance,this.m_filterTolerance,this.m_densifyDist);if(f(1===i),e.getPointCount(t)<2)return n<0?0:(this.addCircle(s,m),2)}const h=0!==this.m_joins&&e.getVertexDescription().hasAttribute(10);this.m_bufferCommands.length=0;const l=e.getFirstPath(t);let c=e.getFirstVertex(l),u=1===n?e.getPrevVertex(c):e.getNextVertex(c),_=1===n?e.getNextVertex(c):e.getPrevVertex(c),g=!0;const d=new B,p=new B,b=new B,y=new B,P=new B,x=new B,C=new B,D=new B,w=this.m_absDistance,v=e.getPathSize(l),S=new B(0,0);for(let f=0;f<v;f++){p.assign(e.getXY(_)),g&&(d.assign(e.getXY(c)),b.assign(e.getXY(u)),x.setSub(d,b),x.normalize(),D.leftPerpendicularOther(x),D.scale(w),y.setAdd(D,d));const t=h&&!!(1&e.getAttributeAsDbl(10,c,0));P.setSub(p,d),P.normalize(),C.leftPerpendicularOther(P),C.scale(w);const s=new B;s.setAdd(d,C);const i=x.crossProduct(P),r=x.dotProduct(P);if(i<0||r<0&&i<Math.abs(r)*Number.EPSILON*8){let e=!1;const n=t?0:this.m_joins;if(1===n){const t=-i;S.setSub(x,P),S.scale(this.m_absDistance/t),S.length()<this.m_miterLimit*this.m_absDistance&&(S.addThis(d),e=!0),this.m_bufferCommands.push(U(y,s,S,e?O.enumMiter:O.enumBevel,this.m_bufferCommands.length+1))}else this.m_bufferCommands.push(U(y,s,d,0===n?O.enumArc:O.enumBevel,this.m_bufferCommands.length+1))}else y.equals(s)||(this.m_bufferCommands.push(J(y,d,this.m_bufferCommands.length+1)),this.m_bufferCommands.push(J(d,s,this.m_bufferCommands.length+1)));const m=new B;m.setAdd(p,C),this.m_bufferCommands.push(U(s,m,d,O.enumLine,this.m_bufferCommands.length+1)),y.setCoordsPoint2D(m),D.setCoordsPoint2D(C),b.setCoordsPoint2D(d),d.setCoordsPoint2D(p),x.setCoordsPoint2D(P),u=c,c=_,g=!1,_=1===n?e.getNextVertex(c):e.getPrevVertex(c)}return this.m_bufferCommands.at(-1).m_next=0,this.processBufferCommands(s),a.setShift(o),s.applyTransformationToPath(a,s.getPathCount()-1),1}bufferOpenPath(e,t,s,i){if(this.m_bRoundBuffer){const n=new w({vd:e.getDescription()});return n.addPath(e,t,!1),n.addSegmentsFromPath(e,t,0,e.getSegmentCountPath(t),!1),this.bufferClosedPath(n,0,s,i,1)}let n=0;const r=new w({vd:e.getDescription()}),m=new B(0,0);{const i=new E,o=i.addPathFromMultiPath(e,t,!1),a=i.getFirstVertex(i.getFirstPath(o)),h=new T;i.queryPoint(a,h),m.assign(h.getXY()),i.filterClosePoints(0,!1,!1,!1,-1);if(i.getPointCount(o)<2)return this.m_bRoundBuffer&&this.addCircle(s,h),2;const l=i.getGeometry(i.getFirstGeometry());r.addPath(l,0,!1),n=r.getPointCount()-1,r.addSegmentsFromPath(l,0,0,l.getSegmentCountPath(0)-1,!1)}const o=new E,a=o.addPathFromMultiPath(r,0,!0);f(o.getFirstPath(a)!==k),f(o.getFirstVertex(o.getFirstPath(a))!==k);const h=new X;h.setShift(m.negate()),o.applyTransformation(h),this.m_bufferCommands.length=0;const l=o.getFirstPath(a),c=0!==this.m_joins&&o.getVertexDescription().hasAttribute(10);let u=o.getFirstVertex(l),_=o.getPrevVertex(u),g=o.getNextVertex(u),d=!0;const p=new B,b=new B,y=new B,P=new B,x=new B,C=new B,D=new B,v=new B,S=this.m_absDistance,I=o.getPathSize(l),M=new B(0,0);for(let f=0;f<I;f++){let e=!1;0!==f&&f!==n||(e=!0),b.assign(o.getXY(g)),d&&(p.assign(o.getXY(u)),y.assign(o.getXY(_)),C.setSub(p,y),C.normalize(),v.leftPerpendicularOther(C),v.scale(S),P.setAdd(v,p));const t=c&&!!(1&o.getAttributeAsDbl(10,u,0));x.setSub(b,p),x.normalize(),D.leftPerpendicularOther(x),D.scale(S);const s=new B;s.setAdd(p,D);const i=C.crossProduct(x),r=C.dotProduct(x);if(i<0||r<0&&i<Math.abs(r)*Number.EPSILON*8)if(e)if(0===this.m_caps)this.m_bufferCommands.push(U(P,s,p,O.enumArc,this.m_bufferCommands.length+1));else if(1===this.m_caps)this.m_bufferCommands.push(U(P,s,p,O.enumLine,this.m_bufferCommands.length+1));else{const e=x.mul(this.m_absDistance).negate(),t=e.clone();e.addThis(P),t.addThis(s),this.m_bufferCommands.push(U(P,e,p,O.enumLine,this.m_bufferCommands.length+1)),this.m_bufferCommands.push(U(e,t,p,O.enumLine,this.m_bufferCommands.length+1)),this.m_bufferCommands.push(U(t,s,p,O.enumLine,this.m_bufferCommands.length+1))}else{let e=!1;const n=t?0:this.m_joins;if(1===n){const t=-i;M.setSub(C,x),M.scale(this.m_absDistance/t),M.length()<this.m_miterLimit*this.m_absDistance&&(M.addThis(p),e=!0),this.m_bufferCommands.push(U(P,s,M,e?O.enumMiter:O.enumBevel,this.m_bufferCommands.length+1))}else this.m_bufferCommands.push(U(P,s,p,0===n?O.enumArc:O.enumBevel,this.m_bufferCommands.length+1))}else P.equals(s)||(this.m_bufferCommands.push(J(P,p,this.m_bufferCommands.length+1)),this.m_bufferCommands.push(J(p,s,this.m_bufferCommands.length+1)));const m=new B;m.setAdd(b,D),this.m_bufferCommands.push(U(s,m,p,O.enumLine,this.m_bufferCommands.length+1)),P.setCoordsPoint2D(m),v.setCoordsPoint2D(D),y.setCoordsPoint2D(p),p.setCoordsPoint2D(b),C.setCoordsPoint2D(x),_=u,u=g,d=!1,g=o.getNextVertex(u)}return this.m_bufferCommands.at(-1).m_next=0,this.processBufferCommands(s),h.setShift(m),s.applyTransformationToPath(h,s.getPathCount()-1),1}processBufferCommands(e){const t=this.cleanupBufferCommands();let s=!0,i=t+1;for(let n=t;i!==t;n=i){const t=this.m_bufferCommands[n];i=-1!==t.m_next?t.m_next:(n+1)%this.m_bufferCommands.length,t.m_type&&(s&&(e.startPath(t.m_from),s=!1),t.m_type&O.enumJoinMask?this.addJoin(t.m_type,e,t.m_center,t.m_from,t.m_to,!1,!0):e.lineTo(t.m_to))}}cleanupBufferCommands(){this.m_helperArray=Y(B,9);let e=0;for(let s=0,i=this.m_bufferCommands.length;s<i;){const t=this.m_bufferCommands[s];if(t.m_type&O.enumConnectionMask){e=s;break}s=t.m_next}let t=e+1;for(let s=e;t!==e;s=t){const e=this.m_bufferCommands[s];t=e.m_next;let i=1,n=null;for(;t!==s&&(n=this.m_bufferCommands[t],!(n.m_type&O.enumConnectionMask));)t=n.m_next,i++;if(1!==i&&(e.m_type&n.m_type)===O.enumLine){this.m_helperLine1.setStartXY(e.m_from),this.m_helperLine1.setEndXY(e.m_to),this.m_helperLine2.setStartXY(n.m_from),this.m_helperLine2.setEndXY(n.m_to);1===this.m_helperLine1.intersect(this.m_helperLine2,this.m_helperArray,null,null,this.m_smallTolerance.total())&&(e.m_to.assign(this.m_helperArray[0]),n.m_from.assign(this.m_helperArray[0]),e.m_next=t)}}return e}isDegeneratePath(e,t){if(1===e.getPathSize(t))return!0;if(0===this.m_joins&&0===this.m_caps){const s=new C;if(e.queryPathEnvelope(t,s),Math.max(s.width(),s.height())<.5*this.m_densifyDist)return!0}return!1}isDegenerateGeometry(e){if(0===this.m_joins&&0===this.m_caps){const t=new C;if(e.queryEnvelope(t),Math.max(t.width(),t.height())<.5*this.m_densifyDist)return!0}return!1}addCircle(e,t){const s=t.getXY();if(0!==this.m_circleTemplate.length){let t=this.m_circleTemplate[0].clone();t.scaleAddThis(this.m_absDistance,s),e.startPath(t);for(let i=1,n=this.m_circleTemplate.length;i<n;i++)t=this.m_circleTemplate[i].clone(),t.scaleAddThis(this.m_absDistance,s),e.lineTo(t);return}const i=this.m_circleTemplateSize,n=Math.trunc((i+3)/4),r=.5*Math.PI/n;e.reserve(4*n);const m=Math.cos(r),o=Math.sin(r);for(let a=3;a>=0;a--){const t=B.construct(0,this.m_absDistance);switch(a){case 0:for(let i=0;i<n;i++)e.lineToCoords(t.x+s.x,t.y+s.y),t.rotateReverse(m,o);break;case 1:for(let i=0;i<n;i++)e.lineToCoords(-t.y+s.x,t.x+s.y),t.rotateReverse(m,o);break;case 2:for(let i=0;i<n;i++)e.lineToCoords(-t.x+s.x,-t.y+s.y),t.rotateReverse(m,o);break;default:e.startPathCoords(t.y+s.x,-t.x+s.y);for(let i=1;i<n;i++)t.rotateReverse(m,o),e.lineToCoords(t.y+s.x,-t.x+s.y)}this.progress_()}}addSquare(e,t){const s=new M({vd:t.getDescription()});s.setCoords(t.getX(),t.getY(),t.getX(),t.getY()),s.inflateCoords(this.m_absDistance,this.m_absDistance),e.addEnvelope(s,!1)}setStrongSimple(e){return e.getImpl().setIsSimple(4,this.m_tolerance.total()),e.getImpl().updateOGCFlagsProtected(),e}}function $(e){return R(e,0),e}function ee(e,t){return!!e.isEmpty()||Math.min(e.width(),e.height())>t}function te(e,t,s,i,n,r,m,o){const a=e.getXY(s),h=e.getXY(i);if(a.equals(h))return-1;const l=.25*m,c=.25*m,u=new B;u.setSub(h,a);const _=u.length(),g=_*_*.25,d=r*r-g;if(d<=g)return-1;const p=Math.sqrt(d);u.normalize();const b=u.clone();b.rightPerpendicularThis();const y=g/p,P=y<=c,x=B.lerp(h,a,.5),C=b.clone(),D=y-l;C.scaleAddThis(Math.max(0,D),x);b.negate().scaleAddThis(p,x);const w=3.61*z(r-c),T=C.sub(a),v=C.sub(h);let S=!1,I=0;const M=G(64,0);f(o===M.length);{for(let o=e.getPrevVertexEx(i,n);o!==s;){if(1===e.getUserIndex(o,t))return-1;if(!e.getXY(o).equals(h))break;{const t=e.getPrevVertexEx(o,n);e.removeVertex(o,!1),o=t}}const r=new B,m=a.clone();M[I++]=1;for(let o=e.getNextVertexEx(s,n);o!==i;){if(1===e.getUserIndex(o,t))return-1;const s=e.getXY(o);if(s.equals(m)){const t=e.getNextVertexEx(o,n);e.removeVertex(o,!1),o=t;continue}M[I++]=0;const i=new B;if(i.setSub(s,a),i.dotProduct(b)<0)return 0;(B.sqrDistance(s,a)>w||B.sqrDistance(s,h)>w)&&(S=!0);let l=0;s.sub(a).crossProduct(T)>=0&&(l=1);if(s.sub(h).crossProduct(v)<=0&&(l|=2),0===l)return 0;M[I-1]=l,r.assign(m),m.assign(s),o=e.getNextVertexEx(o,n)}if(1===I)return 0;f(I<M.length),M[I++]=2}let V=!0;for(let f=1,B=0;f<I;f++)if(M[f]!==M[f-1]&&(B++,V=B<3&&(1===B&&3===M[f]||2===B&&2===M[f]),!V))return 0;if(I>2&&V&&(3===I||!S)){let t=0,r=e.getNextVertexEx(s,n);for(P||(e.setXY(r,C),r=e.getNextVertexEx(r,n));r!==i;){const s=e.getNextVertexEx(r,n);e.removeVertex(r,!1),r=s,++t}return t}if(f(3!==I),S&&I>3)return 0;const E=a.clone();let k=s;const R=a.clone();let A=1,X=-1,Y=k,F=0;for(I=1;Y!==i;){Y=e.getNextVertexEx(Y,n);const t=M[I++];if(0===t){if(Y===i)break;continue}const s=e.getXY(Y);if(-1!==X){if(3&(X&A&t)){e.removeVertex(k,!0),F++,k=Y,R.setCoordsPoint2D(s),A=t;continue}if(3===A&&0!==X&&0!==t){if(R.setCoordsPoint2D(C),P||R.equals(E)){e.removeVertex(k,!0),F++,k=Y,R.setCoordsPoint2D(s),A=t;continue}e.setXY(k,R)}}X=A,E.setCoordsPoint2D(R),k=Y,A=t,R.setCoordsPoint2D(s)}return F}function se(e,t,s,i){let n=-1;const r=new B,m=new B,o=new B;for(let a=0,h=e.getPathSize(i),l=e.getFirstVertex(i);a<h;++a){-1===n&&(e.queryXY(l,m),n=e.getPrevVertex(l),-1!==n&&(e.queryXY(n,r),o.setSub(m,r),o.normalize()));const s=e.getNextVertex(l);if(-1===s)break;const i=e.getXY(s),a=i.sub(m);if(a.normalize(),-1!==n){a.dotProduct(o)<-.99&&Math.abs(a.crossProduct(o))<1e-7&&e.setUserIndex(l,t,1)}n=l,l=s,r.assign(m),m.assign(i),o.assign(a)}}function ie(s,i,n,r,m,o,a){const h={stack:[],error:void 0,hasError:!1};try{const t=s.getFirstPath(i),r=s.createUserIndex();e(h,F((()=>{s.removeUserIndex(r)}),!1),!1),se(s,r,i,t);for(let e=0;e<100;++e){if(0===s.getPathSize(t))return 1;let e=s.getFirstVertex(t),i=s.getPathSize(t);if(i<3)return 1;s.isClosedPath(t)||(i-=1);const o=64;let h=0,l=!1;for(let t=0;t<i&&e!==k;t++){let c=0,u=e;for(let h=1,l=Math.min(o,i-t);h<l;h++)if(u=s.getNextVertexEx(u,n),h>1){const t=te(s,r,e,u,n,m,a,o);if(-1===t)break;c+=t,i-=t}if(h+=c,l=c>0,l){const t=s.getPrevVertexEx(e,n);if(-1!==t){e=t,i++;continue}}e=s.getNextVertexEx(e,n)}if(0===h)break}return s.filterClosePoints(o,!1,!1,!1,-1),1}catch(l){h.error=l,h.hasError=!0}finally{t(h)}}function ne(e,t,s,i,n,r,m){return ie(e,t,s,i,n,r,m)}function re(e,t,s,i){for(let n=0,r=e.getPathCount();n<r;n++){const r=e.getXY(e.getPathStart(n));r.x!==s.xmin&&r.x!==s.xmax&&t.addPath(e,n,i)}}export{Z as B};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{b as e,c as t}from"./tslib.es6.js";import{G as n,v as i}from"./Geometry.js";import{q as r,r as s,P as o,t as m,E as a,S as u,a as c}from"./QuadraticBezier.js";import{P as h,s as l,a as g,i as y,m as _,b as D}from"./Transformation2D.js";function p(){return{outPoint:new h,index:-1,t:Number.NaN}}function v(e,t,n){return{outPoint:e.clone(),index:t,t:n}}function N(e,t,n,i){e.outPoint.assign(t),e.index=n,e.t=i}function f(e,t){e.outPoint.assign(t.outPoint),e.index=t.index,e.t=t.t}function P(e,t,n,i){e.index=n,e.t=i,t.queryCoord2D(e.t,e.outPoint)}function I(e,t){const n=p();f(n,e),f(e,t),f(t,n)}function d(e,t,i,s,o,m){if(e.getGeometryType()===n.enumPolygon){for(;s.nextPath();)if(s.hasNextSegment()){const t=s.nextSegment();if(0!==r(e,t.getEndXY(),0))return N(o,t.getEndXY(),-1,Number.NaN),N(m,t.getEndXY(),-1,Number.NaN),!0}s.resetToFirstPath()}if(t.getGeometryType()===n.enumPolygon){for(;i.nextPath();)if(i.hasNextSegment()){const e=i.nextSegment();if(0!==r(t,e.getEndXY(),0))return N(o,e.getEndXY(),-1,Number.NaN),N(m,e.getEndXY(),-1,Number.NaN),!0}i.resetToFirstPath()}return!1}function q(e){const t=e.getPathCount(),n=new Array(e.getSegmentCount());let i=0;for(let r=0;r<t;++r){const t=i+e.getSegmentCountPath(r);for(let s=i,o=e.getPathStart(r);s<t;++s,++o)n[s]=o;i=t}return s(e.getPointCount(),n),n}function M(e,t){return!!Number.isNaN(t)||e<=t}function x(e){const t=new c;return t.addEnvelope(e,!1),t}class E{constructor(e,t){if(this.m_env2DgeometryA=null,this.m_env2DgeometryB=null,this.m_progressCounter=0,this.m_progressTracker=t,this.m_maxSqrDistance=e*e,this.m_maxDistance=e,this.m_bIsNearCalc=!1,Number.isNaN(this.m_maxDistance)?this.m_maxDistance=Number.POSITIVE_INFINITY:this.m_maxDistance=e,this.m_maxSqrDistance=this.m_maxDistance*this.m_maxDistance,Number.isFinite(this.m_maxSqrDistance)){let e=Math.sqrt(this.m_maxSqrDistance);for(;e<this.m_maxDistance;)this.m_maxSqrDistance*=1+Number.EPSILON,e=Math.sqrt(this.m_maxSqrDistance)}}calculate(e,t,n,i){if(e.getGeometryType()!==o.type||t.getGeometryType()!==o.type){this.m_env2DgeometryA=new m,this.m_env2DgeometryB=new m,e.queryEnvelope(this.m_env2DgeometryA),t.queryEnvelope(this.m_env2DgeometryB);if(!M(this.m_env2DgeometryA.distanceFromEnvelope(this.m_env2DgeometryB),this.m_maxDistance))return Number.POSITIVE_INFINITY}const r=v(new h,D(),Number.NaN),s=v(new h,D(),Number.NaN),a=this._ExecuteBruteForce(e,t,r,s);return M(a,this.m_maxDistance)?(null!==n&&f(n,r),null!==i&&f(i,s),a):Number.POSITIVE_INFINITY}isNear(e,t){if(this.m_bIsNearCalc=!0,e.isEmpty()||t.isEmpty())return!1;if(e===t)return!0;let n=!0;if(e.getGeometryType()!==o.type&&e.getGeometryType()!==a.type||t.getGeometryType()!==o.type&&t.getGeometryType()!==a.type||(n=!1),n){if(this.m_env2DgeometryA=new m,this.m_env2DgeometryB=new m,e.queryEnvelope(this.m_env2DgeometryA),t.queryEnvelope(this.m_env2DgeometryB),!(this.m_env2DgeometryA.sqrMaxMinDistanceEnvelope(this.m_env2DgeometryB)>this.m_maxSqrDistance))return!0;if(this.m_env2DgeometryA.sqrDistanceEnvelope(this.m_env2DgeometryB,null,null)>this.m_maxSqrDistance)return!1}const i=v(new h,D(),Number.NaN),r=v(new h,D(),Number.NaN);return this._ExecuteBruteForce(e,t,i,r)<=this.m_maxDistance}progress_(e=!1){}_ExecuteBruteForce(e,t,i,r){switch(e.getGeometryType()){case n.enumPoint:return this.distancePointGeometry(e,t,i,r);case n.enumMultiPoint:return this.distanceMultipointGeometry(e,t,i,r);case n.enumEnvelope:return this.distanceEnvelopeGeometry(e,t,i,r);case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathGeometry(e,t,i,r);default:return Number.NaN}}distancePointGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:return this.distancePointPoint(e,t,i,r);case n.enumMultiPoint:return this.distancePointMultipoint(e,t,i,r);case n.enumPolyline:case n.enumPolygon:return this.distancePointMultipath(e,t,i,r);case n.enumEnvelope:return this.distancePointEnvelope(e,t,i,r);default:return Number.NaN}}distancePointPoint(e,t,n,i){const r=e.getXY(),s=t.getXY();return N(n,r,0,0),N(i,s,0,0),Math.sqrt(h.sqrDistance(r,s))}distancePointMultipoint(e,t,n,i){const r=e.getXY();let s=this.m_maxSqrDistance,o=s,m=!1;const a=t.getPointCount(),u=new h;for(let c=0;c<a;++c)if(t.queryXY(c,u),o=h.sqrDistance(r,u),this.m_bIsNearCalc){if(o<=s)return 0}else if(!(o>s)&&(!m&&o===s||o<s)&&(s=o,N(n,r,0,0),N(i,u,c,0),m=!0,0===s))return 0;return m?Math.sqrt(s):Number.POSITIVE_INFINITY}distancePointMultipath(e,t,i,s){const o=!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB),a=e.getXY();if(!o&&t.getGeometryType()===n.enumPolygon&&0!==r(t,a,0))return N(i,a,0,0),N(s,a,-1,Number.NaN),0;t.getImpl().getAccelerators();let u=this.m_maxSqrDistance,c=u,l=-1;const g=new m,y=t.querySegmentIterator();let _=!1;for(;y.nextPath();)for(;y.hasNextSegment();){const e=y.nextSegment();e.queryEnvelope(g);const t=g.sqrDistance(a);if(t>u)continue;if(!this.m_bIsNearCalc&&_&&t===u)continue;l=e.getClosestCoordinate(a,!1);const n=e.getCoord2D(l);if(c=h.sqrDistance(a,n),this.m_bIsNearCalc){if(c<=u)return 0}else if(!(c>u)&&(!_||c<u)&&(u=c,N(i,a,0,0),N(s,n,y.getStartPointIndex(),l),_=!0,0===u))return 0}return _?Math.sqrt(u):Number.POSITIVE_INFINITY}distancePointEnvelope(e,t,n,i){const r=e.getXY();N(n,r,0,0),N(i,r,-1,Number.NaN);const s=t.asEnvelope2D();return!s.contains(r)?Math.sqrt(s.sqrDistance(r,i.outPoint)):0}distanceMultipointGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distancePointMultipoint(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumMultiPoint:return this.distanceMultipointMultipoint(e,t,i,r,1,1);case n.enumPolyline:case n.enumPolygon:return this.distanceMultipointMultipath(e,t,i,r);case n.enumEnvelope:return this.distanceMultipointMultipath(e,x(t),i,r);default:return Number.NaN}}distanceMultipointMultipoint(n,i,r,s,o,m){const a={stack:[],error:void 0,hasError:!1};try{if(this.m_bIsNearCalc&&1===o&&1===m){const e=Math.trunc(g(Math.sqrt(n.getPointCount())+1,1,y())),t=Math.trunc(g(Math.sqrt(i.getPointCount())+1,1,y()));if((e>=4||t>=4)&&this.distanceMultipointMultipoint(n,i,r,s,e,t)<=this.m_maxSqrDistance)return 0}let t=this.m_maxSqrDistance;const u=[n],c=[i],D=this.swapGeometriesIfBGtA(u,c);D&&(this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),m=l(o,o=m),I(r,s)),e(a,_((()=>{I(r,s),this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB)}),!D),!1);const p=u[0].getImpl(),v=c[0].getImpl(),f=p.getPointCount(),P=v.getPointCount(),d=P>1;let q=!1;const M=new h,x=new h;for(let e=0;e<f;e+=o){if(p.queryXY(e,M),d){const e=this.m_env2DgeometryB.sqrDistance(M);if(this.m_bIsNearCalc){if(e>t)continue;if(this.m_env2DgeometryB.sqrMaxMinDistance(M)<=t)return 0}else if(e>=t)continue}for(let n=0;n<P;n+=m){v.queryXY(n,x);const i=h.sqrDistance(M,x);if(this.m_bIsNearCalc){if(i<=t)return 0}else if(!(i>t||q&&i===t)&&(!q||i<t)&&(N(r,M,e,0),N(s,x,n,0),q=!0,t=i,0===t))return q?Math.sqrt(t):Number.POSITIVE_INFINITY}}return q?Math.sqrt(t):Number.POSITIVE_INFINITY}catch(u){a.error=u,a.hasError=!0}finally{t(a)}}distanceMultipointMultipath(e,t,i,s){let o=!!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB)&&t.getGeometryType()===n.enumPolygon;const a=t.querySegmentIterator();a.stripAttributes();const u=new m,c=new h;let l=this.m_maxSqrDistance;const g=e.getImpl(),y=g.getPointCount(),_=y>1;let D=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const e=a.nextSegment();if(e.queryLooseEnvelope(u),_){const e=u.sqrDistanceEnvelope(this.m_env2DgeometryA,null,null);if(this.m_bIsNearCalc){if(e>l)continue}else if(e>l||D&&e===l)continue}for(let n=0;n<y;n++){if(g.queryXY(n,c),o&&0!==r(t,c,0))return N(i,c,-1,Number.NaN),N(s,c,n,0),0;{const e=u.sqrDistance(c);if(this.m_bIsNearCalc){if(e>l)continue}else if(e>l)continue}const m=e.getClosestCoordinate(c,!1),h=e.getCoord2D(m);c.subThis(h);const y=c.sqrLength();if(this.m_bIsNearCalc){if(y<=l)return 0}else if(!(y>l)&&(!D||y<l)&&(l=y,N(i,g.getXY(n),n,0),N(s,h,a.getStartPointIndex(),m),D=!0,0===l))return 0}o=!1}return D?Math.sqrt(l):Number.POSITIVE_INFINITY}distanceEnvelopeGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:return this.distancePointEnvelope(t,e,r,i);case n.enumMultiPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distanceMultipointMultipath(t,x(e),r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathMultipath(x(e),t,i,r);case n.enumEnvelope:return this.distanceEnvelopeEnvelope(e,t,i,r);default:return Number.NaN}}distanceEnvelopeEnvelope(e,t,n,i){n.t=Number.NaN,n.index=-1,i.t=Number.NaN,i.index=-1;const r=e.asEnvelope2D(),s=t.asEnvelope2D();return Math.sqrt(r.sqrDistanceEnvelope(s,n.outPoint,i.outPoint))}distanceMultipathGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distancePointMultipath(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumMultiPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distanceMultipointMultipath(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathMultipath(e,t,i,r);case n.enumEnvelope:return this.distanceMultipathMultipath(e,x(t),i,r);default:return Number.NaN}}distanceMultipathMultipath(n,i,r,s){const o={stack:[],error:void 0,hasError:!1};try{const t=[n],a=[i],c=this.swapGeometriesIfAGtB(t,a);c&&(this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),I(r,s)),e(o,_((()=>{I(r,s),this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB)}),!c),!1);const h=t[0],D=a[0],v=h.querySegmentIterator();v.stripAttributes();const N=D.querySegmentIterator();if(N.stripAttributes(),this.m_bIsNearCalc&&this.m_env2DgeometryA.sqrMaxMinDistanceEnvelope(this.m_env2DgeometryB)<=this.m_maxSqrDistance)return 0;if(this.m_bIsNearCalc){const e=Math.trunc(g(Math.sqrt(h.getPointCount())+1,1,y())),t=Math.trunc(g(Math.sqrt(h.getPointCount())+1,1,y()));if(this.distanceMultipointMultipoint(h,D,r,s,e,t)<=this.m_maxSqrDistance)return 0}if(!!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB)){const e=p(),t=p();if(d(h,D,v,N,e,t))return f(r,e),f(s,t),0}const M=q(h),x=[],E=new u,b=new m,B=new m,S=new m;let A=this.m_maxSqrDistance,T=!0,C=!1;for(let e=0,n=M.length;e<n;++e){h.querySegment(M[e],E,!0);const t=E.get();if(t.queryEnvelope(b),!(b.sqrDistanceEnvelope(this.m_env2DgeometryB,null,null)>A)){if(this.m_bIsNearCalc&&b.sqrMaxDistanceEnvelope(this.m_env2DgeometryB)<=A)return 0;for(;N.nextPath();){if(this.progress_(),T)D.queryPathEnvelope(N.getPathIndex(),S),x[N.getPathIndex()]=S.clone();else if(b.sqrDistanceEnvelope(x[N.getPathIndex()],null,null)>A)continue;for(;N.hasNextSegment();){const n=N.nextSegment();if(n.queryEnvelope(B),b.sqrDistanceEnvelope(B,null,null)<=A){const i=!b.isIntersecting(B),o=[0],m=[0];let a=t.distance(n,i,o,m);if(a*=a,this.m_bIsNearCalc&&a<=this.m_maxSqrDistance)return 0;if(a<A||a===A&&M[e]<r.index){if(C=!0,P(r,t,M[e],o[0]),P(s,n,N.getStartPointIndex(),m[0]),0===a)return 0;A=a}}}}N.resetToFirstPath(),T=!1}}return C?Math.sqrt(A):Number.POSITIVE_INFINITY}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}swapGeometriesIfAGtB(e,t){return i(e[0])>i(t[0])&&(t[0]=l(e[0],e[0]=t[0]),!0)}swapGeometriesIfBGtA(e,t){return this.swapGeometriesIfAGtB(t,e)}}export{E as D,p as m,q as s,d as w};
|
|
5
|
+
import{b as e,c as t}from"./tslib.es6.js";import{G as n,v as i}from"./Geometry.js";import{t as r,u as s,P as o,v as m,E as a,S as u,a as c}from"./QuadraticBezier.js";import{P as h,s as l,a as g,i as y,m as _,b as D}from"./Transformation2D.js";function v(){return{outPoint:new h,index:-1,t:Number.NaN}}function p(e,t,n){return{outPoint:e.clone(),index:t,t:n}}function N(e,t,n,i){e.outPoint.assign(t),e.index=n,e.t=i}function f(e,t){e.outPoint.assign(t.outPoint),e.index=t.index,e.t=t.t}function P(e,t,n,i){e.index=n,e.t=i,t.queryCoord2D(e.t,e.outPoint)}function I(e,t){const n=v();f(n,e),f(e,t),f(t,n)}function d(e,t,i,s,o,m){if(e.getGeometryType()===n.enumPolygon){for(;s.nextPath();)if(s.hasNextSegment()){const t=s.nextSegment();if(0!==r(e,t.getEndXY(),0))return N(o,t.getEndXY(),-1,Number.NaN),N(m,t.getEndXY(),-1,Number.NaN),!0}s.resetToFirstPath()}if(t.getGeometryType()===n.enumPolygon){for(;i.nextPath();)if(i.hasNextSegment()){const e=i.nextSegment();if(0!==r(t,e.getEndXY(),0))return N(o,e.getEndXY(),-1,Number.NaN),N(m,e.getEndXY(),-1,Number.NaN),!0}i.resetToFirstPath()}return!1}function q(e){const t=e.getPathCount(),n=new Array(e.getSegmentCount());let i=0;for(let r=0;r<t;++r){const t=i+e.getSegmentCountPath(r);for(let s=i,o=e.getPathStart(r);s<t;++s,++o)n[s]=o;i=t}return s(e.getPointCount(),n),n}function M(e,t){return!!Number.isNaN(t)||e<=t}function x(e){const t=new c;return t.addEnvelope(e,!1),t}class E{constructor(e,t){if(this.m_env2DgeometryA=null,this.m_env2DgeometryB=null,this.m_progressCounter=0,this.m_progressTracker=t,this.m_maxSqrDistance=e*e,this.m_maxDistance=e,this.m_bIsNearCalc=!1,Number.isNaN(this.m_maxDistance)?this.m_maxDistance=Number.POSITIVE_INFINITY:this.m_maxDistance=e,this.m_maxSqrDistance=this.m_maxDistance*this.m_maxDistance,Number.isFinite(this.m_maxSqrDistance)){let e=Math.sqrt(this.m_maxSqrDistance);for(;e<this.m_maxDistance;)this.m_maxSqrDistance*=1+Number.EPSILON,e=Math.sqrt(this.m_maxSqrDistance)}}calculate(e,t,n,i){if(e.getGeometryType()!==o.type||t.getGeometryType()!==o.type){this.m_env2DgeometryA=new m,this.m_env2DgeometryB=new m,e.queryEnvelope(this.m_env2DgeometryA),t.queryEnvelope(this.m_env2DgeometryB);if(!M(this.m_env2DgeometryA.distanceFromEnvelope(this.m_env2DgeometryB),this.m_maxDistance))return Number.POSITIVE_INFINITY}const r=p(new h,D(),Number.NaN),s=p(new h,D(),Number.NaN),a=this._ExecuteBruteForce(e,t,r,s);return M(a,this.m_maxDistance)?(null!==n&&f(n,r),null!==i&&f(i,s),a):Number.POSITIVE_INFINITY}isNear(e,t){if(this.m_bIsNearCalc=!0,e.isEmpty()||t.isEmpty())return!1;if(e===t)return!0;let n=!0;if(e.getGeometryType()!==o.type&&e.getGeometryType()!==a.type||t.getGeometryType()!==o.type&&t.getGeometryType()!==a.type||(n=!1),n){if(this.m_env2DgeometryA=new m,this.m_env2DgeometryB=new m,e.queryEnvelope(this.m_env2DgeometryA),t.queryEnvelope(this.m_env2DgeometryB),!(this.m_env2DgeometryA.sqrMaxMinDistanceEnvelope(this.m_env2DgeometryB)>this.m_maxSqrDistance))return!0;if(this.m_env2DgeometryA.sqrDistanceEnvelope(this.m_env2DgeometryB,null,null)>this.m_maxSqrDistance)return!1}const i=p(new h,D(),Number.NaN),r=p(new h,D(),Number.NaN);return this._ExecuteBruteForce(e,t,i,r)<=this.m_maxDistance}progress_(e=!1){}_ExecuteBruteForce(e,t,i,r){switch(e.getGeometryType()){case n.enumPoint:return this.distancePointGeometry(e,t,i,r);case n.enumMultiPoint:return this.distanceMultipointGeometry(e,t,i,r);case n.enumEnvelope:return this.distanceEnvelopeGeometry(e,t,i,r);case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathGeometry(e,t,i,r);default:return Number.NaN}}distancePointGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:return this.distancePointPoint(e,t,i,r);case n.enumMultiPoint:return this.distancePointMultipoint(e,t,i,r);case n.enumPolyline:case n.enumPolygon:return this.distancePointMultipath(e,t,i,r);case n.enumEnvelope:return this.distancePointEnvelope(e,t,i,r);default:return Number.NaN}}distancePointPoint(e,t,n,i){const r=e.getXY(),s=t.getXY();return N(n,r,0,0),N(i,s,0,0),Math.sqrt(h.sqrDistance(r,s))}distancePointMultipoint(e,t,n,i){const r=e.getXY();let s=this.m_maxSqrDistance,o=s,m=!1;const a=t.getPointCount(),u=new h;for(let c=0;c<a;++c)if(t.queryXY(c,u),o=h.sqrDistance(r,u),this.m_bIsNearCalc){if(o<=s)return 0}else if(!(o>s)&&(!m&&o===s||o<s)&&(s=o,N(n,r,0,0),N(i,u,c,0),m=!0,0===s))return 0;return m?Math.sqrt(s):Number.POSITIVE_INFINITY}distancePointMultipath(e,t,i,s){const o=!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB),a=e.getXY();if(!o&&t.getGeometryType()===n.enumPolygon&&0!==r(t,a,0))return N(i,a,0,0),N(s,a,-1,Number.NaN),0;t.getImpl().getAccelerators();let u=this.m_maxSqrDistance,c=u,l=-1;const g=new m,y=t.querySegmentIterator();let _=!1;for(;y.nextPath();)for(;y.hasNextSegment();){const e=y.nextSegment();e.queryEnvelope(g);const t=g.sqrDistance(a);if(t>u)continue;if(!this.m_bIsNearCalc&&_&&t===u)continue;l=e.getClosestCoordinate(a,!1);const n=e.getCoord2D(l);if(c=h.sqrDistance(a,n),this.m_bIsNearCalc){if(c<=u)return 0}else if(!(c>u)&&(!_||c<u)&&(u=c,N(i,a,0,0),N(s,n,y.getStartPointIndex(),l),_=!0,0===u))return 0}return _?Math.sqrt(u):Number.POSITIVE_INFINITY}distancePointEnvelope(e,t,n,i){const r=e.getXY();N(n,r,0,0),N(i,r,-1,Number.NaN);const s=t.asEnvelope2D();return!s.contains(r)?Math.sqrt(s.sqrDistance(r,i.outPoint)):0}distanceMultipointGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distancePointMultipoint(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumMultiPoint:return this.distanceMultipointMultipoint(e,t,i,r,1,1);case n.enumPolyline:case n.enumPolygon:return this.distanceMultipointMultipath(e,t,i,r);case n.enumEnvelope:return this.distanceMultipointMultipath(e,x(t),i,r);default:return Number.NaN}}distanceMultipointMultipoint(n,i,r,s,o,m){const a={stack:[],error:void 0,hasError:!1};try{if(this.m_bIsNearCalc&&1===o&&1===m){const e=Math.trunc(g(Math.sqrt(n.getPointCount())+1,1,y())),t=Math.trunc(g(Math.sqrt(i.getPointCount())+1,1,y()));if((e>=4||t>=4)&&this.distanceMultipointMultipoint(n,i,r,s,e,t)<=this.m_maxSqrDistance)return 0}let t=this.m_maxSqrDistance;const u=[n],c=[i],D=this.swapGeometriesIfBGtA(u,c);D&&(this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),m=l(o,o=m),I(r,s)),e(a,_((()=>{I(r,s),this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB)}),!D),!1);const v=u[0].getImpl(),p=c[0].getImpl(),f=v.getPointCount(),P=p.getPointCount(),d=P>1;let q=!1;const M=new h,x=new h;for(let e=0;e<f;e+=o){if(v.queryXY(e,M),d){const e=this.m_env2DgeometryB.sqrDistance(M);if(this.m_bIsNearCalc){if(e>t)continue;if(this.m_env2DgeometryB.sqrMaxMinDistance(M)<=t)return 0}else if(e>=t)continue}for(let n=0;n<P;n+=m){p.queryXY(n,x);const i=h.sqrDistance(M,x);if(this.m_bIsNearCalc){if(i<=t)return 0}else if(!(i>t||q&&i===t)&&(!q||i<t)&&(N(r,M,e,0),N(s,x,n,0),q=!0,t=i,0===t))return q?Math.sqrt(t):Number.POSITIVE_INFINITY}}return q?Math.sqrt(t):Number.POSITIVE_INFINITY}catch(u){a.error=u,a.hasError=!0}finally{t(a)}}distanceMultipointMultipath(e,t,i,s){let o=!!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB)&&t.getGeometryType()===n.enumPolygon;const a=t.querySegmentIterator();a.stripAttributes();const u=new m,c=new h;let l=this.m_maxSqrDistance;const g=e.getImpl(),y=g.getPointCount(),_=y>1;let D=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const e=a.nextSegment();if(e.queryLooseEnvelope(u),_){const e=u.sqrDistanceEnvelope(this.m_env2DgeometryA,null,null);if(this.m_bIsNearCalc){if(e>l)continue}else if(e>l||D&&e===l)continue}for(let n=0;n<y;n++){if(g.queryXY(n,c),o&&0!==r(t,c,0))return N(i,c,-1,Number.NaN),N(s,c,n,0),0;{const e=u.sqrDistance(c);if(this.m_bIsNearCalc){if(e>l)continue}else if(e>l)continue}const m=e.getClosestCoordinate(c,!1),h=e.getCoord2D(m);c.subThis(h);const y=c.sqrLength();if(this.m_bIsNearCalc){if(y<=l)return 0}else if(!(y>l)&&(!D||y<l)&&(l=y,N(i,g.getXY(n),n,0),N(s,h,a.getStartPointIndex(),m),D=!0,0===l))return 0}o=!1}return D?Math.sqrt(l):Number.POSITIVE_INFINITY}distanceEnvelopeGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:return this.distancePointEnvelope(t,e,r,i);case n.enumMultiPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distanceMultipointMultipath(t,x(e),r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathMultipath(x(e),t,i,r);case n.enumEnvelope:return this.distanceEnvelopeEnvelope(e,t,i,r);default:return Number.NaN}}distanceEnvelopeEnvelope(e,t,n,i){n.t=Number.NaN,n.index=-1,i.t=Number.NaN,i.index=-1;const r=e.asEnvelope2D(),s=t.asEnvelope2D();return Math.sqrt(r.sqrDistanceEnvelope(s,n.outPoint,i.outPoint))}distanceMultipathGeometry(e,t,i,r){switch(t.getGeometryType()){case n.enumPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distancePointMultipath(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumMultiPoint:{this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB);const n=this.distanceMultipointMultipath(t,e,r,i);return this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),n}case n.enumPolyline:case n.enumPolygon:return this.distanceMultipathMultipath(e,t,i,r);case n.enumEnvelope:return this.distanceMultipathMultipath(e,x(t),i,r);default:return Number.NaN}}distanceMultipathMultipath(n,i,r,s){const o={stack:[],error:void 0,hasError:!1};try{const t=[n],a=[i],c=this.swapGeometriesIfAGtB(t,a);c&&(this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB),I(r,s)),e(o,_((()=>{I(r,s),this.m_env2DgeometryB=l(this.m_env2DgeometryA,this.m_env2DgeometryA=this.m_env2DgeometryB)}),!c),!1);const h=t[0],D=a[0],p=h.querySegmentIterator();p.stripAttributes();const N=D.querySegmentIterator();if(N.stripAttributes(),this.m_bIsNearCalc&&this.m_env2DgeometryA.sqrMaxMinDistanceEnvelope(this.m_env2DgeometryB)<=this.m_maxSqrDistance)return 0;if(this.m_bIsNearCalc){const e=Math.trunc(g(Math.sqrt(h.getPointCount())+1,1,y())),t=Math.trunc(g(Math.sqrt(h.getPointCount())+1,1,y()));if(this.distanceMultipointMultipoint(h,D,r,s,e,t)<=this.m_maxSqrDistance)return 0}if(!!this.m_env2DgeometryA.isIntersecting(this.m_env2DgeometryB)){const e=v(),t=v();if(d(h,D,p,N,e,t))return f(r,e),f(s,t),0}const M=q(h),x=[],E=new u,b=new m,B=new m,S=new m;let A=this.m_maxSqrDistance,T=!0,C=!1;for(let e=0,n=M.length;e<n;++e){h.querySegment(M[e],E,!0);const t=E.get();if(t.queryEnvelope(b),!(b.sqrDistanceEnvelope(this.m_env2DgeometryB,null,null)>A)){if(this.m_bIsNearCalc&&b.sqrMaxDistanceEnvelope(this.m_env2DgeometryB)<=A)return 0;for(;N.nextPath();){if(this.progress_(),T)D.queryPathEnvelope(N.getPathIndex(),S),x[N.getPathIndex()]=S.clone();else if(b.sqrDistanceEnvelope(x[N.getPathIndex()],null,null)>A)continue;for(;N.hasNextSegment();){const n=N.nextSegment();if(n.queryEnvelope(B),b.sqrDistanceEnvelope(B,null,null)<=A){const i=!b.isIntersecting(B),o=[0],m=[0];let a=t.distance(n,i,o,m);if(a*=a,this.m_bIsNearCalc&&a<=this.m_maxSqrDistance)return 0;if(a<A||a===A&&M[e]<r.index){if(C=!0,P(r,t,M[e],o[0]),P(s,n,N.getStartPointIndex(),m[0]),0===a)return 0;A=a}}}}N.resetToFirstPath(),T=!1}}return C?Math.sqrt(A):Number.POSITIVE_INFINITY}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}swapGeometriesIfAGtB(e,t){return i(e[0])>i(t[0])&&(t[0]=l(e[0],e[0]=t[0]),!0)}swapGeometriesIfBGtA(e,t){return this.swapGeometriesIfAGtB(t,e)}}export{E as D,v as m,q as s,d as w};
|
package/chunks/{GeodeticDistanceCalculator-DzvUOSaR.js → GeodeticDistanceCalculator-B5uO-Y_z.js}
RENAMED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{b as t,c as e}from"./tslib.es6.js";import{t as i,G as s,g as n,e as o,v as a,i as r}from"./Geometry.js";import{t as m,K as c,G as u,a0 as h,a1 as l,ap as _,ad as d,an as p,S as g,aq as x,ar as y,ac as P,e as S,as as D,N as G,w as f,a as v,at as T,H as w,ai as M,a2 as b}from"./QuadraticBezier.js";import{P as E,T as C,s as R,f as B,E as I,h as A}from"./Transformation2D.js";import{s as q,w as N,m as k}from"./Distance2DCalculator-DM4OojiI.js";import{O as F}from"./OperatorShapePreservingDensify.js";function X(){return new m}class Y{constructor(t,e,i){void 0!==t?this.reset(t,e,i):this.reset(1,0,1)}reset(t,e,i){this.m_a=t,this.m_e2=e,this.m_b=this.m_a*Math.sqrt(1-this.m_e2),this.m_unitToDegree=i,this.m_unitToRad=.017453292519943295*i,this.m_u180=180/this.m_unitToDegree,this.m_u360=360/this.m_unitToDegree}calculateBbox(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1),r=t(a,new h,!1),m=t(a,new h,!1);l.geodeticDistance(this.m_a,this.m_e2,i*this.m_unitToRad,s*this.m_unitToRad,n*this.m_unitToRad,o*this.m_unitToRad,m,e,r,0);const c=Math.cos(e.val),u=Math.cos(r.val+3.141592653589793),_=s*this.m_unitToRad,d=w.phiToEta(this.m_e2,_),p=Math.sin(e.val)*Math.cos(d);let g=s;if(c*u<0){const t=c<0?-1:1,e=Math.acos(Math.abs(p))*t;g=w.etaToPhi(this.m_e2,e)/this.m_unitToRad}let x=A((n-i)*this.m_unitToRad,2*Math.PI);Math.abs(x)>Math.PI&&(x=x>0?x-2*Math.PI:x+2*Math.PI),x/=this.m_unitToRad,n=i+x;const y=X();return y.xmin=Math.min(i,n),y.xmax=Math.max(i,n),y.ymin=Math.min(s,o),y.ymin=Math.min(y.ymin,g),y.ymax=Math.max(s,o),y.ymax=Math.max(y.ymax,g),y}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}minDistanceGeodesic(t,e){const i=O(t),s=O(e);if(i&&s)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const n=this.normalizeGeodesic_(e,t);return U(t,n)?t.ymin>=n.ymax?this.minDistanceGeodesicUpDown_(t,n):n.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(n,t):t.xmin>n.xmax?this.minDistanceGeodesicLeftRight_(n,t):this.minDistanceGeodesicLeftRight_(t,n):0}sqrMaxMinDistanceGeodesic(t,e){return n(0),0}maxDistanceGeodesic(t,e){return n(0),0}sqrMinDistance(t,e){return n(0),0}sqrMaxDistance(t,e){return n(0),0}sqrMaxMinDistance(t,e){return n(0),0}calculateMaxDim(t){return n(0),0}lowerDistanceGeodesic(t,e,i,s){return n(0),0}upperDistanceGeodesic(t,e,i,s){return n(0),0}normalizeGeodesic_(t,e){const i=t.clone(),s=t.clone();let n=L(i,e);if(0===n)return i;for(;s.xmax>e.xmin;){s.xmin-=this.m_u360,s.xmax-=this.m_u360;const t=L(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}for(s.assign(t);s.xmin<e.xmax;){s.xmin+=this.m_u360,s.xmax+=this.m_u360;const t=L(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}return i}lowerDistanceGeodetic_(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1);{const t=this.m_b*this.m_b/this.m_a,a=w.phiToPhig(this.m_e2,this.m_unitToRad*s),r=w.phiToPhig(this.m_e2,this.m_unitToRad*o);l.geodeticDistance(t,0,this.m_unitToRad*i,a,this.m_unitToRad*n,r,e,null,null,0)}return e.val}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}upperDistanceGeodetic_(t,e,i,s){return n(0),0}minDistanceGeodesicUpDown_(t,e){if(e.xmin<=t.xmin?e.xmax>=t.xmin:t.xmax>=e.xmin)return this.lowerDistanceGeodetic_(0,t.ymin,0,e.ymax);if(e.xmin>t.xmax){const i=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);if(e.xmax-t.xmin<this.m_u180)return i;const s=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,s)}{const i=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);if(t.xmax-e.xmin<this.m_u180)return i;const s=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,s)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let s=Math.abs(t.xmin-e.xmax);for(;s>this.m_u180;)s-=this.m_u360;return Math.abs(i)<=Math.abs(s)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,s;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),s=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,s),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),i}normalizeDistance_(t){return n(0),0}lowerDistanceGeodeticSegMeridional_(t,e,i,s,n,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,s,n,o);const r=this.lowerDistanceGeodeticPtMeridional_(t,i,s,n,o);let m=this.lowerDistanceGeodeticPtMeridional_(s,n,t,e,i);const c=this.lowerDistanceGeodeticPtMeridional_(s,o,t,e,i);return a=Math.min(a,r),m=Math.min(m,c),Math.min(a,m)}minDistanceGeodesicPointBox_(t,e,i){return n(0),0}lowerDistanceGeodeticPtMeridional_(i,s,n,o,a){const r={stack:[],error:void 0,hasError:!1};try{const c=this.m_b*this.m_b/this.m_a,u=w.phiToPhig(this.m_e2,this.m_unitToRad*s),_=w.phiToPhig(this.m_e2,this.m_unitToRad*o),g=w.phiToPhig(this.m_e2,this.m_unitToRad*a),x=t(r,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*n,_,this.m_unitToRad*i,u,x,null,null,0);const y=t(r,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*n,g,this.m_unitToRad*i,u,y,null,null,0);const P=d(1,0,new E(this.m_unitToRad*i,u)),S=d(1,0,new E(this.m_unitToRad*n,_)),D=d(1,0,new E(this.m_unitToRad*n,g));let G=new p;G.setCrossProductVector(S,D);const f=S.dotProduct(D);if(G.length()<1.568e-10)return f>=0?Math.min(x.val,y.val):0;G=G.getUnitVector();let v=new p;if(v.setCrossProductVector(G,P),v.length()<1.568e-10){return Math.min(x.val,y.val)-1e-5*c}v=v.getUnitVector();let T=P.sub(G.mul(P.dotProduct(G)));{const s=new p;s.setCrossProductVector(S,T);const n=new p;n.setCrossProductVector(T,D);let o=G.dotProduct(s)>0&&G.dotProduct(n)>0;if(o||(T.negateThis(),s.setCrossProductVector(S,T),n.setCrossProductVector(T,D),o=G.dotProduct(s)>0&&G.dotProduct(n)>0),o){const s={stack:[],error:void 0,hasError:!1};try{T=T.getUnitVector();const e=M(1,0,T),n=t(s,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*i,u,e.x,e.y,n,null,null,0);const o=Math.min(x.val,y.val);return Math.min(o,n.val)}catch(m){s.error=m,s.hasError=!0}finally{e(s)}}}return Math.min(x.val,y.val)}catch(c){r.error=c,r.hasError=!0}finally{e(r)}}fixAngle(t){return n(0),0}moveCloser(t,e){return n(0),0}}function O(t){return t.xmin===t.xmax&&t.ymin===t.ymax}function U(t,e){return e.xmax<t.xmin||e.xmin>t.xmax||e.ymax<t.ymin||e.ymin>t.ymax}function L(t,e){let i,s=0;return i=t.xmin-e.xmax,i>s&&(s=i),i=e.xmin-t.xmax,i>s&&(s=i),s}class V{}function z(t){return{outPoint:void 0===t?new E:t.clone()}}function j(t,e){t.outPoint.assign(e.outPoint)}function H(){return new m}class K{constructor(t,e,i,s,n=0,o=4){this.m_ptDistFrom=new E,this.m_segStartPt=new E,this.m_segEndPt=new E,this.m_geodeticLength=new h,this.m_az12=new h,this.m_minGeodeticDist=new h,this.m_segStartPt3d=new p,this.m_segEndPt3d=new p,this.m_sr=s,this.m_distCurveType=n,this.m_segCurveType=o,this.m_inputGCS=this.m_sr.getGCS(),this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_bIsPannablePcs=2===this.m_sr.getCoordinateSystemType()&&this.m_sr.isPannable();const a=b();this.m_inputGCS.querySpheroidData(a),this.m_a=a.majorSemiAxis,this.m_eSquared=a.e2,this.setPointDistFrom(t),this.setSegmentEndPoints(e,i)}setSegmentEndPoints(t,e){this.m_segStartPt.assign(t),this.m_segEndPt.assign(e),this.m_bIsPannablePcs||(this.m_segStartPt.mulThis(this.m_rpu),this.m_segEndPt.mulThis(this.m_rpu)),2===this.m_segCurveType&&(this.m_segStartPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segEndPt))),this.calculateAndUpdateSegmentLength()}setPointDistFrom(t){this.m_ptDistFrom.assign(t),this.m_ptDistFrom.scale(this.m_rpu)}setSegmentCurveType(t){this.m_segCurveType=t}setDistanceCurveType(t){this.m_distCurveType=t}makeFunctor(){return i=>{let s;switch(this.m_segCurveType){case 0:case 1:case 3:{const o={stack:[],error:void 0,hasError:!1};try{const e=t(o,new h,!1),n=t(o,new h,!1);l.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*i,this.m_az12.val,e,n,this.m_segCurveType),s=new E(e.val,n.val);break}catch(n){o.error=n,o.hasError=!0}finally{e(o)}}case 2:{const t=p.lerp(this.m_segStartPt3d,this.m_segEndPt3d,i);s=M(this.m_a,this.m_eSquared,t);break}case 4:s=E.lerp(this.m_segStartPt,this.m_segEndPt,i),this.m_bIsPannablePcs&&(x(this.m_sr,0,[s],1),s.mulThis(this.m_rpu));break;default:o("Invalid curve type")}return l.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,s.x,s.y,this.m_minGeodeticDist,null,null,this.m_distCurveType),this.m_minGeodeticDist.val}}calculateAndUpdateSegmentLength(){switch(this.m_segCurveType){case 0:case 2:case 1:case 3:l.geodeticDistance(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_segEndPt.x,this.m_segEndPt.y,this.m_geodeticLength,this.m_az12,null,this.m_segCurveType);break;case 4:this.m_geodeticLength.val=E.distance(this.m_segStartPt,this.m_segEndPt);break;default:o("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function Q(){return new V}class J{constructor(t,e,i,s,n){this.m_boxGeomA=H(),this.m_boxGeomB=H(),this.m_envGeomA=new m,this.m_envGeomB=new m,this.m_progressCounter=0,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new C,this.m_scaleToDegrees=new C,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=s,this.m_maxDeviation=n,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const o=b();this.m_inputGCS.querySpheroidData(o),this.m_a=o.majorSemiAxis,this.m_eSquared=o.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new Y(this.m_a,this.m_eSquared,1),4===this.m_distCurveType&&(this.m_distCurveType=0),this.m_boxGeomA.setEmpty(),this.m_boxGeomB.setEmpty(),this.m_envGeomA.setEmpty(),this.m_envGeomB.setEmpty(),this.m_bIsPannablePcs=2===this.m_inputSR.getCoordinateSystemType()&&this.m_inputSR.isPannable()}progress(t=!1){}calculate(t,e,i,s){const n=z(),o=z();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,n,o))return i&&j(i,n),s&&j(s,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const r=this.prepareGeometry(e);if(r.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,r);const m=this._ExecuteBruteForce(a,r,n,o);return m>=this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(n),j(i,n)),s&&(this.prepareOutput(o),j(s,o)),m)}createDistanceFunctor(t,e,i){const s=new K(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||s.setSegmentCurveType(2),s}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new c).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=u(this.m_inputSR,this.m_inputGCS,null);t=(new c).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,e,n,o){switch(t.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointPoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=i.getXY();e.scale(this.m_rpu);const r=s.getXY();r.scale(this.m_rpu),n.outPoint.assign(e),o.outPoint.assign(r);const m=t(a,new h,!1);return l.geodeticDistance(this.m_a,this.m_eSquared,e.x,e.y,r.x,r.y,m,null,null,this.m_distCurveType),m.val}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipoint(t,e,i,s){return n(0),0}calculateDistanceGeodeticPointMultipath(i,s,o,a){const r={stack:[],error:void 0,hasError:!1};try{const e=new E,m=new E;e.assign(i.getXY()),m.assign(i.getXY()),o.outPoint.assign(m.mul(this.m_rpu)),this.m_bIsPannablePcs&&_(this.m_inputSR,[e],1,!1),this.computeEnvelopesAndBoxes(i,s);const c=this.estimateMinimumDistance(o,a);let u=c<this.m_maxDistance?c:this.m_maxDistance;const h=s.getImpl(),l=new E(0,0),d=new E(0,0),p=[1],g=this.canUseSpatialTree(i,s),x=Q();g&&this.buildSpatialTree(x,s);const y=H();y.setCoords({xmin:m.x,ymin:m.y,xmax:m.x,ymax:m.y});const P=t(r,this.createDistanceFunctor(m,l,d),!1),S=h.querySegmentIterator();if(S.stripAttributes(),g)n(0);else for(;S.nextPath();)for(;S.hasNextSegment();){const t=S.nextSegment(),i=this.findOrComputeBoxSegment(S.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(y,i)>u)continue;const s=this.calculateDistanceGeodeticPointSegment(e,m,t,p,P);if(s.second<u&&(this.updateOutputSegment(a,t,s.first),u=s.second,0===u))return 0}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(m){r.error=m,r.hasError=!0}finally{e(r)}}calculateDistanceGeodeticMultipointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1);this.computeEnvelopesAndBoxes(i,s);const r=this.estimateMinimumDistance(n,o);let m=r<this.m_maxDistance?r:this.m_maxDistance;const c=new E,u=new E,_=i.getImpl(),g=s.getImpl(),x=H(),y=_.getPointCount(),P=g.getPointCount();for(let t=0;t<y;++t){if(c.assign(_.getXY(t)),x.setCoords({xmin:c.x,ymin:c.y,xmax:c.x,ymax:c.y}),this.m_envHelper.minDistanceGeodesic(x,this.m_boxGeomB)>m)continue;c.scale(this.m_rpu);const i=d(this.m_a,this.m_eSquared,c);for(let t=0;t<P;++t){u.assign(g.getXY(t)),u.scale(this.m_rpu);const s=d(this.m_a,this.m_eSquared,u);if(!(p.distance(i,s)>=m)&&(l.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,e,null,null,this.m_distCurveType),e.val<m&&(n.outPoint.assign(c),o.outPoint.assign(u),m=e.val,0===m)))return m}}return m===this.m_maxDistance?Number.POSITIVE_INFINITY:m}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticMultipointMultipath(i,s,o,a){const r={stack:[],error:void 0,hasError:!1};try{const e=s.getImpl().querySegmentIterator();e.stripAttributes(),this.computeEnvelopesAndBoxes(i,s);const m=this.estimateMinimumDistance(o,a);let c=m<this.m_maxDistance?m:this.m_maxDistance;const u=new E,h=new E(0,0),l=new E(0,0),d=new E(0,0),p=[0],g=H(),x=t(r,this.createDistanceFunctor(h,l,d),!1),y=Q(),P=this.canUseSpatialTree(i,s);P&&this.buildSpatialTree(y,s);const S=i.getPointCount();for(let t=0;t<S;++t)if(u.assign(i.getXY(t)),h.assign(i.getXY(t)),this.m_bIsPannablePcs&&_(this.m_inputSR,[u],1,!1),g.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>c))if(x.setPointDistFrom(h),P)n(0);else{for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(this.m_envHelper.minDistanceGeodesic(g,this.findOrComputeBoxSegment(e.getStartPointIndex(),t,this.m_segmentBoxesB))>c)continue;const i=this.calculateDistanceGeodeticPointSegment(u,h,t,p,x);if(i.second<c&&(o.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),c=i.second,0===c))return 0}e.resetToFirstPath()}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(m){r.error=m,r.hasError=!0}finally{e(r)}}calculateDistanceGeodeticMultipathGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipath(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(e,t,o,n);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,s){const n=[t],o=[e],a=this.swapGeometries(n,o),r=n[0],m=o[0];this.computeEnvelopesAndBoxes(n[0],o[0]);const c=this.estimateMinimumDistance(i,s),u=this.calculateDistanceGeodeticMultipathMultipath_(r,m,i,s,c);return a&&(s.outPoint=R(i.outPoint,i.outPoint=s.outPoint)),u}calculateDistanceGeodeticMultipathMultipath_(i,s,o,a,r=Number.MAX_VALUE){const m={stack:[],error:void 0,hasError:!1};try{let e=r;const c=new E(0,0),u=new E,h=new E(0,0),l=new E,_=new E(0,0),d=new E,p=new E,P=new E,S=[new E],D=[0],G=[0],f=H(),v=H(),T=t(m,this.createDistanceFunctor(_,c,h),!1),w=Q(),M=this.canUseSpatialTree(i,s);M&&this.buildSpatialTree(w,s);const b=s.querySegmentIterator();b.stripAttributes();const C=new g,R=q(i);for(let t=0;t<R.length;++t){const s=R[t];i.getSegmentBuffer(s,C,!0);const r=C.get();if(f.assign(this.findOrComputeBoxSegment(s,r,this.m_segmentBoxesA)),M)n(0);else{if(_.assign(r.getStartXY()),d.assign(r.getStartXY()),p.assign(r.getEndXY()),P.assign(r.getEndXY()),this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[d],1),x(this.m_inputSR,0,[P],1)),this.m_envHelper.minDistanceGeodesic(f,this.m_boxGeomB)>e)continue;for(;b.nextPath();){for(;b.hasNextSegment();){const t=b.nextSegment();if(c.assign(t.getStartXY()),u.assign(t.getStartXY()),h.assign(t.getEndXY()),l.assign(t.getEndXY()),r.intersect(t,S,D,G,this.m_tolerance))return this.updateOutputSegment(o,r,D[0]),this.updateOutputSegment(a,t,G[0]),0;if(this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[u],1),x(this.m_inputSR,0,[l],1)),v.assign(this.findOrComputeBoxPoint(b.getStartPointIndex(),u,l,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(f,v)>e)continue;T.setSegmentEndPoints(c,h),T.setPointDistFrom(d);let i=y(T.makeFunctor(),0,1,1e-10);if(i.second<e&&(o.outPoint.assign(d.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setPointDistFrom(P),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(o.outPoint.assign(P.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setSegmentEndPoints(_,p),T.setPointDistFrom(u),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,r,i.first),a.outPoint.assign(u.mul(this.m_rpu)),e=i.second,0===e))break;if(T.setPointDistFrom(l),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,r,i.first),a.outPoint.assign(l.mul(this.m_rpu)),e=i.second,0===e))break}if(0===e)return 0}b.resetToFirstPath()}}return e===this.m_maxDistance?Number.POSITIVE_INFINITY:e}catch(c){m.error=c,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticPointSegment(t,e,i,s,n){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,s,this.m_tolerance)?B(s[0],0):(n.setPointDistFrom(e),n.setSegmentEndPoints(o,a),y(n.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===s.enumPoint||i===s.enumMultiPoint)return this._NormalizeAndProject(e);if(i===s.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=P(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new F).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new c).execute(e,t,this.m_progressTracker)}const n=new m;e.queryLooseEnvelope(n);const o=this.m_inputSR.getPannableExtent();if(n.ymin<o.ymin||n.ymax>o.ymax){const t=new m(n.xmin-1,o.ymin,n.xmax+1,o.ymax);if(e=(new S).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return n.width()>2*o.width()?(e=D(e,-2*o.width(),2*o.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new m;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const n=new I;s.queryIntervalX(n);const o=new I;return i.queryIntervalX(o),t=n.contains(o)?G(t,this.m_inputSR):(new c).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&_(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&x(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new m(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),f(null,i)}envelopeToPolygon(t){const e=new v;return e.addEnvelope(t,!1),e}computeEnvelopesAndBoxes(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.m_boxGeomA=this.computeBoxGeometry(t,this.m_boundaryPtsA,this.m_segmentBoxesA),this.m_boxGeomB=this.computeBoxGeometry(e,this.m_boundaryPtsB,this.m_segmentBoxesB)}computeBoxGeometry(t,e,i){switch(t.getGeometryType()){case s.enumPoint:return this.computeBoxPoint(t,e);case s.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case s.enumPolyline:case s.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:o("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=1,e[0]=i.mul(this.m_rpu);const s=H();return s.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),s}computeBoxSegment(t){return n(0),{}}computeBoxMultiPoint(t,e){let i=!0;for(let n=0;n<t.getPointCount();++n){const s=t.getXY(n);if(i){e.length=4;for(let t=0;t<e.length;++t)e[t]=s.clone();i=!1}s.x<e[0].x&&e[0].assign(s),s.y>e[1].y&&e[1].assign(s),s.x>e[2].x&&e[2].assign(s),s.y<e[3].y&&e[3].assign(s)}for(let n=0;n<e.length;++n)e[n].mulThis(this.m_rpu);const s=H();return t.queryEnvelope(s),s}computeBoxMultiPath(t,e,i){let s=!0;const n=H();n.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),r=t.getEndXY();if(this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[a],1),x(this.m_inputSR,0,[r],1)),s){e.length=4;for(let t=0;t<e.length;++t)e[t]=a.clone();s=!1}a.x<e[0].x&&e[0].assign(a),a.y>e[1].y&&e[1].assign(a),a.x>e[2].x&&e[2].assign(a),a.y<e[3].y&&e[3].assign(a),r.x<e[0].x&&e[0].assign(r),r.y>e[1].y&&e[1].assign(r),r.x>e[2].x&&e[2].assign(r),r.y<e[3].y&&e[3].assign(r);const m=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,r,i);n.mergeEnvelope2D(m)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return n}findOrComputeBoxSegment(t,e,i){if(!i.has(t)){let s=H();if(e.queryEnvelope(s),this.m_bIsPannablePcs){const t=E.construct(s.xmin,s.ymin),e=E.construct(s.xmax,s.ymax);x(this.m_inputSR,0,[t],1),x(this.m_inputSR,0,[e],1),s=this.m_envHelper.calculateBbox(t.x,t.y,e.x,e.y)}return i.set(t,s),s}return i.get(t)}findOrComputeBoxPoint(t,e,i,s){if(!s.has(t)){let n=H();return n.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(n=this.m_envHelper.calculateBbox(n.xmin,n.ymin,n.xmax,n.ymax)),s.set(t,n),n}return s.get(t)}checkPointInPolygon(t,e){return n(0),!1}estimateMinimumDistance(i,s){const n={stack:[],error:void 0,hasError:!1};try{const e=t=>d(this.m_a,this.m_eSquared,t),o=this.m_boundaryPtsA.map(e),a=this.m_boundaryPtsB.map(e);let r=Number.MAX_VALUE,m=0,c=0;for(let t=0;t<o.length;++t)for(let e=0;e<a.length;++e){const i=p.distance(o[t],a[e]);i<r&&(r=i,m=t,c=e)}i.outPoint.assign(this.m_boundaryPtsA[m]),s.outPoint.assign(this.m_boundaryPtsB[c]);const u=t(n,new h,!1);return l.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[m].x,this.m_boundaryPtsA[m].y,this.m_boundaryPtsB[c].x,this.m_boundaryPtsB[c].y,u,null,null,this.m_distCurveType),u.val}catch(o){n.error=o,n.hasError=!0}finally{e(n)}}swapGeometries(t,e){return a(t[0])>a(e[0])&&(e[0]=R(t[0],t[0]=e[0]),this.m_envGeomB=R(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let o=t.getGeometryType(),a=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(o===s.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(T(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(a===s.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(T(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(o===s.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(a===s.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let m,c,u=t,h=e;if(o===s.enumEnvelope&&(m=this.envelopeToPolygon(t),u=m,o=s.enumPolygon),a===s.enumEnvelope&&(c=this.envelopeToPolygon(e),h=c,a=s.enumPolygon),r(o)&&r(a)){const t=u.querySegmentIterator(),e=h.querySegmentIterator(),s=k(),o=k();if(N(u,h,t,e,s,o))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,s){return n(0),!1}getNearestNeighbourVisitor(t,e,i,s,o,a,r){return n(0),{}}buildSpatialTree(t,e){n(0)}}export{J as G,K as a,z as m};
|
|
5
|
+
import{b as t,c as e}from"./tslib.es6.js";import{t as i,G as s,g as n,e as o,v as a,i as r}from"./Geometry.js";import{v as m,Q as c,I as u,a2 as h,a3 as l,ar as _,af as d,ap as p,S as g,as as x,at as y,ae as P,e as S,au as D,R as G,y as f,a as v,av as T,J as w,ak as M,a4 as b}from"./QuadraticBezier.js";import{P as E,T as R,s as B,f as C,E as I,h as A}from"./Transformation2D.js";import{s as q,w as k,m as N}from"./Distance2DCalculator-BX0Ep7eP.js";import{O as F}from"./OperatorShapePreservingDensify.js";function X(){return new m}class Y{constructor(t,e,i){void 0!==t?this.reset(t,e,i):this.reset(1,0,1)}reset(t,e,i){this.m_a=t,this.m_e2=e,this.m_b=this.m_a*Math.sqrt(1-this.m_e2),this.m_unitToDegree=i,this.m_unitToRad=.017453292519943295*i,this.m_u180=180/this.m_unitToDegree,this.m_u360=360/this.m_unitToDegree}calculateBbox(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1),r=t(a,new h,!1),m=t(a,new h,!1);l.geodeticDistance(this.m_a,this.m_e2,i*this.m_unitToRad,s*this.m_unitToRad,n*this.m_unitToRad,o*this.m_unitToRad,m,e,r,0);const c=Math.cos(e.val),u=Math.cos(r.val+3.141592653589793),_=s*this.m_unitToRad,d=w.phiToEta(this.m_e2,_),p=Math.sin(e.val)*Math.cos(d);let g=s;if(c*u<0){const t=c<0?-1:1,e=Math.acos(Math.abs(p))*t;g=w.etaToPhi(this.m_e2,e)/this.m_unitToRad}let x=A((n-i)*this.m_unitToRad,2*Math.PI);Math.abs(x)>Math.PI&&(x=x>0?x-2*Math.PI:x+2*Math.PI),x/=this.m_unitToRad,n=i+x;const y=X();return y.xmin=Math.min(i,n),y.xmax=Math.max(i,n),y.ymin=Math.min(s,o),y.ymin=Math.min(y.ymin,g),y.ymax=Math.max(s,o),y.ymax=Math.max(y.ymax,g),y}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}minDistanceGeodesic(t,e){const i=O(t),s=O(e);if(i&&s)return this.lowerDistanceGeodetic_(t.xmin,t.ymin,e.xmin,e.ymin);const n=this.normalizeGeodesic_(e,t);return U(t,n)?t.ymin>=n.ymax?this.minDistanceGeodesicUpDown_(t,n):n.ymin>=t.ymax?this.minDistanceGeodesicUpDown_(n,t):t.xmin>n.xmax?this.minDistanceGeodesicLeftRight_(n,t):this.minDistanceGeodesicLeftRight_(t,n):0}sqrMaxMinDistanceGeodesic(t,e){return n(0),0}maxDistanceGeodesic(t,e){return n(0),0}sqrMinDistance(t,e){return n(0),0}sqrMaxDistance(t,e){return n(0),0}sqrMaxMinDistance(t,e){return n(0),0}calculateMaxDim(t){return n(0),0}lowerDistanceGeodesic(t,e,i,s){return n(0),0}upperDistanceGeodesic(t,e,i,s){return n(0),0}normalizeGeodesic_(t,e){const i=t.clone(),s=t.clone();let n=L(i,e);if(0===n)return i;for(;s.xmax>e.xmin;){s.xmin-=this.m_u360,s.xmax-=this.m_u360;const t=L(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}for(s.assign(t);s.xmin<e.xmax;){s.xmin+=this.m_u360,s.xmax+=this.m_u360;const t=L(s,e);if(t<n&&(i.assign(s),n=t,0===n))return i}return i}lowerDistanceGeodetic_(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1);{const t=this.m_b*this.m_b/this.m_a,a=w.phiToPhig(this.m_e2,this.m_unitToRad*s),r=w.phiToPhig(this.m_e2,this.m_unitToRad*o);l.geodeticDistance(t,0,this.m_unitToRad*i,a,this.m_unitToRad*n,r,e,null,null,0)}return e.val}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}upperDistanceGeodetic_(t,e,i,s){return n(0),0}minDistanceGeodesicUpDown_(t,e){if(e.xmin<=t.xmin?e.xmax>=t.xmin:t.xmax>=e.xmin)return this.lowerDistanceGeodetic_(0,t.ymin,0,e.ymax);if(e.xmin>t.xmax){const i=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);if(e.xmax-t.xmin<this.m_u180)return i;const s=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);return Math.min(i,s)}{const i=this.lowerDistanceGeodeticSegMeridional_(t.xmin,t.ymin,t.ymax,e.xmax,e.ymin,e.ymax);if(t.xmax-e.xmin<this.m_u180)return i;const s=this.lowerDistanceGeodeticSegMeridional_(t.xmax,t.ymin,t.ymax,e.xmin,e.ymin,e.ymax);return Math.min(i,s)}}minDistanceGeodesicLeftRight_(t,e){let i=Math.abs(t.xmax-e.xmin);for(;i>this.m_u180;)i-=this.m_u360;let s=Math.abs(t.xmin-e.xmax);for(;s>this.m_u180;)s-=this.m_u360;return Math.abs(i)<=Math.abs(s)?this.minDistanceGeodesicLeftRightNormalized_(t,e):this.minDistanceGeodesicLeftRightNormalized_(e,t)}minDistanceGeodesicLeftRightNormalized_(t,e){let i,s;return i=this.lowerDistanceGeodetic_(t.xmax,t.ymin,e.xmin,e.ymin),t.ymin>=e.ymin&&t.ymin<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymin,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymin>=t.ymin&&e.ymin<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymin,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),s=this.lowerDistanceGeodetic_(t.xmax,t.ymax,e.xmin,e.ymax),i=Math.min(i,s),t.ymax>=e.ymin&&t.ymax<=e.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(t.xmax,t.ymax,e.xmin,e.ymin,e.ymax),i=Math.min(i,s)),e.ymax>=t.ymin&&e.ymax<=t.ymax&&(s=this.lowerDistanceGeodeticPtMeridional_(e.xmin,e.ymax,t.xmax,t.ymin,t.ymax),i=Math.min(i,s)),i}normalizeDistance_(t){return n(0),0}lowerDistanceGeodeticSegMeridional_(t,e,i,s,n,o){let a=this.lowerDistanceGeodeticPtMeridional_(t,e,s,n,o);const r=this.lowerDistanceGeodeticPtMeridional_(t,i,s,n,o);let m=this.lowerDistanceGeodeticPtMeridional_(s,n,t,e,i);const c=this.lowerDistanceGeodeticPtMeridional_(s,o,t,e,i);return a=Math.min(a,r),m=Math.min(m,c),Math.min(a,m)}minDistanceGeodesicPointBox_(t,e,i){return n(0),0}lowerDistanceGeodeticPtMeridional_(i,s,n,o,a){const r={stack:[],error:void 0,hasError:!1};try{const c=this.m_b*this.m_b/this.m_a,u=w.phiToPhig(this.m_e2,this.m_unitToRad*s),_=w.phiToPhig(this.m_e2,this.m_unitToRad*o),g=w.phiToPhig(this.m_e2,this.m_unitToRad*a),x=t(r,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*n,_,this.m_unitToRad*i,u,x,null,null,0);const y=t(r,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*n,g,this.m_unitToRad*i,u,y,null,null,0);const P=d(1,0,new E(this.m_unitToRad*i,u)),S=d(1,0,new E(this.m_unitToRad*n,_)),D=d(1,0,new E(this.m_unitToRad*n,g));let G=new p;G.setCrossProductVector(S,D);const f=S.dotProduct(D);if(G.length()<1.568e-10)return f>=0?Math.min(x.val,y.val):0;G=G.getUnitVector();let v=new p;if(v.setCrossProductVector(G,P),v.length()<1.568e-10){return Math.min(x.val,y.val)-1e-5*c}v=v.getUnitVector();let T=P.sub(G.mul(P.dotProduct(G)));{const s=new p;s.setCrossProductVector(S,T);const n=new p;n.setCrossProductVector(T,D);let o=G.dotProduct(s)>0&&G.dotProduct(n)>0;if(o||(T.negateThis(),s.setCrossProductVector(S,T),n.setCrossProductVector(T,D),o=G.dotProduct(s)>0&&G.dotProduct(n)>0),o){const s={stack:[],error:void 0,hasError:!1};try{T=T.getUnitVector();const e=M(1,0,T),n=t(s,new h,!1);l.geodeticDistance(c,0,this.m_unitToRad*i,u,e.x,e.y,n,null,null,0);const o=Math.min(x.val,y.val);return Math.min(o,n.val)}catch(m){s.error=m,s.hasError=!0}finally{e(s)}}}return Math.min(x.val,y.val)}catch(c){r.error=c,r.hasError=!0}finally{e(r)}}fixAngle(t){return n(0),0}moveCloser(t,e){return n(0),0}}function O(t){return t.xmin===t.xmax&&t.ymin===t.ymax}function U(t,e){return e.xmax<t.xmin||e.xmin>t.xmax||e.ymax<t.ymin||e.ymin>t.ymax}function L(t,e){let i,s=0;return i=t.xmin-e.xmax,i>s&&(s=i),i=e.xmin-t.xmax,i>s&&(s=i),s}class V{}function z(t){return{outPoint:void 0===t?new E:t.clone()}}function j(t,e){t.outPoint.assign(e.outPoint)}function H(){return new m}class Q{constructor(t,e,i,s,n=0,o=4){this.m_ptDistFrom=new E,this.m_segStartPt=new E,this.m_segEndPt=new E,this.m_geodeticLength=new h,this.m_az12=new h,this.m_minGeodeticDist=new h,this.m_segStartPt3d=new p,this.m_segEndPt3d=new p,this.m_sr=s,this.m_distCurveType=n,this.m_segCurveType=o,this.m_inputGCS=this.m_sr.getGCS(),this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_bIsPannablePcs=2===this.m_sr.getCoordinateSystemType()&&this.m_sr.isPannable();const a=b();this.m_inputGCS.querySpheroidData(a),this.m_a=a.majorSemiAxis,this.m_eSquared=a.e2,this.setPointDistFrom(t),this.setSegmentEndPoints(e,i)}setSegmentEndPoints(t,e){this.m_segStartPt.assign(t),this.m_segEndPt.assign(e),this.m_bIsPannablePcs||(this.m_segStartPt.mulThis(this.m_rpu),this.m_segEndPt.mulThis(this.m_rpu)),2===this.m_segCurveType&&(this.m_segStartPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segStartPt)),this.m_segEndPt3d.assign(d(this.m_a,this.m_eSquared,this.m_segEndPt))),this.calculateAndUpdateSegmentLength()}setPointDistFrom(t){this.m_ptDistFrom.assign(t),this.m_ptDistFrom.scale(this.m_rpu)}setSegmentCurveType(t){this.m_segCurveType=t}setDistanceCurveType(t){this.m_distCurveType=t}makeFunctor(){return i=>{let s;switch(this.m_segCurveType){case 0:case 1:case 3:{const o={stack:[],error:void 0,hasError:!1};try{const e=t(o,new h,!1),n=t(o,new h,!1);l.geodeticCoordinate(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_geodeticLength.val*i,this.m_az12.val,e,n,this.m_segCurveType),s=new E(e.val,n.val);break}catch(n){o.error=n,o.hasError=!0}finally{e(o)}}case 2:{const t=p.lerp(this.m_segStartPt3d,this.m_segEndPt3d,i);s=M(this.m_a,this.m_eSquared,t);break}case 4:s=E.lerp(this.m_segStartPt,this.m_segEndPt,i),this.m_bIsPannablePcs&&(x(this.m_sr,0,[s],1),s.mulThis(this.m_rpu));break;default:o("Invalid curve type")}return l.geodeticDistance(this.m_a,this.m_eSquared,this.m_ptDistFrom.x,this.m_ptDistFrom.y,s.x,s.y,this.m_minGeodeticDist,null,null,this.m_distCurveType),this.m_minGeodeticDist.val}}calculateAndUpdateSegmentLength(){switch(this.m_segCurveType){case 0:case 2:case 1:case 3:l.geodeticDistance(this.m_a,this.m_eSquared,this.m_segStartPt.x,this.m_segStartPt.y,this.m_segEndPt.x,this.m_segEndPt.y,this.m_geodeticLength,this.m_az12,null,this.m_segCurveType);break;case 4:this.m_geodeticLength.val=E.distance(this.m_segStartPt,this.m_segEndPt);break;default:o("Invalid curve type")}}[Symbol.dispose](){this.m_geodeticLength[Symbol.dispose](),this.m_az12[Symbol.dispose](),this.m_minGeodeticDist[Symbol.dispose]()}}function J(){return new V}class K{constructor(t,e,i,s,n){this.m_boxGeomA=H(),this.m_boxGeomB=H(),this.m_envGeomA=new m,this.m_envGeomB=new m,this.m_progressCounter=0,this.m_transformPCS2GCS=null,this.m_segmentBoxesA=new Map,this.m_segmentBoxesB=new Map,this.m_boundaryPtsA=[],this.m_boundaryPtsB=[],this.m_scaleToRadians=new R,this.m_scaleToDegrees=new R,this.m_inputSR=t,this.m_distCurveType=e,this.m_progressTracker=i,this.m_maxDistance=s,this.m_maxDeviation=n,this.m_inputGCS=t.getGCS(),this.m_peGeogcs=this.m_inputGCS.getPECoordSys(),this.m_tolerance=0;const o=b();this.m_inputGCS.querySpheroidData(o),this.m_a=o.majorSemiAxis,this.m_eSquared=o.e2,this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_envHelper=new Y(this.m_a,this.m_eSquared,1),4===this.m_distCurveType&&(this.m_distCurveType=0),this.m_boxGeomA.setEmpty(),this.m_boxGeomB.setEmpty(),this.m_envGeomA.setEmpty(),this.m_envGeomB.setEmpty(),this.m_bIsPannablePcs=2===this.m_inputSR.getCoordinateSystemType()&&this.m_inputSR.isPannable()}progress(t=!1){}calculate(t,e,i,s){const n=z(),o=z();if(t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.checkGeometriesIntersect(t,e,n,o))return i&&j(i,n),s&&j(s,o),0;const a=this.prepareGeometry(t);if(a.isEmpty())return Number.NaN;const r=this.prepareGeometry(e);if(r.isEmpty())return Number.NaN;this.m_tolerance=this.computeTolerance(a,r);const m=this._ExecuteBruteForce(a,r,n,o);return m>=this.m_maxDistance?Number.NaN:(i&&(this.prepareOutput(n),j(i,n)),s&&(this.prepareOutput(o),j(s,o)),m)}createDistanceFunctor(t,e,i){const s=new Q(t,e,i,this.m_inputSR,this.m_distCurveType);return this.m_bIsPannablePcs||1===this.m_inputSR.getCoordinateSystemType()||s.setSegmentCurveType(2),s}_NormalizeAndProject(t){if(this.m_inputSR.isPannable()&&(t=(new c).foldInto360Range(t,this.m_inputSR)),2===this.m_inputSR.getCoordinateSystemType()){const e=u(this.m_inputSR,this.m_inputGCS,null);t=(new c).execute(t,e,this.m_progressTracker)}return t}_ExecuteBruteForce(t,e,n,o){switch(t.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointGeometry(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointGeometry(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathGeometry(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointPoint(t,e,n,o);case s.enumMultiPoint:return this.calculateDistanceGeodeticPointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:return this.calculateDistanceGeodeticPointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticPointPoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=i.getXY();e.scale(this.m_rpu);const r=s.getXY();r.scale(this.m_rpu),n.outPoint.assign(e),o.outPoint.assign(r);const m=t(a,new h,!1);return l.geodeticDistance(this.m_a,this.m_eSquared,e.x,e.y,r.x,r.y,m,null,null,this.m_distCurveType),m.val}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticPointMultipoint(t,e,i,s){return n(0),0}calculateDistanceGeodeticPointMultipath(i,s,o,a){const r={stack:[],error:void 0,hasError:!1};try{const e=new E,m=new E;e.assign(i.getXY()),m.assign(i.getXY()),o.outPoint.assign(m.mul(this.m_rpu)),this.m_bIsPannablePcs&&_(this.m_inputSR,[e],1,!1),this.computeEnvelopesAndBoxes(i,s);const c=this.estimateMinimumDistance(o,a);let u=c<this.m_maxDistance?c:this.m_maxDistance;const h=s.getImpl(),l=new E(0,0),d=new E(0,0),p=[1],g=this.canUseSpatialTree(i,s),x=J();g&&this.buildSpatialTree(x,s);const y=H();y.setCoords({xmin:m.x,ymin:m.y,xmax:m.x,ymax:m.y});const P=t(r,this.createDistanceFunctor(m,l,d),!1),S=h.querySegmentIterator();if(S.stripAttributes(),g)n(0);else for(;S.nextPath();)for(;S.hasNextSegment();){const t=S.nextSegment(),i=this.findOrComputeBoxSegment(S.getStartPointIndex(),t,this.m_segmentBoxesB);if(this.m_envHelper.minDistanceGeodesic(y,i)>u)continue;const s=this.calculateDistanceGeodeticPointSegment(e,m,t,p,P);if(s.second<u&&(this.updateOutputSegment(a,t,s.first),u=s.second,0===u))return 0}return u===this.m_maxDistance?Number.POSITIVE_INFINITY:u}catch(m){r.error=m,r.hasError=!0}finally{e(r)}}calculateDistanceGeodeticMultipointGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipoint(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipoint(t,e,n,o);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipointMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipointMultipoint(i,s,n,o){const a={stack:[],error:void 0,hasError:!1};try{const e=t(a,new h,!1);this.computeEnvelopesAndBoxes(i,s);const r=this.estimateMinimumDistance(n,o);let m=r<this.m_maxDistance?r:this.m_maxDistance;const c=new E,u=new E,_=i.getImpl(),g=s.getImpl(),x=H(),y=_.getPointCount(),P=g.getPointCount();for(let t=0;t<y;++t){if(c.assign(_.getXY(t)),x.setCoords({xmin:c.x,ymin:c.y,xmax:c.x,ymax:c.y}),this.m_envHelper.minDistanceGeodesic(x,this.m_boxGeomB)>m)continue;c.scale(this.m_rpu);const i=d(this.m_a,this.m_eSquared,c);for(let t=0;t<P;++t){u.assign(g.getXY(t)),u.scale(this.m_rpu);const s=d(this.m_a,this.m_eSquared,u);if(!(p.distance(i,s)>=m)&&(l.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,e,null,null,this.m_distCurveType),e.val<m&&(n.outPoint.assign(c),o.outPoint.assign(u),m=e.val,0===m)))return m}}return m===this.m_maxDistance?Number.POSITIVE_INFINITY:m}catch(r){a.error=r,a.hasError=!0}finally{e(a)}}calculateDistanceGeodeticMultipointMultipath(i,s,o,a){const r={stack:[],error:void 0,hasError:!1};try{const e=s.getImpl().querySegmentIterator();e.stripAttributes(),this.computeEnvelopesAndBoxes(i,s);const m=this.estimateMinimumDistance(o,a);let c=m<this.m_maxDistance?m:this.m_maxDistance;const u=new E,h=new E(0,0),l=new E(0,0),d=new E(0,0),p=[0],g=H(),x=t(r,this.createDistanceFunctor(h,l,d),!1),y=J(),P=this.canUseSpatialTree(i,s);P&&this.buildSpatialTree(y,s);const S=i.getPointCount();for(let t=0;t<S;++t)if(u.assign(i.getXY(t)),h.assign(i.getXY(t)),this.m_bIsPannablePcs&&_(this.m_inputSR,[u],1,!1),g.setCoords({xmin:h.x,ymin:h.y,xmax:h.x,ymax:h.y}),!(this.m_envHelper.minDistanceGeodesic(g,this.m_boxGeomB)>c))if(x.setPointDistFrom(h),P)n(0);else{for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(this.m_envHelper.minDistanceGeodesic(g,this.findOrComputeBoxSegment(e.getStartPointIndex(),t,this.m_segmentBoxesB))>c)continue;const i=this.calculateDistanceGeodeticPointSegment(u,h,t,p,x);if(i.second<c&&(o.outPoint.assign(h.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),c=i.second,0===c))return 0}e.resetToFirstPath()}return c===this.m_maxDistance?Number.POSITIVE_INFINITY:c}catch(m){r.error=m,r.hasError=!0}finally{e(r)}}calculateDistanceGeodeticMultipathGeometry(t,e,n,o){switch(e.getGeometryType()){case s.enumPoint:return this.calculateDistanceGeodeticPointMultipath(e,t,o,n);case s.enumMultiPoint:return this.calculateDistanceGeodeticMultipointMultipath(e,t,o,n);case s.enumPolyline:case s.enumPolygon:case s.enumEnvelope:return this.calculateDistanceGeodeticMultipathMultipath(t,e,n,o);default:i("")}}calculateDistanceGeodeticMultipathMultipath(t,e,i,s){const n=[t],o=[e],a=this.swapGeometries(n,o),r=n[0],m=o[0];this.computeEnvelopesAndBoxes(n[0],o[0]);const c=this.estimateMinimumDistance(i,s),u=this.calculateDistanceGeodeticMultipathMultipath_(r,m,i,s,c);return a&&(s.outPoint=B(i.outPoint,i.outPoint=s.outPoint)),u}calculateDistanceGeodeticMultipathMultipath_(i,s,o,a,r=Number.MAX_VALUE){const m={stack:[],error:void 0,hasError:!1};try{let e=r;const c=new E(0,0),u=new E,h=new E(0,0),l=new E,_=new E(0,0),d=new E,p=new E,P=new E,S=[new E],D=[0],G=[0],f=H(),v=H(),T=t(m,this.createDistanceFunctor(_,c,h),!1),w=J(),M=this.canUseSpatialTree(i,s);M&&this.buildSpatialTree(w,s);const b=s.querySegmentIterator();b.stripAttributes();const R=new g,B=q(i);for(let t=0;t<B.length;++t){const s=B[t];i.getSegmentBuffer(s,R,!0);const r=R.get();if(f.assign(this.findOrComputeBoxSegment(s,r,this.m_segmentBoxesA)),M)n(0);else{if(_.assign(r.getStartXY()),d.assign(r.getStartXY()),p.assign(r.getEndXY()),P.assign(r.getEndXY()),this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[d],1),x(this.m_inputSR,0,[P],1)),this.m_envHelper.minDistanceGeodesic(f,this.m_boxGeomB)>e)continue;for(;b.nextPath();){for(;b.hasNextSegment();){const t=b.nextSegment();if(c.assign(t.getStartXY()),u.assign(t.getStartXY()),h.assign(t.getEndXY()),l.assign(t.getEndXY()),r.intersect(t,S,D,G,this.m_tolerance))return this.updateOutputSegment(o,r,D[0]),this.updateOutputSegment(a,t,G[0]),0;if(this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[u],1),x(this.m_inputSR,0,[l],1)),v.assign(this.findOrComputeBoxPoint(b.getStartPointIndex(),u,l,this.m_segmentBoxesB)),this.m_envHelper.minDistanceGeodesic(f,v)>e)continue;T.setSegmentEndPoints(c,h),T.setPointDistFrom(d);let i=y(T.makeFunctor(),0,1,1e-10);if(i.second<e&&(o.outPoint.assign(d.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setPointDistFrom(P),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(o.outPoint.assign(P.mul(this.m_rpu)),this.updateOutputSegment(a,t,i.first),e=i.second,0===e))break;if(T.setSegmentEndPoints(_,p),T.setPointDistFrom(u),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,r,i.first),a.outPoint.assign(u.mul(this.m_rpu)),e=i.second,0===e))break;if(T.setPointDistFrom(l),i=y(T.makeFunctor(),0,1,1e-10),i.second<e&&(this.updateOutputSegment(o,r,i.first),a.outPoint.assign(l.mul(this.m_rpu)),e=i.second,0===e))break}if(0===e)return 0}b.resetToFirstPath()}}return e===this.m_maxDistance?Number.POSITIVE_INFINITY:e}catch(c){m.error=c,m.hasError=!0}finally{e(m)}}calculateDistanceGeodeticPointSegment(t,e,i,s,n){const o=i.getStartXY(),a=i.getEndXY();return i.intersectPoint(t,s,this.m_tolerance)?C(s[0],0):(n.setPointDistFrom(e),n.setSegmentEndPoints(o,a),y(n.makeFunctor(),0,1,1e-10))}prepareGeometry(t){let e=t.clone();const i=t.getGeometryType();if(i===s.enumPoint||i===s.enumMultiPoint)return this._NormalizeAndProject(e);if(i===s.enumEnvelope&&(e=this.envelopeToPolygon(e)),this.m_inputSR.isPannable())return this.prepareGeometryPannable(e,4);if(2===this.m_inputSR.getCoordinateSystemType()){if(e=P(e,this.m_inputSR,0,null),e.isEmpty())return e;e=(new F).execute(e,this.m_inputSR,5e4,this.m_maxDeviation/2,0,null);const t=this.m_inputSR.getSRToGCSTransform();return(new c).execute(e,t,this.m_progressTracker)}const n=new m;e.queryLooseEnvelope(n);const o=this.m_inputSR.getPannableExtent();if(n.ymin<o.ymin||n.ymax>o.ymax){const t=new m(n.xmin-1,o.ymin,n.xmax+1,o.ymax);if(e=(new S).execute(e,t,this.m_inputSR,this.m_progressTracker),e.isEmpty())return e}return n.width()>2*o.width()?(e=D(e,-2*o.width(),2*o.width(),this.m_inputSR,!0,0,!0,this.m_progressTracker),e):e}prepareGeometryPannable(t,e){const i=new m;t.queryEnvelope(i);const s=this.m_inputSR.getPannableExtent();if(s.containsEnvelope(i))return t;const n=new I;s.queryIntervalX(n);const o=new I;return i.queryIntervalX(o),t=n.contains(o)?G(t,this.m_inputSR):(new c).foldInto360RangeGeodetic(t,this.m_inputSR,e)}prepareOutput(t){t.outPoint.scale(1/this.m_rpu),2===this.m_inputSR.getCoordinateSystemType()&&_(this.m_inputSR,[t.outPoint],1,!1)}updateOutputSegment(t,e,i){e.queryCoord2D(i,t.outPoint),this.m_bIsPannablePcs&&x(this.m_inputSR,0,[t.outPoint],1),t.outPoint.mulThis(this.m_rpu)}computeTolerance(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB);const i=new m(this.m_envGeomA);return i.mergeEnvelope2D(this.m_envGeomB),f(null,i)}envelopeToPolygon(t){const e=new v;return e.addEnvelope(t,!1),e}computeEnvelopesAndBoxes(t,e){t.queryEnvelope(this.m_envGeomA),e.queryEnvelope(this.m_envGeomB),this.m_boxGeomA=this.computeBoxGeometry(t,this.m_boundaryPtsA,this.m_segmentBoxesA),this.m_boxGeomB=this.computeBoxGeometry(e,this.m_boundaryPtsB,this.m_segmentBoxesB)}computeBoxGeometry(t,e,i){switch(t.getGeometryType()){case s.enumPoint:return this.computeBoxPoint(t,e);case s.enumMultiPoint:return this.computeBoxMultiPoint(t,e);case s.enumPolyline:case s.enumPolygon:return this.computeBoxMultiPath(t,e,i);default:o("Invalid geometry type")}}computeBoxPoint(t,e){const i=t.getXY();e.length=1,e[0]=i.mul(this.m_rpu);const s=H();return s.setCoords({xmin:i.x,ymin:i.y,xmax:i.x,ymax:i.y}),s}computeBoxSegment(t){return n(0),{}}computeBoxMultiPoint(t,e){let i=!0;for(let n=0;n<t.getPointCount();++n){const s=t.getXY(n);if(i){e.length=4;for(let t=0;t<e.length;++t)e[t]=s.clone();i=!1}s.x<e[0].x&&e[0].assign(s),s.y>e[1].y&&e[1].assign(s),s.x>e[2].x&&e[2].assign(s),s.y<e[3].y&&e[3].assign(s)}for(let n=0;n<e.length;++n)e[n].mulThis(this.m_rpu);const s=H();return t.queryEnvelope(s),s}computeBoxMultiPath(t,e,i){let s=!0;const n=H();n.setEmpty();const o=t.querySegmentIterator();for(o.stripAttributes();o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),a=t.getStartXY(),r=t.getEndXY();if(this.m_bIsPannablePcs&&(x(this.m_inputSR,0,[a],1),x(this.m_inputSR,0,[r],1)),s){e.length=4;for(let t=0;t<e.length;++t)e[t]=a.clone();s=!1}a.x<e[0].x&&e[0].assign(a),a.y>e[1].y&&e[1].assign(a),a.x>e[2].x&&e[2].assign(a),a.y<e[3].y&&e[3].assign(a),r.x<e[0].x&&e[0].assign(r),r.y>e[1].y&&e[1].assign(r),r.x>e[2].x&&e[2].assign(r),r.y<e[3].y&&e[3].assign(r);const m=this.findOrComputeBoxPoint(o.getStartPointIndex(),a,r,i);n.mergeEnvelope2D(m)}for(let a=0;a<e.length;++a)e[a].mulThis(this.m_rpu);return n}findOrComputeBoxSegment(t,e,i){if(!i.has(t)){let s=H();if(e.queryEnvelope(s),this.m_bIsPannablePcs){const t=E.construct(s.xmin,s.ymin),e=E.construct(s.xmax,s.ymax);x(this.m_inputSR,0,[t],1),x(this.m_inputSR,0,[e],1),s=this.m_envHelper.calculateBbox(t.x,t.y,e.x,e.y)}return i.set(t,s),s}return i.get(t)}findOrComputeBoxPoint(t,e,i,s){if(!s.has(t)){let n=H();return n.setCoords({xmin:e.x,ymin:e.y,xmax:i.x,ymax:i.y}),this.m_bIsPannablePcs&&(n=this.m_envHelper.calculateBbox(n.xmin,n.ymin,n.xmax,n.ymax)),s.set(t,n),n}return s.get(t)}checkPointInPolygon(t,e){return n(0),!1}estimateMinimumDistance(i,s){const n={stack:[],error:void 0,hasError:!1};try{const e=t=>d(this.m_a,this.m_eSquared,t),o=this.m_boundaryPtsA.map(e),a=this.m_boundaryPtsB.map(e);let r=Number.MAX_VALUE,m=0,c=0;for(let t=0;t<o.length;++t)for(let e=0;e<a.length;++e){const i=p.distance(o[t],a[e]);i<r&&(r=i,m=t,c=e)}i.outPoint.assign(this.m_boundaryPtsA[m]),s.outPoint.assign(this.m_boundaryPtsB[c]);const u=t(n,new h,!1);return l.geodeticDistance(this.m_a,this.m_eSquared,this.m_boundaryPtsA[m].x,this.m_boundaryPtsA[m].y,this.m_boundaryPtsB[c].x,this.m_boundaryPtsB[c].y,u,null,null,this.m_distCurveType),u.val}catch(o){n.error=o,n.hasError=!0}finally{e(n)}}swapGeometries(t,e){return a(t[0])>a(e[0])&&(e[0]=B(t[0],t[0]=e[0]),this.m_envGeomB=B(this.m_envGeomA,this.m_envGeomA=this.m_envGeomB),!0)}canUseSpatialTree(t,e){return!1}checkGeometriesIntersect(t,e,i,n){let o=t.getGeometryType(),a=e.getGeometryType();if(this.m_envGeomA.isIntersecting(this.m_envGeomB)){if(o===s.enumPoint&&2===e.getDimension()){const s=[0],o=[t.getXY()];if(T(e,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}else if(a===s.enumPoint&&2===t.getDimension()){const s=[2],o=[e.getXY()];if(T(t,o,1,this.m_tolerance,s),0!==s[0])return i.outPoint.assign(o[0]),n.outPoint.assign(o[0]),!0}if(o===s.enumMultiPoint&&2===e.getDimension())return this.multipointIntersectsArea(t,e,i,n);if(a===s.enumMultiPoint&&2===t.getDimension())return this.multipointIntersectsArea(e,t,n,i);let m,c,u=t,h=e;if(o===s.enumEnvelope&&(m=this.envelopeToPolygon(t),u=m,o=s.enumPolygon),a===s.enumEnvelope&&(c=this.envelopeToPolygon(e),h=c,a=s.enumPolygon),r(o)&&r(a)){const t=u.querySegmentIterator(),e=h.querySegmentIterator(),s=N(),o=N();if(k(u,h,t,e,s,o))return i.outPoint.assign(s.outPoint),n.outPoint.assign(s.outPoint),!0}}return!1}multipointIntersectsArea(t,e,i,s){return n(0),!1}getNearestNeighbourVisitor(t,e,i,s,o,a,r){return n(0),{}}buildSpatialTree(t,e){n(0)}}export{K as G,Q as a,z as m};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{g as e,r}from"./QuadraticBezier.js";class t extends e{getOperatorType(){return 6}execute(e,t,a,s){return r(e,t,a,16,s)}}export{t as O};
|
package/chunks/OperatorCut.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{G as t}from"./SimpleGeometryCursor.js";import{G as e,e as s,g as n}from"./Geometry.js";import{b as r,
|
|
5
|
+
import{G as t}from"./SimpleGeometryCursor.js";import{G as e,e as s,g as n}from"./Geometry.js";import{b as r,h as o,j as m,a as i,k as u,T as c,s as h,l,m as a,n as d,o as y,C as p}from"./QuadraticBezier.js";var _=p;function g(t,e){return{m_geometry:t,m_side:e}}function C(t,e,s,n,r,o){if(e.isEmpty()){const t=g(e,0);return void r.push(t)}if(s.isEmpty()){const t=g(e,0);return void r.push(t)}const m=[],i=new u;{const u=i.createGeometryUserIndex(),y=i.addGeometry(e),p=i.addGeometry(s),C=new c(o);let f=0,E=null;if(i.hasCurves()){E=new _;const t=i.getEnvelope2D(o);f=h(n.total());const e=l(n.total(),t);a(i,e,n.total(),12e3,E,null,o)}i.dbgVerifyCurves(),C.setEditShapeCrackAndCluster(i,n),C.cut(t,u,y,p,m);for(const t of m){null!==E&&E.stitchCurves(i,t,f,!1);const e=g(i.getGeometry(t),d(i.getGeometryUserIndex(t,u)));r.push(e)}null!==E&&E.clearStitcher(i)}}function f(t,e,s,n,r,o){if(e.isEmpty()){const t=g(e,0);return void r.push(t)}if(s.isEmpty()){const t=g(e,0);return void r.push(t)}const m=[],d=new u;{const t=d.createGeometryUserIndex(),p=d.addGeometry(e),C=d.addGeometry(s),f=new c(o);let E=0,G=null;if(d.hasCurves()){G=new _;const t=d.getEnvelope2D(o);E=h(n.total());const e=l(n.total(),t);a(d,e,n.total(),12e3,G,null,o)}d.dbgVerifyCurves(),f.setEditShapeCrackAndCluster(d,n),f.cut(!1,t,p,C,m),null!==G&&G.stitchCurves(d,y,E,!0);let v=d.getGeometry(p);const w=new i,x=new i,k=[];for(let e=0;e<m.length;e++){let s=null;{const r=new u,i=r.addGeometry(v),c=r.addGeometry(d.getGeometry(m[e]));if(r.hasCurves()){const t=r.getEnvelope2D(o);E=h(n.total());const e=l(n.total(),t);a(r,e,n.total(),12e3,G,null,o)}f.setEditShapeCrackAndCluster(r,n);const p=f.intersection(i,c);if(null!==G&&G.stitchCurves(r,y,E,!0),s=r.getGeometry(p),s.isEmpty())continue;const _=d.getGeometryUserIndex(m[e],t);2===_?w.add(s,!1):1===_?x.add(s,!1):k.push(s)}{const t=new u,s=t.addGeometry(v),r=t.addGeometry(d.getGeometry(m[e]));if(t.hasCurves()){const e=t.getEnvelope2D(o);E=h(n.total());const s=l(n.total(),e);a(t,s,n.total(),12e3,G,null,o)}f.setEditShapeCrackAndCluster(t,n);const i=f.difference(s,r);null!==G&&G.stitchCurves(t,y,E,!0);v=t.getGeometry(i)}}if(!v.isEmpty()&&m.length>0&&k.push(v),w.isEmpty()&&x.isEmpty())return;if(!w.isEmpty()){const t=g(w,1);r.push(t)}if(!x.isEmpty()){const t=g(x,2);r.push(t)}for(let e=0,s=k.length;e<s;++e){const t=g(k[e],3);r.push(t)}}}class E{getOperatorType(){return 10005}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}execute(t,e,s,n,r){return new G(t,e,s,n,r)}}class G extends t{constructor(t,e,s,n,i){super(),this.m_cutIndex=-1,this.m_cuts=[],this.m_progressTracker=i,this.m_cuttee=e.clone(),this.m_cutter=new r({copy:s}),this.m_bConsiderTouch=t;const u=o(e,s);this.m_tolerance=m(n,u,!0)}next(){return-1===this.m_cutIndex&&this.generateCuts(),++this.m_cutIndex<this.m_cuts.length?this.m_cuts[this.m_cutIndex]:null}getGeometryID(){return 0}tock(){return!0}getRank(){return 1}generateCuts(){switch(this.m_cuttee.getGeometryType()){case e.enumPolyline:this.generatePolylineCuts();break;case e.enumPolygon:this.generatePolygonCuts()}}generatePolylineCuts(){const t=new r,e=new r,n=new r;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const o=[];C(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,o,this.m_progressTracker);for(let r=0;r<o.length;r++){const m=o[r];1===m.m_side?t.add(m.m_geometry,!1):2===m.m_side||4===m.m_side?e.add(m.m_geometry,!1):3===m.m_side?this.m_cuts.push(m.m_geometry):0===m.m_side?n.add(m.m_geometry,!1):s("")}n.isEmpty()||t.isEmpty()&&e.isEmpty()&&!(this.m_cuts.length>=3)||this.m_cuts.push(n),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}generatePolygonCuts(){const t=new i,e=new i,r=new i;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const o=[];f(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,o,this.m_progressTracker);for(let n=0;n<o.length;n++){const m=o[n];1===m.m_side?t.add(m.m_geometry,!1):2===m.m_side?e.add(m.m_geometry,!1):3===m.m_side?this.m_cuts.push(m.m_geometry):0===m.m_side?r.add(m.m_geometry,!1):s("")}n(r.isEmpty()||1===o.length),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}}export{E as O};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{d as s,t as n,a as i,f as r,G as o,h as m,c as a,b as h,i as c,j as u}from"./Geometry.js";import{F as l,t as _,a as f,O as d,G as g,H as p,b as P,I as x,h as b,P as y,J as w,K as C,N as S,Q as v,z as D,R as I,U as G,V as M,W as T,o as N,x as k,X as A,Y as q,Z as E,j as R,_ as z,$ as X,a0 as B,a1 as Y,a2 as F,a3 as O,a4 as W,a5 as j,a6 as J,a7 as U,a8 as H,a9 as L,aa as V,ab as Q}from"./QuadraticBezier.js";import{b as K,c as Z}from"./tslib.es6.js";import{c as $,d as ee,T as te,P as se,S as ne,g as ie,e as re}from"./Transformation2D.js";import{c as oe}from"./GeometryCleaner-k94LXQsr.js";function me(e,t,s,m,a,h){m<Number.MAX_VALUE&&m>-Number.MAX_VALUE||n("Geodesic_bufferer.buffer - bad distance"),i(e);const c=oe(e),u=c.getGeometryType();if(r(u)){const e=c.getPointCount(),n=8e6;if(Math.abs(m)>n&&(e>50||u!==o.enumMultiPoint&&4===s&&e>2)){let e=c;const i=m>0?1:-1,r=7e6;let o=m,u=1;do{u++,o=(Math.abs(o)-r)*i}while(Math.abs(o)>n);o=m;for(let n=0;n<u-1;n++)e=he(e,t,s,r*i,a,u,h),o=(Math.abs(o)-r)*i;return e=he(e,t,s,o,a,u,h),e}}return he(c,t,s,m,a,1,h)}class ae{constructor(e){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_radTolerance=0,this.m_q90=0,this.m_gcs90=0,this.m_gcs180=0,this.m_gcs360=0,this.m_gcs60=0,this.m_ellipticToGeodesicMaxRatio=0,this.m_curveType=0,this.m_bShapePreserving=!1,this.m_distance=0,this.m_absDistance=0,this.m_convergenceOffset=0,this.m_cornerStep=0,this.m_segmentStep=0,this.m_progressTracker=e}bufferPolygon(e){const t=new f,s=new we(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new we(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new Ce(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new f;if(this.bufferPoint2D(t,!1,s)){const e=D(null,s,!0);s=I(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new C).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(e,t){const s=t;let n=s.getGnomonic();const i=G(M()),r=new Q;i.queryPrecisionDescriptor(r),r.setTolerance(0,.001),G(M(),void 0,r);let o=new T,m=(new l).executeMany(o,i,this.m_progressTracker,2);const a=$(6,!1),h=ee(_,6);this.initializeGrid(a,h);const c=[null,null,null,null,null,null],u=[null,null,null,null,null,null],f=[null,null,null,null,null,null];let d,g,p;for(;null!==(d=s.next());){if(g=s.getGnomonic(),g!==n){if(null!==n){let t=m.next();if(o=null,m=null,null!=t){const s=D(i,t,!0),r=x(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,a,h,c,u,f)}}null!==g&&(o=new T,m=(new l).executeMany(o,i,this.m_progressTracker,2)),n=g}if(s.isRunningInGnomonic()){if(g.project(d),s.needsSimplify()){const e=D(null,d,!0);d=I(d,e,!0,!0,-1,this.m_progressTracker,0,!1)}o.tick(be(d)),m.tock()}else this.putInGridCursors(e,d,i,!0,a,h,c,u,f)}let P=!1;for(let l=0;l<6;l++)if(null!=f[l]){P=!0;break}if(P){let t=!1;const r=[null,null,null,null,null,null];if(e){const n=s.m_densified;if(s.m_densified=null,null!==n){const s=new te;s.scale(1/this.m_rpu,1/this.m_rpu),n.applyTransformation(s),this.m_distance>0?this.putInGridCursors(e,n,i,!1,a,h,c,u,f):(this.processInGrid(e,n,!1,a,h,c,r),t=!0)}}const _=new T,d=(new l).executeMany(_,this.m_gcs,this.m_progressTracker,2);if(null!==m){let t=m.next();o=null,m=null;const s=D(i,t,!0),r=x(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,a,h,c,u,f)}for(let e=0;e<6;e++)if(null!=f[e]){let s=f[e].next();f[e]=null,u[e]=null,t&&null!==r[e]&&(s=(new N).execute(r[e],s,i,this.m_progressTracker));const n=D(i,s,!0),o=x(n);s=c[e].unproject(s,o,this.m_progressTracker),s=(new k).execute(s,this.m_gcs,!0,this.m_progressTracker),_.tick(be(s)),d.tock()}p=d.next()}else{let t,r=!1;if(e){let e=s.m_densified;if(s.m_densified=null,null!==e){const s=new te;s.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(s),g.project(e);const n=D(null,e,!0);e=I(e,n,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(o.tick(be(e)),m.tock()):(t=e,r=!0)}}let a=m.next();o=null,m=null,r&&(a=(new N).execute(t,a,i,this.m_progressTracker));const h=D(i,a,!0),c=x(h);p=n.unproject(a,c,this.m_progressTracker),p=(new k).execute(p,this.m_gcs,!0,this.m_progressTracker)}return p=(new C).foldInto360RangeGeodetic(p,this.m_gcs,2),p}putInGridCursors(e,t,s,n,i,r,o,m,a){const h=[null,null,null,null,null,null];this.processInGrid(e,t,n,i,r,o,h);for(let c=0;c<6;c++)null!==h[c]&&(null===m[c]&&(m[c]=new T,a[c]=(new l).executeMany(m[c],s,this.m_progressTracker,2)),m[c].tick(be(h[c])),a[c].tock())}processInGrid(e,t,s,n,i,r,o){const m=.01,a=this.insertGeodeticPointsAlongGrid(t,i,m);for(let h=0;h<6;h++){if(n[h])continue;const e=i[h].clone();e.inflateCoords(m,m);const c=A(t,e),u=b(null,c,!1).total();let l=q(a,e,u,Number.NaN,this.m_progressTracker);if(null!==l&&!l.isEmpty()){if(l===a&&(l=l.clone()),null===r[h]){const e=new se;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new se;t.setAdd(i[h].getCenter(),e),r[h]=xe(this.m_gcs,t)}r[h].project(l);const e=D(null,l,!0);l=I(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const n=_.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),i=E(this.m_gcs,n,e,!0,this.m_progressTracker),r=new R,o=r.addGeometry(i);return z(r,o,this.m_gcs,0,2,!0,t[0].xmax+s),z(r,o,this.m_gcs,0,2,!0,t[1].xmax+s),z(r,o,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(z(r,o,this.m_gcs,0,2,!0,t[0].xmax-s),z(r,o,this.m_gcs,0,2,!0,t[1].xmax-s),z(r,o,this.m_gcs,0,2,!1,t[1].ymin-s)),r.getGeometry(o)}initializeGrid(e,t){for(let s=0;s<6;s++)e[s]=!1;t[0].setCoords({xmin:-this.m_gcs180,ymin:0,xmax:-this.m_gcs60,ymax:this.m_gcs90}),t[1].setCoords({xmin:-this.m_gcs60,ymin:0,xmax:this.m_gcs60,ymax:this.m_gcs90}),t[2].setCoords({xmin:this.m_gcs60,ymin:0,xmax:this.m_gcs180,ymax:this.m_gcs90}),t[3].setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:-this.m_gcs60,ymax:0}),t[4].setCoords({xmin:-this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs60,ymax:0}),t[5].setCoords({xmin:this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:0})}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t,s,n,i,r){const o=e[0],m=e.at(-1),a=o.y<m.y?o.y:m.y,h=o.y>m.y?o.y:m.y,c=p.q(this.m_a,this.m_eSquared,a),u=p.q(this.m_a,this.m_eSquared,h);if(this.m_q90-(c+t+this.m_absDistance)>.001&&this.m_q90+(u-t-this.m_absDistance)>.001)return!1;const l=s-re,_=n+re,f=l-Math.PI,d=l+Math.PI,g=_+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,l,f,m,_,P,x),le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,g,_,o,f,b,y),(_<P[0]&&P[0]<g||_<x[0]&&x[0]<g)&&(w=!0),w||(f<b[0]&&b[0]<l||f<y[0]&&y[0]<l)&&(w=!0),!w&&i)return!1;const C=[];for(let p=e.length-1;p>=0;p--)C.push(e[p]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let S=0;S=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,l,_,i,S,r),S=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,_,g,this.m_cornerStep,i,S,r,P[0],x[0]),S=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,g,d,i,S,r),S=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,f,l,this.m_cornerStep,i,S,r,b[0],y[0]);let v=!1;return i||(v=this.checkAndPrepForPole(r)),w||v}bufferPoint2D(e,t,s){s.setEmpty(),s.addPathPoint2D(null,0,!0);const n=0;ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,e,-this.m_cornerStep,2*Math.PI,this.m_cornerStep,t,n,s);let i=!1;return t||(i=this.checkAndPrepForPole(s)),i}checkAndPrepForPole(e){const t=this.checkAndPrepForPoleTouch(e),s=this.checkAndPrepForPoleWrap(e);return t||s}checkAndPrepForPoleTouch(e){const t=new _;return e.queryEnvelope(t),!(!X(t.ymax,this.m_gcs90)&&!X(t.ymin,-this.m_gcs90))&&(this.prepPoleTouch(e),!0)}checkAndPrepForPoleWrap(e){const t=e.getXY(0),s=e.getXY(e.getPointCount()-1);return Math.abs(t.x-s.x)>this.m_gcs180?(this.prepSinglePoleWrap(e),!0):this.checkAndPrepForDoublePoleWrap(e)}checkAndPrepForDoublePoleWrap(e){return e.calculateArea2D()<0&&(this.prepDoublePoleWrap(e),!0)}prepPoleTouch(e){const t=new f;t.insertPath2D(-1,null,0,0,!0);const s=e.getPathStart(0),n=e.getPathEnd(0),i=n-s;let r=-1;for(r=s;r<n;r++){const t=e.getXY(r),s=X(t.y,this.m_gcs90),n=X(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=X(n.y,this.m_gcs90),h=X(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=se.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=X(i.y,this.m_gcs90),o=X(i.y,-this.m_gcs90);r||o||(s=se.construct(i.x,n.y),m?t.setXY(t.getPointCount()-1,s):t.insertPoint2D(0,-1,s)),m=!0}else t.insertPoint2D(0,-1,n),a=n.x,m=!1;o=c}while(o!==r);e.setEmpty(),e.add(t,!1)}prepSinglePoleWrap(e){const t=new f,s=new f,n=new te,i=e.getXY(e.getPathStart(0)),r=e.getXY(e.getPathEnd(0)-1),o=this.m_gcs360,m=this.m_gcs180,a=new _;a.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const h=new _;e.queryEnvelope(h);const c=Math.ceil(h.width()/o);let u,l;i.x>r.x?(u=-o,l=this.m_gcs90):(u=o,l=-this.m_gcs90),n.setShiftCoords(u,0),t.addPath(e,0,!0),s.add(t,!1);const d=new y;for(let _=0;_<c;_++)s.applyTransformation(n),s.getPointByVal(0,d),t.lineToPoint(d),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const g=t.getXY(0),p=t.getXY(t.getPointCount()-1);g.y=l,p.y=l,t.lineTo(p);const P=new se;for(P.setCoordsPoint2D(p),P.x-=.5*u;Math.abs(P.x-g.x)>m;)t.lineTo(P),P.x-=.5*u;t.lineTo(g);const x=a.getCenterX(),w=new _;t.queryEnvelope(w);let C=0;const S=w.getCenter().x;S-x>m?C=-Math.ceil((S-x-m)/o):x-S>m&&(C=Math.ceil((x-S-m)/o)),0!==C&&(n.setShiftCoords(C*o,0),t.applyTransformation(n));const v=new R,D=v.addGeometry(t);z(v,D,this.m_gcs,0,2,!0,a.xmin),z(v,D,this.m_gcs,0,2,!0,a.xmax);const I=v.getGeometry(D),G=A(I,a);G.inflateCoords(0,1);const M=b(null,G,!0).total(),T=q(I,a,M,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(T,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,n=new _;n.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const i=n.getCenter().x,r=new _;e.queryPathEnvelope(0,r);let o,m=0,a=r.getCenter().x;if(a-i>s?m=-Math.ceil((a-i-s)/t):i-a>s&&(m=Math.ceil((i-a-s)/t)),0!==m){const s=new te;s.setShiftCoords(m*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,r),a=r.getCenter().x}const h=new _;n.containsExclusiveEnvelope(r)?(o=!1,h.setCoords({env2D:n})):(o=!0,h.setCoords({env2D:n}),h.xmin-=t,h.xmax+=t);let c=e.createInstance();c.addPathPoint2D(null,0,!0);const u=new se;if(u.setCoords(h.xmin,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(h.xmin,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymin),c.insertPoint2D(0,-1,u),o){c.addPath(e,0,!0);const s=new te;a<i?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),c.addPath(e,0,!0);const r=new R,o=r.addGeometry(c);z(r,o,this.m_gcs,0,2,!0,n.xmin),z(r,o,this.m_gcs,0,2,!0,n.xmax),c=r.getGeometry(o);const m=A(c,n);m.inflateCoords(0,1);const h=b(null,m,!0).total();c=q(c,n,h,Number.NaN,this.m_progressTracker)}else c.addPath(e,0,!0);e.setEmpty(),e.add(c,!1)}setMinCornerStep(){const e={stack:[],error:void 0,hasError:!1};try{let s=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);s=Math.min(s,.125*this.m_a*Math.PI);const n=new se;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=K(e,new ne(new B,new B),!1),m=K(e,new ne(new B,new B),!1),a=K(e,new ne(new B,new B),!1),h=K(e,new ne(new B,new B),!1),c=new se,u=new se,l=new se,_=new se;for(Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,i,o.at(0),o.at(1)),c.setCoords(o.at(0).val,o.at(1).val),Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const t=.5*(i+r);Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,t,a.at(0),a.at(1)),l.setCoords(a.at(0).val,a.at(1).val);const o=K(e,new B,!1),f=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),Y.geodeticCoordinate(this.m_a,this.m_eSquared,c.x,c.y,.5*o.val,f.val,h.at(0),h.at(1),2),_.setCoords(h.at(0).val,h.at(1).val);const d=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,d,null,null,2);if(d.val<=this.m_convergenceOffset)break;r*=.9,Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{Z(e)}}const f=r-i,d=2*Math.PI/Math.ceil(2*Math.PI/f);this.m_cornerStep=d}catch(s){e.error=s,e.hasError=!0}finally{Z(e)}}setMinSegmentStep(){const e={stack:[],error:void 0,hasError:!1};try{let n=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);n=Math.min(n,.125*this.m_a*Math.PI);const i=new se,r=new se;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=K(e,new B,!1),m=K(e,new B,!1),a=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=K(e,new ne(new B,new B),!1),c=K(e,new ne(new B,new B),!1),u=new se,l=K(e,new B,!1),_=K(e,new ne(new B,new B),!1),f=K(e,new ne(new B,new B),!1),d=K(e,new ne(new B,new B),!1),g=K(e,new ne(new B,new B),!1),p=new se,P=new se,x=new se,b=new se,y=0;let w=1;const C=o.val,S=m.val,v=C-.5*Math.PI,D=S+.5*Math.PI,I=a.val;for(Y.geodesicCoordinate(this.m_a,this.m_eSquared,i.x,i.y,n,v,_.at(0),_.at(1)),p.setCoords(_.at(0).val,_.at(1).val),Y.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,D,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const s=.5*(y+w);Y.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,s*I,C,h.at(0),h.at(1),this.m_curveType),u.setCoords(h.at(0).val,h.at(1).val),Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,u.x,u.y,null,null,l,this.m_curveType);const o=l.val+.5*Math.PI;Y.geodesicCoordinate(this.m_a,this.m_eSquared,u.x,u.y,n,o,d.at(0),d.at(1)),x.setCoords(d.at(0).val,d.at(1).val);const m=K(e,new B,!1),a=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),Y.geodeticCoordinate(this.m_a,this.m_eSquared,p.x,p.y,.5*m.val,a.val,g.at(0),g.at(1),2),b.setCoords(g.at(0).val,g.at(1).val);const _=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,x.x,x.y,b.x,b.y,_,null,null,2);if(_.val<=this.m_convergenceOffset)break;{const e={stack:[],error:void 0,hasError:!1};try{w*=.9,Y.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,w*I,C,c.at(0),c.at(1),this.m_curveType),r.setCoords(c.at(0).val,c.at(1).val);const t=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,null,null,t,this.m_curveType);const s=t.val+.5*Math.PI;Y.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,s,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{Z(e)}}}catch(s){e.error=s,e.hasError=!0}finally{Z(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{Z(e)}}setConvergenceOffset(){let e;e=this.m_absDistance>5e4?100:this.m_absDistance>1e4?10:1,this.m_absDistance/e<500&&(e=this.m_absDistance/500),e<.01&&(e=.01),this.m_convergenceOffset=e}}function he(e,t,s,n,i,r,l){if(e.isEmpty())return new f({vd:e.getDescription()});let D=e;if(m(D)){const e=10*t.getTolerance(0);D=(new d).execute(D,0,e,0,l,12e3)}const I=new ae(l);I.m_sr=t,I.m_gcs=t.getGCS(),I.m_transform=g(t,I.m_gcs,null);const G=F();I.m_gcs.querySpheroidData(G);const M=new _;D.queryEnvelope(M),I.m_a=G.majorSemiAxis,I.m_eSquared=G.e2,I.m_rpu=I.m_gcs.getUnit().getUnitToBaseFactor(),I.m_gcs90=.5*Math.PI/I.m_rpu,I.m_gcs180=Math.PI/I.m_rpu,I.m_gcs360=2*Math.PI/I.m_rpu,I.m_gcs60=I.m_gcs360/6,I.m_q90=p.q90(I.m_a,I.m_eSquared),I.m_ellipticToGeodesicMaxRatio=.5*I.m_a*Math.PI/I.m_q90;const T=I.m_gcs.getTolerance(0);I.m_radTolerance=T*I.m_rpu,4===s?(I.m_curveType=2,I.m_bShapePreserving=!0):(I.m_curveType=s,I.m_bShapePreserving=!1),I.m_distance=n,I.m_absDistance=Math.abs(n),Number.isNaN(i)||i<=0?I.setConvergenceOffset():I.m_convergenceOffset=Math.max(i,.001),I.m_convergenceOffset/=r;let N,k=D.getGeometryType();if(a(k)){const e=new P({vd:D.getDescription()});e.addSegment(D,!0),N=e,k=o.enumPolyline}else if(k===o.enumEnvelope){const e=D,t=new _;e.queryEnvelope(t);const s=x(b(I.m_sr,M,!0));if(t.minDimension()<=s)if(0===t.maxDimension()){const t=new y({vd:D.getDescription()});e.getCenter(t),N=t,k=o.enumPoint}else{const t=new P({vd:D.getDescription()});t.addEnvelope(e,!1),N=t,k=o.enumPolyline}else{const t=new f({vd:D.getDescription()});t.addEnvelope(e,!1),N=t,k=o.enumPolygon}}else N=D;if(I.setMinCornerStep(),h(k)||I.setMinSegmentStep(),I.m_absDistance<=.5*I.m_convergenceOffset)return k!==o.enumPolygon?new f({vd:N.getDescription()}):I.m_bShapePreserving?N:w(N,I.m_sr,I.m_curveType,I.m_segmentStep,-1,l);if(I.m_distance<0&&k!==o.enumPolygon)return new f({vd:N.getDescription()});if(I.m_bShapePreserving&&c(k)){const e=w(N,t,4,Number.NaN,I.m_convergenceOffset,l);N=(new C).execute(e,I.m_transform,l)}else N=(new C).execute(N,I.m_transform,l);if(N=S(N,I.m_gcs),N.isEmpty())return new f({vd:N.getDescription()});!I.m_bShapePreserving&&c(k)&&(N=v(I.m_rpu,N)),N=fe(N,I.m_gcs);let A=new f;switch(k){case o.enumPolygon:A=I.bufferPolygon(N);break;case o.enumPolyline:A=I.bufferPolyline(N);break;case o.enumMultiPoint:A=I.bufferMultiPoint(N);break;case o.enumPoint:A=I.bufferPoint(N);break;default:u("")}const q=(new C).execute(A,I.m_transform.getInverse(),l);return q.mergeVertexDescription(N.getDescription()),q}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new se;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=K(u,new B,!1),f=K(u,new ne(new B,new B),!1),d=new se,g=new se,p=r.at(-1),P=1/s;for(let s=0;s<r.length;s++){const u=r[s];let x;0===s?x=o:s===r.length-1?x=m:(Y.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),Y.geodesicCoordinate(e,t,u.x,u.y,n,x,f.at(0),f.at(1)),a?g.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=_e(u.x,d.x,l.x,h),g.setCoords(h+d.x,d.y),l.setCoordsPoint2D(g)),g.scale(P),c.insertPoint2D(0,-1,g)}return h}catch(l){u.error=l,u.hasError=!0}finally{Z(u)}}function ue(e,t,s,n,i,r,o,m,a,h,c,u=Number.NaN,l=Number.NaN){const _={stack:[],error:void 0,hasError:!1};try{if(o-r<m)return h;const f=K(_,new ne(new B,new B),!1),d=new se,g=new se,p=new se;g.setNAN(),a||c.getPointCount()>0&&(g.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),g.scale(s));let P=Math.ceil(r/m),x=P++*m;x===r&&(x=P++*m);let b=r;const y=1/s;for(;x<o+m&&(b<u&&u<x?(x=u,P--):b<l&&l<x&&(x=l,P--),!(x>=o));)Y.geodesicCoordinate(e,t,i.x,i.y,n,x,f.at(0),f.at(1)),a?p.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=_e(i.x,d.x,g.x,h),p.setCoords(h+d.x,d.y),g.setCoordsPoint2D(p)),p.scale(y),c.insertPoint2D(0,-1,p),b=x,x=P++*m;return h}catch(f){_.error=f,_.hasError=!0}finally{Z(_)}}function le(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new se,l=new se,_=K(u,new ne(new B,new B),!1);Y.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),Y.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=K(u,new B,!1);for(Y.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,Y.geodeticDistance(e,t,m.x,m.y,l.x,l.y,null,f,null,0),c[0]=f.val;h[0]<=c[0];)h[0]+=ie;for(;h[0]>c[0];)h[0]-=ie;for(;h[0]>=a;)h[0]-=ie,c[0]-=ie;for(;h[0]<a;)h[0]+=ie,c[0]+=ie}catch(l){u.error=l,u.hasError=!0}finally{Z(u)}}function _e(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=ie;for(;e-(n+t)>Math.PI;)n+=ie;return n}return n+t-s>Math.PI?n-=ie:s-(n+t)>Math.PI&&(n+=ie),n}function fe(e,t){const s=e.getGeometryType();let n;if(n=c(s)?e.getPathCount():s===o.enumMultiPoint?e.getPointCount():1,1===n)return e;const i=[],r=[];for(let o=0;o<n;o++){i.push(o);const n=new se;if(c(s)){const t=new _;e.queryPathEnvelope(o,t),n.assign(t.getCenter())}else n.assign(e.getXY(o));const m=t.toGeohash(n);r.push(m)}i.sort(((e,t)=>r[e]<r[t]?-1:r[e]>r[t]?1:0));const m=e.createInstance();for(let o=0;o<n;o++){const t=i[o];c(s)?m.addPath(e,t,!0):m.addPoints(e,t,t+1)}return m}function de(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=s[0],a=s.at(-1),h=K(o,new B,!1),c=K(o,new B,!1),u=K(o,new B,!1);Y.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),Y.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),Y.greatEllipticDistance(e,t,m.x,m.y,a.x,a.y,u,null,null);let l=Math.min(h.val,c.val)+u.val,_=l+n;if(_<r)return!0;const f=K(o,new B,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];Y.greatEllipticDistance(e,t,i.x,i.y,r.x,r.y,f,null,null),f.val>l&&(l=f.val)}return _=l+n,_<r}catch(m){o.error=m,o.hasError=!0}finally{Z(o)}}function ge(e,t,s,n,i,r,o,m){let a;if(n.length%2==0){const e=n.length>>1,t=n[e],s=n[e-1];a=se.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=J(e,t,h,75/180*Math.PI);return!!de(e,t,n,i,h,c)&&(null!==r&&(r.setCoordsPoint2D(a),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(h),null!==m&&(m[0]=c),!0)}function pe(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=K(o,new B,!1);Y.greatEllipticDistance(e,t,i.x,i.y,s.x,s.y,m,null,null);return m.val+n<r}catch(m){o.error=m,o.hasError=!0}finally{Z(o)}}function Pe(e,t,s,n,i,r,o,m){const a=J(e,t,n,75/180*Math.PI);return!!pe(e,t,n,i,n,a)&&(null!==r&&(r.setCoordsPoint2D(n),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(n),null!==m&&(m[0]=a),!0)}function xe(e,t){return new O(e,t)}function be(e){return W(e,0)||j(e,0),e}class ye{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new se,this.m_minGnomonicRadius=Number.NaN,this.m_progressTracker=e}isRunningInGnomonic(){return this.m_bRunningInGnomonic}needsSimplify(){return this.m_bNeedsSimplify}getGnomonic(){return this.m_gnomonic}}class we extends ye{constructor(e,t,s){super(e.m_progressTracker),this.m_segIter=null,this.m_bNextSegmentCannotJoin=!1,this.m_currentDensifiedDelta=[0],this.m_currentBufferedDelta=0,this.m_lastAzimuth=0,this.m_startAzimuth=[0],this.m_endAzimuth=[0],this.m_numWinds=0,this.m_debugCounter=0,this.m_bufferHelper=new f,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const n=new _;this.m_multiPath.queryEnvelope(n);const i=n.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=J(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,75/180*Math.PI)}next(){let e;if(this.m_bNextSegmentCannotJoin)return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e;if(null===this.m_segIter){if(this.m_segIter=this.m_multiPath.getImpl().querySegmentIterator(),!this.m_segIter.nextPath())return null;null!==this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}if(!this.m_segIter.hasNextSegment()){if(!this.m_segIter.nextPath())return null;null!=this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}let t=null;this.m_currentBufferedDelta=0,this.m_currentDensifiedDelta=[0],this.m_numWinds=0,this.m_lastAzimuth=Number.NaN,this.m_bNextSegmentCannotJoin=!1,this.m_densifiedPoints.length=0;const s=16;let n=0;const i=new se,r=new se;for(;this.m_segIter.hasNextSegment()&&this.m_numWinds<s;){const e=this.m_segIter.nextSegment();if(i.setCoordsPoint2D(e.getStartXY()),r.setCoordsPoint2D(e.getEndXY()),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),U(i,r))i.x=r.x;else if(H(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),H(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),U(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=L(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,i,r,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta);if(0===n)this.m_bRunningInGnomonic=this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(this.m_densifiedPoints));else if(this.m_bRunningInGnomonic){if(!this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}else{if(ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_densifiedPoints,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,null,null,null)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}if(0===s||V(i,r)?(this.m_bufferHelper.setEmpty(),this.m_bufferer.bufferPoint2D(i,this.m_bRunningInGnomonic,this.m_bufferHelper),this.m_bNextSegmentCannotJoin=!0):(this.m_bufferHelper.setEmpty(),this.m_bNextSegmentCannotJoin=this.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(s,this.m_bufferHelper)),this.m_bNextSegmentCannotJoin){this.m_segIter.previousSegment(),this.m_segIter.hasPreviousSegment()?(this.m_segIter.previousSegment(),this.m_segIter.nextSegment()):this.m_segIter.resetToFirstSegment(),null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0);break}null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0),null===t&&(t=new f,t.addPathPoint2D(null,0,!0)),this.addJoinAndBufferLeftSide(t),n++}if(this.m_currentDensifiedDelta=[0],n>0){const e=this.m_segIter.getStartPointIndex(),s=this.m_segIter.getPathIndex();for(;n>0;){if(this.m_segIter.previousSegment(),i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),r.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getEndPointIndex())),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic)if(U(i,r))i.x=r.x;else if(H(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),H(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),U(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,L(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,r,i,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta),this.addJoinAndBufferLeftSide(t),n--}return i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),i.scale(this.m_bufferer.m_rpu),this.m_currentBufferedDelta=ue(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,i,this.m_lastAzimuth+.5*Math.PI,this.m_lastAzimuth+1.5*Math.PI,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,t),this.m_segIter.resetToVertex(e,s),this.m_segIter.nextSegment(),t}return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e}isSegmentBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&de(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new se,s=new se,n=[0];return ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t){return this.m_bufferer.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(this.m_densifiedPoints,e,this.m_startAzimuth[0],this.m_endAzimuth[0],this.m_bRunningInGnomonic,t)}addJoinAndBufferLeftSide(e){const t=this.m_densifiedPoints[0];let s=Number.NaN,n=this.m_startAzimuth[0]-re;const i=this.m_endAzimuth[0]+re;let r=!1;if(!Number.isNaN(this.m_lastAzimuth)){this.m_lastAzimuth>=this.m_startAzimuth[0]?(s=this.m_lastAzimuth+re,n=s+Math.PI-(this.m_lastAzimuth-this.m_startAzimuth[0])):(s=this.m_lastAzimuth+re,n=s+Math.PI-(ie-(this.m_startAzimuth[0]-this.m_lastAzimuth))),r=!(this.m_lastAzimuth>=this.m_startAzimuth[0]&&this.m_lastAzimuth-this.m_startAzimuth[0]<=Math.PI)&&!(this.m_lastAzimuth<this.m_startAzimuth[0]&&this.m_startAzimuth[0]-this.m_lastAzimuth>=Math.PI);let i=!1;if(Math.abs(n-s)<=.5*this.m_bufferer.m_cornerStep&&(r||(i=!0)),i){if(e.removePointFromPath(0,e.getPointCount()-1),!this.m_bRunningInGnomonic){const t=new se;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=ie:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=ie)}n=.5*(n+s)}else if(r){const s=new se;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else ue(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_densifiedPoints[0],s,n,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e)}this.m_startAzimuth[0]!==this.m_lastAzimuth&&this.m_numWinds++,ce(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_bufferer.m_curveType,this.m_densifiedPoints,n,i,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e),this.m_lastAzimuth=this.m_endAzimuth[0]}}class Ce extends ye{constructor(e,t){super(e.m_progressTracker),this.m_pointIndex=-1,this.m_bufferer=e,this.m_multiPoint=t,this.m_bNeedsSimplify=!1;const s=new _;this.m_multiPoint.queryEnvelope(s);const n=s.getCenter(),i=n.clone();i.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,n),this.m_gnomonicCenterRad=i.clone(),this.m_minGnomonicRadius=J(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,i,75/180*Math.PI)}next(){if(this.m_bNeedsSimplify=!1,++this.m_pointIndex===this.m_multiPoint.getPointCount())return null;const e=this.m_multiPoint.getXY(this.m_pointIndex);e.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic=this.isPointBufferInCurrentGnomonic(e),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(e));const t=new f,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&pe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new se,s=new se,n=[0];return Pe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class Se{getOperatorType(){return 10110}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n,i,r,o,m){if(o){const o=new ve(e,t,s,n,i,!1,r,m);return(new l).executeMany(o,t,m)}return new ve(e,t,s,n,i,!1,r,m)}execute(t,s,n,i,r,o,m){const a=new e([t]),h=[i];return this.executeMany(a,s,n,h,r,!1,o,m).next()}}class ve extends t{constructor(e,t,i,r,o,m,a,h){super(),this.m_currentUnionEnvelope2D=new _,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=h,m&&s(""),t||n("");0===t.getCoordinateSystemType()&&n(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=i,this.m_distances=r,this.m_convergenceOffset=o,this.m_bOutlineOnly=m,this.m_bUnion=a}next(){let e;for(;e=this.m_inputGeoms.next();)return i(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dindex+1<this.m_distances.length&&this.m_dindex++,this.geodesicBuffer(e,this.m_distances[this.m_dindex]);return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodesicBuffer(e,t){return me(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{Se as OperatorGeodesicBuffer};
|
|
5
|
+
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{d as s,t as n,a as i,f as r,G as o,h as m,c as a,b as h,i as c,j as u}from"./Geometry.js";import{H as l,v as _,a as f,O as d,I as g,J as p,b as P,K as x,j as b,P as y,N as w,Q as C,R as v,U as S,B as D,V as I,W as G,X as M,Y as T,p as N,z as k,Z as A,_ as q,$ as E,k as R,a0 as z,a1 as X,a2 as B,a3 as Y,a4 as O,a5 as F,a6 as W,a7 as j,a8 as J,a9 as U,aa as H,ab as L,ac as V,ad as Q}from"./QuadraticBezier.js";import{b as K,c as Z}from"./tslib.es6.js";import{c as $,d as ee,T as te,P as se,S as ne,g as ie,e as re}from"./Transformation2D.js";import{c as oe}from"./GeometryCleaner-k94LXQsr.js";function me(e,t,s,m,a,h){m<Number.MAX_VALUE&&m>-Number.MAX_VALUE||n("Geodesic_bufferer.buffer - bad distance"),i(e);const c=oe(e),u=c.getGeometryType();if(r(u)){const e=c.getPointCount(),n=8e6;if(Math.abs(m)>n&&(e>50||u!==o.enumMultiPoint&&4===s&&e>2)){let e=c;const i=m>0?1:-1,r=7e6;let o=m,u=1;do{u++,o=(Math.abs(o)-r)*i}while(Math.abs(o)>n);o=m;for(let n=0;n<u-1;n++)e=he(e,t,s,r*i,a,u,h),o=(Math.abs(o)-r)*i;return e=he(e,t,s,o,a,u,h),e}}return he(c,t,s,m,a,1,h)}class ae{constructor(e){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_radTolerance=0,this.m_q90=0,this.m_gcs90=0,this.m_gcs180=0,this.m_gcs360=0,this.m_gcs60=0,this.m_ellipticToGeodesicMaxRatio=0,this.m_curveType=0,this.m_bShapePreserving=!1,this.m_distance=0,this.m_absDistance=0,this.m_convergenceOffset=0,this.m_cornerStep=0,this.m_segmentStep=0,this.m_progressTracker=e}bufferPolygon(e){const t=new f,s=new we(this,e,t);return this.processGnomonicBufferPiecesCursor(!0,s)}bufferPolyline(e){const t=new we(this,e,null);return this.processGnomonicBufferPiecesCursor(!0,t)}bufferMultiPoint(e){const t=new Ce(this,e);return this.processGnomonicBufferPiecesCursor(!1,t)}bufferPoint(e){const t=e.getXY();t.scale(this.m_rpu);let s=new f;if(this.bufferPoint2D(t,!1,s)){const e=D(null,s,!0);s=I(s,e,!0,!0,-1,this.m_progressTracker,0,!1)}return s=(new C).foldInto360RangeGeodetic(s,this.m_gcs,2),s}processGnomonicBufferPiecesCursor(e,t){const s=t;let n=s.getGnomonic();const i=G(M()),r=new Q;i.queryPrecisionDescriptor(r),r.setTolerance(0,.001),G(M(),void 0,r);let o=new T,m=(new l).executeMany(o,i,this.m_progressTracker,2);const a=$(6,!1),h=ee(_,6);this.initializeGrid(a,h);const c=[null,null,null,null,null,null],u=[null,null,null,null,null,null],f=[null,null,null,null,null,null];let d,g,p;for(;null!==(d=s.next());){if(g=s.getGnomonic(),g!==n){if(null!==n){let t=m.next();if(o=null,m=null,null!=t){const s=D(i,t,!0),r=x(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,a,h,c,u,f)}}null!==g&&(o=new T,m=(new l).executeMany(o,i,this.m_progressTracker,2)),n=g}if(s.isRunningInGnomonic()){if(g.project(d),s.needsSimplify()){const e=D(null,d,!0);d=I(d,e,!0,!0,-1,this.m_progressTracker,0,!1)}o.tick(be(d)),m.tock()}else this.putInGridCursors(e,d,i,!0,a,h,c,u,f)}let P=!1;for(let l=0;l<6;l++)if(null!=f[l]){P=!0;break}if(P){let t=!1;const r=[null,null,null,null,null,null];if(e){const n=s.m_densified;if(s.m_densified=null,null!==n){const s=new te;s.scale(1/this.m_rpu,1/this.m_rpu),n.applyTransformation(s),this.m_distance>0?this.putInGridCursors(e,n,i,!1,a,h,c,u,f):(this.processInGrid(e,n,!1,a,h,c,r),t=!0)}}const _=new T,d=(new l).executeMany(_,this.m_gcs,this.m_progressTracker,2);if(null!==m){let t=m.next();o=null,m=null;const s=D(i,t,!0),r=x(s);t=n.unproject(t,r,this.m_progressTracker),this.putInGridCursors(e,t,i,!0,a,h,c,u,f)}for(let e=0;e<6;e++)if(null!=f[e]){let s=f[e].next();f[e]=null,u[e]=null,t&&null!==r[e]&&(s=(new N).execute(r[e],s,i,this.m_progressTracker));const n=D(i,s,!0),o=x(n);s=c[e].unproject(s,o,this.m_progressTracker),s=(new k).execute(s,this.m_gcs,!0,this.m_progressTracker),_.tick(be(s)),d.tock()}p=d.next()}else{let t,r=!1;if(e){let e=s.m_densified;if(s.m_densified=null,null!==e){const s=new te;s.scale(1/this.m_rpu,1/this.m_rpu),e.applyTransformation(s),g.project(e);const n=D(null,e,!0);e=I(e,n,!1,!0,-1,this.m_progressTracker,0,!1),this.m_distance>0?(o.tick(be(e)),m.tock()):(t=e,r=!0)}}let a=m.next();o=null,m=null,r&&(a=(new N).execute(t,a,i,this.m_progressTracker));const h=D(i,a,!0),c=x(h);p=n.unproject(a,c,this.m_progressTracker),p=(new k).execute(p,this.m_gcs,!0,this.m_progressTracker)}return p=(new C).foldInto360RangeGeodetic(p,this.m_gcs,2),p}putInGridCursors(e,t,s,n,i,r,o,m,a){const h=[null,null,null,null,null,null];this.processInGrid(e,t,n,i,r,o,h);for(let c=0;c<6;c++)null!==h[c]&&(null===m[c]&&(m[c]=new T,a[c]=(new l).executeMany(m[c],s,this.m_progressTracker,2)),m[c].tick(be(h[c])),a[c].tock())}processInGrid(e,t,s,n,i,r,o){const m=.01,a=this.insertGeodeticPointsAlongGrid(t,i,m);for(let h=0;h<6;h++){if(n[h])continue;const e=i[h].clone();e.inflateCoords(m,m);const c=A(t,e),u=b(null,c,!1).total();let l=q(a,e,u,Number.NaN,this.m_progressTracker);if(null!==l&&!l.isEmpty()){if(l===a&&(l=l.clone()),null===r[h]){const e=new se;h<3?e.setCoords(0,1):e.setCoords(0,-1);const t=new se;t.setAdd(i[h].getCenter(),e),r[h]=xe(this.m_gcs,t)}r[h].project(l);const e=D(null,l,!0);l=I(l,e,s,!0,-1,this.m_progressTracker,0,!1),o[h]=l}}}insertGeodeticPointsAlongGrid(e,t,s){const n=_.construct(t[3].xmin,t[3].ymin,t[2].xmax,t[2].ymax),i=E(this.m_gcs,n,e,!0,this.m_progressTracker),r=new R,o=r.addGeometry(i);return z(r,o,this.m_gcs,0,2,!0,t[0].xmax+s),z(r,o,this.m_gcs,0,2,!0,t[1].xmax+s),z(r,o,this.m_gcs,0,2,!1,t[1].ymin+s),0!==s&&(z(r,o,this.m_gcs,0,2,!0,t[0].xmax-s),z(r,o,this.m_gcs,0,2,!0,t[1].xmax-s),z(r,o,this.m_gcs,0,2,!1,t[1].ymin-s)),r.getGeometry(o)}initializeGrid(e,t){for(let s=0;s<6;s++)e[s]=!1;t[0].setCoords({xmin:-this.m_gcs180,ymin:0,xmax:-this.m_gcs60,ymax:this.m_gcs90}),t[1].setCoords({xmin:-this.m_gcs60,ymin:0,xmax:this.m_gcs60,ymax:this.m_gcs90}),t[2].setCoords({xmin:this.m_gcs60,ymin:0,xmax:this.m_gcs180,ymax:this.m_gcs90}),t[3].setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:-this.m_gcs60,ymax:0}),t[4].setCoords({xmin:-this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs60,ymax:0}),t[5].setCoords({xmin:this.m_gcs60,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:0})}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t,s,n,i,r){const o=e[0],m=e.at(-1),a=o.y<m.y?o.y:m.y,h=o.y>m.y?o.y:m.y,c=p.q(this.m_a,this.m_eSquared,a),u=p.q(this.m_a,this.m_eSquared,h);if(this.m_q90-(c+t+this.m_absDistance)>.001&&this.m_q90+(u-t-this.m_absDistance)>.001)return!1;const l=s-re,_=n+re,f=l-Math.PI,d=l+Math.PI,g=_+Math.PI,P=[Number.NaN],x=[Number.NaN],b=[Number.NaN],y=[Number.NaN];let w=!1;if(le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,l,f,m,_,P,x),le(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,g,_,o,f,b,y),(_<P[0]&&P[0]<g||_<x[0]&&x[0]<g)&&(w=!0),w||(f<b[0]&&b[0]<l||f<y[0]&&y[0]<l)&&(w=!0),!w&&i)return!1;const C=[];for(let p=e.length-1;p>=0;p--)C.push(e[p]);r.setEmpty(),r.addPathPoint2D(null,0,!0);let v=0;v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,e,l,_,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,m,_,g,this.m_cornerStep,i,v,r,P[0],x[0]),v=ce(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,this.m_curveType,C,g,d,i,v,r),v=ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,o,f,l,this.m_cornerStep,i,v,r,b[0],y[0]);let S=!1;return i||(S=this.checkAndPrepForPole(r)),w||S}bufferPoint2D(e,t,s){s.setEmpty(),s.addPathPoint2D(null,0,!0);const n=0;ue(this.m_a,this.m_eSquared,this.m_rpu,this.m_absDistance,e,-this.m_cornerStep,2*Math.PI,this.m_cornerStep,t,n,s);let i=!1;return t||(i=this.checkAndPrepForPole(s)),i}checkAndPrepForPole(e){const t=this.checkAndPrepForPoleTouch(e),s=this.checkAndPrepForPoleWrap(e);return t||s}checkAndPrepForPoleTouch(e){const t=new _;return e.queryEnvelope(t),!(!X(t.ymax,this.m_gcs90)&&!X(t.ymin,-this.m_gcs90))&&(this.prepPoleTouch(e),!0)}checkAndPrepForPoleWrap(e){const t=e.getXY(0),s=e.getXY(e.getPointCount()-1);return Math.abs(t.x-s.x)>this.m_gcs180?(this.prepSinglePoleWrap(e),!0):this.checkAndPrepForDoublePoleWrap(e)}checkAndPrepForDoublePoleWrap(e){return e.calculateArea2D()<0&&(this.prepDoublePoleWrap(e),!0)}prepPoleTouch(e){const t=new f;t.insertPath2D(-1,null,0,0,!0);const s=e.getPathStart(0),n=e.getPathEnd(0),i=n-s;let r=-1;for(r=s;r<n;r++){const t=e.getXY(r),s=X(t.y,this.m_gcs90),n=X(t.y,-this.m_gcs90);if(!s&&!n)break}let o=r,m=!1,a=Number.NaN;do{const n=e.getXY(o),r=X(n.y,this.m_gcs90),h=X(n.y,-this.m_gcs90),c=s+(o+1-s)%i;if(r||h){let s=se.construct(a,n.y);t.insertPoint2D(0,-1,s);const i=e.getXY(c),r=X(i.y,this.m_gcs90),o=X(i.y,-this.m_gcs90);r||o||(s=se.construct(i.x,n.y),m?t.setXY(t.getPointCount()-1,s):t.insertPoint2D(0,-1,s)),m=!0}else t.insertPoint2D(0,-1,n),a=n.x,m=!1;o=c}while(o!==r);e.setEmpty(),e.add(t,!1)}prepSinglePoleWrap(e){const t=new f,s=new f,n=new te,i=e.getXY(e.getPathStart(0)),r=e.getXY(e.getPathEnd(0)-1),o=this.m_gcs360,m=this.m_gcs180,a=new _;a.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const h=new _;e.queryEnvelope(h);const c=Math.ceil(h.width()/o);let u,l;i.x>r.x?(u=-o,l=this.m_gcs90):(u=o,l=-this.m_gcs90),n.setShiftCoords(u,0),t.addPath(e,0,!0),s.add(t,!1);const d=new y;for(let _=0;_<c;_++)s.applyTransformation(n),s.getPointByVal(0,d),t.lineToPoint(d),t.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);const g=t.getXY(0),p=t.getXY(t.getPointCount()-1);g.y=l,p.y=l,t.lineTo(p);const P=new se;for(P.setCoordsPoint2D(p),P.x-=.5*u;Math.abs(P.x-g.x)>m;)t.lineTo(P),P.x-=.5*u;t.lineTo(g);const x=a.getCenterX(),w=new _;t.queryEnvelope(w);let C=0;const v=w.getCenter().x;v-x>m?C=-Math.ceil((v-x-m)/o):x-v>m&&(C=Math.ceil((x-v-m)/o)),0!==C&&(n.setShiftCoords(C*o,0),t.applyTransformation(n));const S=new R,D=S.addGeometry(t);z(S,D,this.m_gcs,0,2,!0,a.xmin),z(S,D,this.m_gcs,0,2,!0,a.xmax);const I=S.getGeometry(D),G=A(I,a);G.inflateCoords(0,1);const M=b(null,G,!0).total(),T=q(I,a,M,Number.NaN,this.m_progressTracker);e.setEmpty(),e.add(T,!1)}prepDoublePoleWrap(e){const t=this.m_gcs360,s=this.m_gcs180,n=new _;n.setCoords({xmin:-this.m_gcs180,ymin:-this.m_gcs90,xmax:this.m_gcs180,ymax:this.m_gcs90});const i=n.getCenter().x,r=new _;e.queryPathEnvelope(0,r);let o,m=0,a=r.getCenter().x;if(a-i>s?m=-Math.ceil((a-i-s)/t):i-a>s&&(m=Math.ceil((i-a-s)/t)),0!==m){const s=new te;s.setShiftCoords(m*t,0),e.getImpl().applyTransformationToPath(s,0),e.queryPathEnvelope(0,r),a=r.getCenter().x}const h=new _;n.containsExclusiveEnvelope(r)?(o=!1,h.setCoords({env2D:n})):(o=!0,h.setCoords({env2D:n}),h.xmin-=t,h.xmax+=t);let c=e.createInstance();c.addPathPoint2D(null,0,!0);const u=new se;if(u.setCoords(h.xmin,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(h.xmin,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymax),c.insertPoint2D(0,-1,u),u.setCoords(h.xmax,h.ymin),c.insertPoint2D(0,-1,u),u.setCoords(.5*(h.xmin+h.xmax),h.ymin),c.insertPoint2D(0,-1,u),o){c.addPath(e,0,!0);const s=new te;a<i?s.setShiftCoords(t,0):s.setShiftCoords(-t,0),e.getImpl().applyTransformationToPath(s,0),c.addPath(e,0,!0);const r=new R,o=r.addGeometry(c);z(r,o,this.m_gcs,0,2,!0,n.xmin),z(r,o,this.m_gcs,0,2,!0,n.xmax),c=r.getGeometry(o);const m=A(c,n);m.inflateCoords(0,1);const h=b(null,m,!0).total();c=q(c,n,h,Number.NaN,this.m_progressTracker)}else c.addPath(e,0,!0);e.setEmpty(),e.add(c,!1)}setMinCornerStep(){const e={stack:[],error:void 0,hasError:!1};try{let s=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);s=Math.min(s,.125*this.m_a*Math.PI);const n=new se;n.setCoords(0,10*this.m_rpu);const i=0;let r=45*this.m_rpu;const o=K(e,new ne(new B,new B),!1),m=K(e,new ne(new B,new B),!1),a=K(e,new ne(new B,new B),!1),h=K(e,new ne(new B,new B),!1),c=new se,u=new se,l=new se,_=new se;for(Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,i,o.at(0),o.at(1)),c.setCoords(o.at(0).val,o.at(1).val),Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const t=.5*(i+r);Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,t,a.at(0),a.at(1)),l.setCoords(a.at(0).val,a.at(1).val);const o=K(e,new B,!1),f=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,c.x,c.y,u.x,u.y,o,f,null,2),Y.geodeticCoordinate(this.m_a,this.m_eSquared,c.x,c.y,.5*o.val,f.val,h.at(0),h.at(1),2),_.setCoords(h.at(0).val,h.at(1).val);const d=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,l.x,l.y,_.x,_.y,d,null,null,2);if(d.val<=this.m_convergenceOffset)break;r*=.9,Y.geodesicCoordinate(this.m_a,this.m_eSquared,n.x,n.y,s,r,m.at(0),m.at(1)),u.setCoords(m.at(0).val,m.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{Z(e)}}const f=r-i,d=2*Math.PI/Math.ceil(2*Math.PI/f);this.m_cornerStep=d}catch(s){e.error=s,e.hasError=!0}finally{Z(e)}}setMinSegmentStep(){const e={stack:[],error:void 0,hasError:!1};try{let n=Math.min(Math.PI*this.m_a-this.m_absDistance,this.m_absDistance);n=Math.min(n,.125*this.m_a*Math.PI);const i=new se,r=new se;i.setCoords(0,10*this.m_rpu),r.setCoords(10*this.m_rpu,10*this.m_rpu);const o=K(e,new B,!1),m=K(e,new B,!1),a=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,a,o,m,this.m_curveType);const h=K(e,new ne(new B,new B),!1),c=K(e,new ne(new B,new B),!1),u=new se,l=K(e,new B,!1),_=K(e,new ne(new B,new B),!1),f=K(e,new ne(new B,new B),!1),d=K(e,new ne(new B,new B),!1),g=K(e,new ne(new B,new B),!1),p=new se,P=new se,x=new se,b=new se,y=0;let w=1;const C=o.val,v=m.val,S=C-.5*Math.PI,D=v+.5*Math.PI,I=a.val;for(Y.geodesicCoordinate(this.m_a,this.m_eSquared,i.x,i.y,n,S,_.at(0),_.at(1)),p.setCoords(_.at(0).val,_.at(1).val),Y.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,D,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val);;){const e={stack:[],error:void 0,hasError:!1};try{const s=.5*(y+w);Y.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,s*I,C,h.at(0),h.at(1),this.m_curveType),u.setCoords(h.at(0).val,h.at(1).val),Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,u.x,u.y,null,null,l,this.m_curveType);const o=l.val+.5*Math.PI;Y.geodesicCoordinate(this.m_a,this.m_eSquared,u.x,u.y,n,o,d.at(0),d.at(1)),x.setCoords(d.at(0).val,d.at(1).val);const m=K(e,new B,!1),a=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,p.x,p.y,P.x,P.y,m,a,null,2),Y.geodeticCoordinate(this.m_a,this.m_eSquared,p.x,p.y,.5*m.val,a.val,g.at(0),g.at(1),2),b.setCoords(g.at(0).val,g.at(1).val);const _=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,x.x,x.y,b.x,b.y,_,null,null,2);if(_.val<=this.m_convergenceOffset)break;{const e={stack:[],error:void 0,hasError:!1};try{w*=.9,Y.geodeticCoordinate(this.m_a,this.m_eSquared,i.x,i.y,w*I,C,c.at(0),c.at(1),this.m_curveType),r.setCoords(c.at(0).val,c.at(1).val);const t=K(e,new B,!1);Y.geodeticDistance(this.m_a,this.m_eSquared,i.x,i.y,r.x,r.y,null,null,t,this.m_curveType);const s=t.val+.5*Math.PI;Y.geodesicCoordinate(this.m_a,this.m_eSquared,r.x,r.y,n,s,f.at(0),f.at(1)),P.setCoords(f.at(0).val,f.at(1).val)}catch(t){e.error=t,e.hasError=!0}finally{Z(e)}}}catch(s){e.error=s,e.hasError=!0}finally{Z(e)}}let G=w*I;G>1e5&&(G=1e5),this.m_segmentStep=G}catch(n){e.error=n,e.hasError=!0}finally{Z(e)}}setConvergenceOffset(){let e;e=this.m_absDistance>5e4?100:this.m_absDistance>1e4?10:1,this.m_absDistance/e<500&&(e=this.m_absDistance/500),e<.01&&(e=.01),this.m_convergenceOffset=e}}function he(e,t,s,n,i,r,l){if(e.isEmpty())return new f({vd:e.getDescription()});let D=e;if(m(D)){const e=10*t.getTolerance(0);D=(new d).execute(D,0,e,0,l,12e3)}const I=new ae(l);I.m_sr=t,I.m_gcs=t.getGCS(),I.m_transform=g(t,I.m_gcs,null);const G=O();I.m_gcs.querySpheroidData(G);const M=new _;D.queryEnvelope(M),I.m_a=G.majorSemiAxis,I.m_eSquared=G.e2,I.m_rpu=I.m_gcs.getUnit().getUnitToBaseFactor(),I.m_gcs90=.5*Math.PI/I.m_rpu,I.m_gcs180=Math.PI/I.m_rpu,I.m_gcs360=2*Math.PI/I.m_rpu,I.m_gcs60=I.m_gcs360/6,I.m_q90=p.q90(I.m_a,I.m_eSquared),I.m_ellipticToGeodesicMaxRatio=.5*I.m_a*Math.PI/I.m_q90;const T=I.m_gcs.getTolerance(0);I.m_radTolerance=T*I.m_rpu,4===s?(I.m_curveType=2,I.m_bShapePreserving=!0):(I.m_curveType=s,I.m_bShapePreserving=!1),I.m_distance=n,I.m_absDistance=Math.abs(n),Number.isNaN(i)||i<=0?I.setConvergenceOffset():I.m_convergenceOffset=Math.max(i,.001),I.m_convergenceOffset/=r;let N,k=D.getGeometryType();if(a(k)){const e=new P({vd:D.getDescription()});e.addSegment(D,!0),N=e,k=o.enumPolyline}else if(k===o.enumEnvelope){const e=D,t=new _;e.queryEnvelope(t);const s=x(b(I.m_sr,M,!0));if(t.minDimension()<=s)if(0===t.maxDimension()){const t=new y({vd:D.getDescription()});e.getCenter(t),N=t,k=o.enumPoint}else{const t=new P({vd:D.getDescription()});t.addEnvelope(e,!1),N=t,k=o.enumPolyline}else{const t=new f({vd:D.getDescription()});t.addEnvelope(e,!1),N=t,k=o.enumPolygon}}else N=D;if(I.setMinCornerStep(),h(k)||I.setMinSegmentStep(),I.m_absDistance<=.5*I.m_convergenceOffset)return k!==o.enumPolygon?new f({vd:N.getDescription()}):I.m_bShapePreserving?N:w(N,I.m_sr,I.m_curveType,I.m_segmentStep,-1,l);if(I.m_distance<0&&k!==o.enumPolygon)return new f({vd:N.getDescription()});if(I.m_bShapePreserving&&c(k)){const e=w(N,t,4,Number.NaN,I.m_convergenceOffset,l);N=(new C).execute(e,I.m_transform,l)}else N=(new C).execute(N,I.m_transform,l);if(N=v(N,I.m_gcs),N.isEmpty())return new f({vd:N.getDescription()});!I.m_bShapePreserving&&c(k)&&(N=S(I.m_rpu,N)),N=fe(N,I.m_gcs);let A=new f;switch(k){case o.enumPolygon:A=I.bufferPolygon(N);break;case o.enumPolyline:A=I.bufferPolyline(N);break;case o.enumMultiPoint:A=I.bufferMultiPoint(N);break;case o.enumPoint:A=I.bufferPoint(N);break;default:u("")}const q=(new C).execute(A,I.m_transform.getInverse(),l);return q.mergeVertexDescription(N.getDescription()),q}function ce(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const l=new se;l.setNAN(),a||c.getPointCount()>0&&(l.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),l.scale(s));const _=K(u,new B,!1),f=K(u,new ne(new B,new B),!1),d=new se,g=new se,p=r.at(-1),P=1/s;for(let s=0;s<r.length;s++){const u=r[s];let x;0===s?x=o:s===r.length-1?x=m:(Y.geodeticDistance(e,t,p.x,p.y,u.x,u.y,null,null,_,i),x=_.val-.5*Math.PI),Y.geodesicCoordinate(e,t,u.x,u.y,n,x,f.at(0),f.at(1)),a?g.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=_e(u.x,d.x,l.x,h),g.setCoords(h+d.x,d.y),l.setCoordsPoint2D(g)),g.scale(P),c.insertPoint2D(0,-1,g)}return h}catch(l){u.error=l,u.hasError=!0}finally{Z(u)}}function ue(e,t,s,n,i,r,o,m,a,h,c,u=Number.NaN,l=Number.NaN){const _={stack:[],error:void 0,hasError:!1};try{if(o-r<m)return h;const f=K(_,new ne(new B,new B),!1),d=new se,g=new se,p=new se;g.setNAN(),a||c.getPointCount()>0&&(g.setCoordsPoint2D(c.getXY(c.getPointCount()-1)),g.scale(s));let P=Math.ceil(r/m),x=P++*m;x===r&&(x=P++*m);let b=r;const y=1/s;for(;x<o+m&&(b<u&&u<x?(x=u,P--):b<l&&l<x&&(x=l,P--),!(x>=o));)Y.geodesicCoordinate(e,t,i.x,i.y,n,x,f.at(0),f.at(1)),a?p.setCoords(f.at(0).val,f.at(1).val):(d.setCoords(f.at(0).val,f.at(1).val),h=_e(i.x,d.x,g.x,h),p.setCoords(h+d.x,d.y),g.setCoordsPoint2D(p)),p.scale(y),c.insertPoint2D(0,-1,p),b=x,x=P++*m;return h}catch(f){_.error=f,_.hasError=!0}finally{Z(_)}}function le(e,t,s,n,i,r,o,m,a,h,c){const u={stack:[],error:void 0,hasError:!1};try{const s=new se,l=new se,_=K(u,new ne(new B,new B),!1);Y.geodesicCoordinate(e,t,i.x,i.y,n,r,_.at(0),_.at(1)),s.setCoords(_.at(0).val,_.at(1).val),Y.geodesicCoordinate(e,t,i.x,i.y,n,o,_.at(0),_.at(1)),l.setCoords(_.at(0).val,_.at(1).val);const f=K(u,new B,!1);for(Y.geodeticDistance(e,t,m.x,m.y,s.x,s.y,null,f,null,0),h[0]=f.val,Y.geodeticDistance(e,t,m.x,m.y,l.x,l.y,null,f,null,0),c[0]=f.val;h[0]<=c[0];)h[0]+=ie;for(;h[0]>c[0];)h[0]-=ie;for(;h[0]>=a;)h[0]-=ie,c[0]-=ie;for(;h[0]<a;)h[0]+=ie,c[0]+=ie}catch(l){u.error=l,u.hasError=!0}finally{Z(u)}}function _e(e,t,s,n){if(Number.isNaN(s)){for(;n+t-e>Math.PI;)n-=ie;for(;e-(n+t)>Math.PI;)n+=ie;return n}return n+t-s>Math.PI?n-=ie:s-(n+t)>Math.PI&&(n+=ie),n}function fe(e,t){const s=e.getGeometryType();let n;if(n=c(s)?e.getPathCount():s===o.enumMultiPoint?e.getPointCount():1,1===n)return e;const i=[],r=[];for(let o=0;o<n;o++){i.push(o);const n=new se;if(c(s)){const t=new _;e.queryPathEnvelope(o,t),n.assign(t.getCenter())}else n.assign(e.getXY(o));const m=t.toGeohash(n);r.push(m)}i.sort(((e,t)=>r[e]<r[t]?-1:r[e]>r[t]?1:0));const m=e.createInstance();for(let o=0;o<n;o++){const t=i[o];c(s)?m.addPath(e,t,!0):m.addPoints(e,t,t+1)}return m}function de(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=s[0],a=s.at(-1),h=K(o,new B,!1),c=K(o,new B,!1),u=K(o,new B,!1);Y.greatEllipticDistance(e,t,i.x,i.y,m.x,m.y,h,null,null),Y.greatEllipticDistance(e,t,i.x,i.y,a.x,a.y,c,null,null),Y.greatEllipticDistance(e,t,m.x,m.y,a.x,a.y,u,null,null);let l=Math.min(h.val,c.val)+u.val,_=l+n;if(_<r)return!0;const f=K(o,new B,!1);l=Math.max(h.val,c.val);for(let n=1;n<s.length-1;n++){const r=s[n];Y.greatEllipticDistance(e,t,i.x,i.y,r.x,r.y,f,null,null),f.val>l&&(l=f.val)}return _=l+n,_<r}catch(m){o.error=m,o.hasError=!0}finally{Z(o)}}function ge(e,t,s,n,i,r,o,m){let a;if(n.length%2==0){const e=n.length>>1,t=n[e],s=n[e-1];a=se.lerp(t,s,.5)}else{a=n[n.length-1>>1].clone()}const h=a.clone(),c=J(e,t,h,75/180*Math.PI);return!!de(e,t,n,i,h,c)&&(null!==r&&(r.setCoordsPoint2D(a),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(h),null!==m&&(m[0]=c),!0)}function pe(e,t,s,n,i,r){const o={stack:[],error:void 0,hasError:!1};try{if(n>=r)return!1;const m=K(o,new B,!1);Y.greatEllipticDistance(e,t,i.x,i.y,s.x,s.y,m,null,null);return m.val+n<r}catch(m){o.error=m,o.hasError=!0}finally{Z(o)}}function Pe(e,t,s,n,i,r,o,m){const a=J(e,t,n,75/180*Math.PI);return!!pe(e,t,n,i,n,a)&&(null!==r&&(r.setCoordsPoint2D(n),r.scale(1/s)),null!==o&&o.setCoordsPoint2D(n),null!==m&&(m[0]=a),!0)}function xe(e,t){return new F(e,t)}function be(e){return W(e,0)||j(e,0),e}class ye{constructor(e){this.m_bRunningInGnomonic=!1,this.m_bNeedsSimplify=!1,this.m_gnomonic=null,this.m_gnomonicCenterRad=new se,this.m_minGnomonicRadius=Number.NaN,this.m_progressTracker=e}isRunningInGnomonic(){return this.m_bRunningInGnomonic}needsSimplify(){return this.m_bNeedsSimplify}getGnomonic(){return this.m_gnomonic}}class we extends ye{constructor(e,t,s){super(e.m_progressTracker),this.m_segIter=null,this.m_bNextSegmentCannotJoin=!1,this.m_currentDensifiedDelta=[0],this.m_currentBufferedDelta=0,this.m_lastAzimuth=0,this.m_startAzimuth=[0],this.m_endAzimuth=[0],this.m_numWinds=0,this.m_debugCounter=0,this.m_bufferHelper=new f,this.m_densifiedPoints=[],this.m_bufferer=e,this.m_multiPath=t,this.m_densified=s,this.m_bNeedsSimplify=!0;const n=new _;this.m_multiPath.queryEnvelope(n);const i=n.getCenter(),r=i.clone();r.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,i),this.m_gnomonicCenterRad=r.clone(),this.m_minGnomonicRadius=J(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,r,75/180*Math.PI)}next(){let e;if(this.m_bNextSegmentCannotJoin)return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e;if(null===this.m_segIter){if(this.m_segIter=this.m_multiPath.getImpl().querySegmentIterator(),!this.m_segIter.nextPath())return null;null!==this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}if(!this.m_segIter.hasNextSegment()){if(!this.m_segIter.nextPath())return null;null!=this.m_densified&&this.m_densified.addPathPoint2D(null,0,!0)}let t=null;this.m_currentBufferedDelta=0,this.m_currentDensifiedDelta=[0],this.m_numWinds=0,this.m_lastAzimuth=Number.NaN,this.m_bNextSegmentCannotJoin=!1,this.m_densifiedPoints.length=0;const s=16;let n=0;const i=new se,r=new se;for(;this.m_segIter.hasNextSegment()&&this.m_numWinds<s;){const e=this.m_segIter.nextSegment();if(i.setCoordsPoint2D(e.getStartXY()),r.setCoordsPoint2D(e.getEndXY()),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),U(i,r))i.x=r.x;else if(H(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),H(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),U(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0;const s=L(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,i,r,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta);if(0===n)this.m_bRunningInGnomonic=this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(this.m_densifiedPoints));else if(this.m_bRunningInGnomonic){if(!this.isSegmentBufferInCurrentGnomonic(this.m_densifiedPoints)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}else{if(ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_densifiedPoints,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,null,null,null)){this.m_segIter.previousSegment(),this.m_segIter.previousSegment(),this.m_segIter.nextSegment();break}}if(0===s||V(i,r)?(this.m_bufferHelper.setEmpty(),this.m_bufferer.bufferPoint2D(i,this.m_bRunningInGnomonic,this.m_bufferHelper),this.m_bNextSegmentCannotJoin=!0):(this.m_bufferHelper.setEmpty(),this.m_bNextSegmentCannotJoin=this.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(s,this.m_bufferHelper)),this.m_bNextSegmentCannotJoin){this.m_segIter.previousSegment(),this.m_segIter.hasPreviousSegment()?(this.m_segIter.previousSegment(),this.m_segIter.nextSegment()):this.m_segIter.resetToFirstSegment(),null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0);break}null!=this.m_densified&&this.m_densified.insertPointsFromPoints(this.m_densified.getPathCount()-1,-1,this.m_densifiedPoints,0,this.m_densifiedPoints.length-1,!0),null===t&&(t=new f,t.addPathPoint2D(null,0,!0)),this.addJoinAndBufferLeftSide(t),n++}if(this.m_currentDensifiedDelta=[0],n>0){const e=this.m_segIter.getStartPointIndex(),s=this.m_segIter.getPathIndex();for(;n>0;){if(this.m_segIter.previousSegment(),i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),r.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getEndPointIndex())),i.scale(this.m_bufferer.m_rpu),r.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic)if(U(i,r))i.x=r.x;else if(H(i,r))r.x=i.x;else{let e=-1,t=-1;const s=this.m_segIter.getPathIndex(),n=this.m_multiPath.getPathStart(s),o=this.m_multiPath.getPathEnd(s);if(e=this.m_segIter.getStartPointIndex()-1,t=this.m_segIter.getEndPointIndex()+1,e<n&&(e=this.m_multiPath.isClosedPath(s)?o-1:-1),t>o-1&&(t=this.m_multiPath.isClosedPath(s)?n:-1),-1!==e){const t=this.m_multiPath.getXY(e);t.scale(this.m_bufferer.m_rpu),H(t,i)&&(i.x=t.x)}if(-1!==t){const e=this.m_multiPath.getXY(t);e.scale(this.m_bufferer.m_rpu),U(r,e)&&(r.x=e.x)}}this.m_densifiedPoints.length=0,L(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_curveType,r,i,this.m_bufferer.m_segmentStep,Number.NaN,this.m_bufferer.m_radTolerance,this.m_startAzimuth,this.m_endAzimuth,this.m_densifiedPoints,this.m_currentDensifiedDelta),this.addJoinAndBufferLeftSide(t),n--}return i.setCoordsPoint2D(this.m_multiPath.getXY(this.m_segIter.getStartPointIndex())),i.scale(this.m_bufferer.m_rpu),this.m_currentBufferedDelta=ue(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,i,this.m_lastAzimuth+.5*Math.PI,this.m_lastAzimuth+1.5*Math.PI,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,t),this.m_segIter.resetToVertex(e,s),this.m_segIter.nextSegment(),t}return this.m_bNextSegmentCannotJoin=!1,this.m_segIter.nextSegment(),e=this.m_bufferHelper.clone(),e}isSegmentBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&de(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new se,s=new se,n=[0];return ge(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(e,t){return this.m_bufferer.checkAndPrepSegmentForCrossingAzimuthsOrPoleWrap(this.m_densifiedPoints,e,this.m_startAzimuth[0],this.m_endAzimuth[0],this.m_bRunningInGnomonic,t)}addJoinAndBufferLeftSide(e){const t=this.m_densifiedPoints[0];let s=Number.NaN,n=this.m_startAzimuth[0]-re;const i=this.m_endAzimuth[0]+re;let r=!1;if(!Number.isNaN(this.m_lastAzimuth)){this.m_lastAzimuth>=this.m_startAzimuth[0]?(s=this.m_lastAzimuth+re,n=s+Math.PI-(this.m_lastAzimuth-this.m_startAzimuth[0])):(s=this.m_lastAzimuth+re,n=s+Math.PI-(ie-(this.m_startAzimuth[0]-this.m_lastAzimuth))),r=!(this.m_lastAzimuth>=this.m_startAzimuth[0]&&this.m_lastAzimuth-this.m_startAzimuth[0]<=Math.PI)&&!(this.m_lastAzimuth<this.m_startAzimuth[0]&&this.m_startAzimuth[0]-this.m_lastAzimuth>=Math.PI);let i=!1;if(Math.abs(n-s)<=.5*this.m_bufferer.m_cornerStep&&(r||(i=!0)),i){if(e.removePointFromPath(0,e.getPointCount()-1),!this.m_bRunningInGnomonic){const t=new se;t.setCoordsPoint2D(e.getXY(e.getPointCount()-1)),t.scale(this.m_bufferer.m_rpu),t.x-this.m_currentBufferedDelta<-Math.PI?this.m_currentBufferedDelta-=ie:t.x-this.m_currentBufferedDelta>Math.PI&&(this.m_currentBufferedDelta+=ie)}n=.5*(n+s)}else if(r){const s=new se;s.setCoordsPoint2D(t),s.scale(1/this.m_bufferer.m_rpu),e.insertPoint2D(0,-1,s)}else ue(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_densifiedPoints[0],s,n,this.m_bufferer.m_cornerStep,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e)}this.m_startAzimuth[0]!==this.m_lastAzimuth&&this.m_numWinds++,ce(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,this.m_bufferer.m_absDistance,this.m_bufferer.m_curveType,this.m_densifiedPoints,n,i,this.m_bRunningInGnomonic,this.m_currentBufferedDelta,e),this.m_lastAzimuth=this.m_endAzimuth[0]}}class Ce extends ye{constructor(e,t){super(e.m_progressTracker),this.m_pointIndex=-1,this.m_bufferer=e,this.m_multiPoint=t,this.m_bNeedsSimplify=!1;const s=new _;this.m_multiPoint.queryEnvelope(s);const n=s.getCenter(),i=n.clone();i.scale(this.m_bufferer.m_rpu),this.m_gnomonic=xe(this.m_bufferer.m_gcs,n),this.m_gnomonicCenterRad=i.clone(),this.m_minGnomonicRadius=J(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,i,75/180*Math.PI)}next(){if(this.m_bNeedsSimplify=!1,++this.m_pointIndex===this.m_multiPoint.getPointCount())return null;const e=this.m_multiPoint.getXY(this.m_pointIndex);e.scale(this.m_bufferer.m_rpu),this.m_bRunningInGnomonic=this.isPointBufferInCurrentGnomonic(e),this.m_bRunningInGnomonic||(this.m_bRunningInGnomonic=this.tryUpdateGnomonic(e));const t=new f,s=this.m_bufferer.bufferPoint2D(e,this.m_bRunningInGnomonic,t);return this.m_bNeedsSimplify=s,t}isPointBufferInCurrentGnomonic(e){return null!==this.m_gnomonic&&pe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,this.m_gnomonicCenterRad,this.m_minGnomonicRadius)}tryUpdateGnomonic(e){const t=new se,s=new se,n=[0];return Pe(this.m_bufferer.m_a,this.m_bufferer.m_eSquared,this.m_bufferer.m_rpu,e,this.m_bufferer.m_absDistance*this.m_bufferer.m_ellipticToGeodesicMaxRatio,t,s,n)?(this.m_gnomonicCenterRad.setCoordsPoint2D(s),this.m_minGnomonicRadius=n[0],this.m_gnomonic=xe(this.m_bufferer.m_gcs,t),!0):(this.m_gnomonic=null,!1)}}class ve{getOperatorType(){return 10110}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n,i,r,o,m){if(o){const o=new Se(e,t,s,n,i,!1,r,m);return(new l).executeMany(o,t,m)}return new Se(e,t,s,n,i,!1,r,m)}execute(t,s,n,i,r,o,m){const a=new e([t]),h=[i];return this.executeMany(a,s,n,h,r,!1,o,m).next()}}class Se extends t{constructor(e,t,i,r,o,m,a,h){super(),this.m_currentUnionEnvelope2D=new _,this.m_index=-1,this.m_dindex=-1,this.m_progressTracker=h,m&&s(""),t||n("");0===t.getCoordinateSystemType()&&n(""),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=i,this.m_distances=r,this.m_convergenceOffset=o,this.m_bOutlineOnly=m,this.m_bUnion=a}next(){let e;for(;e=this.m_inputGeoms.next();)return i(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dindex+1<this.m_distances.length&&this.m_dindex++,this.geodesicBuffer(e,this.m_distances[this.m_dindex]);return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodesicBuffer(e,t){return me(e,this.m_spatialReference,this.m_curveType,t,this.m_convergenceOffset,this.m_progressTracker)}}export{ve as OperatorGeodesicBuffer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{t as e,a as t,G as i,e as s,g as n}from"./Geometry.js";import{a,O as _,G as r,x as h,t as o,h as m,e as l,bg as p,K as u,ak as c,bh as g,d,au as E,a2 as f,N as P,ax as S,bi as A,bj as x,a0 as y,a1 as R,ad as M,bk as C,an as T,ai as w,L as q,ar as N}from"./QuadraticBezier.js";import{f as b,P as I,K as v,e as $,k as z,T as G,E as k,j as D,c as O,r as L,s as F,t as J,v as U,w as Y}from"./Transformation2D.js";import{O as X}from"./OperatorShapePreservingLength.js";import{b as j,c as B}from"./tslib.es6.js";import{a as H}from"./GeodeticDistanceCalculator-DzvUOSaR.js";class Q{constructor(e,t,i,s,n=100){this.m_startPt=e.clone(),this.m_endPt=t.clone(),this.m_cE2=s,this.m_cE=Math.sqrt(this.m_cE2),this.m_c1By2e=1/(2*this.m_cE),this.m_cRpu=i.getGCS().getUnit().getUnitToBaseFactor(),this.isPcs=2===i.getCoordinateSystemType(),this.PEProjcs=i.getPECoordSys(),this.m_points=new Array(2*n)}setSegmentEndPoints(e,t){this.m_startPt.assign(e),this.m_endPt.assign(t)}makeFunctor(){return e=>{const t=[0,0];t[0]=this.m_startPt.x*(1-e)+this.m_endPt.x*e,t[1]=this.m_startPt.y*(1-e)+this.m_endPt.y*e,this.isPcs&&E.projToGeogCenter(this.PEProjcs,1,t,0);const i=Math.sin(t[1]*this.m_cRpu);if(0===this.m_cE2)return i;return-Math.log((1-this.m_cE*i)/(1+this.m_cE*i))*this.m_c1By2e+i/(1-this.m_cE2*i*i)}}makeArrayFunctor(){return n(0),{}}}function V(e,t,i){const s=new o;e.queryEnvelope(s);const n=m(t,s,!0).total(),a=t.getPannableExtent();a.xmin=s.xmin-10*n,a.xmax=s.xmax+10*n;const _=(new l).execute(e,a,t,i).getImpl().querySegmentIterator();_.stripAttributes();const r=f();t.querySpheroidData(r);const h=r.e2,u=0===h?2:1,c=new I(0,0),g=new I(0,0),d=new v(0),E=new Q(c,g,t,h,100);for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment();c.assign(e.getStartXY()),g.assign(e.getEndXY()),E.setSegmentEndPoints(c,g);const t=p(6,0,1,1e-12,1e-15,E.makeFunctor());d.pe((g.x-c.x)*t)}const P=r.majorSemiAxis;return u*P*P*(1-h)*Math.PI*d.getResult()/t.getPannableExtent().width()}function Z(e,t,i,s,n){const a=se(e,t,n);let _=K(e,a.first,i,s,n),r=1,h=0,o=0;do{if(r++,a.first*=.5,a.first<50*t.getTolerance(0))return _;a.second*=2,o=K(e,a.first,i,s,n),h=Math.abs(o-_),_=o}while(Math.abs(_)>1&&h>1e-8*Math.abs(_)&&(a.second<65e3&&r<8||r<4));return o}function K(e,t,i,s,n){const a=(new _).execute(e,t,0,0,n);let r;r=s?(new u).execute(a,s,n):a;const h=1===i.getUnit().getUnitToBaseFactor()?Math.PI/180:1,m=new o;r.queryEnvelope(m);const l=new o,p=new o,c=new o;l.setCoords({xmin:m.xmin,ymin:75*h,xmax:m.xmax,ymax:90*h}),p.setCoords({xmin:m.xmin,ymin:-60*h,xmax:m.xmax,ymax:75*h}),c.setCoords({xmin:m.xmin,ymin:-90*h,xmax:m.xmax,ymax:-60*h}),l.inflateCoords(.01*l.width(),0),p.inflateCoords(.01*p.width(),0),c.inflateCoords(.01*c.width(),0);let g=0;return g+=W(r,l,i,n),g+=W(r,p,i,n),g+=W(r,c,i,n),g}function W(e,t,i,s){const n=(new l).execute(e,t,i,s);if(null!==n&&!n.isEmpty()){const e=new o;n.queryEnvelope(e);const{first:t,second:a}=ie(i,e,!1),_=r(i,t,null),h=(new u).execute(n,_,s).calculateArea2D();return a&&t.destroy(),h}return 0}const ee=[null,null,null,null,null,null,null];function te(e,t,i){const a=e.getUnit().getUnitToBaseFactor(),_=t.getCenter();_.scale(180*a/Math.PI);const r=new I;r.x=0,r.y=0;let h=0;if(0===h){_.y>45?(r.y=$,h=0):_.y<-45?(r.y=-$,h=1):_.x>=45&&_.x<135?(r.x=$,h=2):_.x>=135||_.x<-135?(r.x=$,h=3):_.x<-45&&_.x>=-135?(r.x=-$,h=4):(r.x=0,h=5);const e=a*Math.sqrt(z(t.xmin-t.xmax)+z(t.ymin-t.ymax)),i=r.clone(),s=t.getCenter();s.scale(a),h<2&&(i.x=s.x);if(I.distance(i,s)+.5*e>$)return null}const o=ee[h];if(null!==o&&o.getGCS().equalHorizontal(e))return o;const m=e.getText(),l=r.x,p=r.y,u=0,E=0;let f=0,P=-1;6!==h?P=c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA:(n(i),f=0,P=c.PE_PRJ_CYLINDRICAL_EQAREA);const S=g("EqualAreaPCS");let A;P===c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA?A=`PROJCS["${S}",${m},PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${u}],PARAMETER["False_Northing",${E}],PARAMETER["Central_Meridian",${l}],PARAMETER["Latitude_of_Origin",${p}],UNIT["Meter",1.0]]`:P===c.PE_PRJ_CYLINDRICAL_EQAREA?A=`PROJCS["${S}",${m},PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting",${u}],PARAMETER["False_Northing",${E}],PARAMETER["Central_Meridian",${l}],PARAMETER["Standard_Parallel_1",${f}],PARAMETER["Latitude_of_Origin",${p}],UNIT["Meter",1.0]]`:s("getEqualAreaPcsFixed");const x=d(A);return ee[h]&&ee[h].destroy(),ee[h]=x,x}function ie(e,t,i){const n=te(e,t,i);if(null!==n)return b(n,!1);const a=e.getText(),_=e.getUnit().getUnitToBaseFactor(),r=(t.xmin+t.width()/2)*_,h=(t.ymin+t.height()/2)*_,o=0,m=0;let l=0,p=0,u=-1;t.ymin*_>=75*Math.PI/180||t.ymax*_<=-60*Math.PI/180?u=c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA:t.ymin>0||t.ymax<0?(l=(t.ymin+1/3*t.height())*_,p=(t.ymin+2/3*t.height())*_,u=c.PE_PRJ_ALBERS):(l=(t.ymin+2/3*t.height())*_,u=c.PE_PRJ_CYLINDRICAL_EQAREA);const E=g("EqualAreaPCS");let f;return u===c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA?f=`PROJCS["${E}",${a},PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:u===c.PE_PRJ_ALBERS?f=`PROJCS["${E}",${a},PROJECTION["Albers"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Standard_Parallel_1",${l}],PARAMETER["Standard_Parallel_2",${p}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:u===c.PE_PRJ_CYLINDRICAL_EQAREA?f=`PROJCS["${E}",${a},PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Standard_Parallel_1",${l}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:s("getEqualAreaPCSInstance"),b(d(f),!0)}function se(e,t,i){const s=e.calculateLength2D(),n=(new X).execute(e,t,i)/25e3,a=s/e.getSegmentCount()*2;let _=Math.min(a,s/n);0===_&&(_=1);return b(_,s/_)}class ne{getOperatorType(){return 10314}supportsCurves(){return!0}accelerateGeometry(e,t,i){return!1}canAccelerateGeometry(e){return!1}execute(s,n,o){if(n&&0!==n.getCoordinateSystemType()||e(""),s.isEmpty()||s.getDimension()<2)return 0;if(t(s),s.getGeometryType()===i.enumEnvelope){const e=new a;return e.addEnvelope(s,!1),this.execute(e,n,o)}let m=s;s.getDescription().getAttributeCount()>1&&(m=s.clone(),m.dropAllAttributes());const l=(new _).execute(m,0,n.getTolerance(0),0,o);let p=null;const u=n.getGCS();u!==n&&(p=r(n,u));let c=(new h).execute(l,n,!1,o);return c.isEmpty()?0:(c===s&&(c=s.clone()),n.isPannable()?V(c,n,o):Z(c,n,u,p,o))}}function ae(){return{m_p_PCS:new I,m_factor:Number.NaN,setValues:_e,assign:re}}function _e(e,t){this.m_factor=e,this.m_p_PCS.assign(t)}function re(e){this.m_factor=e.m_factor,this.m_p_PCS.assign(e.m_p_PCS)}class he{constructor(e,t,i,s){this.m_ptStart=new T,this.m_ptEnd=new T,this.m_ptStart.assign(t),this.m_ptEnd.assign(i),this.m_deltaX=this.m_ptEnd.x-this.m_ptStart.x,this.m_deltaY=this.m_ptEnd.y-this.m_ptStart.y,this.m_e=Math.sqrt(e),this.m_e2=e,this.m_c1MinusE2=1-e;const n=Math.sin(s);let a;a=0===this.m_e2?2*n:n*(U(this.m_e*n)+1/(1-this.m_e2*n*n)),this.m_baseA=a}setSegmentEndPoints(e,t){this.m_ptStart.assign(e),this.m_ptEnd.assign(t),this.m_deltaX=this.m_ptEnd.x-this.m_ptStart.x,this.m_deltaY=this.m_ptEnd.y-this.m_ptStart.y}makeFunctor(){return e=>{const t=1-e,i=t*this.m_ptStart.x+e*this.m_ptEnd.x,s=t*this.m_ptStart.y+e*this.m_ptEnd.y,n=t*this.m_ptStart.z+e*this.m_ptEnd.z,a=i*i+s*s,_=n/Math.sqrt(n*n+this.m_c1MinusE2*this.m_c1MinusE2*a);let r;if(0===this.m_e2)r=2*_;else{r=_*(U(this.m_e*_)+1/(1-this.m_e2*_*_))}return(this.m_deltaY*i-this.m_deltaX*s)/a*(r-this.m_baseA)}}}function oe(){return{e:Number.NaN,one_p_e:Number.NaN,one_m_e:Number.NaN,one_m_e_2:Number.NaN,atanh_e_over_e:Number.NaN,half_qp:Number.NaN,f:Number.NaN,z:Number.NaN}}function me(){return{sin_phi:Number.NaN,one_p_sin_phi:Number.NaN,one_m_sin_phi:Number.NaN,one_m_e_2_sin_2_phi:Number.NaN,sin_half_phi_pf:Number.NaN,sin_half_phi_pz:Number.NaN,sin_half_asin_e_sin_phi_pf:Number.NaN,sin_half_asin_e_sin_phi_pz:Number.NaN,atanh_sin_phi:Number.NaN,atanh_esin_phi:Number.NaN,make_negative:!1,initialize:le,changeSign:pe,assign:ue,clone:ce}}function le(e,t,i,s){const n=.5*e;this.sin_phi=Math.sin(e);const a=t*this.sin_phi,_=.5*Math.asin(a);this.one_p_sin_phi=1+this.sin_phi,this.one_m_sin_phi=1-this.sin_phi,this.one_m_e_2_sin_2_phi=(1+a)*(1-a),this.sin_half_phi_pf=Math.sin(n+i),this.sin_half_phi_pz=Math.sin(n+s),this.sin_half_asin_e_sin_phi_pf=Math.sin(_+i),this.sin_half_asin_e_sin_phi_pz=Math.sin(_+s),this.atanh_sin_phi=Math.log(this.sin_half_phi_pf/this.sin_half_phi_pz),this.atanh_esin_phi=Math.log(this.sin_half_asin_e_sin_phi_pf/this.sin_half_asin_e_sin_phi_pz)}function pe(){this.sin_phi=-this.sin_phi;let e=this.one_p_sin_phi;this.one_p_sin_phi=this.one_m_sin_phi,this.one_m_sin_phi=e,e=this.sin_half_phi_pf,this.sin_half_phi_pf=this.sin_half_phi_pz,this.sin_half_phi_pz=e,e=this.sin_half_asin_e_sin_phi_pf,this.sin_half_asin_e_sin_phi_pf=this.sin_half_asin_e_sin_phi_pz,this.sin_half_asin_e_sin_phi_pz=e,this.atanh_sin_phi=-this.atanh_sin_phi,this.atanh_esin_phi=-this.atanh_esin_phi}function ue(e){this.sin_phi=e.sin_phi,this.one_p_sin_phi=e.one_p_sin_phi,this.one_m_sin_phi=e.one_m_sin_phi,this.one_m_e_2_sin_2_phi=e.one_m_e_2_sin_2_phi,this.sin_half_phi_pf=e.sin_half_phi_pf,this.sin_half_phi_pz=e.sin_half_phi_pz,this.sin_half_asin_e_sin_phi_pf=e.sin_half_asin_e_sin_phi_pf,this.sin_half_asin_e_sin_phi_pz=e.sin_half_asin_e_sin_phi_pz,this.atanh_sin_phi=e.atanh_sin_phi,this.atanh_esin_phi=e.atanh_esin_phi,this.make_negative=e.make_negative}function ce(){return{...this}}class ge{constructor(t,i,s){this.m_transformPCS2GCS=null,this.m_scaleToRadians=new G,this.m_scaleToDegrees=new G,this.m_progressTracker=s,n(4!==i),this.m_curveType=i,this.m_inputSR=t,t&&0!==t.getCoordinateSystemType()||e(""),this.m_inputGCS=t.getGCS(),this.m_a=0,this.m_eSquared=0,this.m_b=0,this.m_rpu=0}executePolygonGeodeticArea(e){let t,i=e.clone();if(i.dropAllAttributes(),e.hasNonLinearSegments()){i=(new _).execute(i,0,this.m_inputSR.getTolerance(0),0,this.m_progressTracker)}if(this.m_inputSR.isPannable()){const e=new o;i.queryEnvelope(e);const t=this.m_inputSR.getPannableExtent();if(!t.containsEnvelope(e)){const s=t.getCenterX()-e.getCenterX(),n=new G;n.setShiftCoords(s,0),i.applyTransformation(n),e.move(s,0);const a=new k;t.queryIntervalX(a);const _=new k;e.queryIntervalX(_),i=a.contains(_)?P(i,this.m_inputSR):(new u).foldInto360RangeGeodetic(i,this.m_inputSR,this.m_curveType)}}if(this.m_transformPCS2GCS?(i=(new h).execute(i,this.m_inputSR,!1,this.m_progressTracker),t=i.createInstance(),S(this.m_transformPCS2GCS,i,t,this.m_progressTracker)||(t=(new u).execute(i,this.m_transformPCS2GCS,this.m_progressTracker))):t=(new h).execute(i,this.m_inputGCS,!1,this.m_progressTracker),t.isEmpty())return 0;if(1===this.m_curveType){const e=f();return this.m_inputGCS.querySpheroidData(e),this.m_a=e.majorSemiAxis,this.m_eSquared=e.e2,this.loxodromeArea(t)}const s=t.getImpl();this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_scaleToRadians.setScale(this.m_rpu),s.applyTransformation(this.m_scaleToRadians),this.m_scaleToDegrees=this.m_scaleToRadians,this.m_scaleToDegrees.invertThis();const n=f();if(this.m_inputGCS.querySpheroidData(n),this.m_a=n.majorSemiAxis,this.m_b=n.minorSemiAxis,this.m_eSquared=n.e2,2===this.m_curveType)return this.executeClippedPolygonGreatEllipticArea(t);{const e={stack:[],error:void 0,hasError:!1};try{const i=A.unit(9101),s=this.m_inputGCS.getPECoordSys(),n=j(e,s.cloneAlterUnits(i),!1);let a,_,r=this.executeClippedPolygonGeodeticArea(t,n,0),h=0;do{h++,a=this.executeClippedPolygonGeodeticArea(t,n,h),_=Math.abs(a-r),r=a}while(Math.abs(a)>1&&_>1e-8*Math.abs(a)&&h<7);return a}catch(a){e.error=a,e.hasError=!0}finally{B(e)}}}executeClippedPolygonGeodeticArea(e,t,i){const s={stack:[],error:void 0,hasError:!1};try{const n=new o;e.queryEnvelope(n);const a=j(s,this.getEqualAreaPCSInstance(t,n),!1),_=e.clone();x(a,_);const r=50,h=_.getImpl().getAttributeStreamRef(0),m=e.getImpl().getAttributeStreamRef(0),l=j(s,new y,!1),p=j(s,new y,!1),u=40,c=[0,0],g=D(ae,u),d=O(u,-1),f=ae(),P=ae();let S,A;const M=a;let C=_.calculateArea2D();const T=new v(0),w=.5*Math.PI,q=1e-10*Math.abs(C)+1e-6,N=e.getPathCount();let b,$,z,G;const k=new I,F=new I,J=new I,U=new I,Y=new I,X=new I;let B,H;for($=e.getPathStart(0),b=0;b<N;b++,$=z)for(z=e.getPathEnd(b),h.queryPoint2D(z-1<<1,J),m.queryPoint2D(z-1<<1,k),Math.abs(k.y)>w&&(k.y=L(w,k.y)),G=$;G<z;G++,J.assign(U),k.assign(F)){if(h.queryPoint2D(G<<1,U),m.queryPoint2D(G<<1,F),Math.abs(F.y)>w&&(F.y=L(w,F.y)),B=I.distance(J,U),B<r||0===k.y&&0===F.y)continue;R.geodeticDistance(this.m_a,this.m_eSquared,k.x,k.y,F.x,F.y,l,p,null,this.m_curveType);const e=l.val,t=p.val;for(f.setValues(0,J),P.setValues(1,U),A=i,g[0].assign(P),d[0]=i,S=0;S>=0;){H=.5*(f.m_factor+P.m_factor),R.geodeticCoordinate(this.m_a,this.m_eSquared,k.x,k.y,e*H,t,l,p,this.m_curveType),Y.x=l.val,Y.y=p.val,c[0]=Y.x,c[1]=Y.y,E.geogToProj(M,1,c),X.x=c[0],X.y=c[1];const i=-X.offset(f.m_p_PCS,P.m_p_PCS),s=.5*i*I.distance(f.m_p_PCS,P.m_p_PCS);if(T.pe(s),Math.abs(s)>q||Math.abs(s)>0&&A>0)P.setValues(H,X),S++,g[S].assign(P),Math.abs(s)<=q?(A--,d[S-1]=A,d[S]=A):(A=d[S-1],d[S]=A);else{if(S<=0)break;f.assign(P),S--,P.assign(g[S]),A=d[S]}}}return C+=T.getResult(),Math.abs(C)}catch(n){s.error=n,s.hasError=!0}finally{B(s)}}executeClippedPolygonGreatEllipticArea(e){const t=[],i=[],s=new I,n=new I,a=M(1,this.m_eSquared,new I(0,.5*Math.PI)),_=new v(0),r=new v(0),h=new v(0),m=new T,l=new T,p=new o;e.queryLooseEnvelope(p);let u=0;p.containsCoords(p.xmin,0)||(u=Math.abs(p.ymin)<Math.abs(p.ymax)?p.ymin:p.ymax);const c=new he(this.m_eSquared,m,l,u),g=this.m_a*this.m_a,d=e.getImpl().querySegmentIterator();for(d.stripAttributes();d.nextPath();)for(;d.hasNextSegment();){const e=d.nextSegment();s.assign(e.getStartXY()),n.assign(e.getEndXY()),n.x-s.x>Math.PI?s.x+=2*Math.PI:n.x-s.x<-Math.PI&&(n.x+=2*Math.PI),this.splitSegmentCrossingItegralThreshold(e,t,i);for(let i of t)m.assign(M(this.m_a,this.m_eSquared,i.getStartXY())),l.assign(M(this.m_a,this.m_eSquared,i.getEndXY())),c.setSegmentEndPoints(m,l),this.adaptiveIntegrationWithRomberg(c,_);for(let t of i){let e=t.getStartXY(),i=t.getEndXY(),s=u;e.y<0&&(i=F(e,e=i),e.y=-e.y,i.y=-i.y,s=-s);const n=M(1,this.m_eSquared,e),_=M(1,this.m_eSquared,i),o=Math.min(e.y,i.y),m=C(this.m_eSquared,e.x,i.x,s,o);r.pe(m);const l=Math.abs(C(this.m_eSquared,e.x,i.x,o,$)),p=new T;p.setSub(n,a);const c=new T;c.setSub(_,a);const d=new T;d.setCrossProductVector(p,c);let E=g*(l-.5*d.length());E=L(E,i.x-e.x),h.pe(E)}t.length=0,i.length=0}return h.getResult()+g*(.5*(1-this.m_eSquared)*_.getResult()+r.getResult())}getEqualAreaPCSInstance(e,t){const i=t.getCenterX(),s=0,n=0;let a,_;const r=t.height();let h,o;(h=t.ymin>45*Math.PI/180||t.ymax<45*-Math.PI/180)?a=L(.5*Math.PI,t.getCenterY()):(a=t.getCenterY(),_=t.ymin+r*(2/3));const m=g("EqualAreaPCS"),l=e.toString();return o=h?A.fromString(c.PE_TYPE_PROJCS,`PROJCS["${m}", ${l}, PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${s}],PARAMETER["False_Northing", ${n}],PARAMETER["Central_Meridian", ${i}], PARAMETER["Latitude_of_Origin", ${a}], UNIT["Meter",1.0]]`):A.fromString(c.PE_TYPE_PROJCS,`PROJCS["${m}", ${l}, PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting", ${s}],PARAMETER["False_Northing", ${n}],PARAMETER["Central_Meridian", ${i}],PARAMETER["Standard_Parallel_1", ${_}],PARAMETER["Latitude_of_Origin", ${a}],UNIT["Meter",1.0]]`),o}splitSegmentCrossingItegralThreshold(e,t,i){const s=100,n=20,a=n*n,_=M(this.m_a,this.m_eSquared,new I(0,$)),r=M(this.m_a,this.m_eSquared,new I(0,-$)),h=this.splitSegmentPassingThroughPole(e);for(let o of h){const e=o.getStartXY(),h=o.getEndXY(),m=M(this.m_a,this.m_eSquared,e),l=M(this.m_a,this.m_eSquared,h),p=new I,u=new T;let c=T.sqrDistance(_,m),g=T.sqrDistance(m,l);if(c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(m.add(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:e,end:p})),e.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),c=T.sqrDistance(_,l),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(l.sub(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:p,end:h})),h.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),l.assign(M(this.m_a,this.m_eSquared,h)),c=T.sqrDistance(r,m),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(m.add(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:e,end:p})),e.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),l.assign(M(this.m_a,this.m_eSquared,h)),c=T.sqrDistance(r,l),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(l.sub(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:p,end:h})),h.assign(p)}t.push(new q({start:e,end:h}))}}splitSegmentPassingThroughPole(e){const t={stack:[],error:void 0,hasError:!1};try{const i=[],s=new T,n=new T,a=new T,_=new I,r=20,h=3.124139361,o=10,m=e.getStartXY(),l=e.getEndXY(),p=j(t,new y,!1);if(R.geodeticDistance(this.m_a,this.m_eSquared,m.x,m.y,l.x,l.y,p,null,null,2),Math.abs(l.x-m.x)>h&&p.val>r){const e=new H(new I(0,90),m.divide(this.m_rpu),l.divide(this.m_rpu),this.m_inputGCS,2,2);let t=N(e.makeFunctor(),0,1,1e-10);if(t.second<=o&&t.first>0&&t.first<1)return s.assign(M(this.m_a,this.m_eSquared,m)),n.assign(M(this.m_a,this.m_eSquared,l)),J(s,n,t.first,a),_.assign(w(this.m_a,this.m_eSquared,a)),i.push(new q({start:m,end:_})),i.push(new q({start:_,end:l})),i;if(e.setPointDistFrom(new I(0,-90)),t=N(e.makeFunctor(),0,1,1e-10),t.second<=o&&t.first>0&&t.first<1)return s.assign(M(this.m_a,this.m_eSquared,m)),n.assign(M(this.m_a,this.m_eSquared,l)),J(s,n,t.first,a),_.assign(w(this.m_a,this.m_eSquared,a)),i.push(new q({start:m,end:_})),i.push(new q({start:_,end:l})),i}return i.push(new q({start:m,end:l})),i}catch(i){t.error=i,t.hasError=!0}finally{B(t)}}adaptiveIntegrationWithRomberg(e,t){const i=e.makeFunctor();let s=0,n=1,a=i(s),_=i(n);const r=1e-17,h=1e-14;let o=(s+n)/2,m=i(o),l=Math.abs(m-a),u=Math.abs(_-m),c=0;for(;c++<32&&(l/u<.1||u/l<.1);)l<u?(t.pe(p(5,s,o,h,r,i)),s=o,a=m):(t.pe(p(5,o,n,h,r,i)),n=o,_=m),o=(s+n)/2,m=Math.abs(i(o)),l=Math.abs(m-a),u=Math.abs(_-m);t.pe(p(5,s,n,h,r,i))}loxodromeAreaHemi(e,t,i,s,n){const a=i.clone(),_=n.clone();let r,h,o,m,l,p,u,c,g,d,E,f,P,S,A,x;return a.make_negative&&a.changeSign(),_.make_negative&&_.changeSign(),E=s-t,1===Math.abs(a.sin_phi)||1===Math.abs(_.sin_phi)?e.half_qp*E:a.sin_phi===_.sin_phi?(d=.5*e.one_m_e_2*a.sin_phi*(1/a.one_m_e_2_sin_2_phi+U(e.e*a.sin_phi))*E,d):(A=Math.log(_.sin_half_phi_pf*a.sin_half_phi_pz/(_.sin_half_phi_pz*a.sin_half_phi_pf)),x=Math.log(_.sin_half_asin_e_sin_phi_pf*a.sin_half_asin_e_sin_phi_pz/(_.sin_half_asin_e_sin_phi_pz*a.sin_half_asin_e_sin_phi_pf)),1===this.m_eSquared?(l=0,r=.5*(A+_.sin_phi/_.one_m_e_2_sin_2_phi-a.sin_phi/a.one_m_e_2_sin_2_phi),h=0):(l=-2*e.atanh_e_over_e*(Math.log(_.one_p_sin_phi/a.one_p_sin_phi)-e.e*x),r=(A-e.e*x)/e.one_m_e_2,h=(Math.log(_.one_m_e_2_sin_2_phi/a.one_m_e_2_sin_2_phi)+l/e.atanh_e_over_e)/e.one_m_e_2),o=-x*(a.atanh_esin_phi+_.atanh_esin_phi),m=1/a.one_m_e_2_sin_2_phi-1/_.one_m_e_2_sin_2_phi,p=Y(_.one_m_sin_phi/e.one_p_e,e.e)-Y(a.one_m_sin_phi/e.one_p_e,e.e),u=Y(_.one_p_sin_phi/e.one_p_e,e.e)-Y(a.one_p_sin_phi/e.one_p_e,e.e),c=Y(a.one_m_sin_phi/-e.one_m_e,e.e)-Y(_.one_m_sin_phi/-e.one_m_e,e.e),g=Y(a.one_p_sin_phi/-e.one_m_e,e.e)-Y(_.one_p_sin_phi/-e.one_m_e,e.e),d=.25/r*(h+o+m+l+.5*(p+u+c+g)),d+=e.half_qp,f=.5*e.one_m_e_2*a.sin_phi*(1/a.one_m_e_2_sin_2_phi+U(e.e*a.sin_phi)),P=.5*e.one_m_e_2*_.sin_phi*(1/_.one_m_e_2_sin_2_phi+U(e.e*_.sin_phi)),P<f&&(S=f,f=P,P=S),d<f&&(d=f),d>P&&(d=P),d*=E,d)}loxodromeArea(e){const t=Math.PI/180;let i=0;const s=oe(),n=me(),a=me();s.e=Math.sqrt(this.m_eSquared),s.one_p_e=1+s.e,s.one_m_e=1-s.e,s.one_m_e_2=1-this.m_eSquared,s.atanh_e_over_e=U(s.e),this.m_eSquared>=1?s.half_qp=1:s.half_qp=.5*(1+s.atanh_e_over_e*s.one_m_e_2),s.f=.25*Math.PI,s.z=.75*Math.PI,a.initialize(0,s.e,s.f,s.z);const _=e.getPathCount(),r=new I,h=new I,o=e.getImpl().getAttributeStreamRef(0);for(let m=0;m<_;m++){const _=e.getPathStart(m),l=e.getPathEnd(m);if(!(l-_<=1)){o.queryPoint2D(2*(l-1),r);for(let e=_;e<l;e++){o.queryPoint2D(2*e,h);const m=r.y*t,l=h.y*t;if(e===_?(n.initialize(m,s.e,s.f,s.z),n.make_negative=!1):n.assign(a),a.initialize(l,s.e,s.f,s.z),a.make_negative=!1,r.y*h.y<0){if(r.y>=90&&h.y<=-90||h.y>=90&&r.y<=-90)return Number.NaN;const e=me();e.initialize(0,s.e,s.f,s.z),e.make_negative=!1;const _=n.atanh_sin_phi-s.e*n.atanh_esin_phi,o=a.atanh_sin_phi-s.e*a.atanh_esin_phi,l=(o*r.x-_*h.x)/(o-_);m<0?(n.make_negative=!0,i-=this.loxodromeAreaHemi(s,r.x*t,n,l*t,e),n.make_negative=!1,i+=this.loxodromeAreaHemi(s,l*t,e,h.x*t,a)):(i+=this.loxodromeAreaHemi(s,r.x*t,n,l*t,e),a.make_negative=!0,i-=this.loxodromeAreaHemi(s,l*t,e,h.x*t,a),a.make_negative=!1)}else r.y>=0?i+=this.loxodromeAreaHemi(s,r.x*t,n,h.x*t,a):(n.make_negative=!0,a.make_negative=!0,i-=this.loxodromeAreaHemi(s,r.x*t,n,h.x*t,a),n.make_negative=!1,a.make_negative=!1);r.assign(h)}}}return this.m_a*i*this.m_a}calculate(e){if(e.isEmpty()||e.getDimension()<2)return 0;if(e.getGeometryType()===i.enumEnvelope){const t=new a;return t.addEnvelope(e,!1),this.calculate(t)}return this.m_inputSR!==this.m_inputGCS&&null===this.m_transformPCS2GCS&&(this.m_transformPCS2GCS=r(this.m_inputSR,this.m_inputGCS,null)),this.executePolygonGeodeticArea(e)}}class de{getOperatorType(){return 10311}supportsCurves(){return!0}accelerateGeometry(e,t,i){return!1}canAccelerateGeometry(e){return!1}execute(e,i,s,n){if(t(e),4===s)return(new ne).execute(e,i,n);return new ge(i,s,n).calculate(e)}}export{de as OperatorGeodeticArea};
|
|
5
|
+
import{t as e,a as t,G as i,e as s,g as n}from"./Geometry.js";import{a,O as _,I as r,z as h,v as o,j as m,e as l,bg as p,Q as u,am as c,bh as g,d,aw as E,a4 as f,R as P,az as S,bi as A,bj as x,a2 as y,a3 as R,af as M,bk as C,ap as T,ak as w,L as q,at as N}from"./QuadraticBezier.js";import{f as b,P as I,K as v,e as $,k as z,T as G,E as k,j as O,c as D,r as L,s as F,t as J,v as Y,w as U}from"./Transformation2D.js";import{O as X}from"./OperatorShapePreservingLength.js";import{b as j,c as B}from"./tslib.es6.js";import{a as H}from"./GeodeticDistanceCalculator-B5uO-Y_z.js";class Q{constructor(e,t,i,s,n=100){this.m_startPt=e.clone(),this.m_endPt=t.clone(),this.m_cE2=s,this.m_cE=Math.sqrt(this.m_cE2),this.m_c1By2e=1/(2*this.m_cE),this.m_cRpu=i.getGCS().getUnit().getUnitToBaseFactor(),this.isPcs=2===i.getCoordinateSystemType(),this.PEProjcs=i.getPECoordSys(),this.m_points=new Array(2*n)}setSegmentEndPoints(e,t){this.m_startPt.assign(e),this.m_endPt.assign(t)}makeFunctor(){return e=>{const t=[0,0];t[0]=this.m_startPt.x*(1-e)+this.m_endPt.x*e,t[1]=this.m_startPt.y*(1-e)+this.m_endPt.y*e,this.isPcs&&E.projToGeogCenter(this.PEProjcs,1,t,0);const i=Math.sin(t[1]*this.m_cRpu);if(0===this.m_cE2)return i;return-Math.log((1-this.m_cE*i)/(1+this.m_cE*i))*this.m_c1By2e+i/(1-this.m_cE2*i*i)}}makeArrayFunctor(){return n(0),{}}}function V(e,t,i){const s=new o;e.queryEnvelope(s);const n=m(t,s,!0).total(),a=t.getPannableExtent();a.xmin=s.xmin-10*n,a.xmax=s.xmax+10*n;const _=(new l).execute(e,a,t,i).getImpl().querySegmentIterator();_.stripAttributes();const r=f();t.querySpheroidData(r);const h=r.e2,u=0===h?2:1,c=new I(0,0),g=new I(0,0),d=new v(0),E=new Q(c,g,t,h,100);for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment();c.assign(e.getStartXY()),g.assign(e.getEndXY()),E.setSegmentEndPoints(c,g);const t=p(6,0,1,1e-12,1e-15,E.makeFunctor());d.pe((g.x-c.x)*t)}const P=r.majorSemiAxis;return u*P*P*(1-h)*Math.PI*d.getResult()/t.getPannableExtent().width()}function Z(e,t,i,s,n){const a=se(e,t,n);let _=W(e,a.first,i,s,n),r=1,h=0,o=0;do{if(r++,a.first*=.5,a.first<50*t.getTolerance(0))return _;a.second*=2,o=W(e,a.first,i,s,n),h=Math.abs(o-_),_=o}while(Math.abs(_)>1&&h>1e-8*Math.abs(_)&&(a.second<65e3&&r<8||r<4));return o}function W(e,t,i,s,n){const a=(new _).execute(e,t,0,0,n);let r;r=s?(new u).execute(a,s,n):a;const h=1===i.getUnit().getUnitToBaseFactor()?Math.PI/180:1,m=new o;r.queryEnvelope(m);const l=new o,p=new o,c=new o;l.setCoords({xmin:m.xmin,ymin:75*h,xmax:m.xmax,ymax:90*h}),p.setCoords({xmin:m.xmin,ymin:-60*h,xmax:m.xmax,ymax:75*h}),c.setCoords({xmin:m.xmin,ymin:-90*h,xmax:m.xmax,ymax:-60*h}),l.inflateCoords(.01*l.width(),0),p.inflateCoords(.01*p.width(),0),c.inflateCoords(.01*c.width(),0);let g=0;return g+=K(r,l,i,n),g+=K(r,p,i,n),g+=K(r,c,i,n),g}function K(e,t,i,s){const n=(new l).execute(e,t,i,s);if(null!==n&&!n.isEmpty()){const e=new o;n.queryEnvelope(e);const{first:t,second:a}=ie(i,e,!1),_=r(i,t,null),h=(new u).execute(n,_,s).calculateArea2D();return a&&t.destroy(),h}return 0}const ee=[null,null,null,null,null,null,null];function te(e,t,i){const a=e.getUnit().getUnitToBaseFactor(),_=t.getCenter();_.scale(180*a/Math.PI);const r=new I;r.x=0,r.y=0;let h=0;if(0===h){_.y>45?(r.y=$,h=0):_.y<-45?(r.y=-$,h=1):_.x>=45&&_.x<135?(r.x=$,h=2):_.x>=135||_.x<-135?(r.x=$,h=3):_.x<-45&&_.x>=-135?(r.x=-$,h=4):(r.x=0,h=5);const e=a*Math.sqrt(z(t.xmin-t.xmax)+z(t.ymin-t.ymax)),i=r.clone(),s=t.getCenter();s.scale(a),h<2&&(i.x=s.x);if(I.distance(i,s)+.5*e>$)return null}const o=ee[h];if(null!==o&&o.getGCS().equalHorizontal(e))return o;const m=e.getText(),l=r.x,p=r.y,u=0,E=0;let f=0,P=-1;6!==h?P=c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA:(n(i),f=0,P=c.PE_PRJ_CYLINDRICAL_EQAREA);const S=g("EqualAreaPCS");let A;P===c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA?A=`PROJCS["${S}",${m},PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${u}],PARAMETER["False_Northing",${E}],PARAMETER["Central_Meridian",${l}],PARAMETER["Latitude_of_Origin",${p}],UNIT["Meter",1.0]]`:P===c.PE_PRJ_CYLINDRICAL_EQAREA?A=`PROJCS["${S}",${m},PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting",${u}],PARAMETER["False_Northing",${E}],PARAMETER["Central_Meridian",${l}],PARAMETER["Standard_Parallel_1",${f}],PARAMETER["Latitude_of_Origin",${p}],UNIT["Meter",1.0]]`:s("getEqualAreaPcsFixed");const x=d(A);return ee[h]&&ee[h].destroy(),ee[h]=x,x}function ie(e,t,i){const n=te(e,t,i);if(null!==n)return b(n,!1);const a=e.getText(),_=e.getUnit().getUnitToBaseFactor(),r=(t.xmin+t.width()/2)*_,h=(t.ymin+t.height()/2)*_,o=0,m=0;let l=0,p=0,u=-1;t.ymin*_>=75*Math.PI/180||t.ymax*_<=-60*Math.PI/180?u=c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA:t.ymin>0||t.ymax<0?(l=(t.ymin+1/3*t.height())*_,p=(t.ymin+2/3*t.height())*_,u=c.PE_PRJ_ALBERS):(l=(t.ymin+2/3*t.height())*_,u=c.PE_PRJ_CYLINDRICAL_EQAREA);const E=g("EqualAreaPCS");let f;return u===c.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA?f=`PROJCS["${E}",${a},PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:u===c.PE_PRJ_ALBERS?f=`PROJCS["${E}",${a},PROJECTION["Albers"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Standard_Parallel_1",${l}],PARAMETER["Standard_Parallel_2",${p}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:u===c.PE_PRJ_CYLINDRICAL_EQAREA?f=`PROJCS["${E}",${a},PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting",${o}],PARAMETER["False_Northing",${m}],PARAMETER["Central_Meridian",${r}],PARAMETER["Standard_Parallel_1",${l}],PARAMETER["Latitude_of_Origin",${h}],UNIT["Meter",1.0]]`:s("getEqualAreaPCSInstance"),b(d(f),!0)}function se(e,t,i){const s=e.calculateLength2D(),n=(new X).execute(e,t,i)/25e3,a=s/e.getSegmentCount()*2;let _=Math.min(a,s/n);0===_&&(_=1);return b(_,s/_)}class ne{getOperatorType(){return 10314}supportsCurves(){return!0}accelerateGeometry(e,t,i){return!1}canAccelerateGeometry(e){return!1}execute(s,n,o){if(n&&0!==n.getCoordinateSystemType()||e(""),s.isEmpty()||s.getDimension()<2)return 0;if(t(s),s.getGeometryType()===i.enumEnvelope){const e=new a;return e.addEnvelope(s,!1),this.execute(e,n,o)}let m=s;s.getDescription().getAttributeCount()>1&&(m=s.clone(),m.dropAllAttributes());const l=(new _).execute(m,0,n.getTolerance(0),0,o);let p=null;const u=n.getGCS();u!==n&&(p=r(n,u));let c=(new h).execute(l,n,!1,o);return c.isEmpty()?0:(c===s&&(c=s.clone()),n.isPannable()?V(c,n,o):Z(c,n,u,p,o))}}function ae(){return{m_p_PCS:new I,m_factor:Number.NaN,setValues:_e,assign:re}}function _e(e,t){this.m_factor=e,this.m_p_PCS.assign(t)}function re(e){this.m_factor=e.m_factor,this.m_p_PCS.assign(e.m_p_PCS)}class he{constructor(e,t,i,s){this.m_ptStart=new T,this.m_ptEnd=new T,this.m_ptStart.assign(t),this.m_ptEnd.assign(i),this.m_deltaX=this.m_ptEnd.x-this.m_ptStart.x,this.m_deltaY=this.m_ptEnd.y-this.m_ptStart.y,this.m_e=Math.sqrt(e),this.m_e2=e,this.m_c1MinusE2=1-e;const n=Math.sin(s);let a;a=0===this.m_e2?2*n:n*(Y(this.m_e*n)+1/(1-this.m_e2*n*n)),this.m_baseA=a}setSegmentEndPoints(e,t){this.m_ptStart.assign(e),this.m_ptEnd.assign(t),this.m_deltaX=this.m_ptEnd.x-this.m_ptStart.x,this.m_deltaY=this.m_ptEnd.y-this.m_ptStart.y}makeFunctor(){return e=>{const t=1-e,i=t*this.m_ptStart.x+e*this.m_ptEnd.x,s=t*this.m_ptStart.y+e*this.m_ptEnd.y,n=t*this.m_ptStart.z+e*this.m_ptEnd.z,a=i*i+s*s,_=n/Math.sqrt(n*n+this.m_c1MinusE2*this.m_c1MinusE2*a);let r;if(0===this.m_e2)r=2*_;else{r=_*(Y(this.m_e*_)+1/(1-this.m_e2*_*_))}return(this.m_deltaY*i-this.m_deltaX*s)/a*(r-this.m_baseA)}}}function oe(){return{e:Number.NaN,one_p_e:Number.NaN,one_m_e:Number.NaN,one_m_e_2:Number.NaN,atanh_e_over_e:Number.NaN,half_qp:Number.NaN,f:Number.NaN,z:Number.NaN}}function me(){return{sin_phi:Number.NaN,one_p_sin_phi:Number.NaN,one_m_sin_phi:Number.NaN,one_m_e_2_sin_2_phi:Number.NaN,sin_half_phi_pf:Number.NaN,sin_half_phi_pz:Number.NaN,sin_half_asin_e_sin_phi_pf:Number.NaN,sin_half_asin_e_sin_phi_pz:Number.NaN,atanh_sin_phi:Number.NaN,atanh_esin_phi:Number.NaN,make_negative:!1,initialize:le,changeSign:pe,assign:ue,clone:ce}}function le(e,t,i,s){const n=.5*e;this.sin_phi=Math.sin(e);const a=t*this.sin_phi,_=.5*Math.asin(a);this.one_p_sin_phi=1+this.sin_phi,this.one_m_sin_phi=1-this.sin_phi,this.one_m_e_2_sin_2_phi=(1+a)*(1-a),this.sin_half_phi_pf=Math.sin(n+i),this.sin_half_phi_pz=Math.sin(n+s),this.sin_half_asin_e_sin_phi_pf=Math.sin(_+i),this.sin_half_asin_e_sin_phi_pz=Math.sin(_+s),this.atanh_sin_phi=Math.log(this.sin_half_phi_pf/this.sin_half_phi_pz),this.atanh_esin_phi=Math.log(this.sin_half_asin_e_sin_phi_pf/this.sin_half_asin_e_sin_phi_pz)}function pe(){this.sin_phi=-this.sin_phi;let e=this.one_p_sin_phi;this.one_p_sin_phi=this.one_m_sin_phi,this.one_m_sin_phi=e,e=this.sin_half_phi_pf,this.sin_half_phi_pf=this.sin_half_phi_pz,this.sin_half_phi_pz=e,e=this.sin_half_asin_e_sin_phi_pf,this.sin_half_asin_e_sin_phi_pf=this.sin_half_asin_e_sin_phi_pz,this.sin_half_asin_e_sin_phi_pz=e,this.atanh_sin_phi=-this.atanh_sin_phi,this.atanh_esin_phi=-this.atanh_esin_phi}function ue(e){this.sin_phi=e.sin_phi,this.one_p_sin_phi=e.one_p_sin_phi,this.one_m_sin_phi=e.one_m_sin_phi,this.one_m_e_2_sin_2_phi=e.one_m_e_2_sin_2_phi,this.sin_half_phi_pf=e.sin_half_phi_pf,this.sin_half_phi_pz=e.sin_half_phi_pz,this.sin_half_asin_e_sin_phi_pf=e.sin_half_asin_e_sin_phi_pf,this.sin_half_asin_e_sin_phi_pz=e.sin_half_asin_e_sin_phi_pz,this.atanh_sin_phi=e.atanh_sin_phi,this.atanh_esin_phi=e.atanh_esin_phi,this.make_negative=e.make_negative}function ce(){return{...this}}class ge{constructor(t,i,s){this.m_transformPCS2GCS=null,this.m_scaleToRadians=new G,this.m_scaleToDegrees=new G,this.m_progressTracker=s,n(4!==i),this.m_curveType=i,this.m_inputSR=t,t&&0!==t.getCoordinateSystemType()||e(""),this.m_inputGCS=t.getGCS(),this.m_a=0,this.m_eSquared=0,this.m_b=0,this.m_rpu=0}executePolygonGeodeticArea(e){let t,i=e.clone();if(i.dropAllAttributes(),e.hasNonLinearSegments()){i=(new _).execute(i,0,this.m_inputSR.getTolerance(0),0,this.m_progressTracker)}if(this.m_inputSR.isPannable()){const e=new o;i.queryEnvelope(e);const t=this.m_inputSR.getPannableExtent();if(!t.containsEnvelope(e)){const s=t.getCenterX()-e.getCenterX(),n=new G;n.setShiftCoords(s,0),i.applyTransformation(n),e.move(s,0);const a=new k;t.queryIntervalX(a);const _=new k;e.queryIntervalX(_),i=a.contains(_)?P(i,this.m_inputSR):(new u).foldInto360RangeGeodetic(i,this.m_inputSR,this.m_curveType)}}if(this.m_transformPCS2GCS?(i=(new h).execute(i,this.m_inputSR,!1,this.m_progressTracker),t=i.createInstance(),S(this.m_transformPCS2GCS,i,t,this.m_progressTracker)||(t=(new u).execute(i,this.m_transformPCS2GCS,this.m_progressTracker))):t=(new h).execute(i,this.m_inputGCS,!1,this.m_progressTracker),t.isEmpty())return 0;if(1===this.m_curveType){const e=f();return this.m_inputGCS.querySpheroidData(e),this.m_a=e.majorSemiAxis,this.m_eSquared=e.e2,this.loxodromeArea(t)}const s=t.getImpl();this.m_rpu=this.m_inputGCS.getUnit().getUnitToBaseFactor(),this.m_scaleToRadians.setScale(this.m_rpu),s.applyTransformation(this.m_scaleToRadians),this.m_scaleToDegrees=this.m_scaleToRadians,this.m_scaleToDegrees.invertThis();const n=f();if(this.m_inputGCS.querySpheroidData(n),this.m_a=n.majorSemiAxis,this.m_b=n.minorSemiAxis,this.m_eSquared=n.e2,2===this.m_curveType)return this.executeClippedPolygonGreatEllipticArea(t);{const e={stack:[],error:void 0,hasError:!1};try{const i=A.unit(9101),s=this.m_inputGCS.getPECoordSys(),n=j(e,s.cloneAlterUnits(i),!1);let a,_,r=this.executeClippedPolygonGeodeticArea(t,n,0),h=0;do{h++,a=this.executeClippedPolygonGeodeticArea(t,n,h),_=Math.abs(a-r),r=a}while(Math.abs(a)>1&&_>1e-8*Math.abs(a)&&h<7);return a}catch(a){e.error=a,e.hasError=!0}finally{B(e)}}}executeClippedPolygonGeodeticArea(e,t,i){const s={stack:[],error:void 0,hasError:!1};try{const n=new o;e.queryEnvelope(n);const a=j(s,this.getEqualAreaPCSInstance(t,n),!1),_=e.clone();x(a,_);const r=50,h=_.getImpl().getAttributeStreamRef(0),m=e.getImpl().getAttributeStreamRef(0),l=j(s,new y,!1),p=j(s,new y,!1),u=40,c=[0,0],g=O(ae,u),d=D(u,-1),f=ae(),P=ae();let S,A;const M=a;let C=_.calculateArea2D();const T=new v(0),w=.5*Math.PI,q=1e-10*Math.abs(C)+1e-6,N=e.getPathCount();let b,$,z,G;const k=new I,F=new I,J=new I,Y=new I,U=new I,X=new I;let B,H;for($=e.getPathStart(0),b=0;b<N;b++,$=z)for(z=e.getPathEnd(b),h.queryPoint2D(z-1<<1,J),m.queryPoint2D(z-1<<1,k),Math.abs(k.y)>w&&(k.y=L(w,k.y)),G=$;G<z;G++,J.assign(Y),k.assign(F)){if(h.queryPoint2D(G<<1,Y),m.queryPoint2D(G<<1,F),Math.abs(F.y)>w&&(F.y=L(w,F.y)),B=I.distance(J,Y),B<r||0===k.y&&0===F.y)continue;R.geodeticDistance(this.m_a,this.m_eSquared,k.x,k.y,F.x,F.y,l,p,null,this.m_curveType);const e=l.val,t=p.val;for(f.setValues(0,J),P.setValues(1,Y),A=i,g[0].assign(P),d[0]=i,S=0;S>=0;){H=.5*(f.m_factor+P.m_factor),R.geodeticCoordinate(this.m_a,this.m_eSquared,k.x,k.y,e*H,t,l,p,this.m_curveType),U.x=l.val,U.y=p.val,c[0]=U.x,c[1]=U.y,E.geogToProj(M,1,c),X.x=c[0],X.y=c[1];const i=-X.offset(f.m_p_PCS,P.m_p_PCS),s=.5*i*I.distance(f.m_p_PCS,P.m_p_PCS);if(T.pe(s),Math.abs(s)>q||Math.abs(s)>0&&A>0)P.setValues(H,X),S++,g[S].assign(P),Math.abs(s)<=q?(A--,d[S-1]=A,d[S]=A):(A=d[S-1],d[S]=A);else{if(S<=0)break;f.assign(P),S--,P.assign(g[S]),A=d[S]}}}return C+=T.getResult(),Math.abs(C)}catch(n){s.error=n,s.hasError=!0}finally{B(s)}}executeClippedPolygonGreatEllipticArea(e){const t=[],i=[],s=new I,n=new I,a=M(1,this.m_eSquared,new I(0,.5*Math.PI)),_=new v(0),r=new v(0),h=new v(0),m=new T,l=new T,p=new o;e.queryLooseEnvelope(p);let u=0;p.containsCoords(p.xmin,0)||(u=Math.abs(p.ymin)<Math.abs(p.ymax)?p.ymin:p.ymax);const c=new he(this.m_eSquared,m,l,u),g=this.m_a*this.m_a,d=e.getImpl().querySegmentIterator();for(d.stripAttributes();d.nextPath();)for(;d.hasNextSegment();){const e=d.nextSegment();s.assign(e.getStartXY()),n.assign(e.getEndXY()),n.x-s.x>Math.PI?s.x+=2*Math.PI:n.x-s.x<-Math.PI&&(n.x+=2*Math.PI),this.splitSegmentCrossingItegralThreshold(e,t,i);for(let i of t)m.assign(M(this.m_a,this.m_eSquared,i.getStartXY())),l.assign(M(this.m_a,this.m_eSquared,i.getEndXY())),c.setSegmentEndPoints(m,l),this.adaptiveIntegrationWithRomberg(c,_);for(let t of i){let e=t.getStartXY(),i=t.getEndXY(),s=u;e.y<0&&(i=F(e,e=i),e.y=-e.y,i.y=-i.y,s=-s);const n=M(1,this.m_eSquared,e),_=M(1,this.m_eSquared,i),o=Math.min(e.y,i.y),m=C(this.m_eSquared,e.x,i.x,s,o);r.pe(m);const l=Math.abs(C(this.m_eSquared,e.x,i.x,o,$)),p=new T;p.setSub(n,a);const c=new T;c.setSub(_,a);const d=new T;d.setCrossProductVector(p,c);let E=g*(l-.5*d.length());E=L(E,i.x-e.x),h.pe(E)}t.length=0,i.length=0}return h.getResult()+g*(.5*(1-this.m_eSquared)*_.getResult()+r.getResult())}getEqualAreaPCSInstance(e,t){const i=t.getCenterX(),s=0,n=0;let a,_;const r=t.height();let h,o;(h=t.ymin>45*Math.PI/180||t.ymax<45*-Math.PI/180)?a=L(.5*Math.PI,t.getCenterY()):(a=t.getCenterY(),_=t.ymin+r*(2/3));const m=g("EqualAreaPCS"),l=e.toString();return o=h?A.fromString(c.PE_TYPE_PROJCS,`PROJCS["${m}", ${l}, PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",${s}],PARAMETER["False_Northing", ${n}],PARAMETER["Central_Meridian", ${i}], PARAMETER["Latitude_of_Origin", ${a}], UNIT["Meter",1.0]]`):A.fromString(c.PE_TYPE_PROJCS,`PROJCS["${m}", ${l}, PROJECTION["Cylindrical_Equal_Area"],PARAMETER["False_Easting", ${s}],PARAMETER["False_Northing", ${n}],PARAMETER["Central_Meridian", ${i}],PARAMETER["Standard_Parallel_1", ${_}],PARAMETER["Latitude_of_Origin", ${a}],UNIT["Meter",1.0]]`),o}splitSegmentCrossingItegralThreshold(e,t,i){const s=100,n=20,a=n*n,_=M(this.m_a,this.m_eSquared,new I(0,$)),r=M(this.m_a,this.m_eSquared,new I(0,-$)),h=this.splitSegmentPassingThroughPole(e);for(let o of h){const e=o.getStartXY(),h=o.getEndXY(),m=M(this.m_a,this.m_eSquared,e),l=M(this.m_a,this.m_eSquared,h),p=new I,u=new T;let c=T.sqrDistance(_,m),g=T.sqrDistance(m,l);if(c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(m.add(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:e,end:p})),e.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),c=T.sqrDistance(_,l),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(l.sub(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:p,end:h})),h.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),l.assign(M(this.m_a,this.m_eSquared,h)),c=T.sqrDistance(r,m),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(m.add(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:e,end:p})),e.assign(p)}if(m.assign(M(this.m_a,this.m_eSquared,e)),l.assign(M(this.m_a,this.m_eSquared,h)),c=T.sqrDistance(r,l),g=T.sqrDistance(m,l),c<=s){if(!(g>a)){i.push(new q({start:e,end:h}));continue}u.assign(l.sub(m)),u.normalizeThis(),u.assign(l.sub(u.mul(n))),p.assign(w(this.m_a,this.m_eSquared,u)),i.push(new q({start:p,end:h})),h.assign(p)}t.push(new q({start:e,end:h}))}}splitSegmentPassingThroughPole(e){const t={stack:[],error:void 0,hasError:!1};try{const i=[],s=new T,n=new T,a=new T,_=new I,r=20,h=3.124139361,o=10,m=e.getStartXY(),l=e.getEndXY(),p=j(t,new y,!1);if(R.geodeticDistance(this.m_a,this.m_eSquared,m.x,m.y,l.x,l.y,p,null,null,2),Math.abs(l.x-m.x)>h&&p.val>r){const e=new H(new I(0,90),m.divide(this.m_rpu),l.divide(this.m_rpu),this.m_inputGCS,2,2);let t=N(e.makeFunctor(),0,1,1e-10);if(t.second<=o&&t.first>0&&t.first<1)return s.assign(M(this.m_a,this.m_eSquared,m)),n.assign(M(this.m_a,this.m_eSquared,l)),J(s,n,t.first,a),_.assign(w(this.m_a,this.m_eSquared,a)),i.push(new q({start:m,end:_})),i.push(new q({start:_,end:l})),i;if(e.setPointDistFrom(new I(0,-90)),t=N(e.makeFunctor(),0,1,1e-10),t.second<=o&&t.first>0&&t.first<1)return s.assign(M(this.m_a,this.m_eSquared,m)),n.assign(M(this.m_a,this.m_eSquared,l)),J(s,n,t.first,a),_.assign(w(this.m_a,this.m_eSquared,a)),i.push(new q({start:m,end:_})),i.push(new q({start:_,end:l})),i}return i.push(new q({start:m,end:l})),i}catch(i){t.error=i,t.hasError=!0}finally{B(t)}}adaptiveIntegrationWithRomberg(e,t){const i=e.makeFunctor();let s=0,n=1,a=i(s),_=i(n);const r=1e-17,h=1e-14;let o=(s+n)/2,m=i(o),l=Math.abs(m-a),u=Math.abs(_-m),c=0;for(;c++<32&&(l/u<.1||u/l<.1);)l<u?(t.pe(p(5,s,o,h,r,i)),s=o,a=m):(t.pe(p(5,o,n,h,r,i)),n=o,_=m),o=(s+n)/2,m=Math.abs(i(o)),l=Math.abs(m-a),u=Math.abs(_-m);t.pe(p(5,s,n,h,r,i))}loxodromeAreaHemi(e,t,i,s,n){const a=i.clone(),_=n.clone();let r,h,o,m,l,p,u,c,g,d,E,f,P,S,A,x;return a.make_negative&&a.changeSign(),_.make_negative&&_.changeSign(),E=s-t,1===Math.abs(a.sin_phi)||1===Math.abs(_.sin_phi)?e.half_qp*E:a.sin_phi===_.sin_phi?(d=.5*e.one_m_e_2*a.sin_phi*(1/a.one_m_e_2_sin_2_phi+Y(e.e*a.sin_phi))*E,d):(A=Math.log(_.sin_half_phi_pf*a.sin_half_phi_pz/(_.sin_half_phi_pz*a.sin_half_phi_pf)),x=Math.log(_.sin_half_asin_e_sin_phi_pf*a.sin_half_asin_e_sin_phi_pz/(_.sin_half_asin_e_sin_phi_pz*a.sin_half_asin_e_sin_phi_pf)),1===this.m_eSquared?(l=0,r=.5*(A+_.sin_phi/_.one_m_e_2_sin_2_phi-a.sin_phi/a.one_m_e_2_sin_2_phi),h=0):(l=-2*e.atanh_e_over_e*(Math.log(_.one_p_sin_phi/a.one_p_sin_phi)-e.e*x),r=(A-e.e*x)/e.one_m_e_2,h=(Math.log(_.one_m_e_2_sin_2_phi/a.one_m_e_2_sin_2_phi)+l/e.atanh_e_over_e)/e.one_m_e_2),o=-x*(a.atanh_esin_phi+_.atanh_esin_phi),m=1/a.one_m_e_2_sin_2_phi-1/_.one_m_e_2_sin_2_phi,p=U(_.one_m_sin_phi/e.one_p_e,e.e)-U(a.one_m_sin_phi/e.one_p_e,e.e),u=U(_.one_p_sin_phi/e.one_p_e,e.e)-U(a.one_p_sin_phi/e.one_p_e,e.e),c=U(a.one_m_sin_phi/-e.one_m_e,e.e)-U(_.one_m_sin_phi/-e.one_m_e,e.e),g=U(a.one_p_sin_phi/-e.one_m_e,e.e)-U(_.one_p_sin_phi/-e.one_m_e,e.e),d=.25/r*(h+o+m+l+.5*(p+u+c+g)),d+=e.half_qp,f=.5*e.one_m_e_2*a.sin_phi*(1/a.one_m_e_2_sin_2_phi+Y(e.e*a.sin_phi)),P=.5*e.one_m_e_2*_.sin_phi*(1/_.one_m_e_2_sin_2_phi+Y(e.e*_.sin_phi)),P<f&&(S=f,f=P,P=S),d<f&&(d=f),d>P&&(d=P),d*=E,d)}loxodromeArea(e){const t=Math.PI/180;let i=0;const s=oe(),n=me(),a=me();s.e=Math.sqrt(this.m_eSquared),s.one_p_e=1+s.e,s.one_m_e=1-s.e,s.one_m_e_2=1-this.m_eSquared,s.atanh_e_over_e=Y(s.e),this.m_eSquared>=1?s.half_qp=1:s.half_qp=.5*(1+s.atanh_e_over_e*s.one_m_e_2),s.f=.25*Math.PI,s.z=.75*Math.PI,a.initialize(0,s.e,s.f,s.z);const _=e.getPathCount(),r=new I,h=new I,o=e.getImpl().getAttributeStreamRef(0);for(let m=0;m<_;m++){const _=e.getPathStart(m),l=e.getPathEnd(m);if(!(l-_<=1)){o.queryPoint2D(2*(l-1),r);for(let e=_;e<l;e++){o.queryPoint2D(2*e,h);const m=r.y*t,l=h.y*t;if(e===_?(n.initialize(m,s.e,s.f,s.z),n.make_negative=!1):n.assign(a),a.initialize(l,s.e,s.f,s.z),a.make_negative=!1,r.y*h.y<0){if(r.y>=90&&h.y<=-90||h.y>=90&&r.y<=-90)return Number.NaN;const e=me();e.initialize(0,s.e,s.f,s.z),e.make_negative=!1;const _=n.atanh_sin_phi-s.e*n.atanh_esin_phi,o=a.atanh_sin_phi-s.e*a.atanh_esin_phi,l=(o*r.x-_*h.x)/(o-_);m<0?(n.make_negative=!0,i-=this.loxodromeAreaHemi(s,r.x*t,n,l*t,e),n.make_negative=!1,i+=this.loxodromeAreaHemi(s,l*t,e,h.x*t,a)):(i+=this.loxodromeAreaHemi(s,r.x*t,n,l*t,e),a.make_negative=!0,i-=this.loxodromeAreaHemi(s,l*t,e,h.x*t,a),a.make_negative=!1)}else r.y>=0?i+=this.loxodromeAreaHemi(s,r.x*t,n,h.x*t,a):(n.make_negative=!0,a.make_negative=!0,i-=this.loxodromeAreaHemi(s,r.x*t,n,h.x*t,a),n.make_negative=!1,a.make_negative=!1);r.assign(h)}}}return this.m_a*i*this.m_a}calculate(e){if(e.isEmpty()||e.getDimension()<2)return 0;if(e.getGeometryType()===i.enumEnvelope){const t=new a;return t.addEnvelope(e,!1),this.calculate(t)}return this.m_inputSR!==this.m_inputGCS&&null===this.m_transformPCS2GCS&&(this.m_transformPCS2GCS=r(this.m_inputSR,this.m_inputGCS,null)),this.executePolygonGeodeticArea(e)}}class de{getOperatorType(){return 10311}supportsCurves(){return!0}accelerateGeometry(e,t,i){return!1}canAccelerateGeometry(e){return!1}execute(e,i,s,n){if(t(e),4===s)return(new ne).execute(e,i,n);return new ge(i,s,n).calculate(e)}}export{de as OperatorGeodeticArea};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{d as r,t as s,a as i}from"./Geometry.js";import{
|
|
5
|
+
import{S as e,G as t}from"./SimpleGeometryCursor.js";import{d as r,t as s,a as i}from"./Geometry.js";import{N as n}from"./QuadraticBezier.js";class m{getOperatorType(){return 10310}supportsCurves(){return!0}accelerateGeometry(e,t,r){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,r,s,i){return new a(e,r,s,t,-1,-1,i)}execute(t,r,s,i,n){const m=new e([t]);return this.executeMany(m,r,s,i,n).next()}}class a extends t{constructor(e,t,i,n,m,a,o){super(),this.m_progressTracker=o,a>0&&r(""),4!==i&&m>0&&r(""),t||s("");0===t.getCoordinateSystemType()&&s(""),n>0||m>0||s(""),this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=t,this.m_curveType=i,this.m_maxLengthMeters=n,this.m_maxDeviationMeters=m,this.m_maxAngle=a}next(){{let e;for(;e=this.m_inputGeoms.next();)return i(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.geodeticDensify(e);return null}}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}geodeticDensify(e){return n(e,this.m_spatialReference,this.m_curveType,this.m_maxLengthMeters,this.m_maxDeviationMeters,this.m_progressTracker)}}export{m as OperatorGeodeticDensifyByLength,a as OperatorGeodeticDensifyCursor};
|