Skip to content

meos.js


meos.js / TBox

Class: TBox ​

Defined in: core/types/boxes/TBox.ts:87

A temporal bounding box with an optional numeric (X) dimension and an optional temporal (T) dimension.

A TBox may have either or both dimensions:

  • X-only: numeric range (integer or float span).
  • T-only: timestamp range.
  • XT: both numeric and temporal ranges.

MEOS outputs TBOXFLOAT X(...) for float-typed X dimensions and TBOX X(...) for integer ones.

Example ​

ts
const b = TBox.fromString('TBOXFLOAT XT([1.5, 10.5],[2020-01-01, 2020-12-31])');
console.log(b.hasX()); // true
console.log(b.hasT()); // true
console.log(b.xmin()); // 1.5
b.free();

Constructors ​

Constructor ​

ts
new TBox(inner): TBox;

Defined in: core/types/boxes/TBox.ts:90

Parameters ​

inner ​

number

Returns ​

TBox

Accessors ​

inner ​

Get Signature ​

ts
get inner(): number;

Defined in: core/types/boxes/TBox.ts:99

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

Returns ​

number

Methods ​

[dispose]() ​

ts
dispose: void;

Defined in: core/types/boxes/TBox.ts:109

Implements the using resource-management protocol — calls free automatically.

Returns ​

void


asHexWKB() ​

ts
asHexWKB(variant?): string;

Defined in: core/types/boxes/TBox.ts:270

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/TBox.ts:575

Returns the MEOS total ordering comparison result.

Parameters ​

other ​

TBox

Returns ​

number

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


contains() ​

ts
contains(other): boolean;

Defined in: core/types/boxes/TBox.ts:356

true if this entirely contains other.

Parameters ​

other ​

TBox

Returns ​

boolean


copy() ​

ts
copy(): TBox;

Defined in: core/types/boxes/TBox.ts:117

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

Returns ​

TBox


eq() ​

ts
eq(other): boolean;

Defined in: core/types/boxes/TBox.ts:542

true if this and other are identical in both dimensions.

Parameters ​

other ​

TBox

Returns ​

boolean


expandFloat() ​

ts
expandFloat(d): TBox;

Defined in: core/types/boxes/TBox.ts:485

Returns a new box with the float X dimension expanded by d on each side.

Parameters ​

d ​

number

Amount to add to each end.

Returns ​

TBox


expandInt() ​

ts
expandInt(i): TBox;

Defined in: core/types/boxes/TBox.ts:477

Returns a new box with the integer X dimension expanded by i on each side. Requires an integer-typed TBox (built from an IntSpan); throws for float boxes.

Parameters ​

i ​

number

Number of integers to add to each end.

Returns ​

TBox


expandTime() ​

ts
expandTime(interval): TBox;

Defined in: core/types/boxes/TBox.ts:524

Returns a new box with the T dimension expanded by the given interval on each side.

Parameters ​

interval ​

number

Raw WASM pointer to a MEOS interval.

Returns ​

TBox


free() ​

ts
free(): void;

Defined in: core/types/boxes/TBox.ts:104

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/TBox.ts:567

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

Parameters ​

other ​

TBox

Returns ​

boolean


gt() ​

ts
gt(other): boolean;

Defined in: core/types/boxes/TBox.ts:562

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

Parameters ​

other ​

TBox

Returns ​

boolean


hash() ​

ts
hash(): number;

Defined in: core/types/boxes/TBox.ts:284

Returns a 32-bit integer hash of this box.

Returns ​

number


hasT() ​

ts
hasT(): boolean;

Defined in: core/types/boxes/TBox.ts:294

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

Returns ​

boolean


hasX() ​

ts
hasX(): boolean;

Defined in: core/types/boxes/TBox.ts:289

true if this box has a numeric (X) dimension.

Returns ​

boolean


intersection() ​

ts
intersection(other): TBox | null;

Defined in: core/types/boxes/TBox.ts:426

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 ​

TBox

Returns ​

TBox | null


isAdjacent() ​

