need the ability to set axisOrientation

We need to be able to set axisOrientation on the underlying GML parser of the Filter subparser of ol.parser.WFS*, also only options and no properties on the instance anymore
This commit is contained in:
Bart van den Eijnden
2013-10-23 13:15:16 +02:00
parent 3184fb02e5
commit 4df848fae0
8 changed files with 87 additions and 48 deletions

View File

@@ -580,6 +580,14 @@ ol.parser.ogc.Filter_v1.prototype.aggregateLogical_ = function(filters,
};
/**
* @return {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3}
*/
ol.parser.ogc.Filter_v1.prototype.getGmlParser = function() {
return this.gml_;
};
/**
* @param {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3} gml The GML parser to
* use.

View File

@@ -19,8 +19,7 @@ ol.ENABLE_WFS_1_1_0 = true;
/**
* @constructor
* @param {ol.parser.WFSOptions=} opt_options
* Optional configuration object.
* @param {Object=} opt_options Options which will be set on this object.
* @extends {ol.parser.ogc.Versioned}
*/
ol.parser.ogc.WFS = function(opt_options) {

View File

@@ -6,16 +6,9 @@ goog.require('ol.parser.XML');
/**
* @constructor
* @param {ol.parser.WFSOptions=} opt_options
* Optional configuration object.
* @extends {ol.parser.XML}
*/
ol.parser.ogc.WFS_v1 = function(opt_options) {
if (goog.isDef(opt_options)) {
this.featureTypes = opt_options.featureTypes;
this.featurePrefix = opt_options.featurePrefix;
this.featureNS = opt_options.featureNS;
}
ol.parser.ogc.WFS_v1 = function() {
this.defaultNamespaceURI = 'http://www.opengis.net/wfs';
// TODO set errorProperty
this.readers = {};
@@ -42,8 +35,8 @@ ol.parser.ogc.WFS_v1 = function(opt_options) {
node.setAttribute('maxFeatures', options.maxFeatures);
}
}
for (var i = 0, ii = this.featureTypes.length; i < ii; i++) {
options.featureType = this.featureTypes[i];
for (var i = 0, ii = options.featureTypes.length; i < ii; i++) {
options.featureType = options.featureTypes[i];
this.writeNode('Query', options, null, node);
}
this.setAttributeNS(
@@ -57,6 +50,14 @@ ol.parser.ogc.WFS_v1 = function(opt_options) {
goog.inherits(ol.parser.ogc.WFS_v1, ol.parser.XML);
/**
* @return {ol.parser.ogc.Filter_v1_0_0|ol.parser.ogc.Filter_v1_1_0}
*/
ol.parser.ogc.WFS_v1.prototype.getFilterParser = function() {
return this.filter_;
};
/**
* @param {ol.parser.ogc.Filter_v1_0_0|ol.parser.ogc.Filter_v1_1_0} filter The
* Filter parser to use.

View File

@@ -9,12 +9,10 @@ goog.require('ol.parser.ogc.WFS_v1');
/**
* @constructor
* @param {ol.parser.WFSOptions=} opt_options
* Optional configuration object.
* @extends {ol.parser.ogc.WFS_v1}
*/
ol.parser.ogc.WFS_v1_0_0 = function(opt_options) {
goog.base(this, opt_options);
ol.parser.ogc.WFS_v1_0_0 = function() {
goog.base(this);
this.version = '1.0.0';
this.schemaLocation = this.defaultNamespaceURI + ' ' +
'http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd';
@@ -43,23 +41,15 @@ ol.parser.ogc.WFS_v1_0_0 = function(opt_options) {
});
goog.object.extend(this.writers[this.defaultNamespaceURI], {
'Query': function(options) {
// TODO see if we really need properties on the instance
/*goog.object.extend(options, {
featureNS: this.featureNS,
featurePrefix: this.featurePrefix,
featureType: this.featureType,
srsName: this.srsName,
srsNameInQuery: this.srsNameInQuery
});*/
var prefix = goog.isDef(this.featurePrefix) ? this.featurePrefix +
var prefix = goog.isDef(options.featurePrefix) ? options.featurePrefix +
':' : '';
var node = this.createElementNS('wfs:Query');
node.setAttribute('typeName', prefix + options.featureType);
if (goog.isDef(options.srsNameInQuery) && goog.isDef(options.srsName)) {
node.setAttribute('srsName', options.srsName);
}
if (goog.isDef(this.featureNS)) {
node.setAttribute('xmlns:' + this.featurePrefix, this.featureNS);
if (goog.isDef(options.featureNS)) {
node.setAttribute('xmlns:' + options.featurePrefix, options.featureNS);
}
if (goog.isDef(options.propertyNames)) {
for (var i = 0, ii = options.propertyNames.length; i < ii; i++) {

View File

@@ -9,12 +9,10 @@ goog.require('ol.parser.ogc.WFS_v1');
/**
* @constructor
* @param {ol.parser.WFSOptions=} opt_options
* Optional configuration object.
* @extends {ol.parser.ogc.WFS_v1}
*/
ol.parser.ogc.WFS_v1_1_0 = function(opt_options) {
goog.base(this, opt_options);
ol.parser.ogc.WFS_v1_1_0 = function() {
goog.base(this);
this.version = '1.1.0';
this.schemaLocation = this.defaultNamespaceURI + ' ' +
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd';
@@ -62,19 +60,13 @@ ol.parser.ogc.WFS_v1_1_0 = function(opt_options) {
return node;
},
'Query': function(options) {
goog.object.extend(options, {
featureNS: this.featureNS,
featurePrefix: this.featurePrefix,
featureType: this.featureType,
srsName: this.srsName
});
var prefix = goog.isDef(options.featurePrefix) ? options.prefix + ':' :
'';
var prefix = goog.isDef(options.featurePrefix) ? options.featurePrefix +
':' : '';
var node = this.createElementNS('wfs:Query');
node.setAttribute('typeName', prefix + options.featureType);
node.setAttribute('srsName', options.srsName);
if (goog.isDef(options.featureNS)) {
node.setAttribute('xmlns:' + options.prefix, options.featureNS);
node.setAttribute('xmlns:' + options.featurePrefix, options.featureNS);
}
if (goog.isDef(options.propertyNames)) {
for (var i = 0, ii = options.propertyNames.length; i < ii; i++) {

View File

@@ -22,8 +22,7 @@ describe('ol.parser.ogc.WFS_v1_0_0', function() {
it('handles writing Query with BBOX Filter', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/query0.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_0_0({featureTypes: ['states'],
featurePrefix: 'topp', featureNS: 'http://www.openplans.org/topp'});
var p = new ol.parser.ogc.WFS_v1_0_0();
var filter = new ol.expr.Call(
new ol.expr.Identifier(ol.expr.functions.EXTENT),
[new ol.expr.Literal(1), new ol.expr.Literal(2),
@@ -31,7 +30,12 @@ describe('ol.parser.ogc.WFS_v1_0_0', function() {
undefined,
new ol.expr.Identifier('the_geom')]);
var output = p.writers[p.defaultNamespaceURI]['Query'].apply(
p, [{filter: filter, featureType: 'states'}]);
p, [{
filter: filter,
featureType: 'states',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp'
}]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});
@@ -40,12 +44,16 @@ describe('ol.parser.ogc.WFS_v1_0_0', function() {
it('handles writing GetFeature with PropertyName', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/getfeature0.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_0_0({featureTypes: ['states'],
featurePrefix: 'topp', featureNS: 'http://www.openplans.org/topp'});
var p = new ol.parser.ogc.WFS_v1_0_0();
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply(
p, [{propertyNames: [new ol.expr.Identifier('STATE_NAME'),
new ol.expr.Identifier('STATE_FIPS'),
new ol.expr.Identifier('STATE_ABBR')]}]);
p, [{
propertyNames: [new ol.expr.Identifier('STATE_NAME'),
new ol.expr.Identifier('STATE_FIPS'),
new ol.expr.Identifier('STATE_ABBR')],
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
featureTypes: ['states']
}]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});

View File

@@ -44,10 +44,40 @@ describe('ol.parser.ogc.WFS_v1_1_0', function() {
});
});
it('handles writing Query with BBOX Filter', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/query0.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_1_0();
var srs = 'urn:ogc:def:crs:EPSG::4326';
var filter = new ol.expr.Call(
new ol.expr.Identifier(ol.expr.functions.EXTENT),
[new ol.expr.Literal(1), new ol.expr.Literal(2),
new ol.expr.Literal(3), new ol.expr.Literal(4),
new ol.expr.Literal(srs),
new ol.expr.Identifier('the_geom')]);
p.getFilterParser().getGmlParser().axisOrientation =
ol.proj.get(srs).getAxisOrientation();
var output = p.writers[p.defaultNamespaceURI]['Query'].apply(
p, [{
srsName: srs,
filter: filter,
featureType: 'states',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp'
}]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});
});
});
});
goog.require('goog.dom.xml');
goog.require('ol.expr.Call');
goog.require('ol.expr.Identifier');
goog.require('ol.expr.Literal');
goog.require('ol.parser.ogc.WFS');
goog.require('ol.parser.ogc.WFS_v1_1_0');
goog.require('ol.proj');

View File

@@ -0,0 +1,11 @@
<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" srsName="urn:ogc:def:crs:EPSG::4326" xmlns:topp="http://www.openplans.org/topp">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>the_geom</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="urn:ogc:def:crs:EPSG::4326">
<gml:lowerCorner>1 2</gml:lowerCorner>
<gml:upperCorner>3 4</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>