From 18101ad0e2eb27c26679c8dec32f9865d230bfbc Mon Sep 17 00:00:00 2001 From: cpsTinK Date: Wed, 3 Aug 2016 13:18:56 +0400 Subject: [PATCH] Refactor AND Fixed description Intersects and Within filters into ol.format.wfs --- src/ol/format/ogc/filter.js | 61 +++++++++++++++------------ test/spec/ol/format/wfsformat.test.js | 4 +- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/ol/format/ogc/filter.js b/src/ol/format/ogc/filter.js index a3d74842f0..46d96b32bb 100644 --- a/src/ol/format/ogc/filter.js +++ b/src/ol/format/ogc/filter.js @@ -76,7 +76,7 @@ ol.format.ogc.filter.bbox = function(geometryName, extent, opt_srsName) { /** * Create a `` operator to test whether a geometry-valued property - * intersects a fixed bounding geometry + * intersects a given geometry. * * @param {!string} geometryName Geometry name to use. * @param {!ol.geom.Geometry} geometry Geometry. @@ -91,7 +91,7 @@ ol.format.ogc.filter.intersects = function(geometryName, geometry, opt_srsName) /** * Create a `` operator to test whether a geometry-valued property - * intersects a fixed bounding geometry + * is within a given geometry. * * @param {!string} geometryName Geometry name to use. * @param {!ol.geom.Geometry} geometry Geometry. @@ -410,10 +410,11 @@ ol.inherits(ol.format.ogc.filter.Bbox, ol.format.ogc.filter.Filter); /** * @classdesc - * Represents a `` operator to test whether a geometry-valued property - * intersects a fixed bounding geometry + * Represents a spatial operator to test whether a geometry-valued property + * relates to a given geometry. * * @constructor + * @param {!string} tagName The XML tag name for this filter. * @param {!string} geometryName Geometry name to use. * @param {!ol.geom.Geometry} geometry Geometry. * @param {string=} opt_srsName SRS name. No srsName attribute will be @@ -421,9 +422,9 @@ ol.inherits(ol.format.ogc.filter.Bbox, ol.format.ogc.filter.Filter); * @extends {ol.format.ogc.filter.Filter} * @api */ -ol.format.ogc.filter.Intersects = function(geometryName, geometry, opt_srsName) { +ol.format.ogc.filter.Spatial = function(tagName, geometryName, geometry, opt_srsName) { - ol.format.ogc.filter.Filter.call(this, 'Intersects'); + ol.format.ogc.filter.Filter.call(this, tagName); /** * @public @@ -443,45 +444,49 @@ ol.format.ogc.filter.Intersects = function(geometryName, geometry, opt_srsName) */ this.srsName = opt_srsName; }; -ol.inherits(ol.format.ogc.filter.Intersects, ol.format.ogc.filter.Filter); +ol.inherits(ol.format.ogc.filter.Spatial, ol.format.ogc.filter.Filter); + + +/** + * @classdesc + * Represents a `` operator to test whether a geometry-valued property + * intersects a given geometry. + * + * @constructor + * @param {!string} geometryName Geometry name to use. + * @param {!ol.geom.Geometry} geometry Geometry. + * @param {string=} opt_srsName SRS name. No srsName attribute will be + * set on geometries when this is not provided. + * @extends {ol.format.ogc.filter.Spatial} + * @api + */ +ol.format.ogc.filter.Intersects = function(geometryName, geometry, opt_srsName) { + + ol.format.ogc.filter.Spatial.call(this, 'Intersects', geometryName, geometry, opt_srsName); + +}; +ol.inherits(ol.format.ogc.filter.Intersects, ol.format.ogc.filter.Spatial); /** * @classdesc * Represents a `` operator to test whether a geometry-valued property - * within a fixed bounding geometry + * is within a given geometry. * * @constructor * @param {!string} geometryName Geometry name to use. * @param {!ol.geom.Geometry} geometry Geometry. * @param {string=} opt_srsName SRS name. No srsName attribute will be * set on geometries when this is not provided. - * @extends {ol.format.ogc.filter.Filter} + * @extends {ol.format.ogc.filter.Spatial} * @api */ ol.format.ogc.filter.Within = function(geometryName, geometry, opt_srsName) { - ol.format.ogc.filter.Filter.call(this, 'Within'); + ol.format.ogc.filter.Spatial.call(this, 'Within', geometryName, geometry, opt_srsName); - /** - * @public - * @type {!string} - */ - this.geometryName = geometryName || 'the_geom'; - - /** - * @public - * @type {ol.geom.Geometry} - */ - this.geometry = geometry; - - /** - * @public - * @type {string|undefined} - */ - this.srsName = opt_srsName; }; -ol.inherits(ol.format.ogc.filter.Within, ol.format.ogc.filter.Filter); +ol.inherits(ol.format.ogc.filter.Within, ol.format.ogc.filter.Spatial); // Property comparison filters diff --git a/test/spec/ol/format/wfsformat.test.js b/test/spec/ol/format/wfsformat.test.js index 713f18345b..c6915c35f1 100644 --- a/test/spec/ol/format/wfsformat.test.js +++ b/test/spec/ol/format/wfsformat.test.js @@ -504,7 +504,7 @@ describe('ol.format.WFS', function() { expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); }); - it('creates an AND intersects filter', function() { + it('creates a intersects filter', function() { var text = '