Skip to content

meos.js


meos.js / STBox

Class: STBox

Defined in: core/types/boxes/STBox.ts:93

A spatio-temporal bounding box with an optional spatial (XYZ) dimension and an optional temporal (T) dimension.

Five WKT variants:

  • STBOX X((x1,y1),(x2,y2)) 2D spatial only
  • STBOX Z((x1,y1,z1),(x2,y2,z2)) 3D spatial only
  • STBOX T([t1, t2]) temporal only
  • STBOX XT(((x1,y1),(x2,y2)),[t1,t2]) 2D spatial + temporal
  • STBOX ZT(((x1,y1,z1),(x2,y2,z2)),[t1,t2]) 3D spatial + temporal

Geodetic variants use the GEODSTBOX prefix (SRID 4326 by default).

Example

ts
const b = STBox.fromString('STBOX XT(((1,1),(2,2)),[2020-01-01,2020-12-31])');
console.log(b.hasX());  // true
console.log(b.hasT());  // true
console.log(b.xmin());  // 1
b.free();

Constructors

Constructor

ts
new STBox(inner): STBox;

Defined in: core/types/boxes/STBox.ts:96

Parameters

inner

number

Returns

STBox

Accessors

inner

Get Signature

ts
get inner(): number;

Defined in: core/types/boxes/STBox.ts:105

Raw WASM heap pointer. Do not free directly; use free.

Returns

number

Methods

[dispose]()

ts
dispose: void;

Defined in: core/types/boxes/STBox.ts:115

Implements the using resource-management protocol calls free automatically.

Returns

void


asHexWKB()

ts
asHexWKB(variant?): string;

Defined in: core/types/boxes/STBox.ts:240

Serialises this box to a hex-encoded WKB string.

Parameters

variant?

number = 4

WKB encoding variant (default 4 = Extended WKB).

Returns

string


cmp()

ts
cmp(other): number;

Defined in: core/types/boxes/STBox.ts:602

Returns the MEOS total ordering comparison result.

Parameters

other

STBox

Returns

number

-1 if this < other, 0 if equal, 1 if this > other.


contains()

ts
contains(other): boolean;

Defined in: core/types/boxes/STBox.ts:420

true if this entirely contains other.

Parameters

other

STBox

Returns

boolean


copy()

ts
copy(): STBox;

Defined in: core/types/boxes/STBox.ts:120

Returns a deep copy of this box. The caller is responsible for calling free on the result.

Returns

STBox


distance()

ts
distance(other): number;

Defined in: core/types/boxes/STBox.ts:538

Returns the nearest-approach distance (in spatial units) between this and other. Returns 0 if the boxes overlap.

Parameters

other

STBox

Returns

number


eq()

ts
eq(other): boolean;

Defined in: core/types/boxes/STBox.ts:569

true if this and other are identical in all dimensions.

Parameters

other

STBox

Returns

boolean


expandSpace()

ts
expandSpace(d): STBox;

Defined in: core/types/boxes/STBox.ts:376

Returns a new STBox with the spatial dimension expanded by d on all sides.

Parameters

d

number

Distance to expand on each side.

Returns

STBox


expandTime()

ts
expandTime(interval): STBox;

Defined in: core/types/boxes/STBox.ts:384

Returns a new STBox with the temporal dimension expanded by the given interval on both sides.

Parameters

interval

number

Raw WASM pointer to a MEOS interval.

Returns

STBox


free()

ts
free(): void;

Defined in: core/types/boxes/STBox.ts:110

Releases the WASM-allocated memory. Must be called when the object is no longer needed.

Returns

void


ge()

ts
ge(other): boolean;

Defined in: core/types/boxes/STBox.ts:594

true if this is greater than or equal to other in MEOS total ordering.

Parameters

other

STBox

Returns

boolean


getSpace()

ts
getSpace(): STBox;

Defined in: core/types/boxes/STBox.ts:368

Returns a new STBox containing only the spatial dimension (temporal dimension stripped).

Returns

STBox


gt()

ts
gt(other): boolean;

Defined in: core/types/boxes/STBox.ts:589

true if this is strictly greater than other in MEOS total ordering.

Parameters

other

STBox

Returns

boolean


hash()

ts
hash(): number;

Defined in: core/types/boxes/STBox.ts:252

Returns a 32-bit integer hash of this box.

Returns

