Files
openlayers/src/ol/geom/geometry.js
Tim Schaub 33457c48de Add transform method to geometries
In the typical sequence of parse-transform-render the most efficient place to transform coordinate values is deep within the parser immediately after values have been read (this would avoid a second pass over whatever structure is used to back geometries).  To accomplish this transform during parsing, we could add back parser read options to pass the transform function around.

Until then, a transform method on geometries is straightforward to implement.  This means we do a second pass through coordinate structures to transform, but this is typically done only once immediately after parsing.
2013-09-27 23:18:34 +01:00

76 lines
1.5 KiB
JavaScript

goog.provide('ol.geom.Geometry');
goog.provide('ol.geom.GeometryType');
goog.require('ol.Extent');
goog.require('ol.TransformFunction');
/**
* @constructor
*/
ol.geom.Geometry = function() {};
/**
* The dimension of this geometry (2 or 3).
* @type {number}
*/
ol.geom.Geometry.prototype.dimension;
/**
* Create a clone of this geometry.
* @return {ol.geom.Geometry} The cloned geometry.
*/
ol.geom.Geometry.prototype.clone = function() {
var clone = new this.constructor(this.getCoordinates());
clone.bounds_ = this.bounds_;
clone.dimension = this.dimension;
return clone;
};
/**
* Get the rectangular 2D envelope for this geoemtry.
* @return {ol.Extent} The bounding rectangular envelope.
*/
ol.geom.Geometry.prototype.getBounds = goog.abstractMethod;
/**
* @return {Array} The GeoJSON style coordinates array for the geometry.
*/
ol.geom.Geometry.prototype.getCoordinates = goog.abstractMethod;
/**
* Get the geometry type.
* @return {ol.geom.GeometryType} The geometry type.
*/
ol.geom.Geometry.prototype.getType = goog.abstractMethod;
/**
* Transform a geometry in place.
* @param {ol.TransformFunction} transform Transform function.
*/
ol.geom.Geometry.prototype.transform = goog.abstractMethod;
/**
* Geometry types.
*
* @enum {string}
*/
ol.geom.GeometryType = {
POINT: 'point',
LINESTRING: 'linestring',
LINEARRING: 'linearring',
POLYGON: 'polygon',
MULTIPOINT: 'multipoint',
MULTILINESTRING: 'multilinestring',
MULTIPOLYGON: 'multipolygon',
GEOMETRYCOLLECTION: 'geometrycollection'
};