FeatureId support in GML (r/w) and KML (w)
Now that we have FeatureId support (see #733), we can add this back to the GML parsers (v2 and v3). Also add write support for FeatureId in KML, read support was already added by @fredj
This commit is contained in:
@@ -687,6 +687,10 @@ ol.parser.KML = function(opt_options) {
|
||||
},
|
||||
'_feature': function(feature) {
|
||||
var node = this.createElementNS('Placemark');
|
||||
var fid = feature.getFeatureId();
|
||||
if (goog.isDef(fid)) {
|
||||
node.setAttribute('id', fid);
|
||||
}
|
||||
this.writeNode('name', feature, null, node);
|
||||
this.writeNode('description', feature, null, node);
|
||||
var literals = feature.getSymbolizerLiterals();
|
||||
|
||||
@@ -291,7 +291,11 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
}
|
||||
}
|
||||
// TODO set feature.type and feature.namespace
|
||||
// TODO set fid
|
||||
var fid = node.getAttribute('fid') ||
|
||||
this.getAttributeNS(node, this.defaultNamespaceURI, 'id');
|
||||
if (!goog.isNull(fid)) {
|
||||
feature.setFeatureId(fid);
|
||||
}
|
||||
obj.features.push(feature);
|
||||
},
|
||||
'_geometry': function(node, obj) {
|
||||
@@ -389,8 +393,10 @@ ol.parser.ogc.GML = function(opt_options) {
|
||||
'_typeName': function(feature) {
|
||||
var node = this.createElementNS('feature:' + this.featureType,
|
||||
this.featureNS);
|
||||
// TODO: https://github.com/openlayers/ol3/issues/558
|
||||
// this.setAttributeNS(node, null, 'fid', feature.fid);
|
||||
var fid = feature.getFeatureId();
|
||||
if (goog.isDef(fid)) {
|
||||
this.setAttributeNS(node, this.defaultNamespaceURI, 'fid', fid);
|
||||
}
|
||||
if (feature.getGeometry() !== null) {
|
||||
this.writeNode('_geometry', feature.getGeometry(), this.featureNS,
|
||||
node);
|
||||
|
||||
@@ -94,7 +94,6 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
||||
[extent.maxX, extent.maxY]], null, node);
|
||||
// srsName attribute is optional for gml:Box
|
||||
if (goog.isDef(this.srsName)) {
|
||||
// TODO setAttribute or this.setAttributeNS
|
||||
node.setAttribute('srsName', this.srsName);
|
||||
}
|
||||
return node;
|
||||
|
||||
Reference in New Issue
Block a user