Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@id-sdk/extent
Advanced tools
📦 Extent class for creating bounding boxes
npm install @id-sdk/extent
This library is distributed in ESM format only. It cannot be require()
'd from CommonJS.
For more, please read Sindre Sorhus’s FAQ.
import { Extent } from '@id-sdk/extent';
This project is just getting started! 🌱
We're not able to support external contributors at this time, but check back in a bit when things have matured.
# new Extent(otherOrMin?: Extent | Vec2, max?: Vec2) <>
Constructs a new Extent.
const e1 = new Extent(); // construct an initially empty extent
const e2 = new Extent([0, 0]); // construct as a point (min and max both [0, 0])
const e3 = new Extent([0, 0], [5, 5]); // construct as a point with given min and max
const e4 = new Extent(e3); // copy an Extent to a new Extent
# equals(other: Extent): boolean <>
Test whether extent equals another extent. Returns true
if they are equal, false
if not.
const a = new Extent([0, 0], [10, 10]);
const b = new Extent([0, 0], [10, 10]);
const c = new Extent([0, 0], [12, 12]);
a.equals(b); // returns true
a.equals(c); // returns false
Returns the area of an extent.
new Extent([0, 0], [5, 10]).area(); // returns 50
Returns the center point of an extent.
new Extent([0, 0], [5, 10]).center(); // returns [2.5, 5]
Returns an array rectangle as [minX, minY, maxX, maxY]
.
new Extent([0, 0], [5, 10]).rectangle(); // returns [0, 0, 5, 10]
Returns a string representation of this extent's rectangle formatted as "minX,minY,maxX,maxY"
. This is often used to request a bounding box from a REST API.
new Extent([0, 0], [5, 10]).toParam(); // returns '0,0,5,10'
Returns a BBox Object with minX
, minY
, maxX
, maxY
properties.
new Extent([0, 0], [5, 10]).bbox(); // returns { minX: 0, minY: 0, maxX: 5, maxY: 10 };
Returns an array of coordinates as a polygon representing the extent wound clockwise.
new Extent([0, 0], [5, 10]).polygon(); // returns [[0, 0], [0, 10], [5, 10], [5, 0], [0, 0]]
# contains(other: Extent): boolean <>
Test whether this extent fully contains another extent. Returns true
if it does, false
if not.
const a = new Extent([0, 0], [5, 5]);
const b = new Extent([1, 1], [2, 2]);
a.contains(b); // returns true
b.contains(a); // returns false
# intersects(other: Extent): boolean <>
Test whether this extent intersects another extent. Returns true
if it does, false
if not.
const a = new Extent([0, 0], [5, 5]);
const b = new Extent([1, 1], [6, 6]);
a.intersects(b); // returns true
b.intersects(a); // returns true
# intersection(other: Extent): Extent <>
Returns a new Extent representing the intersection of this and other extent.
const a = new Extent([0, 0], [5, 5]);
const b = new Extent([1, 1], [6, 6]);
a.intersection(b); // returns new Extent { min: [ 1, 1 ], max: [ 5, 5 ] }
b.intersection(a); // returns new Extent { min: [ 1, 1 ], max: [ 5, 5 ] }
# percentContainedIn(other: Extent): number <>
Returns the percent of other extent contained within this extent, by area.
const a = new Extent([0, 0], [4, 1]);
const b = new Extent([3, 0], [4, 2]);
a.percentContainedIn(b); // returns 0.25
b.percentContainedIn(a); // returns 0.5
# extend(other: Extent): Extent <>
Extend the bounds of an extent, returning a new Extent. This method does not modify the original or other extents.
const a = new Extent([0, 0], [5, 10]);
const b = new Extent([4, -1], [5, 10]);
const c = a.extend(b); // returns new Extent { min: [ 0, -1 ], max: [ 5, 10 ] }
# padByMeters(meters: number): Extent <>
Returns a new Extent representing the current extent (assumed to be defined in WGS84 geographic coordinates) padded by given meters. This method does not modify the original extent.
All of the Extent methods are designed to be used in an immutable programming style, and return new Extents instead of modifying the original object.
const a = new Extent();
const b = new Extent([0, 0], [5, 5]);
const c = a.extend(b); // `extend` returns a new Extent, does not modify a or b
However we make the min
and max
properties publicly mutable, in case you need to modify an extent bounds directly for performance reasons.
const a = new Extent(); // construct an initially empty extent
a.min = [0, 0]; // adjust its min/max later
a.max = [5, 5];
# Vec2
An array of two numbers.
[number, number]
# BBox
An Object containing minX
, minY
, maxX
, maxY
numbers.
{ minX: number, minY: number, maxX: number, maxY: number }
FAQs
Extent class for creating bounding boxes
We found that @id-sdk/extent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.