Remove dimension property from geometries
This was only necessary when using the shared vertices structure.
This commit is contained in:
@@ -14,11 +14,6 @@ goog.require('ol.geom.Geometry');
|
||||
ol.geom.AbstractCollection = function() {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension;
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.geom.Geometry>}
|
||||
*/
|
||||
|
||||
@@ -12,21 +12,12 @@ goog.require('ol.TransformFunction');
|
||||
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.dimension = this.dimension;
|
||||
return clone;
|
||||
return new this.constructor(this.getCoordinates());
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -23,20 +23,6 @@ ol.geom.GeometryCollection = function(geometries) {
|
||||
*/
|
||||
this.components = geometries;
|
||||
|
||||
var dimension = 0;
|
||||
for (var i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
if (goog.isDef(dimension)) {
|
||||
dimension = geometries[i].dimension;
|
||||
} else {
|
||||
goog.asserts.assert(dimension == geometries[i].dimension);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = dimension;
|
||||
|
||||
};
|
||||
goog.inherits(ol.geom.GeometryCollection, ol.geom.AbstractCollection);
|
||||
|
||||
|
||||
@@ -26,12 +26,6 @@ ol.geom.LineString = function(coordinates) {
|
||||
*/
|
||||
this.coordinates_ = coordinates;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates[0].length;
|
||||
goog.asserts.assert(this.dimension >= 2);
|
||||
|
||||
/**
|
||||
* @type {ol.Extent}
|
||||
* @private
|
||||
@@ -119,11 +113,10 @@ ol.geom.LineString.prototype.distanceFromCoordinate = function(coordinate) {
|
||||
*/
|
||||
ol.geom.LineString.prototype.transform = function(transform) {
|
||||
var coordinates = this.getCoordinates();
|
||||
var dimension = this.dimension;
|
||||
var coord;
|
||||
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
coord = coordinates[i];
|
||||
transform(coord, coord, dimension);
|
||||
transform(coord, coord, coord.length);
|
||||
}
|
||||
this.bounds_ = null;
|
||||
};
|
||||
|
||||
@@ -27,11 +27,6 @@ ol.geom.MultiLineString = function(coordinates) {
|
||||
this.components[i] = new ol.geom.LineString(coordinates[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates[0][0].length;
|
||||
|
||||
};
|
||||
goog.inherits(ol.geom.MultiLineString, ol.geom.AbstractCollection);
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@ ol.geom.MultiPoint = function(coordinates) {
|
||||
this.components[i] = new ol.geom.Point(coordinates[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates[0].length;
|
||||
|
||||
};
|
||||
goog.inherits(ol.geom.MultiPoint, ol.geom.AbstractCollection);
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ ol.geom.MultiPolygon = function(coordinates) {
|
||||
this.components[i] = new ol.geom.Polygon(coordinates[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates[0][0][0].length;
|
||||
|
||||
};
|
||||
goog.inherits(ol.geom.MultiPolygon, ol.geom.AbstractCollection);
|
||||
|
||||
|
||||
@@ -22,12 +22,6 @@ ol.geom.Point = function(coordinates) {
|
||||
*/
|
||||
this.coordinates_ = coordinates;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates.length;
|
||||
goog.asserts.assert(this.dimension >= 2);
|
||||
|
||||
/**
|
||||
* @type {ol.Extent}
|
||||
* @private
|
||||
@@ -82,6 +76,6 @@ ol.geom.Point.prototype.getType = function() {
|
||||
*/
|
||||
ol.geom.Point.prototype.transform = function(transform) {
|
||||
var coordinates = this.getCoordinates();
|
||||
transform(coordinates, coordinates, this.dimension);
|
||||
transform(coordinates, coordinates, coordinates.length);
|
||||
this.bounds_ = null;
|
||||
};
|
||||
|
||||
@@ -54,12 +54,6 @@ ol.geom.Polygon = function(coordinates) {
|
||||
this.rings[i] = new ol.geom.LinearRing(ringCoords);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = coordinates[0][0].length;
|
||||
goog.asserts.assert(this.dimension >= 2);
|
||||
|
||||
};
|
||||
goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ ol.renderer.canvas.VectorRenderer.prototype.renderLineStringFeatures_ =
|
||||
function(features, symbolizer) {
|
||||
|
||||
var context = this.context_,
|
||||
i, ii, feature, id, currentSize, geometry, components, j, jj, line, dim,
|
||||
i, ii, feature, id, currentSize, geometry, components, j, jj, line,
|
||||
k, kk, vec, strokeSize;
|
||||
|
||||
context.globalAlpha = symbolizer.opacity;
|
||||
@@ -197,7 +197,6 @@ ol.renderer.canvas.VectorRenderer.prototype.renderLineStringFeatures_ =
|
||||
}
|
||||
for (j = 0, jj = components.length; j < jj; ++j) {
|
||||
line = components[j];
|
||||
dim = line.dimension;
|
||||
for (k = 0, kk = line.getCount(); k < kk; ++k) {
|
||||
vec = [line.get(k, 0), line.get(k, 1), 0];
|
||||
goog.vec.Mat4.multVec3(this.transform_, vec, vec);
|
||||
@@ -347,7 +346,7 @@ ol.renderer.canvas.VectorRenderer.prototype.renderPolygonFeatures_ =
|
||||
fillOpacity = symbolizer.fillOpacity,
|
||||
globalAlpha,
|
||||
i, ii, geometry, components, j, jj, poly,
|
||||
rings, numRings, ring, dim, k, kk, vec, feature;
|
||||
rings, numRings, ring, k, kk, vec, feature;
|
||||
|
||||
if (strokeColor) {
|
||||
context.strokeStyle = strokeColor;
|
||||
@@ -384,7 +383,6 @@ ol.renderer.canvas.VectorRenderer.prototype.renderPolygonFeatures_ =
|
||||
}
|
||||
for (j = 0, jj = components.length; j < jj; ++j) {
|
||||
poly = components[j];
|
||||
dim = poly.dimension;
|
||||
rings = poly.rings;
|
||||
numRings = rings.length;
|
||||
if (numRings > 0) {
|
||||
|
||||
@@ -36,25 +36,6 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||
expect(multi.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var multi = new ol.geom.GeometryCollection([
|
||||
new ol.geom.Point([30, 40, 50])
|
||||
]);
|
||||
expect(multi.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#clone()', function() {
|
||||
|
||||
it('has a working clone method', function() {
|
||||
|
||||
@@ -11,20 +11,6 @@ describe('ol.geom.LinearRing', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
||||
expect(ring.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var ring = new ol.geom.LinearRing([[10, 20, 30], [40, 50, 60]]);
|
||||
expect(ring.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getCoordinates()', function() {
|
||||
|
||||
it('is an array', function() {
|
||||
|
||||
@@ -12,20 +12,6 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
expect(line.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var line = new ol.geom.LineString([[10, 20, 30], [40, 50, 60]]);
|
||||
expect(line.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
@@ -12,13 +12,6 @@ describe('ol.geom.MultiLineString', function() {
|
||||
expect(multi).to.be.a(ol.geom.Geometry);
|
||||
});
|
||||
|
||||
it('throws when given with insufficient dimensions', function() {
|
||||
expect(function() {
|
||||
var multi = new ol.geom.MultiLineString([1]);
|
||||
multi = multi; // suppress gjslint warning about unused variable
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#components', function() {
|
||||
@@ -36,24 +29,6 @@ describe('ol.geom.MultiLineString', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var multi = new ol.geom.MultiLineString([
|
||||
[[10, 20], [30, 40]],
|
||||
[[20, 30], [40, 50]]]);
|
||||
expect(multi.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var multi = new ol.geom.MultiLineString([
|
||||
[[10, 20, 30], [30, 40, 50]],
|
||||
[[20, 30, 40], [40, 50, 60]]]);
|
||||
expect(multi.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
@@ -10,13 +10,6 @@ describe('ol.geom.MultiPoint', function() {
|
||||
expect(multi).to.be.a(ol.geom.Geometry);
|
||||
});
|
||||
|
||||
it('throws when given with insufficient dimensions', function() {
|
||||
expect(function() {
|
||||
var multi = new ol.geom.MultiPoint([1]);
|
||||
multi = multi; // suppress gjslint warning about unused variable
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#components', function() {
|
||||
@@ -32,20 +25,6 @@ describe('ol.geom.MultiPoint', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||
expect(multi.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var multi = new ol.geom.MultiPoint([[10, 20, 30], [30, 40, 50]]);
|
||||
expect(multi.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
@@ -41,22 +41,6 @@ describe('ol.geom.MultiPolygon', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var multi = new ol.geom.MultiPolygon([
|
||||
[outer1, inner1a, inner1b],
|
||||
[outer2]]);
|
||||
expect(multi.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var multi = new ol.geom.MultiPolygon([[[[10, 20, 30], [40, 50, 60]]]]);
|
||||
expect(multi.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
@@ -10,27 +10,6 @@ describe('ol.geom.Point', function() {
|
||||
expect(point).to.be.a(ol.geom.Geometry);
|
||||
});
|
||||
|
||||
it('throws when given with insufficient dimensions', function() {
|
||||
expect(function() {
|
||||
var point = new ol.geom.Point([1]);
|
||||
point = point; // suppress gjslint warning about unused variable
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
expect(point.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var point = new ol.geom.Point([10, 20, 30]);
|
||||
expect(point.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
@@ -51,20 +51,6 @@ describe('ol.geom.Polygon', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
it('can be 2', function() {
|
||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
expect(poly.dimension).to.be(2);
|
||||
});
|
||||
|
||||
it('can be 3', function() {
|
||||
var poly = new ol.geom.Polygon([[[10, 20, 30], [40, 50, 60]]]);
|
||||
expect(poly.dimension).to.be(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
@@ -15,7 +15,6 @@ describe('ol.parser.KML', function() {
|
||||
var geom = obj.features[0].getGeometry();
|
||||
expect(obj.features[0].getId()).to.eql('KML.Polygon');
|
||||
expect(geom instanceof ol.geom.Polygon).to.be.ok();
|
||||
expect(geom.dimension).to.eql(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -28,7 +27,6 @@ describe('ol.parser.KML', function() {
|
||||
expect(obj.features.length).to.eql(2);
|
||||
var geom = obj.features[0].getGeometry();
|
||||
expect(geom instanceof ol.geom.LineString).to.be.ok();
|
||||
expect(geom.dimension).to.eql(3);
|
||||
geom = obj.features[1].getGeometry();
|
||||
expect(geom instanceof ol.geom.LineString).to.be.ok();
|
||||
done();
|
||||
@@ -43,7 +41,6 @@ describe('ol.parser.KML', function() {
|
||||
expect(obj.features.length).to.eql(1);
|
||||
var geom = obj.features[0].getGeometry();
|
||||
expect(geom instanceof ol.geom.Point).to.be.ok();
|
||||
expect(geom.dimension).to.eql(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user