Merge pull request #1160 from bartvde/wfst

Add parser for WFS (r=@ahocevar)
This commit is contained in:
Bart van den Eijnden
2013-11-25 07:38:08 -08:00
25 changed files with 896 additions and 14 deletions

View File

@@ -182,7 +182,8 @@ ol.parser.ogc.Filter_v1 = function() {
var args = [], container = {};
this.readChildNodes(node, container);
if (goog.isDef(container.geometry)) {
args.push(new ol.expr.Literal(this.gml_.createGeometry(container)));
args.push(new ol.expr.Literal(this.gmlParser_.createGeometry(
container)));
} else {
args = [new ol.expr.Literal(container.bounds[0]),
new ol.expr.Literal(container.bounds[1]),
@@ -580,29 +581,37 @@ 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.gmlParser_;
};
/**
* @param {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3} gml The GML parser to
* use.
* @protected
*/
ol.parser.ogc.Filter_v1.prototype.setGmlParser = function(gml) {
this.gml_ = gml;
for (var uri in this.gml_.readers) {
for (var key in this.gml_.readers[uri]) {
this.gmlParser_ = gml;
for (var uri in this.gmlParser_.readers) {
for (var key in this.gmlParser_.readers[uri]) {
if (!goog.isDef(this.readers[uri])) {
this.readers[uri] = {};
}
this.readers[uri][key] = goog.bind(this.gml_.readers[uri][key],
this.gml_);
this.readers[uri][key] = goog.bind(this.gmlParser_.readers[uri][key],
this.gmlParser_);
}
}
for (uri in this.gml_.writers) {
for (key in this.gml_.writers[uri]) {
for (uri in this.gmlParser_.writers) {
for (key in this.gmlParser_.writers[uri]) {
if (!goog.isDef(this.writers[uri])) {
this.writers[uri] = {};
}
this.writers[uri][key] = goog.bind(this.gml_.writers[uri][key],
this.gml_);
this.writers[uri][key] = goog.bind(this.gmlParser_.writers[uri][key],
this.gmlParser_);
}
}
};

View File

@@ -91,12 +91,14 @@ ol.parser.ogc.Filter_v1_0_0 = function() {
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
var bbox = [
args[0].getValue(), args[1].getValue(),
args[2].getValue(), args[3].getValue()
];
var projection = args[4].getValue();
var projection;
if (args[4] instanceof ol.expr.Literal) {
projection = args[4].getValue();
}
var property = args[5];
// PropertyName is mandatory in 1.0.0, but e.g. GeoServer also
// accepts filters without it.
@@ -167,7 +169,7 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
var child;
if (geom !== null) {
child = this.writeNode('_geometry', {value: geom},
this.gml_.featureNS).firstChild;
this.gmlParser_.featureNS).firstChild;
} else if (bbox.length === 4) {
child = this.writeNode('Box', bbox,
'http://www.opengis.net/gml');

View File

@@ -225,7 +225,7 @@ ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
var child;
if (geom !== null) {
child = this.writeNode('_geometry', {value: geom},
this.gml_.featureNS).firstChild;
this.gmlParser_.featureNS).firstChild;
} else if (bbox.length === 4) {
child = this.writeNode('Envelope', bbox,
'http://www.opengis.net/gml');

View File

@@ -148,6 +148,9 @@ ol.parser.ogc.GML = function(opt_options) {
'polygonMember': function(node, obj) {
this.readChildNodes(node, obj);
},
'boundedBy': function(node, obj) {
this.readChildNodes(node, obj);
},
'Point': function(node, container) {
var coordinates = [];
this.readers[this.defaultNamespaceURI]['_inherit'].apply(this,

View File

@@ -0,0 +1,37 @@
goog.require('ol.parser.ogc.Versioned');
goog.provide('ol.parser.ogc.WFS');
goog.require('ol.parser.ogc.WFS_v1_0_0');
goog.require('ol.parser.ogc.WFS_v1_1_0');
/**
* @define {boolean} Whether to enable OGC WFS version 1.0.0.
*/
ol.ENABLE_WFS_1_0_0 = true;
/**
* @define {boolean} Whether to enable OGC WFS version 1.1.0.
*/
ol.ENABLE_WFS_1_1_0 = true;
/**
* @constructor
* @param {Object=} opt_options Options which will be set on this object.
* @extends {ol.parser.ogc.Versioned}
*/
ol.parser.ogc.WFS = function(opt_options) {
var options = opt_options || {};
options['defaultVersion'] = '1.0.0';
this.parsers = {};
if (ol.ENABLE_WFS_1_0_0) {
this.parsers['v1_0_0'] = ol.parser.ogc.WFS_v1_0_0;
}
if (ol.ENABLE_WFS_1_1_0) {
this.parsers['v1_1_0'] = ol.parser.ogc.WFS_v1_1_0;
}
goog.base(this, options);
};
goog.inherits(ol.parser.ogc.WFS, ol.parser.ogc.Versioned);

View File

@@ -0,0 +1,181 @@
goog.provide('ol.parser.ogc.WFS_v1');
goog.require('goog.dom.xml');
goog.require('ol.parser.XML');
/**
* @typedef {{featureNS: string,
featurePrefix: string,
featureTypes: Array.<string>,
handle: string,
outputFormat: string,
nativeElements: Array.<{
vendorId: string,
safeToIgnore: boolean,
value: string
}>,
maxFeatures: number}}
*/
ol.parser.WFSWriteOptions;
/**
* @constructor
* @extends {ol.parser.XML}
*/
ol.parser.ogc.WFS_v1 = function() {
this.defaultNamespaceURI = 'http://www.opengis.net/wfs';
// TODO set errorProperty
this.readers = {};
this.readers[this.defaultNamespaceURI] = {
'FeatureCollection': function(node, obj) {
obj.features = [];
this.readChildNodes(node, obj);
}
};
this.writers = {};
this.writers[this.defaultNamespaceURI] = {
'GetFeature': function(options) {
options = /** @type {ol.parser.WFSWriteOptions} */(options);
var node = this.createElementNS('wfs:GetFeature');
node.setAttribute('service', 'WFS');
node.setAttribute('version', this.version);
if (goog.isDef(options)) {
if (goog.isDef(options.handle)) {
node.setAttribute('handle', options.handle);
}
if (goog.isDef(options.outputFormat)) {
node.setAttribute('outputFormat', options.outputFormat);
}
if (goog.isDef(options.maxFeatures)) {
node.setAttribute('maxFeatures', options.maxFeatures);
}
}
for (var i = 0, ii = options.featureTypes.length; i < ii; i++) {
options.featureType = options.featureTypes[i];
this.writeNode('Query', options, null, node);
}
this.setAttributeNS(
node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
return {node: node, options: options};
},
'Transaction': function(obj) {
obj = obj || {};
var options = /** {ol.parser.WFSWriteOptions} */(obj.options || {});
var node = this.createElementNS('wfs:Transaction');
node.setAttribute('service', 'WFS');
node.setAttribute('version', this.version);
if (goog.isDef(options.handle)) {
node.setAttribute('handle', options.handle);
}
var i, ii;
var features = obj.features;
if (goog.isDefAndNotNull(features)) {
// TODO implement multi option for geometry types
var name, feature;
for (i = 0, ii = features.length; i < ii; ++i) {
feature = features[i];
// TODO Update (use feature.getOriginal())
// TODO Insert and Delete
if (goog.isDef(name)) {
this.writeNode(name, {
feature: feature,
options: options
}, null, node);
}
}
}
if (goog.isDef(options.nativeElements)) {
for (i = 0, ii = options.nativeElements.length; i < ii; ++i) {
this.writeNode('Native', options.nativeElements[i], null, node);
}
}
return node;
},
'Native': function(nativeElement) {
var node = this.createElementNS('wfs:Native');
node.setAttribute('vendorId', nativeElement.vendorId);
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
node.appendChild(this.createTextNode(nativeElement.value));
return node;
}
};
goog.base(this);
};
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.
* @protected
*/
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.isDef(this.readers[uri])) {
this.readers[uri] = {};
}
// do not overwrite any readers
if (!goog.isDef(this.readers[uri][key])) {
this.readers[uri][key] = goog.bind(this.filter_.readers[uri][key],
this.filter_);
}
}
}
for (uri in this.filter_.writers) {
for (key in this.filter_.writers[uri]) {
if (!goog.isDef(this.writers[uri])) {
this.writers[uri] = {};
}
// do not overwrite any writers
if (!goog.isDef(this.writers[uri][key])) {
this.writers[uri][key] = goog.bind(this.filter_.writers[uri][key],
this.filter_);
}
}
}
};
/**
* @param {string|Document|Element} data Data to read.
* @return {Object} An object representing the document.
*/
ol.parser.ogc.WFS_v1.prototype.read = function(data) {
if (goog.isString(data)) {
data = goog.dom.xml.loadXml(data);
}
if (data && data.nodeType == 9) {
data = data.documentElement;
}
var obj = {};
this.readNode(data, obj);
return obj;
};
/**
* @param {Array.<ol.Feature>} features The features to write out.
* @param {ol.parser.WFSWriteOptions} options Write options.
* @return {string} A serialized WFS transaction.
*/
ol.parser.ogc.WFS_v1.prototype.write = function(features, options) {
var root = this.writeNode('Transaction', {features: features,
options: options});
this.setAttributeNS(
root, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
return this.serialize(root);
};

View File

@@ -0,0 +1,79 @@
goog.provide('ol.parser.ogc.WFS_v1_0_0');
goog.require('goog.array');
goog.require('goog.functions');
goog.require('goog.object');
goog.require('ol.parser.ogc.Filter_v1_0_0');
goog.require('ol.parser.ogc.WFS_v1');
/**
* @constructor
* @extends {ol.parser.ogc.WFS_v1}
*/
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';
goog.object.extend(this.readers[this.defaultNamespaceURI], {
'WFS_TransactionResponse': function(node, obj) {
obj.insertIds = [];
obj.success = false;
this.readChildNodes(node, obj);
},
'InsertResult': function(node, container) {
var obj = {fids: []};
this.readChildNodes(node, obj);
for (var key in obj.fids) {
container.insertIds.push(key);
}
},
'TransactionResult': function(node, obj) {
this.readChildNodes(node, obj);
},
'Status': function(node, obj) {
this.readChildNodes(node, obj);
},
'SUCCESS': function(node, obj) {
obj.success = true;
}
});
goog.object.extend(this.writers[this.defaultNamespaceURI], {
'GetFeature': goog.functions.compose(
function(obj) {
return obj.node;
},
this.writers['http://www.opengis.net/wfs']['GetFeature']
),
'Query': function(options) {
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(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++) {
this.writeNode('PropertyName', options.propertyNames[i],
'http://www.opengis.net/ogc', node);
}
}
if (goog.isDef(options.filter)) {
this.writeNode('Filter', options.filter,
'http://www.opengis.net/ogc', node);
}
return node;
}
});
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,
ol.parser.ogc.WFS_v1);

View File

@@ -0,0 +1,101 @@
goog.provide('ol.parser.ogc.WFS_v1_1_0');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.object');
goog.require('ol.expr.Identifier');
goog.require('ol.parser.ogc.Filter_v1_1_0');
goog.require('ol.parser.ogc.WFS_v1');
/**
* @constructor
* @extends {ol.parser.ogc.WFS_v1}
*/
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';
goog.object.extend(this.readers[this.defaultNamespaceURI], {
'FeatureCollection': goog.functions.sequence(
function(node, obj) {
var numberOfFeatures = node.getAttribute('numberOfFeatures');
if (!goog.isNull(numberOfFeatures)) {
obj.numberOfFeatures = parseInt(numberOfFeatures, 10);
}
},
this.readers['http://www.opengis.net/wfs']['FeatureCollection']
),
'TransactionResponse': function(node, obj) {
obj.insertIds = [];
obj.success = false;
this.readChildNodes(node, obj);
},
'TransactionSummary': function(node, obj) {
// this is a limited test of success
obj.success = true;
},
'InsertResults': function(node, obj) {
this.readChildNodes(node, obj);
},
'Feature': function(node, container) {
var obj = {};
this.readChildNodes(node, obj);
for (var key in obj.fids) {
container.insertIds.push(key);
}
}
});
goog.object.extend(this.writers[this.defaultNamespaceURI], {
'GetFeature': goog.functions.compose(
function(obj) {
var options = obj.options;
var node = obj.node;
if (goog.isDef(options)) {
if (goog.isDef(options.resultType)) {
node.setAttribute('resultType', options.resultType);
}
if (goog.isDef(options.startIndex)) {
node.setAttribute('startIndex', options.startIndex);
}
if (goog.isDef(options.count)) {
node.setAttribute('count', options.count);
}
}
return node;
},
this.writers['http://www.opengis.net/wfs']['GetFeature']
),
'Query': function(options) {
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.featurePrefix, options.featureNS);
}
if (goog.isDef(options.propertyNames)) {
for (var i = 0, ii = options.propertyNames.length; i < ii; i++) {
this.writeNode('PropertyName', options.propertyNames[i], null, node);
}
}
if (goog.isDef(options.filter)) {
this.writeNode('Filter', options.filter,
'http://www.opengis.net/ogc', node);
}
return node;
},
'PropertyName': function(obj) {
goog.asserts.assertInstanceof(obj, ol.expr.Identifier);
var node = this.createElementNS('wfs:PropertyName');
node.appendChild(this.createTextNode(obj.getName()));
return node;
}
});
this.setFilterParser(new ol.parser.ogc.Filter_v1_1_0());
};
goog.inherits(ol.parser.ogc.WFS_v1_1_0,
ol.parser.ogc.WFS_v1);

View File

@@ -0,0 +1,92 @@
goog.provide('ol.test.parser.ogc.WFS_v1');
describe('ol.parser.ogc.WFS', function() {
var parser = new ol.parser.ogc.WFS();
describe('reading and writing', function() {
it('handles read of FeatureCollection', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1/FeatureCollection.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.features.length).to.equal(1);
done();
});
});
it('handles writing out GetFeature with a handle', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_0_0();
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
apply(p, [{
featureNS: 'http://www.openplans.org/topp',
featureTypes: ['states'],
featurePrefix: 'topp',
handle: 'handle_g',
maxFeatures: 1,
outputFormat: 'json'
}
]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});
});
it('handles writing out Transaction with a handle', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_0_0();
var output = p.writers[p.defaultNamespaceURI]['Transaction'].
apply(p, [{
options: {handle: 'handle_t'}
}
]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});
});
it('handles writing out Native', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Native.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_1_0();
var output = p.write(null, {nativeElements: [{
vendorId: 'ORACLE',
safeToIgnore: true,
value: 'ALTER SESSION ENABLE PARALLEL DML'
}, {
vendorId: 'ORACLE',
safeToIgnore: false,
value: 'Another native line goes here'
}]});
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
done();
});
});
it('handles writing out GetFeature with > 1 typename', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_0_0();
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
apply(p, [{
featureNS: 'http://www.openplans.org/topp',
featureTypes: ['states', 'cities'],
featurePrefix: 'topp'
}
]);
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
done();
});
});
});
});
goog.require('goog.dom.xml');
goog.require('ol.parser.ogc.WFS');
goog.require('ol.parser.ogc.WFS_v1_0_0');
goog.require('ol.parser.ogc.WFS_v1_1_0');