number


hasT()

ts
hasT(): boolean;

Defined in: core/types/boxes/STBox.ts:267

true if this box has a temporal (T) dimension.

Returns

boolean


hasX()

ts
hasX(): boolean;

Defined in: core/types/boxes/STBox.ts:257

true if this box has a spatial (XY) dimension.

Returns

boolean


hasZ()

ts
hasZ(): boolean;

Defined in: core/types/boxes/STBox.ts:262

true if this box has a Z (third spatial) dimension.

Returns

boolean


intersection()

ts
intersection(other): STBox | null;

Defined in: core/types/boxes/STBox.ts:550

Returns the intersection of this and other, or null if they are disjoint. The caller is responsible for calling free on the result.

Parameters

other

STBox

Returns

STBox | null


isAbove()

ts
isAbove(other): boolean;

Defined in: core/types/boxes/STBox.ts:473

true if this is strictly above other on the Y axis.

Parameters

other

STBox

Returns

boolean


isAdjacent()

ts
isAdjacent(other): boolean;

Defined in: core/types/boxes/STBox.ts:410

true if this and other share exactly one boundary point without overlapping.

Parameters

other

STBox

Returns

boolean


isAfter()

ts
isAfter(other): boolean;

Defined in: core/types/boxes/STBox.ts:521

true if this is entirely after other on the temporal axis.

Parameters

other

STBox

Returns

boolean


isBefore()

ts
isBefore(other): boolean;

Defined in: core/types/boxes/STBox.ts:511

true if this is entirely before other on the temporal axis.

Parameters

other

STBox

Returns

boolean


isBehind()

ts
isBehind(other): boolean;

Defined in: core/types/boxes/STBox.ts:497

true if this is strictly behind other on the Z axis.

Parameters

other

STBox

Returns

boolean


isBelow()

ts
isBelow(other): boolean;

Defined in: core/types/boxes/STBox.ts:463

true if this is strictly below other on the Y axis.

Parameters

other

STBox

Returns

boolean


isContainedIn()

ts
isContainedIn(other): boolean;

Defined in: core/types/boxes/STBox.ts:415

true if this is entirely contained within other.

Parameters

other

STBox

Returns

boolean


isFront()

ts
isFront(other): boolean;

Defined in: core/types/boxes/STBox.ts:487

true if this is strictly in front of other on the Z axis.

Parameters

other

STBox

Returns

boolean


isGeodetic()

ts
isGeodetic(): boolean;

Defined in: core/types/boxes/STBox.ts:272

true if this box uses geodetic (WGS-84) coordinates.

Returns

boolean


isLeft()

ts
isLeft(other): boolean;

Defined in: core/types/boxes/STBox.ts:439

true if this is strictly to the left of other on the X axis.

Parameters

other

STBox

Returns

boolean


isOverOrAbove()

ts
isOverOrAbove(other): boolean;

Defined in: core/types/boxes/STBox.ts:478

true if this does not extend below other on the Y axis.

Parameters

other

STBox

Returns

boolean


isOverOrAfter()

ts
isOverOrAfter(other): boolean;

Defined in: core/types/boxes/STBox.ts:526

true if this does not extend before other on the temporal axis.

Parameters

other

STBox

Returns

boolean


isOverOrBefore()

ts
isOverOrBefore(other): boolean;

Defined in: core/types/boxes/STBox.ts:516

true if this does not extend after other on the temporal axis.

Parameters

other

STBox

Returns

boolean


isOverOrBehind()

ts
isOverOrBehind(other): boolean;

Defined in: core/types/boxes/STBox.ts:502

true if this does not extend in front of other on the Z axis.

Parameters

other

STBox

Returns

boolean


isOverOrBelow()

ts
isOverOrBelow(other): boolean;

Defined in: core/types/boxes/STBox.ts:468

true if this does not extend above other on the Y axis.

Parameters

other

STBox

Returns

boolean


isOverOrFront()

ts
isOverOrFront(other): boolean;

Defined in: core/types/boxes/STBox.ts:492

true if this does not extend behind other on the Z axis.

Parameters

other

STBox

Returns

boolean


isOverOrLeft()

ts
isOverOrLeft(other): boolean;

Defined in: core/types/boxes/STBox.ts:444

true if this does not extend to the right of other on the X axis.

Parameters

other

STBox

Returns

boolean


