Merge remote-tracking branch 'openlayers/master' into vector-api

This commit is contained in:
Tom Payne
2013-12-06 16:29:13 +01:00
13 changed files with 371 additions and 90 deletions
+36
View File
@@ -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;
}
};
+2 -3
View File
@@ -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');
+23 -3
View File
@@ -414,7 +414,7 @@ ol.parser.ogc.GML = function(opt_options) {
}
}
};
this.featureNSWiters_ = {
this.featureNSWriters_ = {
'_typeName': function(feature) {
var node = this.createElementNS('feature:' + this.featureType,
this.featureNS);
@@ -472,13 +472,23 @@ ol.parser.ogc.GML = function(opt_options) {
}
};
if (goog.isDef(this.featureNS)) {
this.writers[this.featureNS] = this.featureNSWiters_;
this.writers[this.featureNS] = this.featureNSWriters_;
}
goog.base(this);
};
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.
@@ -541,7 +551,7 @@ ol.parser.ogc.GML.prototype.readNode = function(node, obj, opt_first) {
(/^(.*:)?featureMembers?$/).test(node.parentNode.nodeName))) {
this.featureType = node.nodeName.split(':').pop();
this.readers[node.namespaceURI] = this.featureNSReaders_;
this.writers[node.namespaceURI] = this.featureNSWiters_;
this.writers[node.namespaceURI] = this.featureNSWriters_;
this.featureNS = node.namespaceURI;
this.autoConfig = true;
}
@@ -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_;
};
+1 -1
View File
@@ -22,7 +22,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
'http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
'1.0.0/gmlsf.xsd';
goog.base(this, opt_options);
this.featureNSWiters_['_geometry'] = function(obj) {
this.featureNSWriters_['_geometry'] = function(obj) {
var node = this.createElementNS('feature:' + obj.name,
this.featureNS);
var geometry = obj.value;
+39 -2
View File
@@ -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.
@@ -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,