diff --git a/src/ol/parser/ogc/filterparser_v1.js b/src/ol/parser/ogc/filterparser_v1.js index b141c98279..6a5822ee4f 100644 --- a/src/ol/parser/ogc/filterparser_v1.js +++ b/src/ol/parser/ogc/filterparser_v1.js @@ -596,6 +596,9 @@ ol.parser.ogc.Filter_v1.prototype.getGmlParser = function() { */ ol.parser.ogc.Filter_v1.prototype.setGmlParser = function(gml) { this.gmlParser_ = gml; + if (this.featureNS) { + gml.setFeatureNS(this.featureNS); + } for (var uri in this.gmlParser_.readers) { for (var key in this.gmlParser_.readers[uri]) { if (!goog.isDef(this.readers[uri])) { @@ -615,3 +618,36 @@ ol.parser.ogc.Filter_v1.prototype.setGmlParser = function(gml) { } } }; + + +/** + * @param {string} featureNS Feature namespace. + */ +ol.parser.ogc.Filter_v1.prototype.setFeatureNS = function(featureNS) { + this.featureNS = featureNS; + if (goog.isDefAndNotNull(this.gmlParser_)) { + this.setGmlParser(this.gmlParser_); + } +}; + + +/** + * @param {string} featureType Feature type. + */ +ol.parser.ogc.Filter_v1.prototype.setFeatureType = function(featureType) { + this.featureType = featureType; + if (goog.isDefAndNotNull(this.gmlParser_)) { + this.gmlParser_.featureType = featureType; + } +}; + + +/** + * @param {string} srsName SRS name. + */ +ol.parser.ogc.Filter_v1.prototype.setSrsName = function(srsName) { + this.srsName = srsName; + if (goog.isDefAndNotNull(this.gmlParser_)) { + this.gmlParser_.srsName = this.srsName; + } +}; diff --git a/src/ol/parser/ogc/filterparser_v1_0_0.js b/src/ol/parser/ogc/filterparser_v1_0_0.js index eecebe2504..dcd75f34c0 100644 --- a/src/ol/parser/ogc/filterparser_v1_0_0.js +++ b/src/ol/parser/ogc/filterparser_v1_0_0.js @@ -114,7 +114,7 @@ ol.parser.ogc.Filter_v1_0_0 = function() { return node; } }); - this.setGmlParser(new ol.parser.ogc.GML_v2({featureNS: 'http://foo'})); + this.setGmlParser(new ol.parser.ogc.GML_v2()); }; goog.inherits(ol.parser.ogc.Filter_v1_0_0, ol.parser.ogc.Filter_v1); @@ -168,8 +168,7 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) { } else { var child; if (geom !== null) { - child = this.writeNode('_geometry', {value: geom}, - this.gmlParser_.featureNS).firstChild; + child = this.gmlParser_.writeGeometry(geom); } else if (bbox.length === 4) { child = this.writeNode('Box', bbox, 'http://www.opengis.net/gml'); diff --git a/src/ol/parser/ogc/gmlparser.js b/src/ol/parser/ogc/gmlparser.js index f4c35e610f..894bfe17ec 100644 --- a/src/ol/parser/ogc/gmlparser.js +++ b/src/ol/parser/ogc/gmlparser.js @@ -479,6 +479,16 @@ ol.parser.ogc.GML = function(opt_options) { goog.inherits(ol.parser.ogc.GML, ol.parser.XML); +/** + * @param {ol.geom.Geometry} geometry Geometry. + * @return {Element} XML node representing the geometry. + */ +ol.parser.ogc.GML.prototype.writeGeometry = function(geometry) { + return this.featureNSWriters_['_geometry'].call(this, {value: geometry}) + .firstChild; +}; + + /** * @param {string|Document|Element|Object} data Data to read. * @param {ol.parser.GMLReadOptions=} opt_options Read options. @@ -645,3 +655,13 @@ ol.parser.ogc.GML.prototype.applyWriteOptions = function(obj, opt_options) { this.axisOrientation = ol.proj.get(this.srsName).getAxisOrientation(); } }; + + +/** + * @param {string} featureNS Feature namespace. + */ +ol.parser.ogc.GML.prototype.setFeatureNS = function(featureNS) { + this.featureNS = featureNS; + this.readers[featureNS] = this.featureNSReaders_; + this.writers[featureNS] = this.featureNSWriters_; +}; diff --git a/src/ol/parser/ogc/wfsparser_v1.js b/src/ol/parser/ogc/wfsparser_v1.js index 892e7a851f..2fb5f685fa 100644 --- a/src/ol/parser/ogc/wfsparser_v1.js +++ b/src/ol/parser/ogc/wfsparser_v1.js @@ -122,8 +122,12 @@ ol.parser.ogc.WFS_v1.prototype.getFilterParser = function() { */ ol.parser.ogc.WFS_v1.prototype.setFilterParser = function(filter) { this.filter_ = filter; - for (var uri in this.filter_.readers) { - for (var key in this.filter_.readers[uri]) { + if (goog.isDefAndNotNull(this.featureNS)) { + filter.setFeatureNS(this.featureNS); + } + var uri, key; + for (uri in this.filter_.readers) { + for (key in this.filter_.readers[uri]) { if (!goog.isDef(this.readers[uri])) { this.readers[uri] = {}; } @@ -149,6 +153,39 @@ ol.parser.ogc.WFS_v1.prototype.setFilterParser = function(filter) { }; +/** + * @param {string} featureType Feature type. + */ +ol.parser.ogc.WFS_v1.prototype.setFeatureType = function(featureType) { + this.featureType = featureType; + if (goog.isDefAndNotNull(this.filter_)) { + this.filter_.setFeatureType(featureType); + } +}; + + +/** + * @param {string} featureNS Feature namespace. + */ +ol.parser.ogc.WFS_v1.prototype.setFeatureNS = function(featureNS) { + this.featureNS = featureNS; + if (goog.isDefAndNotNull(this.filter_)) { + this.setFilterParser(this.filter_); + } +}; + + +/** + * @param {string} srsName SRS name. + */ +ol.parser.ogc.WFS_v1.prototype.setSrsName = function(srsName) { + this.srsName = srsName; + if (goog.isDefAndNotNull(this.filter_)) { + this.filter_.setSrsName(this.srsName); + } +}; + + /** * @param {string|Document|Element} data Data to read. * @return {Object} An object representing the document. diff --git a/src/ol/parser/ogc/wfsparser_v1_0_0.js b/src/ol/parser/ogc/wfsparser_v1_0_0.js index 28e64c98b8..630db7579a 100644 --- a/src/ol/parser/ogc/wfsparser_v1_0_0.js +++ b/src/ol/parser/ogc/wfsparser_v1_0_0.js @@ -72,7 +72,6 @@ ol.parser.ogc.WFS_v1_0_0 = function() { } }); var filter = new ol.parser.ogc.Filter_v1_0_0(); - delete filter.getGmlParser().featureNS; this.setFilterParser(filter); }; goog.inherits(ol.parser.ogc.WFS_v1_0_0,