isOverOrRight()

ts
isOverOrRight(other): boolean;

Defined in: core/types/boxes/STBox.ts:454

true if this does not extend to the left of other on the X axis.

Parameters

other

STBox

Returns

boolean


isRight()

ts
isRight(other): boolean;

Defined in: core/types/boxes/STBox.ts:449

true if this is strictly to the right of other on the X axis.

Parameters

other

STBox

Returns

boolean


isSame()

ts
isSame(other): boolean;

Defined in: core/types/boxes/STBox.ts:430

true if this and other cover the exact same region (same bounds and inclusivity).

Parameters

other

STBox

Returns

boolean


le()

ts
le(other): boolean;

Defined in: core/types/boxes/STBox.ts:584

true if this is less than or equal to other in MEOS total ordering.

Parameters

other

STBox

Returns

boolean


lt()

ts
lt(other): boolean;

Defined in: core/types/boxes/STBox.ts:579

true if this is strictly less than other in MEOS total ordering.

Parameters

other

STBox

Returns

boolean


ne()

ts
ne(other): boolean;

Defined in: core/types/boxes/STBox.ts:574

true if this and other differ in at least one dimension.

Parameters

other

STBox

Returns

boolean


overlaps()

ts
overlaps(other): boolean;

Defined in: core/types/boxes/STBox.ts:425

true if this and other share at least one point.

Parameters

other

STBox

Returns

boolean


round()

ts
round(maxdd): STBox;

Defined in: core/types/boxes/STBox.ts:401

Returns a new STBox with spatial coordinates rounded to maxdd decimal places.

Parameters

maxdd

number

Number of decimal digits to keep.

Returns

STBox


setSrid()

ts
setSrid(value): STBox;

Defined in: core/types/boxes/STBox.ts:339

Returns a new STBox with the SRID set to value.

Parameters

value

number

The new SRID.

Returns

STBox


shiftScaleTime()

ts
shiftScaleTime(shift, duration): STBox;

Defined in: core/types/boxes/STBox.ts:393

Returns a new STBox with the temporal dimension shifted and/or scaled.

Parameters

shift

number

Raw WASM pointer to a MEOS interval for the shift amount (0 to skip).

duration

number

Raw WASM pointer to a MEOS interval for the new duration (0 to skip).

Returns

STBox


srid()

ts
srid(): number;

Defined in: core/types/boxes/STBox.ts:331

Returns the SRID of this box (0 = no SRID set).

Returns

number


tmax()

ts
tmax(): number;

Defined in: core/types/boxes/STBox.ts:312

Returns the upper temporal bound as microseconds since 2000-01-01 UTC. Returns 0 if the box has no T dimension.

Returns

number


tmaxInc()

ts
tmaxInc(): boolean;

Defined in: core/types/boxes/STBox.ts:322

true if the upper temporal bound is inclusive (]).

Returns

boolean


tmin()

ts
tmin(): number;

Defined in: core/types/boxes/STBox.ts:307

Returns the lower temporal bound as microseconds since 2000-01-01 UTC. Returns 0 if the box has no T dimension.

Returns

number


tminInc()

ts
tminInc(): boolean;

Defined in: core/types/boxes/STBox.ts:317

