add an optional argument to getAttributes so we can get a feature's attributes except for the geometry ones

This commit is contained in:
Bart van den Eijnden
2013-11-19 15:39:22 +01:00
parent 936f86568e
commit 8d03fa1197
4 changed files with 28 additions and 10 deletions

View File

@@ -351,11 +351,7 @@ ol.parser.GeoJSON.prototype.encodeFeatureCollection_ = function(collection) {
*/
ol.parser.GeoJSON.prototype.encodeFeature_ = function(feature) {
var geometry = feature.getGeometry(),
attributes = feature.getAttributes();
var properties = goog.object.filter(attributes,
function(element, index, array) {
return !(element instanceof ol.geom.Geometry);
});
properties = feature.getAttributes(true);
return /** @type {GeoJSONFeature} */({
type: 'Feature',
properties: properties,

View File

@@ -422,11 +422,10 @@ ol.parser.ogc.GML = function(opt_options) {
this.writeNode('_geometry', feature.getGeometry(), this.featureNS,
node);
}
var attributes = feature.getAttributes();
var attributes = feature.getAttributes(true);
for (var name in attributes) {
var value = attributes[name];
if (goog.isDefAndNotNull(value) && !(value instanceof
ol.geom.Geometry)) {
if (goog.isDefAndNotNull(value)) {
this.writeNode('_attribute', {name: name, value: value},
this.featureNS, node);
}