withinOperator

AMD: require(["esri/geometry/operators/withinOperator"], (withinOperator) => { /* code goes here */ });
ESM: import * as withinOperator from "@arcgis/core/geometry/operators/withinOperator.js";
Object: esri/geometry/operators/withinOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

Perform a relational operation to determine if one 2D geometry is within another 2D geometry. Geometry A is within geometry B, when A is the intersection of A and B.

Geometry A can be non-simple geometry.

Method Overview

Name Return Type Summary Object

Accelerate a geometry.

withinOperator

Perform a within operation on two geometries.

withinOperator

Method Details

accelerateGeometry

Method
accelerateGeometry(geometry){Boolean}

Accelerate a geometry. This method prepares the geometry for faster within operations when the same geometry is tested multiple times (e.g. in a loop with hundreds of iterations).

Parameter
geometry Geometry

The geometry to accelerate.

Returns
Type Description
Boolean Returns true if the geometry was successfully accelerated.

execute

Method
execute(inner, outer){Boolean}

Perform a within operation on two geometries.

Parameters
inner Geometry

The base geometry that is tested for the "within" relationship with outer.

outer Geometry

The comparison geometry that is tested for the "contains" relationship with inner.

Returns
Type Description
Boolean Returns true if inner is within outer.
Example
Returns true if a geometry is completely within another
const isWithin = withinOperator.execute(polygon1, polygon2);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.