ts
isAdjacent(other): boolean;

Defined in: core/types/boxes/TBox.ts:346

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

Parameters ​

other ​

TBox

Returns ​

boolean


isAfter() ​

ts
isAfter(other): boolean;

Defined in: core/types/boxes/TBox.ts:409

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

Parameters ​

other ​

TBox

Returns ​

boolean


isBefore() ​

ts
isBefore(other): boolean;

Defined in: core/types/boxes/TBox.ts:399

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

Parameters ​

other ​

TBox

Returns ​

boolean


isContainedIn() ​

ts
isContainedIn(other): boolean;

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

true if this is entirely contained within other.

Parameters ​

other ​

TBox

Returns ​

boolean


isLeft() ​

ts
isLeft(other): boolean;

Defined in: core/types/boxes/TBox.ts:375

true if this is entirely to the left of other on the numeric axis.

Parameters ​

other ​

TBox

Returns ​

boolean


isOverOrAfter() ​

ts
isOverOrAfter(other): boolean;

Defined in: core/types/boxes/TBox.ts:414

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

Parameters ​

other ​

TBox

Returns ​

boolean


isOverOrBefore() ​

ts
isOverOrBefore(other): boolean;

Defined in: core/types/boxes/TBox.ts:404

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

Parameters ​

other ​

TBox

Returns ​

boolean


isOverOrLeft() ​

ts
isOverOrLeft(other): boolean;

Defined in: core/types/boxes/TBox.ts:380

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

Parameters ​

other ​

TBox

Returns ​

boolean


isOverOrRight() ​

ts
isOverOrRight(other): boolean;

Defined in: core/types/boxes/TBox.ts:390

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

Parameters ​

other ​

TBox

Returns ​

boolean


isRight() ​

ts
isRight(other): boolean;

Defined in: core/types/boxes/TBox.ts:385

true if this is entirely to the right of other on the numeric axis.

Parameters ​

other ​

TBox

Returns ​

boolean


isSame() ​

ts
isSame(other): boolean;

Defined in: core/types/boxes/TBox.ts:366

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

Parameters ​

other ​

TBox

Returns ​

boolean


le() ​

ts
le(other): boolean;

Defined in: core/types/boxes/TBox.ts:557

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

Parameters ​

other ​

TBox

Returns ​

boolean


lt() ​

ts
lt(other): boolean;

Defined in: core/types/boxes/TBox.ts:552

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

Parameters ​

other ​

TBox

Returns ​

boolean


ne() ​

ts
ne(other): boolean;

Defined in: core/types/boxes/TBox.ts:547

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

Parameters ​

other ​

TBox

Returns ​

boolean


overlaps() ​

ts
overlaps(other): boolean;

Defined in: core/types/boxes/TBox.ts:361

true if this and other share at least one point.

Parameters ​

other ​

TBox

Returns ​

boolean


round() ​

ts
round(maxdd): TBox;

Defined in: core/types/boxes/TBox.ts:493

Returns a new box with the float X bounds rounded to maxdd decimal places.

Parameters ​

maxdd ​

number

Number of decimal digits to keep.

Returns ​

TBox


shiftScaleFloat() ​

ts
shiftScaleFloat(
   shift, 
   width, 
   hasShift?, 
   hasWidth?): TBox;

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

Returns a new box with the float X dimension shifted and/or scaled.

Parameters ​

shift ​

number

Amount to add to every float bound (ignored when hasShift is false).

width ​

number

New float width (ignored when hasWidth is false).

hasShift? ​

boolean = true

Set to false to skip shifting (default true).

hasWidth? ​

boolean = true

Set to false to skip scaling (default true).

Returns ​

TBox


shiftScaleInt() ​

ts
shiftScaleInt(
   shift, 
   width, 
   hasShift?, 
   hasWidth?): TBox;

Defined in: core/types/boxes/TBox.ts:505

Returns a new box with the integer X dimension shifted and/or scaled. Requires an integer-typed TBox (built from an IntSpan); throws for float boxes.

Parameters ​

shift ​

