Add a basic geometry interface

This commit is contained in:
Marc Jansen
2012-06-22 16:05:03 +02:00
parent db3a6e9c4a
commit 5a3dad9326
2 changed files with 45 additions and 3 deletions

View File

@@ -1,11 +1,13 @@
goog.provide('ol.geom.Geometry');
goog.require('ol.geom.IGeometry');
goog.require('ol.Bounds');
/**
* Creates ol.Geometry objects.
*
* @export
* @implements {ol.geom.IGeometry}
* @constructor
*/
ol.geom.Geometry = function() {
@@ -34,10 +36,23 @@ ol.geom.Geometry.prototype.setBounds = function(bounds) {
};
/**
* @returns ol.Loc
* Returns the centroid of the geometry.
*
* @returns {ol.geom.Point} The centroid of the geometry.
*/
ol.geom.Geometry.prototype.getCentroid = function() {
//FIXME: stub only to get popups working
return new ol.Loc(-76,45);
// throw an error to enforce subclasses to implement it properly
ol.error('ol.geom.Geometry: getCentroid must be implemented by subclasses');
return null;
};
/**
* Returns the area of the geometry.
*
* @returns {number} The area of the geometry.
*/
ol.geom.Geometry.prototype.getArea = function() {
// throw an error to enforce subclasses to implement it properly
ol.error('ol.geom.Geometry: getArea must be implemented by subclasses');
return 0;
};