UNPKG

@arcgis/core

Version:

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

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