From 491a5c0f62b0d8e52e70285917f512e5311da05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 9 May 2011 07:16:39 +0000 Subject: [PATCH] SWGetRecords format additions for sorting, p=fvanderbiest, r=me,bartvde (closes #2952) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11957 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js | 21 +++++------ lib/OpenLayers/Format/Filter/v1_0_0.js | 5 ++- lib/OpenLayers/Format/Filter/v1_1_0.js | 35 +++++++++++++++++-- tests/Format/Filter/v1_1_0.html | 27 +++++++++++++- 4 files changed, 72 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js index 049bfd1e88..e17c800d03 100644 --- a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js +++ b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js @@ -32,7 +32,8 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, csw: "http://www.opengis.net/cat/csw/2.0.2", dc: "http://purl.org/dc/elements/1.1/", dct: "http://purl.org/dc/terms/", - ows: "http://www.opengis.net/ows" + ows: "http://www.opengis.net/ows", + ogc: "http://www.opengis.net/ogc" }, /** @@ -389,14 +390,13 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, node ); } - //TODO: not implemented in ogc filters? - //if (options.SortBy) { - //this.writeNode( - //"ogc:SortBy", - //options.SortBy, - //node - //); - //} + if (options.SortBy) { + this.writeNode( + "ogc:SortBy", + options.SortBy, + node + ); + } return node; }, "ElementName": function(options) { @@ -433,7 +433,8 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, } return node; } - } + }, + "ogc": OpenLayers.Format.Filter.v1_1_0.prototype.writers["ogc"] }, CLASS_NAME: "OpenLayers.Format.CSWGetRecords.v2_0_2" diff --git a/lib/OpenLayers/Format/Filter/v1_0_0.js b/lib/OpenLayers/Format/Filter/v1_0_0.js index ef1cc9853b..5e1811338d 100644 --- a/lib/OpenLayers/Format/Filter/v1_0_0.js +++ b/lib/OpenLayers/Format/Filter/v1_0_0.js @@ -130,11 +130,10 @@ OpenLayers.Format.Filter.v1_0_0 = OpenLayers.Class( box.setAttribute("srsName", filter.projection); } return node; - }}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]), - + } + }, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]), "gml": OpenLayers.Format.GML.v2.prototype.writers["gml"], "feature": OpenLayers.Format.GML.v2.prototype.writers["feature"] - }, /** diff --git a/lib/OpenLayers/Format/Filter/v1_1_0.js b/lib/OpenLayers/Format/Filter/v1_1_0.js index cd36a94c89..0bec38d4a9 100644 --- a/lib/OpenLayers/Format/Filter/v1_1_0.js +++ b/lib/OpenLayers/Format/Filter/v1_1_0.js @@ -146,8 +146,39 @@ OpenLayers.Format.Filter.v1_1_0 = OpenLayers.Class( } node.appendChild(box); return node; - }}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]), - + }, + "SortBy": function(sortProperties) { + var node = this.createElementNSPlus("ogc:SortBy"); + for (var i=0,l=sortProperties.length;i'+ + ''+ + 'Title'+ + 'ASC'+ + ''+ + ''+ + 'Relevance'+ + 'DESC'+ + ''+ + ''; + + var parser = new OpenLayers.Format.Filter.v1_1_0(); + var node = parser.writers['ogc'].SortBy.call(parser, [{ + "property": 'Title', + "order": "ASC" + },{ + "property": 'Relevance', + "order": "DESC" + }]); + + t.xml_eq(node, out, "Check SortBy"); + }