View File

@@ -0,0 +1,72 @@
goog.provide('ol.test.parser.ogc.WFS_v1_0_0');
describe('ol.parser.ogc.WFS_v1_0_0', function() {
var parser = new ol.parser.ogc.WFS();
describe('reading and writing', function() {
it('handles read of transaction response', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_0_0/Transaction_Response.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.insertIds.length).to.equal(2);
expect(obj.insertIds[0]).to.equal('parcelle.40');
expect(obj.insertIds[1]).to.equal('parcelle.41');
expect(obj.version).to.equal('1.0.0');
expect(obj.success).to.be(true);
done();
});
});
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();
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),
undefined,
new ol.expr.Identifier('the_geom')]);
p.getFilterParser().getGmlParser().axisOrientation = 'enu';
var output = p.writers[p.defaultNamespaceURI]['Query'].apply(
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();
});
});
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();
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')],
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
featureTypes: ['states']
}]);
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_0_0');

View File

@@ -0,0 +1,122 @@
goog.provide('ol.test.parser.ogc.WFS_v1_1_0');
describe('ol.parser.ogc.WFS_v1_1_0', function() {
var parser = new ol.parser.ogc.WFS();
describe('reading and writing', function() {
it('handles read of transaction response', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/TransactionResponse.xml';
afterLoadXml(url, function(xml) {
var obj = parser.read(xml);
expect(obj.insertIds.length).to.equal(2);
expect(obj.insertIds[0]).to.equal('parcelle.40');
expect(obj.insertIds[1]).to.equal('parcelle.41');
expect(obj.version).to.equal('1.1.0');
expect(obj.success).to.be(true);
done();
});
});
it('handles read of number of features', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/NumberOfFeatures.xml';
afterLoadXml(url, function(xml) {
// the XML does not contain a version attribute on the root node
var p = new ol.parser.ogc.WFS_v1_1_0();
var obj = p.read(xml);
expect(obj.numberOfFeatures).to.equal(625);
done();
});
});
it('handles read of boundedBy on the FeatureCollection', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/boundedBy.xml';
afterLoadXml(url, function(xml) {
// the XML does not contain a version attribute on the root node
var p = new ol.parser.ogc.WFS_v1_1_0();
var obj = p.read(xml);
expect(obj.bounds[0]).to.equal(3197.88);
expect(obj.bounds[1]).to.equal(306457.313);
expect(obj.bounds[2]).to.equal(280339.156);
expect(obj.bounds[3]).to.equal(613850.438);
done();
});
});
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();
});
});
it('handles writing GetFeature with resultType hits', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature0.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_1_0();
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply(
p, [{
resultType: 'hits',
srsName: 'urn:ogc:def:crs:EPSG::4326',
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();
});
});
it('handles writing GetFeature with paging info', function(done) {
var url = 'spec/ol/parser/ogc/xml/wfs_v1_1_0/getfeature1.xml';
afterLoadXml(url, function(xml) {
var p = new ol.parser.ogc.WFS_v1_1_0();
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].apply(
p, [{
count: 10,
startIndex: 20,
srsName: 'urn:ogc:def:crs:EPSG::4326',
featureNS: 'http://www.openplans.org/topp',
featurePrefix: 'topp',
featureTypes: ['states']
}]);
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,41 @@
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:gml="http://www.opengis.net/gml">
<gml:featureMember>
<topp:states fid="states.3">
<topp:the_geom>
<gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">-75.70742,38.557476 -75.71106,38.649551 -75.724937,38.83017 -75.752922,39.141548 -75.761658,39.247753 -75.764664,39.295849 -75.772697,39.383007 -75.791435,39.723755 -75.775269,39.724442 -75.745934,39.774818 -75.695114,39.820347 -75.644341,39.838196 -75.583794,39.840008 -75.470345,39.826435 -75.42083,39.79887 -75.412117,39.789658 -75.428009,39.77813 -75.460754,39.763248 -75.475128,39.741718 -75.476334,39.719971 -75.489639,39.714745 -75.610725,39.612793 -75.562996,39.566723 -75.590187,39.463768 -75.515572,39.36694 -75.402481,39.257637 -75.397728,39.073036 -75.324852,39.012386 -75.307899,38.945911 -75.190941,38.80867 -75.083138,38.799812 -75.045998,38.44949 -75.068298,38.449963 -75.093094,38.450451 -75.350204,38.455208 -75.69915,38.463066 -75.70742,38.557476</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</topp:the_geom>
<topp:STATE_NAME>Delaware</topp:STATE_NAME>
<topp:STATE_FIPS>10</topp:STATE_FIPS>
<topp:SUB_REGION>S Atl</topp:SUB_REGION>
<topp:STATE_ABBR>DE</topp:STATE_ABBR>
<topp:LAND_KM>5062.456</topp:LAND_KM>
<topp:WATER_KM>1385.022</topp:WATER_KM>
<topp:PERSONS>666168.0</topp:PERSONS>
<topp:FAMILIES>175867.0</topp:FAMILIES>
<topp:HOUSHOLD>247497.0</topp:HOUSHOLD>
<topp:MALE>322968.0</topp:MALE>
<topp:FEMALE>343200.0</topp:FEMALE>
<topp:WORKERS>247566.0</topp:WORKERS>
<topp:DRVALONE>258087.0</topp:DRVALONE>
<topp:CARPOOL>42968.0</topp:CARPOOL>
<topp:PUBTRANS>8069.0</topp:PUBTRANS>
<topp:EMPLOYED>335147.0</topp:EMPLOYED>
<topp:UNEMPLOY>13945.0</topp:UNEMPLOY>
<topp:SERVICE>87973.0</topp:SERVICE>
<topp:MANUAL>44140.0</topp:MANUAL>
<topp:P_MALE>0.485</topp:P_MALE>
<topp:P_FEMALE>0.515</topp:P_FEMALE>
<topp:SAMP_POP>102776.0</topp:SAMP_POP>
</topp:states>
</gml:featureMember>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,3 @@
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_g" outputFormat="json" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
</wfs:GetFeature>

View File

@@ -0,0 +1,4 @@
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
<wfs:Query typeName="topp:cities" xmlns:topp="http://www.openplans.org/topp"/>
</wfs:GetFeature>

View File

@@ -0,0 +1 @@
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Native vendorId="ORACLE" safeToIgnore="true">ALTER SESSION ENABLE PARALLEL DML</wfs:Native><wfs:Native vendorId="ORACLE" safeToIgnore="false">Another native line goes here</wfs:Native></wfs:Transaction>

View File

@@ -0,0 +1 @@
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_t" />

View File

@@ -0,0 +1,11 @@
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
<wfs:InsertResult>
<ogc:FeatureId fid="parcelle.40"/>
<ogc:FeatureId fid="parcelle.41"/>
</wfs:InsertResult>
<wfs:TransactionResult>
<wfs:Status>
<wfs:SUCCESS/>
</wfs:Status>
</wfs:TransactionResult>
</wfs:WFS_TransactionResponse>

View File

@@ -0,0 +1,11 @@
<wfs:GetFeature service="WFS" version="1.0.0" xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<ogc:PropertyName>STATE_NAME</ogc:PropertyName>
<ogc:PropertyName>STATE_FIPS</ogc:PropertyName>
<ogc:PropertyName>STATE_ABBR</ogc:PropertyName>
</wfs:Query>
</wfs:GetFeature>

View File

@@ -0,0 +1,10 @@
<wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" 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:Box xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4</gml:coordinates>
</gml:Box>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:rws="http://mapserver.gis.umn.edu/mapserver"
xmlns:gml="http://www.opengis.net/gml"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://intranet.rijkswaterstaat.nl/services/geoservices/nwb_wegen?SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=feature:AAA64&amp;OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" numberOfFeatures="625">
</wfs:FeatureCollection>

View File

@@ -0,0 +1,16 @@
<wfs:TransactionResponse version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:tiger="http://www.census.gov" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:sf="http://www.openplans.org/spearfish" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
<wfs:TransactionSummary>
<wfs:totalInserted>0</wfs:totalInserted>
<wfs:totalUpdated>1</wfs:totalUpdated>
<wfs:totalDeleted>0</wfs:totalDeleted>
</wfs:TransactionSummary>
<wfs:TransactionResults/>
<wfs:InsertResults>
<wfs:Feature>
<ogc:FeatureId fid="parcelle.40"/>
</wfs:Feature>
<wfs:Feature>
<ogc:FeatureId fid="parcelle.41"/>
</wfs:Feature>
</wfs:InsertResults>
</wfs:TransactionResponse>

View File

@@ -0,0 +1,47 @@
<wfs:FeatureCollection
xmlns:rws="http://mapserver.gis.umn.edu/mapserver"
xmlns:gml="http://www.opengis.net/gml"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://ontwikkel.intranet.rijkswaterstaat.nl/services/geoservices/ov_zonering?SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=AAA212&amp;OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:28992">
<gml:lowerCorner>3197.880000 306457.313000</gml:lowerCorner>
<gml:upperCorner>280339.156000 613850.438000</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<rws:AAA212 gml:id="AAA212.791">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:28992">
<gml:lowerCorner>196507.469000 502347.938000</gml:lowerCorner>
<gml:upperCorner>202430.844000 510383.719000</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<rws:geometry>
<gml:MultiSurface srsName="EPSG:28992">
<gml:surfaceMembers>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">200448.047000 510383.719000 198475.031000 509253.875000 198477.422000 507339.688000 196507.469000 505841.969000 196507.625000 504980.281000 196621.359000 505029.969000 196825.328000 505114.000000 197310.031000 505183.469000 197636.609000 505148.750000 197837.594000 505061.563000 197941.031000 504953.688000 198003.094000 504817.719000 198023.781000 504721.688000 198016.391000 504597.531000 197907.234000 504363.219000 197716.734000 504013.969000 197700.156000 503567.563000 197775.531000 503373.969000 197930.688000 503153.781000 198034.234000 503045.594000 198170.078000 502932.125000 198504.047000 502725.250000 198858.719000 502550.875000 199138.000000 502460.719000 199336.000000 502347.938000 199044.125000 504910.969000 199549.359000 507065.781000 200280.594000 506878.938000 202430.844000 507474.625000 202430.844000 508850.906000 200448.047000 510383.719000 </gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMembers>
</gml:MultiSurface>
</rws:geometry>
<rws:OBJECTID>791</rws:OBJECTID>
<rws:HECTARES>1800.89</rws:HECTARES>
<rws:ZONENR>4620</rws:ZONENR>
<rws:NULZONES> </rws:NULZONES>
<rws:AREA>0</rws:AREA>
<rws:PERIMETER>24305.1</rws:PERIMETER>
</rws:AAA212>
</gml:featureMember>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,11 @@
<wfs:GetFeature service="WFS" version="1.1.0" resultType="hits" xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<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">
<wfs:PropertyName>STATE_NAME</wfs:PropertyName>
<wfs:PropertyName>STATE_FIPS</wfs:PropertyName>
<wfs:PropertyName>STATE_ABBR</wfs:PropertyName>
</wfs:Query>
</wfs:GetFeature>

View File

@@ -0,0 +1,8 @@
<wfs:GetFeature service="WFS" version="1.1.0" startIndex="20" count="10" xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<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">
</wfs:Query>
</wfs:GetFeature>

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>