Members
(readonly) is3D :boolean
true iff the geometry has a z component.
- boolean
- Since
- 6.0.0
(readonly) isGeographic :boolean
true if the geometry is geographic, false if it is geometric.
- boolean
- Since
- 6.0.0
(readonly) isMeasured :boolean
true iff the geometry has a measurement component.
- boolean
- Since
- 6.0.0
(readonly) isProjected :boolean
true iff the geometry is geographic and the underlying coordinate system is a projected reference system.
- boolean
- Since
- 6.0.0
(nullable) srid :integer
Spatial reference id for geographic geometries or null for cartesian geometries.
- integer
- Since
- 6.0.0
Methods
(static) fromGeoJSON(geoJSON) → {$g.Geometry}
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
geoJSON | object | A GeoJSON JavaScript object. Properties
|
- Since
- 6.0.0
If the parameter is not a valid GeoJSON object.
- Type:
- $g.
Geometry
(static) fromWKB(wkb) → {$g.Geometry}
Constructs a geometry object from an (exteneded) well-known binary representation of a geometry (including optional SRID bytes).
Name | Type | Description |
---|---|---|
wkb | Array.<number> | (E)WKB byte array. |
- Since
- 6.0.0
If the parameter is not a valid (E)WKB byte array.
- Type:
- $g.
Geometry
(static) fromWKT(wkt) → {$g.Geometry}
Constructs a geometry object from an (exteneded) well-known text representation of a geometry (including an optional SRID as prefix).
Name | Type | Description |
---|---|---|
wkt | string | (E)WKT string. |
- Since
- 6.0.0
If the parameter is not a valid (E)WKT string.
- Type:
- $g.
Geometry
$g.Geometry.fromWKT('POINT (10 20)')
$g.Geometry.fromWKT('SRID=4326;POINT (9 50)')
contains(geometry) → {boolean}
Tests if the given geometry lies completely inside this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
convexHull() → {$g.Polygon}
Constructs a polygon that represents the convex hull of all points that are inside this geometry.
- Since
- 6.0.0
- Type:
- $g.
Polygon
crosses(geometry) → {boolean}
Tests if the given geometry crosses this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
disjoint(geometry) → {boolean}
Tests if the given geometry lies completely outside this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
distance(geometry) → {number}
Calculates the shortest distance from any point of this geometry to any point of the parameter. The return value is only really useful for cartesian or projected geographic geometries. For geometries with geodetic coordinates, use .geodesicDistance().
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to calculate the distance to. It should have the same SRID. |
- Since
- 6.0.0
If the argument is not a valid geometry
The distance in the natural distance unit defined by the reference system
- Type:
- number
equals(value) → {boolean}
Returns true if the values are equal
Name | Type | Description |
---|---|---|
value | Another attribute value |
- Type:
- boolean
geodesicDistance(geometry) → {number}
Calculates the shortest geodesic distance from any point of this geometry to any point of the parameter. The return value is only really useful for geodetic geometries. For geometries with cartesic or projected coordinates, use .distance().
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to calculate the distance to. It must have the same SRID. |
- Since
- 6.0.0
If the argument is not a valid geometry, the SRIDs do not match or the geometries are not geodetic.
If the computation is not possible due to missing libraries.
The geodesic distance in meters
- Type:
- number
intersects(geometry) → {boolean}
Tests if the given geometry intersects this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
overlaps(geometry) → {boolean}
Tests if the given geometry has some (but not all) points in common with this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
relate(geometry) → {string}
Calculates a string representation of the Clementini-Matrix resulting from applying the Dimensionally Extended 9-Intersection Model (DE-9IM) to this geometry and the parameter.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- string
$g.Geometry.fromWKT('LINESTRING (0 0, 5 5)').relate($g.Geometry.fromWKT('LINESTRING (0 5, 5 0)')) // returns '0F1FF0102'
relates(geometry, pattern) → {boolean}
Calculates with the Dimensionally Extended 9-Intersection Model (DE-9IM) whether the relation between this geometry and the first parameter matches the pattern string.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
pattern | string | A 9 letter string over the alphabet {0, 1, 2, T, F, *}. |
- Since
- 6.0.0
- Type:
- boolean
$g.Geometry.fromWKT('LINESTRING (0 0, 5 5)').relates($g.Geometry.fromWKT('LINESTRING (0 5, 5 0)'), '0F1FF0102') // returns true
setSRID(sridopt)
Set the spatial reference id for the geometry
Name | Type | Attributes | Description |
---|---|---|---|
srid | number | <optional> | Spatial reference id or undefined for cartesian geometry |
- Since
- 6.0.0
toGeoJSON() → {object}
Creates a GeoJSON object from this geometry.
- Since
- 6.0.0
If this geometry cannot be represented as GeoJSON, e.g. because of empty points.
GeoJSON object.
- Type:
- object
const geoJSON = new $g.Point(10, 20).toGeoJSON() // { type: 'Point', coordinates: [10, 20] }
JSON.stringify(geoJSON) // To get the JSON string, use JSON.stringify
touches(geometry) → {boolean}
Tests if the given geometry touches (but does not intersect) this geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean
toWKB(extendedopt) → {Array.<number>}
(Extended) WKB byte representation of this geometry.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
extended | boolean | <optional> | true | Include extended bytes for SRID |
- Since
- 6.0.0
Byte array
- Type:
- Array.<number>
toWKT(extendedopt) → {string}
(Extended) WKT string representation of this geometry.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
extended | boolean | <optional> | true | Include SRID tag |
- Since
- 6.0.0
- Type:
- string
new $g.LineString(new $g.Point(0, 1), new $g.Point(2, 3)).toWKT() // A line string with cartesian coordinates starting from 0,1 ending at 2,3: LINESTRING (0 1, 2 3)
new $g.Point(9, 50, 4326).toWKT() // A point with WGS84 (EPSG ID 4326) latitude 50°N and longitude 9°E: SRID=4326;POINT (9 50)
transformTo(targetSRID) → {$g.Geometry}
Transforms the geometry to another coordinate reference system and returns a new geometry. Depending on the source and target reference system, this may result in a loss of accuracy.
Name | Type | Description |
---|---|---|
targetSRID | number | The identifier of the target coordinate reference system. |
- Since
- 6.0.0
If this geometry has no coordinate reference system, or the source or target reference system is invalid
An equivalent geometry in the coordinate reference system identified by the given SRID.
- Type:
- $g.
Geometry
within(geometry) → {boolean}
Tests if this geometry lies completely inside the given geometry, using the Dimensionally Extended 9-Intersection Model (DE-9IM), ignoring any z values.
Name | Type | Description |
---|---|---|
geometry | $g. | The geometry to compare this object to. It should have the same SRID. |
- Since
- 6.0.0
- Type:
- boolean