Merge pull request #733 from ahocevar/fid
Store the feature's commonly used id. r=@fredj,@bartvde
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
@exportSymbol ol.Feature
|
||||
@exportProperty ol.Feature.prototype.get
|
||||
@exportProperty ol.Feature.prototype.getAttributes
|
||||
@exportProperty ol.Feature.prototype.getFeatureId
|
||||
@exportProperty ol.Feature.prototype.getGeometry
|
||||
@exportProperty ol.Feature.prototype.set
|
||||
@exportProperty ol.Feature.prototype.setFeatureId
|
||||
@exportProperty ol.Feature.prototype.setGeometry
|
||||
@exportProperty ol.Feature.prototype.setSymbolizers
|
||||
|
||||
@@ -14,6 +14,12 @@ ol.Feature = function(opt_values) {
|
||||
|
||||
goog.base(this, opt_values);
|
||||
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.featureId_;
|
||||
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
* @private
|
||||
@@ -46,6 +52,17 @@ ol.Feature.prototype.getAttributes = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the feature's commonly used identifier. This identifier is usually
|
||||
* the unique id in the source store.
|
||||
*
|
||||
* @return {string|undefined} The feature's identifier.
|
||||
*/
|
||||
ol.Feature.prototype.getFeatureId = function() {
|
||||
return this.featureId_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.geom.Geometry} The geometry (or null if none).
|
||||
*/
|
||||
@@ -85,6 +102,17 @@ ol.Feature.prototype.set = function(key, value) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the feature's commonly used identifier. This identifier is usually the
|
||||
* unique id in the source store.
|
||||
*
|
||||
* @param {string} featureId The feature's identifier.
|
||||
*/
|
||||
ol.Feature.prototype.setFeatureId = function(featureId) {
|
||||
this.featureId_ = featureId;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry The geometry.
|
||||
*/
|
||||
|
||||
@@ -144,6 +144,9 @@ ol.parser.GeoJSON.prototype.parseFeature_ = function(json, opt_options) {
|
||||
geometry = null,
|
||||
options = opt_options || {};
|
||||
var feature = new ol.Feature(json.properties);
|
||||
if (goog.isDef(json.id)) {
|
||||
feature.setFeatureId(json.id);
|
||||
}
|
||||
if (geomJson) {
|
||||
var type = geomJson.type;
|
||||
var callback = options.callback;
|
||||
|
||||
@@ -104,6 +104,7 @@ 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)) {
|
||||
var track = container.track, j, jj;
|
||||
@@ -125,6 +126,9 @@ ol.parser.KML = function(opt_options) {
|
||||
container.properties['altitude'] = track.points[i].coordinates[2];
|
||||
}
|
||||
var feature = new ol.Feature(container.properties);
|
||||
if (!goog.isNull(id)) {
|
||||
feature.setFeatureId(id);
|
||||
}
|
||||
var geom = track.points[i];
|
||||
if (geom) {
|
||||
sharedVertices = undefined;
|
||||
@@ -150,6 +154,9 @@ ol.parser.KML = function(opt_options) {
|
||||
}
|
||||
}
|
||||
feature = new ol.Feature(container.properties);
|
||||
if (!goog.isNull(id)) {
|
||||
feature.setFeatureId(id);
|
||||
}
|
||||
if (container.geometry) {
|
||||
sharedVertices = undefined;
|
||||
if (this.readFeaturesOptions_) {
|
||||
|
||||
Reference in New Issue
Block a user