Class: Geometry

ol/geom/Geometry~Geometry


import Geometry from 'ol/geom/Geometry';

Abstract base class; normally only used for creating subclasses and not instantiated in apps. Base class for vector geometries.

To get notified of changes to the geometry, register a listener for the generic change event on your geometry instance.

new Geometry()

geom/Geometry.js, line 31

Methods

getClosestPoint(point, opt_closestPoint){module:ol/coordinate~Coordinate}

geom/Geometry.js, line 93

Return the closest point of the geometry to the passed point as coordinate.

Name Type Description
point module:ol/coordinate~Coordinate

Point.

closestPoint module:ol/coordinate~Coordinate

Closest point.

Returns:
Closest point.

getExtent(opt_extent){module:ol/extent~Extent}

geom/Geometry.js, line 124

Get the extent of the geometry.

Name Type Description
extent module:ol/extent~Extent

Extent.

Returns:
extent Extent.

intersectsCoordinate(coordinate){boolean}

geom/Geometry.js, line 106

Returns true if this geometry includes the specified coordinate. If the coordinate is on the boundary of the geometry, returns false.

Name Type Description
coordinate module:ol/coordinate~Coordinate

Coordinate.

Returns:
Contains coordinate.

rotate(angle, anchor)

geom/Geometry.js, line 140

Rotate the geometry around a given coordinate. This modifies the geometry coordinates in place.

Name Type Description
angle number

Rotation angle in radians.

anchor module:ol/coordinate~Coordinate

The rotation center.

scale(sx, opt_sy, opt_anchor)

geom/Geometry.js, line 153

Scale the geometry (with an optional origin). This modifies the geometry coordinates in place.

Name Type Description
sx number

The scaling factor in the x-direction.

sy number

The scaling factor in the y-direction (defaults to sx).

anchor module:ol/coordinate~Coordinate

The scale origin (defaults to the center of the geometry extent).

simplify(tolerance){module:ol/geom/Geometry~Geometry}

geom/Geometry.js, line 176

Create a simplified version of this geometry. For linestrings, this uses the the Douglas Peucker algorithm. For polygons, a quantization-based simplification is used to preserve topology.

Name Type Description
tolerance number

The tolerance distance for simplification.

Returns:
A new, simplified version of the original geometry.

transform(source, destination){module:ol/geom/Geometry~Geometry}

geom/Geometry.js, line 239

Transform each coordinate of the geometry from one coordinate reference system to another. The geometry is modified in place. For example, a line will be transformed to a line and a circle to a circle. If you do not want the geometry modified in place, first clone() it and then use this function on the clone.

Name Type Description
source module:ol/proj~ProjectionLike

The current projection. Can be a string identifier or a module:ol/proj/Projection~Projection object.

destination module:ol/proj~ProjectionLike

The desired projection. Can be a string identifier or a module:ol/proj/Projection~Projection object.

Returns:
This geometry. Note that original geometry is modified in place.

translate(deltaX, deltaY)

geom/Geometry.js, line 162

Translate the geometry. This modifies the geometry coordinates in place.

Name Type Description
deltaX number

Delta X.

deltaY number

Delta Y.