diff --git a/examples/kml-earthquakes.js b/examples/kml-earthquakes.js
index c1bc43ce6e..826f1fb54f 100644
--- a/examples/kml-earthquakes.js
+++ b/examples/kml-earthquakes.js
@@ -32,7 +32,7 @@ var style = new ol.style.Style({
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
- parser: new ol.parser.KML({dimension: 2}),
+ parser: new ol.parser.KML(),
url: 'data/kml/2012_Earthquakes_Mag5.kml'
}),
style: style
diff --git a/examples/kml-timezones.js b/examples/kml-timezones.js
index b768552986..80524a9e00 100644
--- a/examples/kml-timezones.js
+++ b/examples/kml-timezones.js
@@ -54,7 +54,7 @@ var style = new ol.style.Style({
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
- parser: new ol.parser.KML({dimension: 2}),
+ parser: new ol.parser.KML(),
url: 'data/kml/timezones.kml'
}),
style: style
diff --git a/examples/kml.js b/examples/kml.js
index 7e0fce8da3..d99e343ecc 100644
--- a/examples/kml.js
+++ b/examples/kml.js
@@ -22,7 +22,7 @@ var raster = new ol.layer.Tile({
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.KML({
- maxDepth: 1, dimension: 2, extractStyles: true, extractAttributes: true
+ maxDepth: 1, extractStyles: true, extractAttributes: true
}),
url: 'data/kml/lines.kml'
})
diff --git a/examples/topojson.html b/examples/topojson.html
index 9bf116555d..0afee83db1 100644
--- a/examples/topojson.html
+++ b/examples/topojson.html
@@ -4,6 +4,7 @@
+
diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc
index 9386a27feb..332699752c 100644
--- a/src/objectliterals.jsdoc
+++ b/src/objectliterals.jsdoc
@@ -412,8 +412,6 @@
/**
* @typedef {Object} ol.parser.KMLOptions
- * @property {number|undefined} dimension Create geometries with `dimension`
- * dimensions. Default is 3.
* @property {boolean|undefined} extractAttributes Should we extract attributes
* from the KML? Default is `true´.
* @property {boolean|undefined} extractStyles Should we extract styles from the
diff --git a/src/ol/geom/abstractcollection.js b/src/ol/geom/abstractcollection.js
index eabe5972fd..590b3cd15a 100644
--- a/src/ol/geom/abstractcollection.js
+++ b/src/ol/geom/abstractcollection.js
@@ -14,11 +14,6 @@ goog.require('ol.geom.Geometry');
ol.geom.AbstractCollection = function() {
goog.base(this);
- /**
- * @type {number}
- */
- this.dimension;
-
/**
* @type {Array.
}
*/
@@ -67,3 +62,15 @@ ol.geom.AbstractCollection.prototype.getCoordinates = function() {
* @inheritDoc
*/
ol.geom.AbstractCollection.prototype.getType = goog.abstractMethod;
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.AbstractCollection.prototype.transform = function(transform) {
+ var components = this.components;
+ for (var i = 0, ii = components.length; i < ii; ++i) {
+ components[i].transform(transform);
+ }
+ this.bounds = null;
+};
diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js
index 383c255fa1..189f347421 100644
--- a/src/ol/geom/geometry.js
+++ b/src/ol/geom/geometry.js
@@ -2,41 +2,22 @@ goog.provide('ol.geom.Geometry');
goog.provide('ol.geom.GeometryType');
goog.require('ol.Extent');
-goog.require('ol.geom.SharedVertices');
+goog.require('ol.TransformFunction');
/**
* @constructor
*/
-ol.geom.Geometry = function() {
-
- /**
- * @type {ol.geom.SharedVertices}
- * @protected
- */
- this.vertices = null;
-
-};
+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. The clone will not be represented in any
- * shared structure.
+ * 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;
+ return new this.constructor(this.getCoordinates());
};
@@ -53,15 +34,6 @@ ol.geom.Geometry.prototype.getBounds = goog.abstractMethod;
ol.geom.Geometry.prototype.getCoordinates = goog.abstractMethod;
-/**
- * Get the shared vertices for this geometry.
- * @return {ol.geom.SharedVertices} The shared vertices.
- */
-ol.geom.Geometry.prototype.getSharedVertices = function() {
- return this.vertices;
-};
-
-
/**
* Get the geometry type.
* @return {ol.geom.GeometryType} The geometry type.
@@ -69,6 +41,13 @@ ol.geom.Geometry.prototype.getSharedVertices = function() {
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.
*
diff --git a/src/ol/geom/geometrycollection.js b/src/ol/geom/geometrycollection.js
index 71e96e7cfb..4cdee57aed 100644
--- a/src/ol/geom/geometrycollection.js
+++ b/src/ol/geom/geometrycollection.js
@@ -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);
diff --git a/src/ol/geom/linearring.js b/src/ol/geom/linearring.js
index 5fb5e5a3ef..fb7eb418eb 100644
--- a/src/ol/geom/linearring.js
+++ b/src/ol/geom/linearring.js
@@ -3,7 +3,6 @@ goog.provide('ol.geom.LinearRing');
goog.require('ol.CoordinateArray');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
-goog.require('ol.geom.SharedVertices');
@@ -12,10 +11,9 @@ goog.require('ol.geom.SharedVertices');
* @extends {ol.geom.LineString}
* @param {ol.CoordinateArray} coordinates Vertex array (e.g.
* [[x0, y0], [x1, y1]]).
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.LinearRing = function(coordinates, opt_shared) {
- goog.base(this, coordinates, opt_shared);
+ol.geom.LinearRing = function(coordinates) {
+ goog.base(this, coordinates);
/**
* We're intentionally not enforcing that rings be closed right now. This
diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js
index 682d474a18..b992d5c490 100644
--- a/src/ol/geom/linestring.js
+++ b/src/ol/geom/linestring.js
@@ -2,48 +2,29 @@ goog.provide('ol.geom.LineString');
goog.require('goog.asserts');
goog.require('ol.CoordinateArray');
+goog.require('ol.extent');
goog.require('ol.geom');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType');
-goog.require('ol.geom.SharedVertices');
/**
* @constructor
* @extends {ol.geom.Geometry}
- * @param {ol.CoordinateArray} coordinates Vertex array (e.g.
+ * @param {ol.CoordinateArray} coordinates Array of coordinates (e.g.
* [[x0, y0], [x1, y1]]).
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.LineString = function(coordinates, opt_shared) {
+ol.geom.LineString = function(coordinates) {
goog.base(this);
goog.asserts.assert(goog.isArray(coordinates[0]));
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- dimension = coordinates[0].length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
/**
- * @type {ol.geom.SharedVertices}
- */
- this.vertices = vertices;
-
- /**
- * @type {number}
+ * Array of coordinates.
+ * @type {ol.CoordinateArray}
* @private
*/
- this.sharedId_ = vertices.add(coordinates);
-
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
- goog.asserts.assert(this.dimension >= 2);
+ this.coordinates_ = coordinates;
/**
* @type {ol.Extent}
@@ -62,7 +43,9 @@ goog.inherits(ol.geom.LineString, ol.geom.Geometry);
* @return {number} The vertex coordinate value.
*/
ol.geom.LineString.prototype.get = function(index, dim) {
- return this.vertices.get(this.sharedId_, index, dim);
+ var coordinates = this.getCoordinates();
+ goog.asserts.assert(coordinates.length > index);
+ return coordinates[index][dim];
};
@@ -71,17 +54,7 @@ ol.geom.LineString.prototype.get = function(index, dim) {
* @return {ol.CoordinateArray} Coordinates array.
*/
ol.geom.LineString.prototype.getCoordinates = function() {
- var count = this.getCount();
- var coordinates = new Array(count);
- var vertex;
- for (var i = 0; i < count; ++i) {
- vertex = new Array(this.dimension);
- for (var j = 0; j < this.dimension; ++j) {
- vertex[j] = this.get(i, j);
- }
- coordinates[i] = vertex;
- }
- return coordinates;
+ return this.coordinates_;
};
@@ -90,7 +63,7 @@ ol.geom.LineString.prototype.getCoordinates = function() {
* @return {number} The vertex count.
*/
ol.geom.LineString.prototype.getCount = function() {
- return this.vertices.getCount(this.sharedId_);
+ return this.getCoordinates().length;
};
@@ -99,34 +72,12 @@ ol.geom.LineString.prototype.getCount = function() {
*/
ol.geom.LineString.prototype.getBounds = function() {
if (goog.isNull(this.bounds_)) {
- var dimension = this.dimension,
- vertices = this.vertices,
- id = this.sharedId_,
- count = vertices.getCount(id),
- start = vertices.getStart(id),
- end = start + (count * dimension),
- coordinates = vertices.coordinates,
- minX, maxX,
- minY, maxY,
- x, y, i;
-
- minX = maxX = coordinates[start];
- minY = maxY = coordinates[start + 1];
- for (i = start + dimension; i < end; i += dimension) {
- x = coordinates[i];
- y = coordinates[i + 1];
- if (x < minX) {
- minX = x;
- } else if (x > maxX) {
- maxX = x;
- }
- if (y < minY) {
- minY = y;
- } else if (y > maxY) {
- maxY = y;
- }
+ var coordinates = this.getCoordinates();
+ var extent = ol.extent.createEmpty();
+ for (var i = 0, ii = coordinates.length; i < ii; ++i) {
+ ol.extent.extendCoordinate(extent, coordinates[i]);
}
- this.bounds_ = [minX, minY, maxX, maxY];
+ this.bounds_ = extent;
}
return this.bounds_;
};
@@ -140,15 +91,6 @@ ol.geom.LineString.prototype.getType = function() {
};
-/**
- * Get the identifier used to mark this line in the shared vertices structure.
- * @return {number} The identifier.
- */
-ol.geom.LineString.prototype.getSharedId = function() {
- return this.sharedId_;
-};
-
-
/**
* Calculate the distance from a coordinate to this linestring.
*
@@ -164,3 +106,17 @@ ol.geom.LineString.prototype.distanceFromCoordinate = function(coordinate) {
}
return Math.sqrt(dist2);
};
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.LineString.prototype.transform = function(transform) {
+ var coordinates = this.getCoordinates();
+ var coord;
+ for (var i = 0, ii = coordinates.length; i < ii; ++i) {
+ coord = coordinates[i];
+ transform(coord, coord, coord.length);
+ }
+ this.bounds_ = null;
+};
diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js
index a884e7411b..756f1fb0cf 100644
--- a/src/ol/geom/multilinestring.js
+++ b/src/ol/geom/multilinestring.js
@@ -5,7 +5,6 @@ goog.require('ol.CoordinateArray');
goog.require('ol.geom.AbstractCollection');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
-goog.require('ol.geom.SharedVertices');
@@ -13,21 +12,11 @@ goog.require('ol.geom.SharedVertices');
* @constructor
* @extends {ol.geom.AbstractCollection}
* @param {Array.} coordinates Coordinates array.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.MultiLineString = function(coordinates, opt_shared) {
+ol.geom.MultiLineString = function(coordinates) {
goog.base(this);
goog.asserts.assert(goog.isArray(coordinates[0][0]));
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- // try to get dimension from first vertex in first line
- dimension = coordinates[0][0].length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
var numParts = coordinates.length;
/**
@@ -35,14 +24,9 @@ ol.geom.MultiLineString = function(coordinates, opt_shared) {
*/
this.components = new Array(numParts);
for (var i = 0; i < numParts; ++i) {
- this.components[i] = new ol.geom.LineString(coordinates[i], vertices);
+ this.components[i] = new ol.geom.LineString(coordinates[i]);
}
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
-
};
goog.inherits(ol.geom.MultiLineString, ol.geom.AbstractCollection);
@@ -78,14 +62,13 @@ ol.geom.MultiLineString.prototype.distanceFromCoordinate =
* Create a multi-linestring geometry from an array of linestring geometries.
*
* @param {Array.} geometries Array of geometries.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
* @return {ol.geom.MultiLineString} A new geometry.
*/
-ol.geom.MultiLineString.fromParts = function(geometries, opt_shared) {
+ol.geom.MultiLineString.fromParts = function(geometries) {
var count = geometries.length;
var coordinates = new Array(count);
for (var i = 0; i < count; ++i) {
coordinates[i] = geometries[i].getCoordinates();
}
- return new ol.geom.MultiLineString(coordinates, opt_shared);
+ return new ol.geom.MultiLineString(coordinates);
};
diff --git a/src/ol/geom/multipoint.js b/src/ol/geom/multipoint.js
index ce9e0c100e..fe8f75d971 100644
--- a/src/ol/geom/multipoint.js
+++ b/src/ol/geom/multipoint.js
@@ -5,7 +5,6 @@ goog.require('ol.CoordinateArray');
goog.require('ol.geom.AbstractCollection');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Point');
-goog.require('ol.geom.SharedVertices');
@@ -13,26 +12,11 @@ goog.require('ol.geom.SharedVertices');
* @constructor
* @extends {ol.geom.AbstractCollection}
* @param {ol.CoordinateArray} coordinates Coordinates array.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.MultiPoint = function(coordinates, opt_shared) {
+ol.geom.MultiPoint = function(coordinates) {
goog.base(this);
goog.asserts.assert(goog.isArray(coordinates[0]));
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- // try to get dimension from first vertex
- dimension = coordinates[0].length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
- /**
- * @type {ol.geom.SharedVertices}
- */
- this.vertices = vertices;
-
var numParts = coordinates.length;
/**
@@ -40,14 +24,9 @@ ol.geom.MultiPoint = function(coordinates, opt_shared) {
*/
this.components = new Array(numParts);
for (var i = 0; i < numParts; ++i) {
- this.components[i] = new ol.geom.Point(coordinates[i], vertices);
+ this.components[i] = new ol.geom.Point(coordinates[i]);
}
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
-
};
goog.inherits(ol.geom.MultiPoint, ol.geom.AbstractCollection);
@@ -64,14 +43,13 @@ ol.geom.MultiPoint.prototype.getType = function() {
* Create a multi-point geometry from an array of point geometries.
*
* @param {Array.} geometries Array of geometries.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
* @return {ol.geom.MultiPoint} A new geometry.
*/
-ol.geom.MultiPoint.fromParts = function(geometries, opt_shared) {
+ol.geom.MultiPoint.fromParts = function(geometries) {
var count = geometries.length;
var coordinates = new Array(count);
for (var i = 0; i < count; ++i) {
coordinates[i] = geometries[i].getCoordinates();
}
- return new ol.geom.MultiPoint(coordinates, opt_shared);
+ return new ol.geom.MultiPoint(coordinates);
};
diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js
index be355cfd65..45c5e20cf4 100644
--- a/src/ol/geom/multipolygon.js
+++ b/src/ol/geom/multipolygon.js
@@ -5,7 +5,6 @@ goog.require('ol.CoordinateArray');
goog.require('ol.geom.AbstractCollection');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
@@ -14,21 +13,11 @@ goog.require('ol.geom.SharedVertices');
* @extends {ol.geom.AbstractCollection}
* @param {Array.>} coordinates Coordinates
* array.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.MultiPolygon = function(coordinates, opt_shared) {
+ol.geom.MultiPolygon = function(coordinates) {
goog.base(this);
goog.asserts.assert(goog.isArray(coordinates[0][0][0]));
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- // try to get dimension from first vertex in first ring of the first poly
- dimension = coordinates[0][0][0].length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
var numParts = coordinates.length;
/**
@@ -36,14 +25,9 @@ ol.geom.MultiPolygon = function(coordinates, opt_shared) {
*/
this.components = new Array(numParts);
for (var i = 0; i < numParts; ++i) {
- this.components[i] = new ol.geom.Polygon(coordinates[i], vertices);
+ this.components[i] = new ol.geom.Polygon(coordinates[i]);
}
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
-
};
goog.inherits(ol.geom.MultiPolygon, ol.geom.AbstractCollection);
@@ -78,14 +62,13 @@ ol.geom.MultiPolygon.prototype.containsCoordinate = function(coordinate) {
* Create a multi-polygon geometry from an array of polygon geometries.
*
* @param {Array.} geometries Array of geometries.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
* @return {ol.geom.MultiPolygon} A new geometry.
*/
-ol.geom.MultiPolygon.fromParts = function(geometries, opt_shared) {
+ol.geom.MultiPolygon.fromParts = function(geometries) {
var count = geometries.length;
var coordinates = new Array(count);
for (var i = 0; i < count; ++i) {
coordinates[i] = geometries[i].getCoordinates();
}
- return new ol.geom.MultiPolygon(coordinates, opt_shared);
+ return new ol.geom.MultiPolygon(coordinates);
};
diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js
index b65f21fc18..2b349c84c2 100644
--- a/src/ol/geom/point.js
+++ b/src/ol/geom/point.js
@@ -4,43 +4,23 @@ goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType');
-goog.require('ol.geom.SharedVertices');
/**
* @constructor
* @extends {ol.geom.Geometry}
- * @param {ol.Coordinate} coordinates Coordinates array (e.g. [x, y]).
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
+ * @param {ol.Coordinate} coordinates Coordinate values (e.g. [x, y]).
*/
-ol.geom.Point = function(coordinates, opt_shared) {
+ol.geom.Point = function(coordinates) {
goog.base(this);
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- dimension = coordinates.length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
/**
- * @type {ol.geom.SharedVertices}
- */
- this.vertices = vertices;
-
- /**
- * @type {number}
+ * Point coordinate values.
+ * @type {ol.Coordinate}
* @private
*/
- this.sharedId_ = vertices.add([coordinates]);
-
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
- goog.asserts.assert(this.dimension >= 2);
+ this.coordinates_ = coordinates;
/**
* @type {ol.Extent}
@@ -57,7 +37,7 @@ goog.inherits(ol.geom.Point, ol.geom.Geometry);
* @return {number} The coordinate value.
*/
ol.geom.Point.prototype.get = function(dim) {
- return this.vertices.get(this.sharedId_, 0, dim);
+ return this.getCoordinates()[dim];
};
@@ -79,11 +59,7 @@ ol.geom.Point.prototype.getBounds = function() {
* @return {ol.Coordinate} Coordinates array.
*/
ol.geom.Point.prototype.getCoordinates = function() {
- var coordinates = new Array(this.dimension);
- for (var i = 0; i < this.dimension; ++i) {
- coordinates[i] = this.get(i);
- }
- return coordinates;
+ return this.coordinates_;
};
@@ -96,9 +72,10 @@ ol.geom.Point.prototype.getType = function() {
/**
- * Get the identifier used to mark this point in the shared vertices structure.
- * @return {number} The identifier.
+ * @inheritDoc
*/
-ol.geom.Point.prototype.getSharedId = function() {
- return this.sharedId_;
+ol.geom.Point.prototype.transform = function(transform) {
+ var coordinates = this.getCoordinates();
+ transform(coordinates, coordinates, coordinates.length);
+ this.bounds_ = null;
};
diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js
index 2f442a56e4..b1ec7d68a2 100644
--- a/src/ol/geom/polygon.js
+++ b/src/ol/geom/polygon.js
@@ -6,7 +6,6 @@ goog.require('ol.extent');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LinearRing');
-goog.require('ol.geom.SharedVertices');
@@ -21,32 +20,17 @@ goog.require('ol.geom.SharedVertices');
* @extends {ol.geom.Geometry}
* @param {Array.} coordinates Array of rings. First
* is outer, any remaining are inner.
- * @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
*/
-ol.geom.Polygon = function(coordinates, opt_shared) {
+ol.geom.Polygon = function(coordinates) {
goog.base(this);
goog.asserts.assert(goog.isArray(coordinates[0][0]));
- var vertices = opt_shared,
- dimension;
-
- if (!goog.isDef(vertices)) {
- // try to get dimension from first vertex in first ring
- dimension = coordinates[0][0].length;
- vertices = new ol.geom.SharedVertices({dimension: dimension});
- }
-
/**
* @private
* @type {ol.Coordinate}
*/
this.labelPoint_ = null;
- /**
- * @type {ol.geom.SharedVertices}
- */
- this.vertices = vertices;
-
var numRings = coordinates.length;
/**
@@ -67,15 +51,9 @@ ol.geom.Polygon = function(coordinates, opt_shared) {
ringCoords.reverse();
}
}
- this.rings[i] = new ol.geom.LinearRing(ringCoords, vertices);
+ this.rings[i] = new ol.geom.LinearRing(ringCoords);
}
- /**
- * @type {number}
- */
- this.dimension = vertices.getDimension();
- goog.asserts.assert(this.dimension >= 2);
-
};
goog.inherits(ol.geom.Polygon, ol.geom.Geometry);
@@ -179,3 +157,14 @@ ol.geom.Polygon.prototype.getInteriorPoint = function() {
return this.labelPoint_;
};
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.Polygon.prototype.transform = function(transform) {
+ var rings = this.rings;
+ for (var i = 0, ii = rings.length; i < ii; ++i) {
+ rings[i].transform(transform);
+ }
+};
diff --git a/src/ol/geom/sharedvertices.js b/src/ol/geom/sharedvertices.js
deleted file mode 100644
index e6c432997b..0000000000
--- a/src/ol/geom/sharedvertices.js
+++ /dev/null
@@ -1,157 +0,0 @@
-goog.provide('ol.geom.SharedVertices');
-
-goog.require('goog.asserts');
-goog.require('ol.Coordinate');
-goog.require('ol.CoordinateArray');
-
-
-/**
- * @typedef {{dimension: (number),
- * offset: (ol.Coordinate|undefined)}}
- */
-ol.geom.SharedVerticesOptions;
-
-
-
-/**
- * Provides methods for dealing with shared, flattened arrays of vertices.
- *
- * @constructor
- * @param {ol.geom.SharedVerticesOptions=} opt_options Shared vertices options.
- */
-ol.geom.SharedVertices = function(opt_options) {
- var options = opt_options ? opt_options : {};
-
- /**
- * @type {Array.}
- */
- this.coordinates = [];
-
- /**
- * @type {Array.}
- * @private
- */
- this.starts_ = [];
-
- /**
- * @type {Array.}
- * @private
- */
- this.counts_ = [];
-
- /**
- * Number of dimensions per vertex. Default is 2.
- * @type {number}
- * @private
- */
- this.dimension_ = options.dimension || 2;
-
- /**
- * Vertex offset.
- * @type {Array.}
- * @private
- */
- this.offset_ = options.offset || null;
- goog.asserts.assert(goog.isNull(this.offset_) ||
- this.offset_.length === this.dimension_);
-
-};
-
-
-/**
- * Adds a vertex array to the shared coordinate array.
- * @param {ol.CoordinateArray} vertices Array of vertices.
- * @return {number} Index used to reference the added vertex array.
- */
-ol.geom.SharedVertices.prototype.add = function(vertices) {
- var start = this.coordinates.length;
- var offset = this.offset_;
- var dimension = this.dimension_;
- var count = vertices.length;
- var vertex, index;
- for (var i = 0; i < count; ++i) {
- vertex = vertices[i];
- index = start + (i * dimension);
- for (var j = 0; j < dimension; ++j) {
- this.coordinates[index + j] = vertex[j] - (offset ? offset[j] : 0);
- }
- }
- var length = this.starts_.push(start);
- this.counts_.push(count);
- return length - 1;
-};
-
-
-/**
- * @param {number} id The vertex array identifier (returned by add).
- * @param {number} index The vertex index.
- * @param {number} dim The coordinate dimension.
- * @return {number} The coordinate value.
- */
-ol.geom.SharedVertices.prototype.get = function(id, index, dim) {
- goog.asserts.assert(id < this.starts_.length);
- goog.asserts.assert(dim <= this.dimension_);
- goog.asserts.assert(index < this.counts_[id]);
- var start = this.starts_[id];
- var value = this.coordinates[start + (index * this.dimension_) + dim];
- if (this.offset_) {
- value += this.offset_[dim];
- }
- return value;
-};
-
-
-/**
- * @param {number} id The vertex array identifier (returned by add).
- * @return {number} The number of vertices in the referenced array.
- */
-ol.geom.SharedVertices.prototype.getCount = function(id) {
- goog.asserts.assert(id < this.counts_.length);
- return this.counts_[id];
-};
-
-
-/**
- * Get the array of counts. The index returned by the add method can be used
- * to look up the number of vertices.
- *
- * @return {Array.} The counts array.
- */
-ol.geom.SharedVertices.prototype.getCounts = function() {
- return this.counts_;
-};
-
-
-/**
- * @return {number} The dimension of each vertex in the array.
- */
-ol.geom.SharedVertices.prototype.getDimension = function() {
- return this.dimension_;
-};
-
-
-/**
- * @return {Array.} The offset array for vertex coordinates (or null).
- */
-ol.geom.SharedVertices.prototype.getOffset = function() {
- return this.offset_;
-};
-
-
-/**
- * @param {number} id The vertex array identifier (returned by add).
- * @return {number} The start index in the shared vertices array.
- */
-ol.geom.SharedVertices.prototype.getStart = function(id) {
- goog.asserts.assert(id < this.starts_.length);
- return this.starts_[id];
-};
-
-
-/**
- * Get the array of start indexes.
- * @return {Array.} The starts array.
- */
-ol.geom.SharedVertices.prototype.getStarts = function() {
- return this.starts_;
-};
diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js
index f88beaf076..0d1147f1c7 100644
--- a/src/ol/layer/vectorlayer.js
+++ b/src/ol/layer/vectorlayer.js
@@ -13,7 +13,6 @@ goog.require('ol.expr.LogicalOp');
goog.require('ol.expr.functions');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
-goog.require('ol.geom.SharedVertices');
goog.require('ol.layer.Layer');
goog.require('ol.proj');
goog.require('ol.source.Vector');
@@ -286,27 +285,6 @@ ol.layer.Vector = function(options) {
this.transformFeatureInfo_ = goog.isDef(options.transformFeatureInfo) ?
options.transformFeatureInfo : ol.layer.Vector.uidTransformFeatureInfo;
- /**
- * TODO: this means we need to know dimension at construction
- * @type {ol.geom.SharedVertices}
- * @private
- */
- this.pointVertices_ = new ol.geom.SharedVertices();
-
- /**
- * TODO: this means we need to know dimension at construction
- * @type {ol.geom.SharedVertices}
- * @private
- */
- this.lineVertices_ = new ol.geom.SharedVertices();
-
- /**
- * TODO: this means we need to know dimension at construction
- * @type {ol.geom.SharedVertices}
- * @private
- */
- this.polygonVertices_ = new ol.geom.SharedVertices();
-
/**
* True if this is a temporary layer.
* @type {boolean}
@@ -399,30 +377,6 @@ ol.layer.Vector.prototype.getFeaturesObjectForExtent = function(extent,
};
-/**
- * @return {ol.geom.SharedVertices} Shared line vertices.
- */
-ol.layer.Vector.prototype.getLineVertices = function() {
- return this.lineVertices_;
-};
-
-
-/**
- * @return {ol.geom.SharedVertices} Shared point vertices.
- */
-ol.layer.Vector.prototype.getPointVertices = function() {
- return this.pointVertices_;
-};
-
-
-/**
- * @return {ol.geom.SharedVertices} Shared polygon vertices.
- */
-ol.layer.Vector.prototype.getPolygonVertices = function() {
- return this.polygonVertices_;
-};
-
-
/**
* @param {Object.} features Features.
* @param {number} resolution Map resolution.
@@ -497,17 +451,6 @@ ol.layer.Vector.prototype.getFeatureWithUid = function(uid) {
* view in one projection.
*/
ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
- var lookup = {};
- lookup[ol.geom.GeometryType.POINT] = this.pointVertices_;
- lookup[ol.geom.GeometryType.LINESTRING] = this.lineVertices_;
- lookup[ol.geom.GeometryType.POLYGON] = this.polygonVertices_;
- lookup[ol.geom.GeometryType.MULTIPOINT] = this.pointVertices_;
- lookup[ol.geom.GeometryType.MULTILINESTRING] = this.lineVertices_;
- lookup[ol.geom.GeometryType.MULTIPOLYGON] = this.polygonVertices_;
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var addFeatures = function(data) {
var features = data.features;
@@ -516,46 +459,35 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
sourceProjection = data.metadata.projection;
}
var transform = ol.proj.getTransform(sourceProjection, projection);
-
- transform(
- this.pointVertices_.coordinates,
- this.pointVertices_.coordinates,
- this.pointVertices_.getDimension());
-
- transform(
- this.lineVertices_.coordinates,
- this.lineVertices_.coordinates,
- this.lineVertices_.getDimension());
-
- transform(
- this.polygonVertices_.coordinates,
- this.polygonVertices_.coordinates,
- this.polygonVertices_.getDimension());
-
+ var geometry = null;
+ for (var i = 0, ii = features.length; i < ii; ++i) {
+ geometry = features[i].getGeometry();
+ if (!goog.isNull(geometry)) {
+ geometry.transform(transform);
+ }
+ }
this.addFeatures(features);
};
- var options = {callback: callback}, result;
+ var result;
if (goog.isString(data)) {
if (goog.isFunction(parser.readFeaturesFromStringAsync)) {
- parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this),
- options);
+ parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this));
} else {
goog.asserts.assert(
goog.isFunction(parser.readFeaturesFromString),
'Expected parser with a readFeaturesFromString method.');
- result = parser.readFeaturesFromString(data, options);
+ result = parser.readFeaturesFromString(data);
addFeatures.call(this, result);
}
} else if (goog.isObject(data)) {
if (goog.isFunction(parser.readFeaturesFromObjectAsync)) {
- parser.readFeaturesFromObjectAsync(data, goog.bind(addFeatures, this),
- options);
+ parser.readFeaturesFromObjectAsync(data, goog.bind(addFeatures, this));
} else {
goog.asserts.assert(
goog.isFunction(parser.readFeaturesFromObject),
'Expected parser with a readFeaturesFromObject method.');
- result = parser.readFeaturesFromObject(data, options);
+ result = parser.readFeaturesFromObject(data);
addFeatures.call(this, result);
}
} else {
diff --git a/src/ol/parser/featureparser.js b/src/ol/parser/featureparser.js
index d284865c1c..cd614b4f91 100644
--- a/src/ol/parser/featureparser.js
+++ b/src/ol/parser/featureparser.js
@@ -2,7 +2,6 @@ goog.provide('ol.parser.AsyncObjectFeatureParser');
goog.provide('ol.parser.AsyncStringFeatureParser');
goog.provide('ol.parser.DomFeatureParser');
goog.provide('ol.parser.ObjectFeatureParser');
-goog.provide('ol.parser.ReadFeaturesOptions');
goog.provide('ol.parser.ReadFeaturesResult');
goog.provide('ol.parser.StringFeatureParser');
@@ -18,7 +17,6 @@ ol.parser.DomFeatureParser = function() {};
/**
* @param {Element|Document} node Document or element node.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
ol.parser.DomFeatureParser.prototype.readFeaturesFromNode =
@@ -34,7 +32,6 @@ ol.parser.ObjectFeatureParser = function() {};
/**
* @param {Object} obj Object representing features.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
ol.parser.ObjectFeatureParser.prototype.readFeaturesFromObject =
@@ -50,7 +47,6 @@ ol.parser.StringFeatureParser = function() {};
/**
* @param {string} data String data.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
ol.parser.StringFeatureParser.prototype.readFeaturesFromString =
@@ -68,7 +64,6 @@ ol.parser.AsyncStringFeatureParser = function() {};
* @param {string} data String data.
* @param {function(ol.parser.ReadFeaturesResult)} callback Callback which is
* called after parsing.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
*/
ol.parser.AsyncStringFeatureParser.prototype.readFeaturesFromStringAsync =
goog.abstractMethod;
@@ -85,30 +80,17 @@ ol.parser.AsyncObjectFeatureParser = function() {};
* @param {Object} obj Object representing features.
* @param {function(ol.parser.ReadFeaturesResult)} callback Callback which is
* called after parsing.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
*/
ol.parser.AsyncObjectFeatureParser.prototype.readFeaturesFromObjectAsync =
goog.abstractMethod;
-/**
- * @typedef {function(ol.Feature, ol.geom.GeometryType):ol.geom.SharedVertices}
- */
-ol.parser.ReadFeaturesCallback;
-
-
/**
* @typedef {{projection: ol.proj.ProjectionLike}}
*/
ol.parser.ReadFeaturesMetadata;
-/**
- * @typedef {{callback: ol.parser.ReadFeaturesCallback}}
- */
-ol.parser.ReadFeaturesOptions;
-
-
/**
* @typedef {{features: Array.,
* metadata: ol.parser.ReadFeaturesMetadata}}
diff --git a/src/ol/parser/geojsonparser.js b/src/ol/parser/geojsonparser.js
index ad648cbf9a..7e448188e3 100644
--- a/src/ol/parser/geojsonparser.js
+++ b/src/ol/parser/geojsonparser.js
@@ -12,9 +12,7 @@ goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
goog.require('ol.parser.Parser');
-goog.require('ol.parser.ReadFeaturesOptions');
goog.require('ol.parser.ReadFeaturesResult');
goog.require('ol.parser.StringFeatureParser');
@@ -60,13 +58,11 @@ ol.parser.GeoJSON.read = function(str) {
/**
* Parse a GeoJSON feature collection.
* @param {string} str GeoJSON feature collection.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.GeoJSON.prototype.readFeaturesFromString =
- function(str, opt_options) {
+ol.parser.GeoJSON.prototype.readFeaturesFromString = function(str) {
var json = /** @type {GeoJSONFeatureCollection} */ (JSON.parse(str));
- return this.parseAsFeatureCollection_(json, opt_options);
+ return this.parseAsFeatureCollection_(json);
};
@@ -74,43 +70,38 @@ ol.parser.GeoJSON.prototype.readFeaturesFromString =
* Parse a GeoJSON feature collection from decoded JSON.
* @param {GeoJSONFeatureCollection} object GeoJSON feature collection decoded
* from JSON.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.GeoJSON.prototype.readFeaturesFromObject =
- function(object, opt_options) {
- return this.parseAsFeatureCollection_(object, opt_options);
+ol.parser.GeoJSON.prototype.readFeaturesFromObject = function(object) {
+ return this.parseAsFeatureCollection_(object);
};
/**
- * Parse any GeoJSON object. Note that this method should not be called
- * recursively due to the shared vertex creation.
+ * Parse any GeoJSON object.
*
* @param {GeoJSONObject} json GeoJSON object.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.Feature|Array.|
* ol.geom.Geometry|Array.} Parsed geometry or array
* of geometries.
* @private
*/
-ol.parser.GeoJSON.prototype.parse_ = function(json, opt_options) {
+ol.parser.GeoJSON.prototype.parse_ = function(json) {
var result;
if (json.type === 'FeatureCollection') {
result = this.parseFeatureCollection_(
- /** @type {GeoJSONFeatureCollection} */ (json), opt_options);
+ /** @type {GeoJSONFeatureCollection} */ (json));
} else if (json.type === 'Feature') {
result = this.parseFeature_(
- /** @type {GeoJSONFeature} */ (json), opt_options);
+ /** @type {GeoJSONFeature} */ (json));
} else if (json.type === 'GeometryCollection') {
result = this.parseGeometryCollection_(
- /** @type {GeoJSONGeometryCollection} */ (json), opt_options);
+ /** @type {GeoJSONGeometryCollection} */ (json));
} else {
// we've been called with a geometry or an unknown object
// create a feature to get shared vertices handling
var feature = this.parseFeature_(
- /** @type {GeoJSONFeature} */ ({type: 'Feature', geometry: json}),
- opt_options);
+ /** @type {GeoJSONFeature} */ ({type: 'Feature', geometry: json}));
result = feature.getGeometry();
}
return result;
@@ -119,14 +110,12 @@ ol.parser.GeoJSON.prototype.parse_ = function(json, opt_options) {
/**
* @param {GeoJSONObject} json GeoJSON object.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Parsed object coerced into array of
* features.
* @private
*/
-ol.parser.GeoJSON.prototype.parseAsFeatureCollection_ = function(json,
- opt_options) {
- var obj = this.parse_(json, opt_options);
+ol.parser.GeoJSON.prototype.parseAsFeatureCollection_ = function(json) {
+ var obj = this.parse_(json);
var features = [];
var feature;
if (obj instanceof ol.Feature) {
@@ -164,45 +153,36 @@ ol.parser.GeoJSON.prototype.parseAsFeatureCollection_ = function(json,
/**
* @param {GeoJSONFeature} json GeoJSON feature.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Read options.
* @return {ol.Feature} Parsed feature.
* @private
*/
-ol.parser.GeoJSON.prototype.parseFeature_ = function(json, opt_options) {
+ol.parser.GeoJSON.prototype.parseFeature_ = function(json) {
var geomJson = json.geometry,
- geometry = null,
- options = opt_options || {};
+ geometry = null;
var feature = new ol.Feature(json.properties);
if (goog.isDef(json.id)) {
feature.setId(json.id);
}
if (geomJson) {
var type = geomJson.type;
- var callback = options.callback;
- var sharedVertices;
- if (callback) {
- goog.asserts.assert(type in ol.parser.GeoJSON.GeometryType,
- 'Bad geometry type: ' + type);
- sharedVertices = callback(feature, ol.parser.GeoJSON.GeometryType[type]);
- }
switch (type) {
case 'Point':
- geometry = this.parsePoint_(geomJson, sharedVertices);
+ geometry = this.parsePoint_(geomJson);
break;
case 'LineString':
- geometry = this.parseLineString_(geomJson, sharedVertices);
+ geometry = this.parseLineString_(geomJson);
break;
case 'Polygon':
- geometry = this.parsePolygon_(geomJson, sharedVertices);
+ geometry = this.parsePolygon_(geomJson);
break;
case 'MultiPoint':
- geometry = this.parseMultiPoint_(geomJson, sharedVertices);
+ geometry = this.parseMultiPoint_(geomJson);
break;
case 'MultiLineString':
- geometry = this.parseMultiLineString_(geomJson, sharedVertices);
+ geometry = this.parseMultiLineString_(geomJson);
break;
case 'MultiPolygon':
- geometry = this.parseMultiPolygon_(geomJson, sharedVertices);
+ geometry = this.parseMultiPolygon_(geomJson);
break;
default:
throw new Error('Bad geometry type: ' + type);
@@ -215,20 +195,17 @@ ol.parser.GeoJSON.prototype.parseFeature_ = function(json, opt_options) {
/**
* @param {GeoJSONFeatureCollection} json GeoJSON feature collection.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Read options.
* @return {Array.} Parsed array of features.
* @private
*/
-ol.parser.GeoJSON.prototype.parseFeatureCollection_ = function(
- json, opt_options) {
+ol.parser.GeoJSON.prototype.parseFeatureCollection_ = function(json) {
var features = json.features,
len = features.length,
result = new Array(len),
i;
for (i = 0; i < len; ++i) {
- result[i] = this.parseFeature_(
- /** @type {GeoJSONFeature} */ (features[i]), opt_options);
+ result[i] = this.parseFeature_(/** @type {GeoJSONFeature} */ (features[i]));
}
return result;
};
@@ -236,20 +213,17 @@ ol.parser.GeoJSON.prototype.parseFeatureCollection_ = function(
/**
* @param {GeoJSONGeometryCollection} json GeoJSON geometry collection.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Read options.
* @return {Array.} Parsed array of geometries.
* @private
*/
-ol.parser.GeoJSON.prototype.parseGeometryCollection_ = function(json,
- opt_options) {
+ol.parser.GeoJSON.prototype.parseGeometryCollection_ = function(json) {
var geometries = json.geometries,
len = geometries.length,
result = new Array(len),
i;
for (i = 0; i < len; ++i) {
- result[i] = this.parse_(/** @type {GeoJSONGeometry} */ (geometries[i]),
- opt_options);
+ result[i] = this.parse_(/** @type {GeoJSONGeometry} */ (geometries[i]));
}
return result;
};
@@ -257,68 +231,61 @@ ol.parser.GeoJSON.prototype.parseGeometryCollection_ = function(json,
/**
* @param {GeoJSONGeometry} json GeoJSON linestring.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.LineString} Parsed linestring.
* @private
*/
-ol.parser.GeoJSON.prototype.parseLineString_ = function(json, opt_vertices) {
- return new ol.geom.LineString(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parseLineString_ = function(json) {
+ return new ol.geom.LineString(json.coordinates);
};
/**
* @param {GeoJSONGeometry} json GeoJSON multi-linestring.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.MultiLineString} Parsed multi-linestring.
* @private
*/
-ol.parser.GeoJSON.prototype.parseMultiLineString_ = function(
- json, opt_vertices) {
- return new ol.geom.MultiLineString(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parseMultiLineString_ = function(json) {
+ return new ol.geom.MultiLineString(json.coordinates);
};
/**
* @param {GeoJSONGeometry} json GeoJSON multi-point.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.MultiPoint} Parsed multi-point.
* @private
*/
-ol.parser.GeoJSON.prototype.parseMultiPoint_ = function(json, opt_vertices) {
- return new ol.geom.MultiPoint(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parseMultiPoint_ = function(json) {
+ return new ol.geom.MultiPoint(json.coordinates);
};
/**
* @param {GeoJSONGeometry} json GeoJSON multi-polygon.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.MultiPolygon} Parsed multi-polygon.
* @private
*/
-ol.parser.GeoJSON.prototype.parseMultiPolygon_ = function(json, opt_vertices) {
- return new ol.geom.MultiPolygon(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parseMultiPolygon_ = function(json) {
+ return new ol.geom.MultiPolygon(json.coordinates);
};
/**
* @param {GeoJSONGeometry} json GeoJSON point.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.Point} Parsed point.
* @private
*/
-ol.parser.GeoJSON.prototype.parsePoint_ = function(json, opt_vertices) {
- return new ol.geom.Point(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parsePoint_ = function(json) {
+ return new ol.geom.Point(json.coordinates);
};
/**
* @param {GeoJSONGeometry} json GeoJSON polygon.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.Polygon} Parsed polygon.
* @private
*/
-ol.parser.GeoJSON.prototype.parsePolygon_ = function(json, opt_vertices) {
- return new ol.geom.Polygon(json.coordinates, opt_vertices);
+ol.parser.GeoJSON.prototype.parsePolygon_ = function(json) {
+ return new ol.geom.Polygon(json.coordinates);
};
diff --git a/src/ol/parser/gpxparser.js b/src/ol/parser/gpxparser.js
index a8e0f61057..9648360d87 100644
--- a/src/ol/parser/gpxparser.js
+++ b/src/ol/parser/gpxparser.js
@@ -9,7 +9,6 @@ goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.parser.DomFeatureParser');
goog.require('ol.parser.ObjectFeatureParser');
-goog.require('ol.parser.ReadFeaturesOptions');
goog.require('ol.parser.StringFeatureParser');
goog.require('ol.parser.XML');
@@ -58,14 +57,7 @@ ol.parser.GPX = function(opt_options) {
parseFloat(node.getAttribute('lat'))];
this.readChildNodes(node, properties);
var feature = new ol.Feature(properties);
- var sharedVertices;
- if (this.readFeaturesOptions_) {
- var callback = this.readFeaturesOptions_.callback;
- if (callback) {
- sharedVertices = callback(feature, ol.geom.GeometryType.POINT);
- }
- }
- var geometry = new ol.geom.Point(coordinates, sharedVertices);
+ var geometry = new ol.geom.Point(coordinates);
feature.setGeometry(geometry);
obj.features.push(feature);
}
@@ -82,15 +74,7 @@ ol.parser.GPX = function(opt_options) {
};
this.readChildNodes(node, container);
var feature = new ol.Feature(container.properties);
- var sharedVertices;
- if (this.readFeaturesOptions_) {
- var callback = this.readFeaturesOptions_.callback;
- if (callback) {
- sharedVertices = callback(feature, type);
- }
- }
- var geometry = new ol.geom.LineString(container.geometry.coordinates,
- sharedVertices);
+ var geometry = new ol.geom.LineString(container.geometry.coordinates);
feature.setGeometry(geometry);
obj.features.push(feature);
}
@@ -255,12 +239,9 @@ ol.parser.GPX.prototype.read = function(data) {
/**
* Parse a GPX document provided as a string.
* @param {string} str GPX document.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.GPX.prototype.readFeaturesFromString =
- function(str, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.GPX.prototype.readFeaturesFromString = function(str) {
return this.read(str);
};
@@ -268,24 +249,18 @@ ol.parser.GPX.prototype.readFeaturesFromString =
/**
* Parse a GPX document provided as a DOM structure.
* @param {Element|Document} node Document or element node.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.GPX.prototype.readFeaturesFromNode =
- function(node, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.GPX.prototype.readFeaturesFromNode = function(node) {
return this.read(node);
};
/**
* @param {Object} obj Object representing features.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.GPX.prototype.readFeaturesFromObject =
- function(obj, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.GPX.prototype.readFeaturesFromObject = function(obj) {
return this.read(obj);
};
diff --git a/src/ol/parser/kmlparser.js b/src/ol/parser/kmlparser.js
index d10945df1b..66e426ed0d 100644
--- a/src/ol/parser/kmlparser.js
+++ b/src/ol/parser/kmlparser.js
@@ -20,11 +20,9 @@ goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
goog.require('ol.parser.AsyncObjectFeatureParser');
goog.require('ol.parser.AsyncStringFeatureParser');
goog.require('ol.parser.DomFeatureParser');
-goog.require('ol.parser.ReadFeaturesOptions');
goog.require('ol.parser.StringFeatureParser');
goog.require('ol.parser.XML');
goog.require('ol.style.Fill');
@@ -54,8 +52,6 @@ ol.parser.KML = function(opt_options) {
options.extractStyles : false;
this.schemaLocation = 'http://www.opengis.net/kml/2.2 ' +
'http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd';
- // TODO re-evaluate once shared structures support 3D
- this.dimension = goog.isDef(options.dimension) ? options.dimension : 3;
this.maxDepth = goog.isDef(options.maxDepth) ? options.maxDepth : 0;
this.trackAttributes = goog.isDef(options.trackAttributes) ?
options.trackAttributes : null;
@@ -104,7 +100,6 @@ ol.parser.KML = function(opt_options) {
},
'Placemark': function(node, obj) {
var container = {properties: {}};
- var sharedVertices, callback;
var id = node.getAttribute('id');
this.readChildNodes(node, container);
if (goog.isDef(container.track)) {
@@ -132,15 +127,7 @@ ol.parser.KML = function(opt_options) {
}
var geom = track.points[i];
if (geom) {
- sharedVertices = undefined;
- if (this.readFeaturesOptions_) {
- callback = this.readFeaturesOptions_.callback;
- if (callback) {
- sharedVertices = callback(feature, geom.type);
- }
- }
- var geometry = this.createGeometry_({geometry: geom},
- sharedVertices);
+ var geometry = this.createGeometry_({geometry: geom});
if (goog.isDef(geometry)) {
feature.setGeometry(geometry);
}
@@ -159,14 +146,7 @@ ol.parser.KML = function(opt_options) {
feature.setId(id);
}
if (container.geometry) {
- sharedVertices = undefined;
- if (this.readFeaturesOptions_) {
- callback = this.readFeaturesOptions_.callback;
- if (callback) {
- sharedVertices = callback(feature, container.geometry.type);
- }
- }
- geometry = this.createGeometry_(container, sharedVertices);
+ geometry = this.createGeometry_(container);
if (goog.isDef(geometry)) {
feature.setGeometry(geometry);
}
@@ -281,8 +261,7 @@ ol.parser.KML = function(opt_options) {
for (var i = 0, ii = coords.length; i < ii; i++) {
var array = coords[i].replace(reg.removeSpace, '').split(',');
var pair = [];
- var jj = Math.min(array.length, this.dimension);
- for (var j = 0; j < jj; j++) {
+ for (var j = 0, jj = array.length; j < jj; j++) {
pair.push(parseFloat(array[j]));
}
coordArray.push(pair);
@@ -562,7 +541,7 @@ ol.parser.KML = function(opt_options) {
'coord': function(node, container) {
var str = this.getChildValue(node);
var coords = str.replace(this.regExes.trimSpace, '').split(/\s+/);
- for (var i = 0, ii = this.dimension; i < ii; ++i) {
+ for (var i = 0, ii = coords.length; i < ii; ++i) {
coords[i] = parseFloat(coords[i]);
}
var point = {
@@ -850,11 +829,8 @@ goog.inherits(ol.parser.KML, ol.parser.XML);
* @param {Object} obj Object representing features.
* @param {function(ol.parser.ReadFeaturesResult)} callback Callback which is
* called after parsing.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
*/
-ol.parser.KML.prototype.readFeaturesFromObjectAsync =
- function(obj, callback, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.KML.prototype.readFeaturesFromObjectAsync = function(obj, callback) {
this.read(obj, callback);
};
@@ -863,11 +839,8 @@ ol.parser.KML.prototype.readFeaturesFromObjectAsync =
* @param {string} str String data.
* @param {function(ol.parser.ReadFeaturesResult)}
* callback Callback which is called after parsing.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
*/
-ol.parser.KML.prototype.readFeaturesFromStringAsync =
- function(str, callback, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.KML.prototype.readFeaturesFromStringAsync = function(str, callback) {
this.read(str, callback);
};
@@ -875,12 +848,9 @@ ol.parser.KML.prototype.readFeaturesFromStringAsync =
/**
* Parse a KML document provided as a string.
* @param {string} str KML document.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.KML.prototype.readFeaturesFromString =
- function(str, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.KML.prototype.readFeaturesFromString = function(str) {
return /** @type {ol.parser.ReadFeaturesResult} */ (this.read(str));
};
@@ -888,24 +858,18 @@ ol.parser.KML.prototype.readFeaturesFromString =
/**
* Parse a KML document provided as a DOM structure.
* @param {Element|Document} node Document or element node.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.KML.prototype.readFeaturesFromNode =
- function(node, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.KML.prototype.readFeaturesFromNode = function(node) {
return /** @type {ol.parser.ReadFeaturesResult} */ (this.read(node));
};
/**
* @param {Object} obj Object representing features.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Feature reading options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.KML.prototype.readFeaturesFromObject =
- function(obj, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.KML.prototype.readFeaturesFromObject = function(obj) {
return /** @type {ol.parser.ReadFeaturesResult} */ (this.read(obj));
};
@@ -1028,52 +992,47 @@ ol.parser.KML.prototype.applyStyle_ = function(feature, styles,
/**
* @private
* @param {Object} container Geometry container.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.Geometry} The geometry created.
*/
-ol.parser.KML.prototype.createGeometry_ = function(container,
- opt_vertices) {
+ol.parser.KML.prototype.createGeometry_ = function(container) {
var geometry = null, coordinates, i, ii;
switch (container.geometry.type) {
case ol.geom.GeometryType.POINT:
- geometry = new ol.geom.Point(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.Point(container.geometry.coordinates);
break;
case ol.geom.GeometryType.LINESTRING:
- geometry = new ol.geom.LineString(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.LineString(container.geometry.coordinates);
break;
case ol.geom.GeometryType.POLYGON:
- geometry = new ol.geom.Polygon(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.Polygon(container.geometry.coordinates);
break;
case ol.geom.GeometryType.MULTIPOINT:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiPoint(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiPoint(coordinates);
break;
case ol.geom.GeometryType.MULTILINESTRING:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiLineString(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiLineString(coordinates);
break;
case ol.geom.GeometryType.MULTIPOLYGON:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiPolygon(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiPolygon(coordinates);
break;
case ol.geom.GeometryType.GEOMETRYCOLLECTION:
var geometries = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
geometries.push(this.createGeometry_({
geometry: container.geometry.parts[i]
- }, opt_vertices));
+ }));
}
geometry = new ol.geom.GeometryCollection(geometries);
break;
diff --git a/src/ol/parser/ogc/gmlparser.js b/src/ol/parser/ogc/gmlparser.js
index 35bf2302ef..250e845714 100644
--- a/src/ol/parser/ogc/gmlparser.js
+++ b/src/ol/parser/ogc/gmlparser.js
@@ -303,15 +303,7 @@ ol.parser.ogc.GML = function(opt_options) {
var feature = new ol.Feature(container.properties);
var geom = container.geometry;
if (geom) {
- var sharedVertices = undefined;
- if (this.readFeaturesOptions_) {
- var callback = this.readFeaturesOptions_.callback;
- if (callback) {
- sharedVertices = callback(feature, geom.type);
- }
- }
- var geometry = this.createGeometry({geometry: geom},
- sharedVertices);
+ var geometry = this.createGeometry({geometry: geom});
if (goog.isDef(geometry)) {
feature.setGeometry(geometry);
}
@@ -551,57 +543,51 @@ ol.parser.ogc.GML.prototype.readNode = function(node, obj, opt_first) {
/**
* @param {Object} container Geometry container.
- * @param {ol.geom.SharedVertices=} opt_vertices Shared vertices.
* @return {ol.geom.Geometry} The geometry created.
*/
// TODO use a mixin since this is also used in the KML parser
-ol.parser.ogc.GML.prototype.createGeometry = function(container,
- opt_vertices) {
+ol.parser.ogc.GML.prototype.createGeometry = function(container) {
var geometry = null, coordinates, i, ii;
switch (container.geometry.type) {
case ol.geom.GeometryType.POINT:
- geometry = new ol.geom.Point(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.Point(container.geometry.coordinates);
break;
case ol.geom.GeometryType.LINEARRING:
- geometry = new ol.geom.LinearRing(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.LinearRing(container.geometry.coordinates);
break;
case ol.geom.GeometryType.LINESTRING:
- geometry = new ol.geom.LineString(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.LineString(container.geometry.coordinates);
break;
case ol.geom.GeometryType.POLYGON:
- geometry = new ol.geom.Polygon(container.geometry.coordinates,
- opt_vertices);
+ geometry = new ol.geom.Polygon(container.geometry.coordinates);
break;
case ol.geom.GeometryType.MULTIPOINT:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiPoint(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiPoint(coordinates);
break;
case ol.geom.GeometryType.MULTILINESTRING:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiLineString(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiLineString(coordinates);
break;
case ol.geom.GeometryType.MULTIPOLYGON:
coordinates = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
coordinates.push(container.geometry.parts[i].coordinates);
}
- geometry = new ol.geom.MultiPolygon(coordinates, opt_vertices);
+ geometry = new ol.geom.MultiPolygon(coordinates);
break;
case ol.geom.GeometryType.GEOMETRYCOLLECTION:
var geometries = [];
for (i = 0, ii = container.geometry.parts.length; i < ii; i++) {
geometries.push(this.createGeometry({
geometry: container.geometry.parts[i]
- }, opt_vertices));
+ }));
}
geometry = new ol.geom.GeometryCollection(geometries);
break;
@@ -615,12 +601,9 @@ ol.parser.ogc.GML.prototype.createGeometry = function(container,
/**
* Parse a GML document provided as a string.
* @param {string} str GML document.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.ogc.GML.prototype.readFeaturesFromString =
- function(str, opt_options) {
- this.readFeaturesOptions_ = opt_options;
+ol.parser.ogc.GML.prototype.readFeaturesFromString = function(str) {
return this.read(str);
};
diff --git a/src/ol/parser/topojsonparser.js b/src/ol/parser/topojsonparser.js
index 0dcccb8165..8bcbaf57e6 100644
--- a/src/ol/parser/topojsonparser.js
+++ b/src/ol/parser/topojsonparser.js
@@ -3,7 +3,6 @@ goog.provide('ol.parser.TopoJSON');
goog.require('ol.Coordinate');
goog.require('ol.CoordinateArray');
goog.require('ol.Feature');
-goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.MultiPoint');
@@ -11,7 +10,6 @@ goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.parser.Parser');
-goog.require('ol.parser.ReadFeaturesOptions');
goog.require('ol.parser.StringFeatureParser');
@@ -23,18 +21,7 @@ goog.require('ol.parser.StringFeatureParser');
* @implements {ol.parser.StringFeatureParser}
* @extends {ol.parser.Parser}
*/
-ol.parser.TopoJSON = function() {
-
- /**
- * Common feature for all shared vertex creation.
- * // TODO: make feature optional in shared vertex callback
- *
- * @type {ol.Feature}
- * @private
- */
- this.feature_ = new ol.Feature();
-
-};
+ol.parser.TopoJSON = function() {};
goog.inherits(ol.parser.TopoJSON, ol.parser.Parser);
goog.addSingletonGetter(ol.parser.TopoJSON);
@@ -65,6 +52,10 @@ ol.parser.TopoJSON.prototype.concatenateArcs_ = function(indices, arcs) {
}
coordinates.push.apply(coordinates, arc);
}
+ // provide fresh copies of coordinate arrays
+ for (var j = 0, jj = coordinates.length; j < jj; ++j) {
+ coordinates[j] = coordinates[j].slice();
+ }
return coordinates;
};
@@ -84,17 +75,17 @@ ol.parser.TopoJSON.prototype.read = function(str) {
* Create features from a TopoJSON topology string.
*
* @param {string} str TopoJSON topology string.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.TopoJSON.prototype.readFeaturesFromString =
- function(str, opt_options) {
+ol.parser.TopoJSON.prototype.readFeaturesFromString = function(str) {
var topology = /** @type {TopoJSONTopology} */ (JSON.parse(str));
if (topology.type !== 'Topology') {
throw new Error('Not a "Topology" type object');
}
- return {features: this.readFeaturesFromTopology_(topology, opt_options),
- metadata: {projection: 'EPSG:4326'}};
+ return {
+ features: this.readFeaturesFromTopology_(topology),
+ metadata: {projection: 'EPSG:4326'}
+ };
};
@@ -102,16 +93,16 @@ ol.parser.TopoJSON.prototype.readFeaturesFromString =
* Create features from a TopoJSON topology object.
*
* @param {TopoJSONTopology} topology TopoJSON topology object.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.parser.ReadFeaturesResult} Features and metadata.
*/
-ol.parser.TopoJSON.prototype.readFeaturesFromObject =
- function(topology, opt_options) {
+ol.parser.TopoJSON.prototype.readFeaturesFromObject = function(topology) {
if (topology.type !== 'Topology') {
throw new Error('Not a "Topology" type object');
}
- return {features: this.readFeaturesFromTopology_(topology, opt_options),
- metadata: {projection: 'EPSG:4326'}};
+ return {
+ features: this.readFeaturesFromTopology_(topology),
+ metadata: {projection: 'EPSG:4326'}
+ };
};
@@ -122,32 +113,30 @@ ol.parser.TopoJSON.prototype.readFeaturesFromObject =
* @param {Array.} arcs Array of arcs.
* @param {Array.} scale Scale for each dimension.
* @param {Array.} translate Translation for each dimension.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.Feature} Feature.
* @private
*/
ol.parser.TopoJSON.prototype.readFeatureFromGeometry_ = function(object, arcs,
- scale, translate, opt_options) {
+ scale, translate) {
var geometry;
var type = object.type;
if (type === 'Point') {
geometry = this.readPoint_(/** @type {TopoJSONPoint} */ (object), scale,
- translate, opt_options);
+ translate);
} else if (type === 'LineString') {
geometry = this.readLineString_(/** @type {TopoJSONLineString} */ (object),
- arcs, opt_options);
+ arcs);
} else if (type === 'Polygon') {
- geometry = this.readPolygon_(/** @type {TopoJSONPolygon} */ (object), arcs,
- opt_options);
+ geometry = this.readPolygon_(/** @type {TopoJSONPolygon} */ (object), arcs);
} else if (type === 'MultiPoint') {
geometry = this.readMultiPoint_(/** @type {TopoJSONMultiPoint} */ (object),
- scale, translate, opt_options);
+ scale, translate);
} else if (type === 'MultiLineString') {
geometry = this.readMultiLineString_(
- /** @type {TopoJSONMultiLineString} */(object), arcs, opt_options);
+ /** @type {TopoJSONMultiLineString} */(object), arcs);
} else if (type === 'MultiPolygon') {
geometry = this.readMultiPolygon_(
- /** @type {TopoJSONMultiPolygon} */ (object), arcs, opt_options);
+ /** @type {TopoJSONMultiPolygon} */ (object), arcs);
} else {
throw new Error('Unsupported geometry type: ' + type);
}
@@ -168,18 +157,17 @@ ol.parser.TopoJSON.prototype.readFeatureFromGeometry_ = function(object, arcs,
* @param {Array.} arcs Array of arcs.
* @param {Array.} scale Scale for each dimension.
* @param {Array.} translate Translation for each dimension.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {Array.} Array of features.
* @private
*/
ol.parser.TopoJSON.prototype.readFeaturesFromGeometryCollection_ = function(
- collection, arcs, scale, translate, opt_options) {
+ collection, arcs, scale, translate) {
var geometries = collection.geometries;
var num = geometries.length;
var features = new Array(num);
for (var i = 0; i < num; ++i) {
features[i] = this.readFeatureFromGeometry_(geometries[i], arcs, scale,
- translate, opt_options);
+ translate);
}
return features;
};
@@ -187,12 +175,10 @@ ol.parser.TopoJSON.prototype.readFeaturesFromGeometryCollection_ = function(
/**
* @param {TopoJSONTopology} topology TopoJSON object.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {Array.} Parsed features.
* @private
*/
-ol.parser.TopoJSON.prototype.readFeaturesFromTopology_ = function(
- topology, opt_options) {
+ol.parser.TopoJSON.prototype.readFeaturesFromTopology_ = function(topology) {
var transform = topology.transform;
var scale = transform.scale;
var translate = transform.translate;
@@ -204,11 +190,11 @@ ol.parser.TopoJSON.prototype.readFeaturesFromTopology_ = function(
if (objects[key].type === 'GeometryCollection') {
features.push.apply(features, this.readFeaturesFromGeometryCollection_(
/** @type {TopoJSONGeometryCollection} */ (objects[key]),
- arcs, scale, translate, opt_options));
+ arcs, scale, translate));
} else {
features.push(this.readFeatureFromGeometry_(
/** @type {TopoJSONGeometry} */ (objects[key]),
- arcs, scale, translate, opt_options));
+ arcs, scale, translate));
}
}
return features;
@@ -220,20 +206,12 @@ ol.parser.TopoJSON.prototype.readFeaturesFromTopology_ = function(
*
* @param {TopoJSONLineString} object TopoJSON object.
* @param {Array.} arcs Array of arcs.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.LineString} Geometry.
* @private
*/
-ol.parser.TopoJSON.prototype.readLineString_ = function(object, arcs,
- opt_options) {
+ol.parser.TopoJSON.prototype.readLineString_ = function(object, arcs) {
var coordinates = this.concatenateArcs_(object.arcs, arcs);
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_, ol.geom.GeometryType.LINESTRING);
- }
- return new ol.geom.LineString(coordinates, sharedVertices);
+ return new ol.geom.LineString(coordinates);
};
@@ -242,26 +220,17 @@ ol.parser.TopoJSON.prototype.readLineString_ = function(object, arcs,
*
* @param {TopoJSONMultiLineString} object TopoJSON object.
* @param {Array.} arcs Array of arcs.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.MultiLineString} Geometry.
* @private
*/
-ol.parser.TopoJSON.prototype.readMultiLineString_ = function(object, arcs,
- opt_options) {
+ol.parser.TopoJSON.prototype.readMultiLineString_ = function(object, arcs) {
var array = object.arcs; // I'm out of good names
var num = array.length;
var coordinates = new Array(num);
for (var i = 0; i < num; ++i) {
coordinates[i] = this.concatenateArcs_(array[i], arcs);
}
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_,
- ol.geom.GeometryType.MULTILINESTRING);
- }
- return new ol.geom.MultiLineString(coordinates, sharedVertices);
+ return new ol.geom.MultiLineString(coordinates);
};
@@ -271,23 +240,16 @@ ol.parser.TopoJSON.prototype.readMultiLineString_ = function(object, arcs,
* @param {TopoJSONMultiPoint} object TopoJSON object.
* @param {Array.} scale Scale for each dimension.
* @param {Array.} translate Translation for each dimension.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.MultiPoint} Geometry.
* @private
*/
ol.parser.TopoJSON.prototype.readMultiPoint_ = function(object, scale,
- translate, opt_options) {
+ translate) {
var coordinates = object.coordinates;
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
this.transformVertex_(coordinates[i], scale, translate);
}
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_, ol.geom.GeometryType.MULTIPOINT);
- }
- return new ol.geom.MultiPoint(coordinates, sharedVertices);
+ return new ol.geom.MultiPoint(coordinates);
};
@@ -296,12 +258,10 @@ ol.parser.TopoJSON.prototype.readMultiPoint_ = function(object, scale,
*
* @param {TopoJSONMultiPolygon} object TopoJSON object.
* @param {Array.} arcs Array of arcs.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.MultiPolygon} Geometry.
* @private
*/
-ol.parser.TopoJSON.prototype.readMultiPolygon_ = function(object, arcs,
- opt_options) {
+ol.parser.TopoJSON.prototype.readMultiPolygon_ = function(object, arcs) {
var array = object.arcs;
var numPolys = array.length;
var coordinates = new Array(numPolys);
@@ -317,13 +277,7 @@ ol.parser.TopoJSON.prototype.readMultiPolygon_ = function(object, arcs,
}
coordinates[i] = ringCoords;
}
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_, ol.geom.GeometryType.MULTIPOLYGON);
- }
- return new ol.geom.MultiPolygon(coordinates, sharedVertices);
+ return new ol.geom.MultiPolygon(coordinates);
};
@@ -333,21 +287,13 @@ ol.parser.TopoJSON.prototype.readMultiPolygon_ = function(object, arcs,
* @param {TopoJSONPoint} object TopoJSON object.
* @param {Array.} scale Scale for each dimension.
* @param {Array.} translate Translation for each dimension.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.Point} Geometry.
* @private
*/
-ol.parser.TopoJSON.prototype.readPoint_ = function(object, scale, translate,
- opt_options) {
+ol.parser.TopoJSON.prototype.readPoint_ = function(object, scale, translate) {
var coordinates = object.coordinates;
this.transformVertex_(coordinates, scale, translate);
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_, ol.geom.GeometryType.POINT);
- }
- return new ol.geom.Point(coordinates, sharedVertices);
+ return new ol.geom.Point(coordinates);
};
@@ -356,25 +302,17 @@ ol.parser.TopoJSON.prototype.readPoint_ = function(object, scale, translate,
*
* @param {TopoJSONPolygon} object TopoJSON object.
* @param {Array.} arcs Array of arcs.
- * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options.
* @return {ol.geom.Polygon} Geometry.
* @private
*/
-ol.parser.TopoJSON.prototype.readPolygon_ = function(object, arcs,
- opt_options) {
+ol.parser.TopoJSON.prototype.readPolygon_ = function(object, arcs) {
var array = object.arcs; // I'm out of good names
var num = array.length;
var coordinates = new Array(num);
for (var i = 0; i < num; ++i) {
coordinates[i] = this.concatenateArcs_(array[i], arcs);
}
- // TODO: make feature optional in callback
- var callback = opt_options && opt_options.callback;
- var sharedVertices;
- if (callback) {
- sharedVertices = callback(this.feature_, ol.geom.GeometryType.POLYGON);
- }
- return new ol.geom.Polygon(coordinates, sharedVertices);
+ return new ol.geom.Polygon(coordinates);
};
diff --git a/src/ol/renderer/canvas/canvasvectorrenderer.js b/src/ol/renderer/canvas/canvasvectorrenderer.js
index 1e4543f446..14252a439d 100644
--- a/src/ol/renderer/canvas/canvasvectorrenderer.js
+++ b/src/ol/renderer/canvas/canvasvectorrenderer.js
@@ -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) {
diff --git a/test/spec/ol/geom/geometrycollection.test.js b/test/spec/ol/geom/geometrycollection.test.js
index 014fd39b8a..010e5b2b5e 100644
--- a/test/spec/ol/geom/geometrycollection.test.js
+++ b/test/spec/ol/geom/geometrycollection.test.js
@@ -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() {
diff --git a/test/spec/ol/geom/linearring.test.js b/test/spec/ol/geom/linearring.test.js
index 341e688ae6..42fba0a33f 100644
--- a/test/spec/ol/geom/linearring.test.js
+++ b/test/spec/ol/geom/linearring.test.js
@@ -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() {
diff --git a/test/spec/ol/geom/linestring.test.js b/test/spec/ol/geom/linestring.test.js
index 39f6ff3693..5cf4f65885 100644
--- a/test/spec/ol/geom/linestring.test.js
+++ b/test/spec/ol/geom/linestring.test.js
@@ -10,28 +10,6 @@ describe('ol.geom.LineString', function() {
expect(line).to.be.a(ol.geom.Geometry);
});
- it('accepts shared vertices', function() {
- var vertices = new ol.geom.SharedVertices();
- var l1 = new ol.geom.LineString([[10, 20], [30, 40]], vertices);
- var l2 = new ol.geom.LineString([[50, 60], [70, 80]], vertices);
- expect(l1.getCoordinates()).to.eql([[10, 20], [30, 40]]);
- expect(l2.getCoordinates()).to.eql([[50, 60], [70, 80]]);
- });
-
- });
-
- 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() {
@@ -56,36 +34,33 @@ describe('ol.geom.LineString', function() {
});
- describe('#getSharedId()', function() {
+ describe('#transform()', function() {
- it('returns identifiers', function() {
- var vertices = new ol.geom.SharedVertices();
+ var forward = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
+ var inverse = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
- var l1 = new ol.geom.LineString([[10, 20], [30, 40]], vertices);
- var l2 = new ol.geom.LineString(
- [[50, 60], [70, 80], [90, 100]], vertices);
+ it('forward transforms a linestring in place', function() {
+ var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]);
+ line.transform(forward);
+ expect(line.get(0, 0)).to.roughlyEqual(1113195, 1);
+ expect(line.get(0, 1)).to.roughlyEqual(2273031, 1);
+ expect(line.get(1, 0)).to.roughlyEqual(2226390, 1);
+ expect(line.get(1, 1)).to.roughlyEqual(3503550, 1);
+ expect(line.get(2, 0)).to.roughlyEqual(3339585, 1);
+ expect(line.get(2, 1)).to.roughlyEqual(4865942, 1);
+ });
- var id1 = l1.getSharedId();
- var id2 = l2.getSharedId();
-
- expect(vertices.coordinates).to.eql(
- [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
-
- expect(vertices.getStart(id1)).to.be(0);
- expect(vertices.getCount(id1)).to.be(2);
- expect(vertices.get(id1, 0, 0)).to.be(10);
- expect(vertices.get(id1, 0, 1)).to.be(20);
- expect(vertices.get(id1, 1, 0)).to.be(30);
- expect(vertices.get(id1, 1, 1)).to.be(40);
-
- expect(vertices.getStart(id2)).to.be(4);
- expect(vertices.getCount(id2)).to.be(3);
- expect(vertices.get(id2, 0, 0)).to.be(50);
- expect(vertices.get(id2, 0, 1)).to.be(60);
- expect(vertices.get(id2, 1, 0)).to.be(70);
- expect(vertices.get(id2, 1, 1)).to.be(80);
- expect(vertices.get(id2, 2, 0)).to.be(90);
- expect(vertices.get(id2, 2, 1)).to.be(100);
+ it('inverse transforms a linestring in place', function() {
+ var line = new ol.geom.LineString([
+ [1113195, 2273031], [2226390, 3503550], [3339585, 4865942]
+ ]);
+ line.transform(inverse);
+ expect(line.get(0, 0)).to.roughlyEqual(10, 0.001);
+ expect(line.get(0, 1)).to.roughlyEqual(20, 0.001);
+ expect(line.get(1, 0)).to.roughlyEqual(20, 0.001);
+ expect(line.get(1, 1)).to.roughlyEqual(30, 0.001);
+ expect(line.get(2, 0)).to.roughlyEqual(30, 0.001);
+ expect(line.get(2, 1)).to.roughlyEqual(40, 0.001);
});
});
@@ -94,4 +69,4 @@ describe('ol.geom.LineString', function() {
goog.require('ol.geom.Geometry');
goog.require('ol.geom.LineString');
-goog.require('ol.geom.SharedVertices');
+goog.require('ol.proj');
diff --git a/test/spec/ol/geom/multilinestring.test.js b/test/spec/ol/geom/multilinestring.test.js
index 571b038175..b619813149 100644
--- a/test/spec/ol/geom/multilinestring.test.js
+++ b/test/spec/ol/geom/multilinestring.test.js
@@ -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() {
diff --git a/test/spec/ol/geom/multipoint.test.js b/test/spec/ol/geom/multipoint.test.js
index a79a75b59a..772186250b 100644
--- a/test/spec/ol/geom/multipoint.test.js
+++ b/test/spec/ol/geom/multipoint.test.js
@@ -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() {
@@ -68,8 +47,37 @@ describe('ol.geom.MultiPoint', function() {
});
+ describe('#transform', function() {
+
+ var forward = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
+ var inverse = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
+
+ it('forward transforms a multi-point', function() {
+ var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
+ multi.transform(forward);
+
+ expect(multi.components[0].get(0)).to.roughlyEqual(1113195, 1);
+ expect(multi.components[0].get(1)).to.roughlyEqual(2273031, 1);
+ expect(multi.components[1].get(0)).to.roughlyEqual(3339584, 1);
+ expect(multi.components[1].get(1)).to.roughlyEqual(4865942, 1);
+ });
+
+ it('inverse transforms a multi-point', function() {
+ var multi = new ol.geom.MultiPoint(
+ [[1113195, 2273031], [3339584, 4865942]]);
+ multi.transform(inverse);
+
+ expect(multi.components[0].get(0)).to.roughlyEqual(10, 0.001);
+ expect(multi.components[0].get(1)).to.roughlyEqual(20, 0.001);
+ expect(multi.components[1].get(0)).to.roughlyEqual(30, 0.001);
+ expect(multi.components[1].get(1)).to.roughlyEqual(40, 0.001);
+ });
+
+ });
+
});
goog.require('ol.geom.Geometry');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.Point');
+goog.require('ol.proj');
diff --git a/test/spec/ol/geom/multipolygon.test.js b/test/spec/ol/geom/multipolygon.test.js
index 2cd118e0ed..e667427d0b 100644
--- a/test/spec/ol/geom/multipolygon.test.js
+++ b/test/spec/ol/geom/multipolygon.test.js
@@ -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() {
diff --git a/test/spec/ol/geom/point.test.js b/test/spec/ol/geom/point.test.js
index ff3e7db02e..48b5a7f1e6 100644
--- a/test/spec/ol/geom/point.test.js
+++ b/test/spec/ol/geom/point.test.js
@@ -10,37 +10,6 @@ describe('ol.geom.Point', function() {
expect(point).to.be.a(ol.geom.Geometry);
});
- it('accepts shared vertices', function() {
- var vertices = new ol.geom.SharedVertices();
- var p1 = new ol.geom.Point([10, 20], vertices);
- var p2 = new ol.geom.Point([30, 40], vertices);
- var p3 = new ol.geom.Point([50, 60], vertices);
- expect(p1.getCoordinates()).to.eql([10, 20]);
- expect(p2.getCoordinates()).to.eql([30, 40]);
- expect(p3.getCoordinates()).to.eql([50, 60]);
- });
-
- 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() {
@@ -65,37 +34,23 @@ describe('ol.geom.Point', function() {
});
+ describe('#transform()', function() {
- describe('#getSharedId()', function() {
+ var forward = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
+ var inverse = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
- it('returns identifiers', function() {
- var vertices = new ol.geom.SharedVertices();
+ it('forward transforms a point in place', function() {
+ var point = new ol.geom.Point([10, 20]);
+ point.transform(forward);
+ expect(point.get(0)).to.roughlyEqual(1113195, 1);
+ expect(point.get(1)).to.roughlyEqual(2273031, 1);
+ });
- var p1 = new ol.geom.Point([10, 20], vertices);
- var p2 = new ol.geom.Point([30, 40], vertices);
- var p3 = new ol.geom.Point([50, 60], vertices);
-
- var id1 = p1.getSharedId();
- var id2 = p2.getSharedId();
- var id3 = p3.getSharedId();
-
- expect(vertices.coordinates).to.eql(
- [10, 20, 30, 40, 50, 60]);
-
- expect(vertices.getStart(id1)).to.be(0);
- expect(vertices.getCount(id1)).to.be(1);
- expect(vertices.get(id1, 0, 0)).to.be(10);
- expect(vertices.get(id1, 0, 1)).to.be(20);
-
- expect(vertices.getStart(id2)).to.be(2);
- expect(vertices.getCount(id2)).to.be(1);
- expect(vertices.get(id2, 0, 0)).to.be(30);
- expect(vertices.get(id2, 0, 1)).to.be(40);
-
- expect(vertices.getStart(id3)).to.be(4);
- expect(vertices.getCount(id3)).to.be(1);
- expect(vertices.get(id3, 0, 0)).to.be(50);
- expect(vertices.get(id3, 0, 1)).to.be(60);
+ it('inverse transforms a point in place', function() {
+ var point = new ol.geom.Point([1113195, 2273031]);
+ point.transform(inverse);
+ expect(point.get(0)).to.roughlyEqual(10, 0.001);
+ expect(point.get(1)).to.roughlyEqual(20, 0.001);
});
});
@@ -104,4 +59,4 @@ describe('ol.geom.Point', function() {
goog.require('ol.geom.Geometry');
goog.require('ol.geom.Point');
-goog.require('ol.geom.SharedVertices');
+goog.require('ol.proj');
diff --git a/test/spec/ol/geom/polygon.test.js b/test/spec/ol/geom/polygon.test.js
index 4cac05c9e7..b895d27482 100644
--- a/test/spec/ol/geom/polygon.test.js
+++ b/test/spec/ol/geom/polygon.test.js
@@ -14,16 +14,6 @@ describe('ol.geom.Polygon', function() {
expect(poly).to.be.a(ol.geom.Geometry);
});
- it('accepts shared vertices', function() {
- var vertices = new ol.geom.SharedVertices();
- var p1 = new ol.geom.Polygon([outer], vertices);
- var p2 = new ol.geom.Polygon([outer, inner1], vertices);
- var p3 = new ol.geom.Polygon([outer, inner2], vertices);
- expect(p1.getCoordinates()).to.eql([outer]);
- expect(p2.getCoordinates()).to.eql([outer, inner1]);
- expect(p3.getCoordinates()).to.eql([outer, inner2]);
- });
-
});
describe('#rings', function() {
@@ -61,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() {
@@ -97,9 +73,68 @@ describe('ol.geom.Polygon', function() {
});
+ describe('#transform()', function() {
+
+ var forward = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
+ var inverse = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
+
+ var gg, sm;
+ beforeEach(function() {
+ gg = [
+ [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]],
+ [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]],
+ [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]]
+ ];
+
+ sm = [[
+ [0, 0], [0, 1118890], [1113195, 1118890], [1113195, 0], [0, 0]
+ ], [
+ [111319, 111325], [222639, 111325], [222639, 222684],
+ [111319, 222684], [111319, 111325]
+ ], [
+ [890556, 893464], [1001875, 893464], [1001875, 1006021],
+ [890556, 1006021], [890556, 893464]
+ ]];
+
+ });
+
+ it('forward transforms a polygon in place', function() {
+
+ var poly = new ol.geom.Polygon(gg);
+ poly.transform(forward);
+ var coordinates = poly.getCoordinates();
+ var ring;
+ for (var i = 0, ii = coordinates.length; i < ii; ++i) {
+ var ring = coordinates[i];
+ for (var j = 0, jj = ring.length; j < jj; ++j) {
+ expect(ring[j][0]).to.roughlyEqual(sm[i][j][0], 1);
+ expect(ring[j][1]).to.roughlyEqual(sm[i][j][1], 1);
+ }
+ }
+
+ });
+
+ it('inverse transforms a polygon in place', function() {
+
+ var poly = new ol.geom.Polygon(sm);
+ poly.transform(inverse);
+ var coordinates = poly.getCoordinates();
+ var ring;
+ for (var i = 0, ii = coordinates.length; i < ii; ++i) {
+ var ring = coordinates[i];
+ for (var j = 0, jj = ring.length; j < jj; ++j) {
+ expect(ring[j][0]).to.roughlyEqual(gg[i][j][0], 0.001);
+ expect(ring[j][1]).to.roughlyEqual(gg[i][j][1], 0.001);
+ }
+ }
+
+ });
+
+ });
+
});
goog.require('ol.geom.Geometry');
goog.require('ol.geom.LinearRing');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
+goog.require('ol.proj');
diff --git a/test/spec/ol/geom/sharedvertices.test.js b/test/spec/ol/geom/sharedvertices.test.js
deleted file mode 100644
index 3c3adce456..0000000000
--- a/test/spec/ol/geom/sharedvertices.test.js
+++ /dev/null
@@ -1,221 +0,0 @@
-goog.provide('ol.test.geom.SharedVertices');
-
-describe('ol.geom.SharedVertices', function() {
-
- describe('constructor', function() {
- it('creates an instance', function() {
- var vertices = new ol.geom.SharedVertices();
- expect(vertices).to.be.a(ol.geom.SharedVertices);
- });
-
- it('accepts options', function() {
- var vertices = new ol.geom.SharedVertices({
- dimension: 4,
- offset: [1, 2, 3, 4]
- });
-
- expect(vertices.getDimension()).to.be(4);
- expect(vertices.getOffset()).to.eql([1, 2, 3, 4]);
- });
- });
-
- describe('offset option', function() {
- it('offsets the internally stored vertex coordinates', function() {
- var vertices = new ol.geom.SharedVertices({offset: [3, -1]});
- vertices.add([[3, -1], [0, 0]]);
- vertices.add([[10, 20]]);
- expect(vertices.coordinates).to.eql([0, 0, -3, 1, 7, 21]);
- });
- });
-
- describe('#add()', function() {
- it('adds vertex arrays to the shared coordinates', function() {
- var vertices = new ol.geom.SharedVertices();
- expect(vertices.coordinates.length).to.be(0);
-
- vertices.add([[1, 2], [3, 4]]);
- expect(vertices.coordinates).to.eql([1, 2, 3, 4]);
-
- vertices.add([[5, 6]]);
- expect(vertices.coordinates).to.eql([1, 2, 3, 4, 5, 6]);
- });
-
- it('ignores extra dimensions', function() {
- var vertices = new ol.geom.SharedVertices({dimension: 2});
- expect(vertices.coordinates.length).to.be(0);
-
- vertices.add([[1, 2], [3, 4, 5], [6, 7]]);
- expect(vertices.coordinates).to.eql([1, 2, 3, 4, 6, 7]);
-
- vertices.add([[8, 9, 10]]);
- expect(vertices.coordinates).to.eql([1, 2, 3, 4, 6, 7, 8, 9]);
- });
-
- it('pads with NaN when dimension not provided', function() {
- var vertices = new ol.geom.SharedVertices({dimension: 3});
- expect(vertices.coordinates.length).to.be(0);
-
- vertices.add([[1, 2], [3, 4, 5], [6, 7]]);
- expect(vertices.coordinates).to.eql([1, 2, NaN, 3, 4, 5, 6, 7, NaN]);
- });
-
- it('returns an identifier for coordinate access', function() {
- var vertices = new ol.geom.SharedVertices();
- var id = vertices.add([[1, 2], [3, 4]]);
- expect(typeof id).to.be('number');
- });
-
- it('returns the index of the added vertices', function() {
- var vertices = new ol.geom.SharedVertices();
-
- var first = vertices.add([[1, 2]]);
- var second = vertices.add([[3, 4], [5, 6]]);
- var third = vertices.add([[7, 8], [9, 10], [11, 12]]);
-
- expect(vertices.coordinates).to.eql(
- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
-
- expect(first).to.be(0);
- expect(second).to.be(1);
- expect(third).to.be(2);
- });
-
- });
-
- describe('#get()', function() {
- it('provides access to vertex coordinates', function() {
- var vertices = new ol.geom.SharedVertices();
- var first = vertices.add([[1, 2], [3, 4]]);
- var second = vertices.add([[5, 6]]);
-
- expect(vertices.get(first, 0, 0)).to.be(1);
- expect(vertices.get(first, 0, 1)).to.be(2);
- expect(vertices.get(first, 1, 0)).to.be(3);
- expect(vertices.get(first, 1, 1)).to.be(4);
- expect(vertices.get(second, 0, 0)).to.be(5);
- expect(vertices.get(second, 0, 1)).to.be(6);
- });
-
- it('works for non-2d vertices', function() {
- var vertices = new ol.geom.SharedVertices({dimension: 3});
- var id = vertices.add([[1, 2, 3], [4, 5, 6]]);
-
- expect(vertices.get(id, 0, 0)).to.be(1);
- expect(vertices.get(id, 0, 1)).to.be(2);
- expect(vertices.get(id, 0, 2)).to.be(3);
- expect(vertices.get(id, 1, 0)).to.be(4);
- expect(vertices.get(id, 1, 1)).to.be(5);
- expect(vertices.get(id, 1, 2)).to.be(6);
- });
-
- it('works when an offset is provided', function() {
- var vertices = new ol.geom.SharedVertices({offset: [3, 3]});
- var id = vertices.add([[1, 2], [3, 4], [5, 6]]);
-
- expect(vertices.get(id, 0, 0)).to.be(1);
- expect(vertices.get(id, 0, 1)).to.be(2);
- expect(vertices.get(id, 1, 0)).to.be(3);
- expect(vertices.get(id, 1, 1)).to.be(4);
- expect(vertices.get(id, 2, 0)).to.be(5);
- expect(vertices.get(id, 2, 1)).to.be(6);
- });
-
- });
-
- describe('#getCount()', function() {
- it('returns the length of an identified vertex array', function() {
- var vertices = new ol.geom.SharedVertices();
- var first = vertices.add([[2, 3], [3, 4], [4, 5]]);
- var second = vertices.add([[5, 6], [6, 6]]);
-
- expect(vertices.getCount(first)).to.be(3);
- expect(vertices.getCount(second)).to.be(2);
- });
- });
-
- describe('#getCounts()', function() {
- it('returns the counts array', function() {
- var vertices = new ol.geom.SharedVertices();
- vertices.add([[2, 3], [3, 4], [4, 5]]);
- vertices.add([[5, 6], [6, 6]]);
- vertices.add([[7, 8]]);
-
- expect(vertices.getCounts()).to.eql([3, 2, 1]);
- });
- });
-
- describe('#getDimension()', function() {
- it('returns 2 by default', function() {
- var vertices = new ol.geom.SharedVertices();
- expect(vertices.getDimension()).to.be(2);
- });
-
- it('returns the dimension provided to the constructor', function() {
- var vertices = new ol.geom.SharedVertices({dimension: 10});
- expect(vertices.getDimension()).to.be(10);
- });
- });
-
- describe('#getOffset()', function() {
- it('returns null by default', function() {
- var vertices = new ol.geom.SharedVertices();
- expect(vertices.getOffset()).to.be(null);
- });
-
- it('returns the offset provided to the constructor', function() {
- var vertices = new ol.geom.SharedVertices({offset: [1, 2]});
- expect(vertices.getOffset()).to.eql([1, 2]);
- });
- });
-
- describe('#getStart()', function() {
- it('returns the start index of an identified vertex array', function() {
- var vertices = new ol.geom.SharedVertices();
- var first = vertices.add([[2, 3], [4, 5], [6, 7]]);
- var second = vertices.add([[8, 9], [10, 11]]);
- var third = vertices.add([[12, 13]]);
-
- expect(vertices.coordinates).to.eql(
- [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
- // 0 1 2 3 4 5 6 7 8 9 10 11
-
- expect(vertices.getStart(first)).to.be(0);
- expect(vertices.getStart(second)).to.be(6);
- expect(vertices.getStart(third)).to.be(10);
- });
- });
-
- describe('#getStarts()', function() {
- it('returns the counts array', function() {
- var vertices = new ol.geom.SharedVertices();
- vertices.add([[2, 3], [3, 4], [4, 5]]);
- vertices.add([[5, 6], [6, 6]]);
- vertices.add([[7, 8]]);
-
- expect(vertices.getStarts()).to.eql([0, 6, 10]);
- });
- });
-
- describe('#coordinates', function() {
- it('is a flat array of all coordinate values', function() {
- var vertices = new ol.geom.SharedVertices();
- vertices.add([[1, 2], [3, 4]]);
- vertices.add([[5, 6]]);
- vertices.add([[7, 8], [9, 10], [11, 12]]);
- expect(vertices.coordinates).to.eql(
- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
- });
-
- it('is not reassigned', function() {
- var vertices = new ol.geom.SharedVertices();
- vertices.add([[1, 2], [3, 4]]);
- var coordinates = vertices.coordinates;
-
- vertices.add([[5, 6]]);
- expect(vertices.coordinates).to.be(coordinates);
- });
- });
-
-});
-
-goog.require('ol.geom.SharedVertices');
diff --git a/test/spec/ol/parser/geojson.test.js b/test/spec/ol/parser/geojson.test.js
index ebba2a1506..c8c7923c32 100644
--- a/test/spec/ol/parser/geojson.test.js
+++ b/test/spec/ol/parser/geojson.test.js
@@ -218,74 +218,11 @@ describe('ol.parser.GeoJSON', function() {
});
});
- it('parses countries.geojson with shared vertices', function() {
- afterLoadText('spec/ol/parser/geojson/countries.geojson', function(text) {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
-
- var result = parser.readFeaturesFromString(text,
- {callback: callback}).features;
- expect(result.length).to.be(179);
-
- expect(pointVertices.coordinates.length).to.be(0);
- expect(lineVertices.coordinates.length).to.be(0);
- expect(polygonVertices.coordinates.length).to.be(21344);
-
- var first = result[0];
- expect(first).to.be.a(ol.Feature);
- expect(first.get('name')).to.be('Afghanistan');
- var firstGeom = first.getGeometry();
- expect(firstGeom).to.be.a(ol.geom.Polygon);
- expect(ol.extent.equals(firstGeom.getBounds(),
- [60.52843, 29.318572, 75.158028, 38.486282]))
- .to.be(true);
-
- var last = result[178];
- expect(last).to.be.a(ol.Feature);
- expect(last.get('name')).to.be('Zimbabwe');
- var lastGeom = last.getGeometry();
- expect(lastGeom).to.be.a(ol.geom.Polygon);
- expect(ol.extent.equals(lastGeom.getBounds(),
- [25.264226, -22.271612, 32.849861, -15.507787]))
- .to.be(true);
- });
- });
-
});
describe('#parseAsFeatureCollection_()', function() {
it('generates an array of features for FeatureCollection', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
@@ -310,8 +247,7 @@ describe('ol.parser.GeoJSON', function() {
}
}]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(2);
@@ -326,30 +262,10 @@ describe('ol.parser.GeoJSON', function() {
expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
- expect(pointVertices.coordinates.length).to.be(2);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('reads named crs from top-level object', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
@@ -380,8 +296,7 @@ describe('ol.parser.GeoJSON', function() {
}
}]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(2);
@@ -396,30 +311,10 @@ describe('ol.parser.GeoJSON', function() {
expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
- expect(pointVertices.coordinates.length).to.be(2);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:1234');
});
it('accepts null crs', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
@@ -445,8 +340,7 @@ describe('ol.parser.GeoJSON', function() {
}
}]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(2);
@@ -461,30 +355,10 @@ describe('ol.parser.GeoJSON', function() {
expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
- expect(pointVertices.coordinates.length).to.be(2);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('generates an array of features for Feature', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
@@ -497,8 +371,7 @@ describe('ol.parser.GeoJSON', function() {
coordinates: [[1, 2], [3, 4]]
}
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(1);
@@ -508,30 +381,10 @@ describe('ol.parser.GeoJSON', function() {
expect(first.get('bam')).to.be('baz');
expect(first.getGeometry()).to.be.a(ol.geom.LineString);
- expect(pointVertices.coordinates.length).to.be(0);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('generates an array of features for GeometryCollection', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
@@ -547,8 +400,7 @@ describe('ol.parser.GeoJSON', function() {
coordinates: [[[7, 8], [9, 10], [11, 12], [7, 8]]]
}]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(3);
@@ -557,124 +409,57 @@ describe('ol.parser.GeoJSON', function() {
expect(features[1].getGeometry()).to.be.a(ol.geom.LineString);
expect(features[2].getGeometry()).to.be.a(ol.geom.Polygon);
- expect(pointVertices.coordinates.length).to.be(2);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(8);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('generates an array of features for Point', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
type: 'Point',
coordinates: [1, 2]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(1);
expect(features[0].getGeometry()).to.be.a(ol.geom.Point);
- expect(pointVertices.coordinates.length).to.be(2);
- expect(lineVertices.coordinates.length).to.be(0);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('generates an array of features for LineString', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
type: 'LineString',
coordinates: [[3, 4], [5, 6]]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(1);
expect(features[0].getGeometry()).to.be.a(ol.geom.LineString);
- expect(pointVertices.coordinates.length).to.be(0);
- expect(lineVertices.coordinates.length).to.be(4);
- expect(polygonVertices.coordinates.length).to.be(0);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
it('generates an array of features for Polygon', function() {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
var parser = new ol.parser.GeoJSON();
var json = {
type: 'Polygon',
coordinates: [[[7, 8], [9, 10], [11, 12], [7, 8]]]
};
- var result = parser.parseAsFeatureCollection_(json,
- {callback: callback});
+ var result = parser.parseAsFeatureCollection_(json);
var features = result.features;
expect(features.length).to.be(1);
expect(features[0].getGeometry()).to.be.a(ol.geom.Polygon);
- expect(pointVertices.coordinates.length).to.be(0);
- expect(lineVertices.coordinates.length).to.be(0);
- expect(polygonVertices.coordinates.length).to.be(8);
-
expect(result.metadata.projection).to.be('EPSG:4326');
});
@@ -690,5 +475,4 @@ goog.require('ol.geom.LinearRing');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
goog.require('ol.parser.GeoJSON');
diff --git a/test/spec/ol/parser/kml.test.js b/test/spec/ol/parser/kml.test.js
index 3a3d104abb..30e2ab1e47 100644
--- a/test/spec/ol/parser/kml.test.js
+++ b/test/spec/ol/parser/kml.test.js
@@ -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();
});
});
diff --git a/test/spec/ol/parser/topojson.test.js b/test/spec/ol/parser/topojson.test.js
index 9cda1170d9..6e83e3014c 100644
--- a/test/spec/ol/parser/topojson.test.js
+++ b/test/spec/ol/parser/topojson.test.js
@@ -56,33 +56,12 @@ describe('ol.parser.TopoJSON', function() {
describe('#readFeaturesFromString()', function() {
- it('parses world-110m.geojson with shared vertices', function(done) {
+ it('parses world-110m.geojson', function(done) {
afterLoadText('spec/ol/parser/topojson/world-110m.json', function(text) {
- var pointVertices = new ol.geom.SharedVertices();
- var lineVertices = new ol.geom.SharedVertices();
- var polygonVertices = new ol.geom.SharedVertices();
-
- var lookup = {
- 'point': pointVertices,
- 'linestring': lineVertices,
- 'polygon': polygonVertices,
- 'multipoint': pointVertices,
- 'multilinstring': lineVertices,
- 'multipolygon': polygonVertices
- };
-
- var callback = function(feature, type) {
- return lookup[type];
- };
-
- var result = parser.readFeaturesFromString(text, {callback: callback});
+ var result = parser.readFeaturesFromString(text);
expect(result.features.length).to.be(178);
- expect(pointVertices.coordinates.length).to.be(0);
- expect(lineVertices.coordinates.length).to.be(0);
- expect(polygonVertices.coordinates.length).to.be(31400);
-
var first = result.features[0];
expect(first).to.be.a(ol.Feature);
var firstGeom = first.getGeometry();
@@ -110,6 +89,5 @@ describe('ol.parser.TopoJSON', function() {
goog.require('ol.Feature');
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Polygon');
-goog.require('ol.geom.SharedVertices');
goog.require('ol.parser.Parser');
goog.require('ol.parser.TopoJSON');