@id-sdk/extent
Advanced tools
Comparing version 3.0.0-pre.8 to 3.0.0-pre.9
@@ -12,3 +12,3 @@ import { Vec2 } from '@id-sdk/vector'; | ||
constructor(other?: Extent | Vec2, max?: Vec2); | ||
equals(other: Extent | Vec2, max?: Vec2): boolean; | ||
equals(other: Extent): boolean; | ||
area(): number; | ||
@@ -20,8 +20,8 @@ center(): Vec2; | ||
polygon(): Vec2[]; | ||
contains(other: Extent | Vec2, max?: Vec2): boolean; | ||
intersects(other: Extent | Vec2, max?: Vec2): boolean; | ||
intersection(other: Extent | Vec2, max?: Vec2): Extent; | ||
percentContainedIn(other: Extent | Vec2, max?: Vec2): number; | ||
extend(other: Extent | Vec2, max?: Vec2): Extent; | ||
contains(other: Extent): boolean; | ||
intersects(other: Extent): boolean; | ||
intersection(other: Extent): Extent; | ||
percentContainedIn(other: Extent): number; | ||
extend(other: Extent): Extent; | ||
padByMeters(meters: number): Extent; | ||
} |
{ | ||
"name": "@id-sdk/extent", | ||
"version": "3.0.0-pre.8", | ||
"version": "3.0.0-pre.9", | ||
"description": "Extent class for creating bounding boxes", | ||
@@ -31,4 +31,4 @@ "homepage": "https://github.com/ideditor/id-sdk/tree/main/packages/math/extent#readme", | ||
"dependencies": { | ||
"@id-sdk/geo": "^3.0.0-pre.7", | ||
"@id-sdk/vector": "^3.0.0-pre.7" | ||
"@id-sdk/geo": "^3.0.0-pre.9", | ||
"@id-sdk/vector": "^3.0.0-pre.9" | ||
}, | ||
@@ -38,3 +38,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "dd46ede1079e77f8146f8c1da25683563b56fb69" | ||
"gitHead": "46e77c10acbe719353d4f0b771cdc5881dfa9ea2" | ||
} |
@@ -31,3 +31,3 @@ [![npm version](https://badge.fury.io/js/%40id-sdk%2Fextent.svg)](https://badge.fury.io/js/%40id-sdk%2Fextent) | ||
* [new Extent](#constructor)(otherOrMin?: Extent | Vec2, max?: Vec2) _constructor_ | ||
* [equals](#equals)(other: any): boolean | ||
* [equals](#equals)(other: Extent): boolean | ||
* [area](#area)(): number | ||
@@ -39,6 +39,6 @@ * [center](#center)(): Vec2 | ||
* [polygon](#polygon)(): Vec2[5] | ||
* [contains](#contains)(other: any): boolean | ||
* [intersects](#intersects)(other: any): boolean | ||
* [intersection](#intersection)(other: any): Extent | ||
* [percentContainedIn](#percentContainedIn)(other: any): number | ||
* [contains](#contains)(other: Extent): boolean | ||
* [intersects](#intersects)(other: Extent): boolean | ||
* [intersection](#intersection)(other: Extent): Extent | ||
* [percentContainedIn](#percentContainedIn)(other: Extent): number | ||
* [extend](#extend)(other: any): Extent | ||
@@ -71,3 +71,3 @@ * [padByMeters](#padByMeters)(meters: number): Extent | ||
<a name="equals" href="#equals">#</a> <b>equals</b>(other: any): boolean | ||
<a name="equals" href="#equals">#</a> <b>equals</b>(other: Extent): boolean | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L38 "Source") | ||
@@ -146,3 +146,3 @@ | ||
<a name="contains" href="#contains">#</a> <b>contains</b>(other: any): boolean | ||
<a name="contains" href="#contains">#</a> <b>contains</b>(other: Extent): boolean | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L85 "Source") | ||
@@ -160,3 +160,3 @@ | ||
<a name="intersects" href="#intersects">#</a> <b>intersects</b>(other: any): boolean | ||
<a name="intersects" href="#intersects">#</a> <b>intersects</b>(other: Extent): boolean | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L96 "Source") | ||
@@ -174,3 +174,3 @@ | ||
<a name="intersection" href="#intersection">#</a> <b>intersection</b>(other: any): Extent | ||
<a name="intersection" href="#intersection">#</a> <b>intersection</b>(other: Extent): Extent | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L107 "Source") | ||
@@ -188,3 +188,3 @@ | ||
<a name="percentContainedIn" href="#percentContainedIn">#</a> <b>percentContainedIn</b>(other: any): number | ||
<a name="percentContainedIn" href="#percentContainedIn">#</a> <b>percentContainedIn</b>(other: Extent): number | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L116 "Source") | ||
@@ -202,3 +202,3 @@ | ||
<a name="extend" href="#extend">#</a> <b>extend</b>(other: any): Extent | ||
<a name="extend" href="#extend">#</a> <b>extend</b>(other: Extent): Extent | ||
[<>](https://github.com/ideditor/id-sdk/blob/main/packages/math/extent/src/extent.ts#L129 "Source") | ||
@@ -229,4 +229,5 @@ | ||
```js | ||
const e1 = new Extent(); // construct an initially empty extent | ||
const e2 = e1.extend([[0, 0], [5, 5]]); // `extend` returns a new Extent, does not modify e1 | ||
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 | ||
``` | ||
@@ -237,5 +238,5 @@ | ||
```js | ||
const e1 = new Extent(); // construct an initially empty extent | ||
e1.min = [0, 0]; // adjust its min/max later | ||
e1.max = [5, 5]; | ||
const a = new Extent(); // construct an initially empty extent | ||
a.min = [0, 0]; // adjust its min/max later | ||
a.max = [5, 5]; | ||
``` | ||
@@ -242,0 +243,0 @@ |
@@ -37,4 +37,3 @@ import { geoMetersToLat, geoMetersToLon } from '@id-sdk/geo'; | ||
// Test whether extent equals another extent | ||
equals(other: Extent | Vec2, max?: Vec2): boolean { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
equals(other: Extent): boolean { | ||
return ( | ||
@@ -85,4 +84,3 @@ this.min[0] === other.min[0] && | ||
// Test whether this extent contains another extent | ||
contains(other: Extent | Vec2, max?: Vec2): boolean { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
contains(other: Extent): boolean { | ||
return ( | ||
@@ -97,4 +95,3 @@ other.min[0] >= this.min[0] && | ||
// Test whether this extent intersects another extent | ||
intersects(other: Extent | Vec2, max?: Vec2): boolean { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
intersects(other: Extent): boolean { | ||
return ( | ||
@@ -109,4 +106,3 @@ other.min[0] <= this.max[0] && | ||
// Returns a new Extent representing the intersection of this and other extents | ||
intersection(other: Extent | Vec2, max?: Vec2): Extent { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
intersection(other: Extent): Extent { | ||
if (!this.intersects(other)) return new Extent(); | ||
@@ -120,4 +116,3 @@ return new Extent( | ||
// Returns the percent of other extent contained within this extent, by area | ||
percentContainedIn(other: Extent | Vec2, max?: Vec2): number { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
percentContainedIn(other: Extent): number { | ||
const a1 = this.intersection(other).area(); | ||
@@ -136,4 +131,3 @@ const a2 = this.area(); | ||
// Extend the bounds of an extent, returning a new Extent | ||
extend(other: Extent | Vec2, max?: Vec2): Extent { | ||
if (!(other instanceof Extent)) other = new Extent(other, max); | ||
extend(other: Extent): Extent { | ||
return new Extent( | ||
@@ -140,0 +134,0 @@ [Math.min(other.min[0], this.min[0]), Math.min(other.min[1], this.min[1])], |
Sorry, the diff of this file is not supported yet
249
17587
234
Updated@id-sdk/geo@^3.0.0-pre.9
Updated@id-sdk/vector@^3.0.0-pre.9