Remove shared vertex handling from vector layer
This commit is contained in:
+12
-80
@@ -13,7 +13,6 @@ goog.require('ol.expr.LogicalOp');
|
|||||||
goog.require('ol.expr.functions');
|
goog.require('ol.expr.functions');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.geom.SharedVertices');
|
|
||||||
goog.require('ol.layer.Layer');
|
goog.require('ol.layer.Layer');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.Vector');
|
goog.require('ol.source.Vector');
|
||||||
@@ -286,27 +285,6 @@ ol.layer.Vector = function(options) {
|
|||||||
this.transformFeatureInfo_ = goog.isDef(options.transformFeatureInfo) ?
|
this.transformFeatureInfo_ = goog.isDef(options.transformFeatureInfo) ?
|
||||||
options.transformFeatureInfo : ol.layer.Vector.uidTransformFeatureInfo;
|
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.
|
* True if this is a temporary layer.
|
||||||
* @type {boolean}
|
* @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.<string, ol.Feature>} features Features.
|
* @param {Object.<string, ol.Feature>} features Features.
|
||||||
* @param {number} resolution Map resolution.
|
* @param {number} resolution Map resolution.
|
||||||
@@ -497,17 +451,6 @@ ol.layer.Vector.prototype.getFeatureWithUid = function(uid) {
|
|||||||
* view in one projection.
|
* view in one projection.
|
||||||
*/
|
*/
|
||||||
ol.layer.Vector.prototype.parseFeatures = function(data, parser, 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 addFeatures = function(data) {
|
||||||
var features = data.features;
|
var features = data.features;
|
||||||
@@ -516,46 +459,35 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
|
|||||||
sourceProjection = data.metadata.projection;
|
sourceProjection = data.metadata.projection;
|
||||||
}
|
}
|
||||||
var transform = ol.proj.getTransform(sourceProjection, projection);
|
var transform = ol.proj.getTransform(sourceProjection, projection);
|
||||||
|
var geometry = null;
|
||||||
transform(
|
for (var i = 0, ii = features.length; i < ii; ++i) {
|
||||||
this.pointVertices_.coordinates,
|
geometry = features[i].getGeometry();
|
||||||
this.pointVertices_.coordinates,
|
if (!goog.isNull(geometry)) {
|
||||||
this.pointVertices_.getDimension());
|
geometry.transform(transform);
|
||||||
|
}
|
||||||
transform(
|
}
|
||||||
this.lineVertices_.coordinates,
|
|
||||||
this.lineVertices_.coordinates,
|
|
||||||
this.lineVertices_.getDimension());
|
|
||||||
|
|
||||||
transform(
|
|
||||||
this.polygonVertices_.coordinates,
|
|
||||||
this.polygonVertices_.coordinates,
|
|
||||||
this.polygonVertices_.getDimension());
|
|
||||||
|
|
||||||
this.addFeatures(features);
|
this.addFeatures(features);
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = {callback: callback}, result;
|
var result;
|
||||||
if (goog.isString(data)) {
|
if (goog.isString(data)) {
|
||||||
if (goog.isFunction(parser.readFeaturesFromStringAsync)) {
|
if (goog.isFunction(parser.readFeaturesFromStringAsync)) {
|
||||||
parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this),
|
parser.readFeaturesFromStringAsync(data, goog.bind(addFeatures, this));
|
||||||
options);
|
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isFunction(parser.readFeaturesFromString),
|
goog.isFunction(parser.readFeaturesFromString),
|
||||||
'Expected parser with a readFeaturesFromString method.');
|
'Expected parser with a readFeaturesFromString method.');
|
||||||
result = parser.readFeaturesFromString(data, options);
|
result = parser.readFeaturesFromString(data);
|
||||||
addFeatures.call(this, result);
|
addFeatures.call(this, result);
|
||||||
}
|
}
|
||||||
} else if (goog.isObject(data)) {
|
} else if (goog.isObject(data)) {
|
||||||
if (goog.isFunction(parser.readFeaturesFromObjectAsync)) {
|
if (goog.isFunction(parser.readFeaturesFromObjectAsync)) {
|
||||||
parser.readFeaturesFromObjectAsync(data, goog.bind(addFeatures, this),
|
parser.readFeaturesFromObjectAsync(data, goog.bind(addFeatures, this));
|
||||||
options);
|
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isFunction(parser.readFeaturesFromObject),
|
goog.isFunction(parser.readFeaturesFromObject),
|
||||||
'Expected parser with a readFeaturesFromObject method.');
|
'Expected parser with a readFeaturesFromObject method.');
|
||||||
result = parser.readFeaturesFromObject(data, options);
|
result = parser.readFeaturesFromObject(data);
|
||||||
addFeatures.call(this, result);
|
addFeatures.call(this, result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user