Skip to main content

Type Definitions

Geometry

edit
Point<P> | LineString<P> | LinearRing<P> | Polygon<P> | MultiPoint<P> | MultiLineString<P> | MultiPolygon<P> | GeometryCollection<P> | CircularString<P> | CompoundCurve<P> | CurvePolygon<P> | MultiCurve<P> | MultiSurface<P>
  • P - The type of optional data assigned to a geometry instance.

Union type of all possible geometry types.

Each geometry type is an instance of GeometryRef.

Prepared

edit
G & { [ __PREPARED__ ]: true }
  • G - The type of prepared geometry, for example, Geometry or more specific Polygon

Branded type representing one of geometries that was prepared.

Geometry preparation is especially useful when a certain geometry will be compared many times with other geometries when computing spatial predicates or calculating distances.

Point

edit

Point is an instance of GeometryRef that represents the point geometry.

Point extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'Point'

Methods

toJSON

clone

() -> Point<P>

See also

  • point creates a point geometry from a single coordinate

Examples

const a = fromGeoJSON({ type: 'Point', coordinates: [ 0, 0 ] });
const b = point([ 0, 0 ]); // shortcut to above
const c = fromWKT('POINT (0 0)');

LineString

edit

LineString is an instance of GeometryRef that represents the line string geometry.

LineString extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'LineString'

Methods

toJSON

clone

() -> LineString<P>

See also

  • lineString creates a line string geometry from an array of positions

Examples

const a = fromGeoJSON({
    type: 'LineString',
    coordinates: [ [ 0, 0 ], [ 1, 1 ], [ 2, 2 ] ],
});
const b = lineString([ [ 0, 0 ], [ 1, 1 ], [ 2, 2 ] ]); // shortcut to above
const c = fromWKT('LINESTRING (0 0, 1 1, 2 2)');

LinearRing

edit

LinearRing extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'LinearRing'

Methods

toJSON

clone

() -> LinearRing<P>

Polygon

edit

Polygon is an instance of GeometryRef that represents the polygon geometry.

Polygon extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'Polygon'

Methods

toJSON

clone

() -> Polygon<P>

See also

  • polygon creates a polygon geometry from an array of linear rings coordinates

Examples

const a = fromGeoJSON({
    type: 'Polygon',
    coordinates: [
        [ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 0, 0 ] ],
    ],
});
const b = polygon([ // shortcut to above
    [ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 0, 0 ] ],
]);
const c = fromWKT('POLYGON ((0 0, 0 1, 1 0, 0 0))');
const d = polygon([
    [ [ 0, 0 ], [ 0, 8 ], [ 8, 0 ], [ 0, 0 ] ], // shell
    [ [ 2, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ], // hole 1
    [ [ 2, 2 ], [ 2, 3 ], [ 3, 2 ], [ 2, 2 ] ], // hole 2
]);

MultiPoint

edit

MultiPoint is an instance of GeometryRef that represents the multi point geometry.

MultiPoint extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'MultiPoint'

Methods

toJSON

clone

() -> MultiPoint<P>

See also

  • multiPoint creates a multi point geometry from an array of positions

Examples

const a = fromGeoJSON({
    type: 'MultiPoint',
    coordinates: [ [ 0, 0 ], [ 1, 1 ], [ 2, 2 ] ],
});
const b = multiPoint([ [ 0, 0 ], [ 1, 1 ], [ 2, 2 ] ]); // shortcut to above
const c = fromWKT('MULTIPOINT (0 0, 1 1, 2 2)');

MultiLineString

edit

MultiLineString is an instance of GeometryRef that represents the multi line string geometry.

MultiLineString extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'MultiLineString'

Methods

toJSON

clone

See also

  • multiLineString creates a multi line string geometry from an array of line strings coordinates

Examples

const a = fromGeoJSON({
    type: 'MultiLineString',
    coordinates: [
        [ [ 0, 0 ], [ 1, 1 ] ], // line 1
        [ [ 2, 2 ], [ 3, 3 ] ], // line 2
    ],
});
const b = multiLineString([ // shortcut to above
    [ [ 0, 0 ], [ 1, 1 ] ],
    [ [ 2, 2 ], [ 3, 3 ] ],
]);
const c = fromWKT('MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))');

MultiPolygon

edit

MultiPolygon is an instance of GeometryRef that represents the multi polygon geometry.

MultiPolygon extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'MultiPolygon'

Methods

toJSON

clone

See also

  • multiPolygon creates a multi polygon geometry from an array of polygon coordinates

Examples

const a = fromGeoJSON({
    type: 'MultiPolygon',
    coordinates: [
        [ [ [ 0, 1 ], [ 1, 0 ], [ 1, 1 ], [ 0, 1 ] ] ], // polygon 1
        [ [ [ 1, 1 ], [ 1, 3 ], [ 3, 1 ], [ 1, 1 ] ] ], // polygon 2
    ],
});
const b = multiPolygon([ // shortcut to above
    [ [ [ 0, 1 ], [ 1, 0 ], [ 1, 1 ], [ 0, 1 ] ] ],
    [ [ [ 1, 1 ], [ 1, 3 ], [ 3, 1 ], [ 1, 1 ] ] ],
]);
const c = fromWKT('MULTIPOLYGON (((0 1, 1 0, 1 1, 0 1)), ((1 1, 1 3, 3 1, 1 1)))');

GeometryCollection

edit

GeometryCollection is an instance of GeometryRef that represents the geometry collection.

GeometryCollection extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'GeometryCollection'

Methods

toJSON

clone

See also

Examples

const a = fromGeoJSON({
    type: 'GeometryCollection',
    geometries: [
        { type: 'Point', coordinates: [ 0, 0 ] },
        { type: 'LineString', coordinates: [ [ 0, 1 ], [ 1, 0 ] ] },
    ],
});
const b = geometryCollection([
    point([ 0, 0 ]),
    lineString([ [ 0, 1 ], [ 1, 0 ] ]),
]);

CircularString

edit

CircularString extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'CircularString'

Methods

toJSON

clone

CompoundCurve

edit

CompoundCurve extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'CompoundCurve'

Methods

toJSON

clone

CurvePolygon

edit

CurvePolygon extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'CurvePolygon'

Methods

toJSON

clone

MultiCurve

edit

MultiCurve extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'MultiCurve'

Methods

toJSON

clone

() -> MultiCurve<P>

MultiSurface

edit

MultiSurface extends GeometryRef.

Type Parameters

  • P

Properties

type readonly

'MultiSurface'

Methods

toJSON

clone

JSON_FeatureCollection

edit

Similar to the GeoJSON_FeatureCollection but allows for more geometry types.

Type Parameters

  • G - The type of JSON geometry

  • P

Properties

type

'FeatureCollection'

features

JSON_Feature

edit

Similar to the GeoJSON_Feature but allows for more geometry types.

Type Parameters

  • G - The type of JSON geometry

  • P

Properties

type

'Feature'

geometry

id optional

string | number | undefined

properties

JSON_Geometry

JSON_GeometryCollection

edit

Similar to the GeoJSON_GeometryCollection but allows for more geometry types.

Type Parameters

  • G - The type of JSON geometry

Properties

type

'GeometryCollection'

geometries

G[]

JSON_CircularString

edit

Properties

type

'CircularString'

coordinates

JSON_CompoundCurve

edit

Properties

type

'CompoundCurve'

segments

JSON_CurvePolygon

JSON_MultiCurve

JSON_MultiSurface

edit

Properties

type

'MultiSurface'

surfaces