$g. Point

Geometry objects represent the values of attributes with attribute type geometry. All geometry objects can have an optional SRID that associates the geometry with a coordinate reference system. While it is possible to store z (elevation) and m (measurement) values with the geometries, most operations will ignore these.

Constructor

new $g.Point(x, y, sridopt)

Constructs a new point object. For constructing Points with z and m values, see $g.Point.create

Parameters:
NameTypeAttributesDescription
xnumber

x coordinate

ynumber

y coordinate

sridnumber<optional>

Spatial reference id

Since
  • 6.0.0

Extends

Members

(readonly) is3D :boolean

true iff the geometry has a z component.

Type:
  • boolean
Since
  • 6.0.0
Inherited From

(readonly) isGeographic :boolean

true if the geometry is geographic, false if it is geometric.

Type:
  • boolean
Since
  • 6.0.0

(readonly) isMeasured :boolean

true iff the geometry has a measurement component.

Type:
  • boolean
Since
  • 6.0.0

(readonly) isProjected :boolean

true iff the geometry is geographic and the underlying coordinate system is a projected reference system.

Type:
  • boolean
Since
  • 6.0.0

(readonly, nullable) m :number

The measurement value, or undefined if this point has no measurement.

Type:
  • number
Since
  • 6.0.0

(nullable) srid :integer

Spatial reference id for geographic geometries or null for cartesian geometries.

Type:
  • integer
Since
  • 6.0.0
Inherited From

(readonly) x :number

The x coordinate.

Type:
  • number
Since
  • 6.0.0

(readonly) y :number

The y coordinate.

Type:
  • number
Since
  • 6.0.0

(readonly, nullable) z :number

The z coordinate, or undefined if this point is not 3D.

Type:
  • number
Since
  • 6.0.0

Methods

(static) create(x, y, zopt, mopt, sridopt) → {$g.Point}

Constructs a new Point object with optional z and m values.

Parameters:
NameTypeAttributesDescription
xnumber

x coordinate

ynumber

y coordinate

znumber<optional>

z coordinate

mnumber<optional>

m value (Measurement)

sridnumber<optional>

Spatial reference id

Since
  • 6.0.0
Returns:
Type: 
$g.Point

(static) fromString(coordinateString) → {$g.Point|undefined}

Tries to parse the coordinate string in various formats like UTM, MGRS, and latitude/longitude pairs. In case of success the resulting point will also have the correct SRID set.

Parameters:
NameTypeDescription
coordinateStringstring

A string representation of a geographic point.

Since
  • 6.0.0
Returns:

The parsed point or undefined, if the string cannot be interpreted.

Type: 
$g.Point | undefined
Examples
$g.Point.fromString(`N49° 52' 18" E8° 39' 0.96"`) // latitude/longitude coordinate string, returns a $g.Point object with x: 8.6502666666667, y: 49.871666666667, srid: 4326
$g.Point.fromString('4Q FJ 1 6') // UTM coordinate string, returns a $k.Point object with x: 610000, y: 2360000, srid: 32604
$g.Point.fromString('gibberish') // returns undefined

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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
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
Returns:
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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
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().

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to calculate the distance to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Throws:

If the argument is not a valid geometry

Type
$k.exception.InvalidValue
Returns:

The distance in the natural distance unit defined by the reference system

Type: 
number

equals(value) → {boolean}

Returns true if the values are equal

Parameters:
NameTypeDescription
value

Another attribute value

Inherited From
Returns:
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().

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to calculate the distance to. It must have the same SRID.

Since
  • 6.0.0
Throws:
Returns:

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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Returns:
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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
Type: 
string
Example
$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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

patternstring

A 9 letter string over the alphabet {0, 1, 2, T, F, *}.

Since
  • 6.0.0
Inherited From
Returns:
Type: 
boolean
Example
$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

Parameters:
NameTypeAttributesDescription
sridnumber<optional>

Spatial reference id or undefined for cartesian geometry

Since
  • 6.0.0
Inherited From

toGeoJSON() → {object}

Creates a GeoJSON object from this geometry.

Since
  • 6.0.0
Inherited From
Throws:

If this geometry cannot be represented as GeoJSON, e.g. because of empty points.

Type
$k.exception.InvalidValue
Returns:

GeoJSON object.

Type: 
object
Example
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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
Type: 
boolean

toWKB(extendedopt) → {Array.<number>}

(Extended) WKB byte representation of this geometry.

Parameters:
NameTypeAttributesDefaultDescription
extendedboolean<optional>
true

Include extended bytes for SRID

Since
  • 6.0.0
Inherited From
Returns:

Byte array

Type: 
Array.<number>

toWKT(extendedopt) → {string}

(Extended) WKT string representation of this geometry.

Parameters:
NameTypeAttributesDefaultDescription
extendedboolean<optional>
true

Include SRID tag

Since
  • 6.0.0
Inherited From
Returns:
Type: 
string
Examples
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.

Parameters:
NameTypeDescription
targetSRIDnumber

The identifier of the target coordinate reference system.

Since
  • 6.0.0
Throws:

If this geometry has no coordinate reference system, or the source or target reference system is invalid

Type
$k.exception.InvalidValue
Returns:

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.

Parameters:
NameTypeDescription
geometry$g.Geometry

The geometry to compare this object to. It should have the same SRID.

Since
  • 6.0.0
Inherited From
Returns:
Type: 
boolean