UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 3.86 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{G as e,S as t}from"../../../chunks/SimpleGeometryCursor.js";import{l as n,d as r,G as o,f as u,t as i}from"../../../chunks/Geometry.js";import{P as s}from"../../../chunks/Envelope.js";import{i as m,e as c,C as a,P as g,a as l,g as y,f}from"../../../chunks/QuadraticBezier.js";import{Envelope2D as p}from"../../../chunks/Envelope2D.js";class x{getOperatorType(){return 10102}supportsCurves(){return!1}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n){return new C(t,e,n)}execute(e,t){return P(e)}isConvex(e,t){if(n(e),r(e),e.isEmpty())return!0;const i=e.getGeometryType();if(i===o.enumPoint)return!0;if(i===o.enumEnvelope){const t=e;return t.getXMin()!==t.getXMax()&&t.getYMin()!==t.getYMax()}if(u(i)){const t=e;return!t.getStartXY().equals(t.getEndXY())}if(i===o.enumMultiPoint){return 1===e.getPointCount()}if(i===o.enumPolyline){const t=e;return 1===t.getPathCount()&&2===t.getPointCount()&&!t.getXY(0).equals(t.getXY(1))}if(i===o.enumGeometryCollection){const n=e;return 1===n.getGeometryCount()&&this.isConvex(n.getGeometry(0),t)}const s=e;return!(1!==s.getPathCount()||s.getPointCount()<3)&&m(s,0)}constructOrientedMinimumBoundingBox(e,t,n,r,o){c(e,t,n,r,o)}}class C extends e{constructor(e,t,n){super(),t||i(""),this.m_progressTracker=n,this.m_index=-1,this.m_bMerge=e,this.m_bDone=!1,this.m_inputGeometryCursor=t}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}next(){if(this.m_bMerge){if(!this.m_bDone){const e=h(this.m_inputGeometryCursor);return this.m_bDone=!0,e}return null}if(!this.m_bDone){const e=this.m_inputGeometryCursor.next();if(null!==e)return n(e),r(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),P(e);this.m_bDone=!0}return null}}function h(e,t){const o=new a;let u;for(;u=e.next();)n(u),r(u),o.addGeometry(u);return o.getBoundingGeometry()}function P(e,t){if(e||i(""),n(e),r(e),e.isEmpty())return e.createInstance();const m=e.getGeometryType();if(u(m)){const t=e;if(t.getStartXY().equals(t.getEndXY())){const e=new s;return t.queryStart(e),e}{const n=new s,r=new g({vd:e.getDescription()});return t.queryStart(n),r.startPathPoint(n),t.queryEnd(n),r.lineToPoint(n),r}}if(m===o.enumEnvelope){const t=e,n=new p;if(t.queryEnvelope(n),n.xmin===n.xmax&&n.ymin===n.ymax){const e=new s;return t.queryCornerByVal(0,e),e}if(n.xmin===n.xmax||n.ymin===n.ymax){const n=new s,r=new g({vd:e.getDescription()});return t.queryCornerByVal(0,n),r.startPathPoint(n),t.queryCornerByVal(1,n),r.lineToPoint(n),r}{const n=new l({vd:e.getDescription()});return n.addEnvelope(t,!1),n}}if(m===o.enumGeometryCollection)return h(y(e,-1));if(G(e)){if(m===o.enumMultiPoint){const t=e,n=new s;return t.getPointByVal(0,n),n}return e}return f(e)}function G(e,t){if(n(e),r(e),e.isEmpty())return!0;const i=e.getGeometryType();if(i===o.enumPoint)return!0;if(i===o.enumEnvelope){const t=e;return t.getXMin()!==t.getXMax()&&t.getYMin()!==t.getYMax()}if(u(i)){const t=e;return!t.getStartXY().equals(t.getEndXY())}if(i===o.enumMultiPoint){return 1===e.getPointCount()}if(i===o.enumPolyline){const t=e;return 1===t.getPathCount()&&2===t.getPointCount()&&!t.getXY(0).equals(t.getXY(1))}if(i===o.enumGeometryCollection){const t=e;return 1===t.getGeometryCount()&&G(t.getGeometry(0))}const s=e;return!(1!==s.getPathCount()||s.getPointCount()<3)&&m(s,0)}const d=new x;function M(e){return d.execute(e,null)}function v(e,n){const r=d.executeMany(new t(e),n,null);return Array.from(r)}function _(e){return d.isConvex(e,null)}function E(e,t,n,r,o){return d.constructOrientedMinimumBoundingBox(e,t,n,r,o)}function X(){return d.supportsCurves()}export{E as constructOrientedMinimumBoundingBox,M as execute,v as executeMany,_ as isConvex,X as supportsCurves};