number

Amount to add to every integer bound (ignored when hasShift is false).

width ​

number

New integer width (ignored when hasWidth is false).

hasShift? ​

boolean = true

Set to false to skip shifting (default true).

hasWidth? ​

boolean = true

Set to false to skip scaling (default true).

Returns ​

TBox


shiftScaleTime() ​

ts
shiftScaleTime(shift, duration): TBox;

Defined in: core/types/boxes/TBox.ts:533

Returns a new box with the T 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 ​

TBox


tmax() ​

ts
tmax(): number;

Defined in: core/types/boxes/TBox.ts:327

Returns the upper temporal bound as microseconds since 2000-01-01 UTC.

Returns ​

number


tmaxInc() ​

ts
tmaxInc(): boolean;

Defined in: core/types/boxes/TBox.ts:337

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

Returns ​

boolean


tmin() ​

ts
tmin(): number;

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

Returns the lower temporal bound as microseconds since 2000-01-01 UTC.

Returns ​

number


tminInc() ​

ts
tminInc(): boolean;

Defined in: core/types/boxes/TBox.ts:332

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

Returns ​

boolean


toFloatSpan() ​

ts
toFloatSpan(): number;

Defined in: core/types/boxes/TBox.ts:456

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

Returns ​

number


toIntSpan() ​

ts
toIntSpan(): number;

Defined in: core/types/boxes/TBox.ts:448

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

Returns ​

number


toString() ​

ts
toString(maxdd?): string;

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

Returns the WKT string representation.

Parameters ​

maxdd? ​

number = 15

Maximum decimal digits for float values (default 15).

Returns ​

string


toTsTzSpan() ​

ts
toTsTzSpan(): number;

Defined in: core/types/boxes/TBox.ts:464

Extracts the T 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?): TBox;

Defined in: core/types/boxes/TBox.ts:436

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

Parameters ​

other ​

TBox

strict? ​

boolean = false

If true, throws when the boxes do not overlap or touch (default false).

Returns ​

TBox


xmax() ​

ts
xmax(): number;

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

Returns the upper numeric bound. For integer X dimensions, returns the inclusive upper value (half-open span upper minus 1).

Returns ​

number


xmaxInc() ​

ts
xmaxInc(): boolean;

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

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

Returns ​

boolean


xmin() ​

ts
xmin(): number;

Defined in: core/types/boxes/TBox.ts:299

Returns the lower numeric bound. For integer X dimensions, returns the inclusive lower value.

Returns ​

number


xminInc() ​

ts
xminInc(): boolean;

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

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

Returns ​

boolean


fromFloat() ​

ts
static fromFloat(d): TBox;

Defined in: core/types/boxes/TBox.ts:153

Creates a T-only TBox from a single float value (X dimension is a degenerate point span).

Parameters ​

d ​

number

Float value.

Returns ​

TBox


fromFloatTimestamp() ​

ts
static fromFloatTimestamp(d, t): TBox;

Defined in: core/types/boxes/TBox.ts:187

Creates an XT TBox from a single float and a single timestamp.

Parameters ​

d ​

number

Float value for the X dimension.

t ​

number

Timestamp as microseconds since 2000-01-01 UTC for the T dimension.

Returns ​

TBox


fromFloatTsTzSpan() ​

ts
static fromFloatTsTzSpan(d, tstzSpanPtr): TBox;

Defined in: core/types/boxes/TBox.ts:205

Creates an XT TBox from a single float and a timestamp span.

Parameters ​

d ​

number

Float value for the X dimension.

tstzSpanPtr ​

number

Raw WASM pointer to a TsTzSpan for the T dimension.

Returns ​

TBox


fromHexWKB() ​

ts
static fromHexWKB(hexwkb): TBox;

Defined in: core/types/boxes/TBox.ts:137

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

Parameters ​

hexwkb ​

string

Hex-encoded WKB string.

Returns ​

TBox


fromInt() ​

ts
static fromInt(i): TBox;

Defined in: core/types/boxes/TBox.ts:145

