@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.93 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{NumericIdentifiableMixin as t}from"../../../core/Identifiable.js";import o from"../../../core/Logger.js";import{isNone as s}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{project as a}from"../../../geometry/projection.js";import{extentContainsPoint as m,polygonContainsPoint as c}from"../../../geometry/support/contains.js";import{nearestCoordinate as p}from"../../../geometry/support/near.js";var l;let y=l=class extends(t(r)){constructor(e){super(e),this.geometry=null,this.spatialReference=null}get normalizedGeometry(){if(s(this.geometry)||!this.spatialReference)return null;if(!this.spatialReference.equals(this.geometry.spatialReference))try{return a(this.geometry,this.spatialReference)}catch(e){return o.getLogger(this.declaredClass).error("#constraints.geometry","could not project the geometry to the view's spatial reference",{geometry:this.geometry,spatialReference:this.spatialReference,error:e}),null}return this.geometry}constrain(e,r){if(s(this.normalizedGeometry))return e;const t=e.targetGeometry;if("extent"===this.normalizedGeometry.type?m(this.normalizedGeometry,t):c(this.normalizedGeometry,t))return e;const{coordinate:o}=p(this.normalizedGeometry,t);return o?(e.targetGeometry=o,e):e}clone(){return new l({geometry:this.geometry?.clone(),spatialReference:this.spatialReference?.clone()})}};e([i({constructOnly:!0})],y.prototype,"geometry",void 0),e([i({readOnly:!0})],y.prototype,"normalizedGeometry",null),e([i({constructOnly:!0})],y.prototype,"spatialReference",void 0),y=l=e([n("esri.views.2d.constraints.GeometryConstraint")],y);export{y as GeometryConstraint};