Allow instanceof checks for geometries

This commit is contained in:
Tim Schaub
2013-02-19 23:21:05 -07:00
parent 083404bd58
commit 0015e466dc
11 changed files with 30 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ goog.provide('ol.geom.GeometryType');
/**
* @interface
* @constructor
*/
ol.geom.Geometry = function() {};
@@ -30,7 +30,7 @@ ol.geom.Geometry.prototype.getBounds = goog.abstractMethod;
* Get the geometry type.
* @return {ol.geom.GeometryType} The geometry type.
*/
ol.geom.Geometry.prototype.getType = function() {};
ol.geom.Geometry.prototype.getType = goog.abstractMethod;
/**

View File

@@ -10,10 +10,12 @@ goog.require('ol.geom.GeometryType');
* A collection of geometries. This constructor should not called. Instead
* create one of the fixed type collections.
* @constructor
* @implements {ol.geom.Geometry}
* @extends {ol.geom.Geometry}
*/
ol.geom.GeometryCollection = function() {
goog.base(this);
/**
* @type {Array.<ol.geom.Geometry>}
*/
@@ -31,6 +33,7 @@ ol.geom.GeometryCollection = function() {
this.bounds = null;
};
goog.inherits(ol.geom.GeometryCollection, ol.geom.Geometry);
/**

View File

@@ -10,12 +10,14 @@ goog.require('ol.geom.GeometryType');
/**
* @constructor
* @implements {ol.geom.Geometry}
* @extends {ol.geom.Geometry}
* @param {ol.geom.CoordinateArray} coordinates Coordinates array (e.g.
* [[x0, y0], [x1, y1]]).
*/
ol.geom.LineString = function(coordinates) {
goog.base(this);
// assume the same dimension for all coordinates
var dimension = coordinates[0].length,
count = coordinates.length,
@@ -43,6 +45,7 @@ ol.geom.LineString = function(coordinates) {
this.bounds_ = null;
};
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
/**

View File

@@ -10,11 +10,13 @@ goog.require('ol.geom.GeometryType');
/**
* @constructor
* @implements {ol.geom.Geometry}
* @extends {ol.geom.Geometry}
* @param {ol.geom.Coordinate} coordinates Coordinates array (e.g. [x, y]).
*/
ol.geom.Point = function(coordinates) {
goog.base(this);
/**
* @type {Float64Array}
*/
@@ -33,6 +35,7 @@ ol.geom.Point = function(coordinates) {
this.bounds_ = null;
};
goog.inherits(ol.geom.Point, ol.geom.Geometry);
/**

View File

@@ -11,12 +11,14 @@ goog.require('ol.geom.LinearRing');
/**
* @constructor
* @implements {ol.geom.Geometry}
* @extends {ol.geom.Geometry}
* @param {Array.<ol.geom.CoordinateArray>} coordinates Array of rings. First
* is outer, any remaining are inner.
*/
ol.geom.Polygon = function(coordinates) {
goog.base(this);
var numRings = coordinates.length,
dimension;
@@ -46,6 +48,7 @@ ol.geom.Polygon = function(coordinates) {
this.bounds_ = null;
};
goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
/**