Make shared vertices structures accessible

This commit is contained in:
Tim Schaub
2013-03-07 23:09:23 -07:00
parent faee18bae1
commit 4918106a22
+60 -18
View File
@@ -170,6 +170,27 @@ ol.layer.Vector = function(layerOptions) {
*/ */
this.featureCache_ = new ol.layer.FeatureCache(); this.featureCache_ = new ol.layer.FeatureCache();
/**
* 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();
}; };
goog.inherits(ol.layer.Vector, ol.layer.Layer); goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -213,6 +234,30 @@ ol.layer.Vector.prototype.getFeaturesObject = function(opt_filter) {
}; };
/**
* @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.
* @return {Array.<Array>} symbolizers for features. * @return {Array.<Array>} symbolizers for features.
@@ -261,17 +306,14 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
*/ */
ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) { ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
var features; var features;
var pointVertices = new ol.geom.SharedVertices();
var lineVertices = new ol.geom.SharedVertices();
var polygonVertices = new ol.geom.SharedVertices();
var lookup = { var lookup = {
'point': pointVertices, 'point': this.pointVertices_,
'linestring': lineVertices, 'linestring': this.lineVertices_,
'polygon': polygonVertices, 'polygon': this.polygonVertices_,
'multipoint': pointVertices, 'multipoint': this.pointVertices_,
'multilinstring': lineVertices, 'multilinstring': this.lineVertices_,
'multipolygon': polygonVertices 'multipolygon': this.polygonVertices_
}; };
var callback = function(feature, type) { var callback = function(feature, type) {
@@ -289,19 +331,19 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
var transform = ol.projection.getTransform(sourceProjection, projection); var transform = ol.projection.getTransform(sourceProjection, projection);
transform( transform(
pointVertices.coordinates, this.pointVertices_.coordinates,
pointVertices.coordinates, this.pointVertices_.coordinates,
pointVertices.getDimension()); this.pointVertices_.getDimension());
transform( transform(
lineVertices.coordinates, this.lineVertices_.coordinates,
lineVertices.coordinates, this.lineVertices_.coordinates,
lineVertices.getDimension()); this.lineVertices_.getDimension());
transform( transform(
polygonVertices.coordinates, this.polygonVertices_.coordinates,
polygonVertices.coordinates, this.polygonVertices_.coordinates,
polygonVertices.getDimension()); this.polygonVertices_.getDimension());
this.addFeatures(features); this.addFeatures(features);
}; };