true if the lower temporal bound is inclusive ([).

Returns

boolean


toGeoPtr()

ts
toGeoPtr(): number;

Defined in: core/types/boxes/STBox.ts:359

Extracts the spatial dimension as a GSERIALIZED geometry and returns the raw WASM pointer. Will be typed once TGeomPoint is implemented.

Returns

number


toString()

ts
toString(maxdd?): string;

Defined in: core/types/boxes/STBox.ts:232

Returns the WKT string representation.

Parameters

maxdd?

number = 15

Maximum decimal digits for coordinate values (default 15).

Returns

string


toTsTzSpan()

ts
toTsTzSpan(): number;

Defined in: core/types/boxes/STBox.ts:351

Extracts the temporal dimension as a TsTzSpan and returns the raw WASM pointer. Use new TsTzSpan(ptr) to obtain a typed object.

Returns

number


union()

ts
union(other, strict?): STBox;

Defined in: core/types/boxes/STBox.ts:560

Returns the union of this and other. The caller is responsible for calling free on the result.

Parameters

other

STBox

strict?

boolean = false

If true, throws when the boxes are not contiguous (default false).

Returns

STBox


xmax()

ts
xmax(): number;

Defined in: core/types/boxes/STBox.ts:282

Returns the maximum X coordinate. Returns 0 if the box has no X dimension.

Returns

number


xmin()

ts
xmin(): number;

Defined in: core/types/boxes/STBox.ts:277

Returns the minimum X coordinate. Returns 0 if the box has no X dimension.

Returns

number


ymax()

ts
ymax(): number;

Defined in: core/types/boxes/STBox.ts:292

Returns the maximum Y coordinate. Returns 0 if the box has no X dimension.

Returns

number


ymin()

ts
ymin(): number;

Defined in: core/types/boxes/STBox.ts:287

Returns the minimum Y coordinate. Returns 0 if the box has no X dimension.

Returns

number


zmax()

ts
zmax(): number;

Defined in: core/types/boxes/STBox.ts:302

Returns the maximum Z coordinate. Returns 0 if the box has no Z dimension.

Returns

number


zmin()

ts
zmin(): number;

Defined in: core/types/boxes/STBox.ts:297

Returns the minimum Z coordinate. Returns 0 if the box has no Z dimension.

Returns

number


fromHexWKB()

ts
static fromHexWKB(hexwkb): STBox;

Defined in: core/types/boxes/STBox.ts:140

Deserialises an STBox from a hex-encoded WKB string produced by asHexWKB.

Parameters

hexwkb

string

Hex-encoded WKB string.

Returns

STBox


fromString()

ts
static fromString(str): STBox;

Defined in: core/types/boxes/STBox.ts:132

Parses an STBox from its WKT string representation.

Parameters

str

string

WKT string, e.g. "STBOX XT(((1,1),(2,2)),[2020-01-01,2020-12-31])".

Returns

STBox


fromTimestamp()

ts
static fromTimestamp(t): STBox;

Defined in: core/types/boxes/STBox.ts:148

Creates a T-only STBox from a single timestamp.

Parameters

t

number

Timestamp as microseconds since 2000-01-01 UTC.

Returns

STBox


fromTsTzSet()

ts
static fromTsTzSet(tstzSetPtr): STBox;

Defined in: core/types/boxes/STBox.ts:156

Creates a T-only STBox from a TsTzSet WASM pointer.

Parameters

tstzSetPtr

number

Raw WASM pointer to a TsTzSet.

Returns

STBox


fromTsTzSpan()

ts
static fromTsTzSpan(tstzSpanPtr): STBox;

Defined in: core/types/boxes/STBox.ts:164

Creates a T-only STBox from a TsTzSpan WASM pointer.

Parameters

tstzSpanPtr

number

Raw WASM pointer to a TsTzSpan.

Returns

STBox


fromTsTzSpanSet()

ts
static fromTsTzSpanSet(tstzSpanSetPtr): STBox;

Defined in: core/types/boxes/STBox.ts:172

Creates a T-only STBox from a TsTzSpanSet WASM pointer.

Parameters

tstzSpanSetPtr

number

Raw WASM pointer to a TsTzSpanSet.

Returns

STBox


make()

ts
static make(
   hasx, 
   hasz, 
   geodetic, 
   srid, 
   xmin, 
   xmax, 
   ymin, 
   ymax, 
   zmin, 
   zmax, 
   tstzSpanPtr): STBox;

Defined in: core/types/boxes/STBox.ts:194

Builds an STBox from explicit coordinate bounds.

At least the 2D spatial dimension (hasx = true) or the temporal dimension (tstzSpanPtr !== 0) must be provided.

Parameters

hasx

boolean

true to include the XY spatial dimension.

hasz

boolean

true to also include the Z spatial dimension.

geodetic

boolean

true for a geodetic (WGS-84) box.

srid

number

Spatial reference system identifier (e.g. 4326).

xmin

number

Minimum X coordinate (ignored when hasx is false).

xmax

number

Maximum X coordinate (ignored when hasx is false).

ymin

number

Minimum Y coordinate (ignored when hasx is false).

ymax

number

Maximum Y coordinate (ignored when hasx is false).

zmin

number

Minimum Z coordinate (ignored when hasz is false).

zmax

number

Maximum Z coordinate (ignored when hasz is false).

tstzSpanPtr

number

Raw WASM pointer to a TsTzSpan for the T dimension (0 = no T dimension).

Returns

STBox