Creates a T-only TBox from a single integer value (X dimension is a degenerate point span).

Parameters ​

i ​

number

Integer value.

Returns ​

TBox


fromIntTimestamp() ​

ts
static fromIntTimestamp(i, t): TBox;

Defined in: core/types/boxes/TBox.ts:178

Creates an XT TBox from a single integer and a single timestamp.

Parameters ​

i ​

number

Integer value for the X dimension.

t ​

number

Timestamp as microseconds since 2000-01-01 UTC for the T dimension.

Returns ​

TBox


fromIntTsTzSpan() ​

ts
static fromIntTsTzSpan(i, tstzSpanPtr): TBox;

Defined in: core/types/boxes/TBox.ts:196

Creates an XT TBox from a single integer and a timestamp span.

Parameters ​

i ​

number

Integer value for the X dimension.

tstzSpanPtr ​

number

Raw WASM pointer to a TsTzSpan for the T dimension.

Returns ​

TBox


fromNumSpanTimestamp() ​

ts
static fromNumSpanTimestamp(numSpanPtr, t): TBox;

Defined in: core/types/boxes/TBox.ts:223

Creates an XT TBox from a numeric span and a single timestamp.

Parameters ​

numSpanPtr ​

number

Raw WASM pointer to an IntSpan or FloatSpan for the X dimension.

t ​

number

Timestamp as microseconds since 2000-01-01 UTC for the T dimension.

Returns ​

TBox


fromNumSpanTsTzSpan() ​

ts
static fromNumSpanTsTzSpan(numSpanPtr, tstzSpanPtr): TBox;

Defined in: core/types/boxes/TBox.ts:214

Creates an XT TBox from a numeric span and a timestamp span.

Parameters ​

numSpanPtr ​

number

Raw WASM pointer to an IntSpan or FloatSpan for the X dimension.

tstzSpanPtr ​

number

Raw WASM pointer to a TsTzSpan for the T dimension.

Returns ​

TBox


fromSet() ​

ts
static fromSet(setPtr): TBox;

Defined in: core/types/boxes/TBox.ts:231

Creates a TBox from a MEOS set (IntSet or FloatSet).

Parameters ​

setPtr ​

number

Raw WASM pointer to a set.

Returns ​

TBox


fromSpan() ​

ts
static fromSpan(spanPtr): TBox;

Defined in: core/types/boxes/TBox.ts:161

Creates an X-only TBox from a numeric span (IntSpan or FloatSpan).

Parameters ​

spanPtr ​

number

Raw WASM pointer to an IntSpan or FloatSpan.

Returns ​

TBox


fromSpanSet() ​

ts
static fromSpanSet(spanSetPtr): TBox;

Defined in: core/types/boxes/TBox.ts:239

Creates a TBox from a MEOS span set (IntSpanSet, FloatSpanSet, or TsTzSpanSet).

Parameters ​

spanSetPtr ​

number

Raw WASM pointer to a span set.

Returns ​

TBox


fromString() ​

ts
static fromString(str): TBox;

Defined in: core/types/boxes/TBox.ts:129

Parses a TBox from its WKT string representation.

Parameters ​

str ​

string

WKT string, e.g. "TBOXFLOAT XT([1.5, 10.5],[2020-01-01, 2020-12-31])".

Returns ​

TBox


fromTimestamp() ​

ts
static fromTimestamp(t): TBox;

Defined in: core/types/boxes/TBox.ts:169

Creates a T-only TBox from a single timestamp.

Parameters ​

t ​

number

Timestamp as microseconds since 2000-01-01 UTC.

Returns ​

TBox


make() ​

ts
static make(xSpanPtr, tSpanPtr): TBox;

Defined in: core/types/boxes/TBox.ts:250

Builds a TBox from a numeric span and/or a temporal span. Pass 0 for either argument to omit that dimension.

Parameters ​

xSpanPtr ​

number

Raw WASM pointer to an IntSpan or FloatSpan (0 = no X dimension).

tSpanPtr ​

number

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

Returns ​

TBox