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
This commit is contained in:
Éric Lemoine
2011-05-09 07:16:39 +00:00
parent c0112c9bc6
commit 491a5c0f62
4 changed files with 72 additions and 16 deletions
+11 -10
View File
@@ -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", csw: "http://www.opengis.net/cat/csw/2.0.2",
dc: "http://purl.org/dc/elements/1.1/", dc: "http://purl.org/dc/elements/1.1/",
dct: "http://purl.org/dc/terms/", 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 node
); );
} }
//TODO: not implemented in ogc filters? if (options.SortBy) {
//if (options.SortBy) { this.writeNode(
//this.writeNode( "ogc:SortBy",
//"ogc:SortBy", options.SortBy,
//options.SortBy, node
//node );
//); }
//}
return node; return node;
}, },
"ElementName": function(options) { "ElementName": function(options) {
@@ -433,7 +433,8 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
} }
return node; return node;
} }
} },
"ogc": OpenLayers.Format.Filter.v1_1_0.prototype.writers["ogc"]
}, },
CLASS_NAME: "OpenLayers.Format.CSWGetRecords.v2_0_2" CLASS_NAME: "OpenLayers.Format.CSWGetRecords.v2_0_2"
+2 -3
View File
@@ -130,11 +130,10 @@ OpenLayers.Format.Filter.v1_0_0 = OpenLayers.Class(
box.setAttribute("srsName", filter.projection); box.setAttribute("srsName", filter.projection);
} }
return node; return node;
}}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]), }
}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]),
"gml": OpenLayers.Format.GML.v2.prototype.writers["gml"], "gml": OpenLayers.Format.GML.v2.prototype.writers["gml"],
"feature": OpenLayers.Format.GML.v2.prototype.writers["feature"] "feature": OpenLayers.Format.GML.v2.prototype.writers["feature"]
}, },
/** /**
+33 -2
View File
@@ -146,8 +146,39 @@ OpenLayers.Format.Filter.v1_1_0 = OpenLayers.Class(
} }
node.appendChild(box); node.appendChild(box);
return node; 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<l;i++) {
this.writeNode(
"ogc:SortProperty",
sortProperties[i],
node
);
}
return node;
},
"SortProperty": function(sortProperty) {
var node = this.createElementNSPlus("ogc:SortProperty");
this.writeNode(
"ogc:PropertyName",
sortProperty,
node
);
this.writeNode(
"ogc:SortOrder",
(sortProperty.order == 'DESC') ? 'DESC' : 'ASC',
node
);
return node;
},
"SortOrder": function(value) {
var node = this.createElementNSPlus("ogc:SortOrder", {
value: value
});
return node;
}
}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]),
"gml": OpenLayers.Format.GML.v3.prototype.writers["gml"], "gml": OpenLayers.Format.GML.v3.prototype.writers["gml"],
"feature": OpenLayers.Format.GML.v3.prototype.writers["feature"] "feature": OpenLayers.Format.GML.v3.prototype.writers["feature"]
}, },
+26 -1
View File
@@ -336,7 +336,32 @@
return new OpenLayers.Format.XML().read(xml).documentElement; return new OpenLayers.Format.XML().read(xml).documentElement;
} }
function test_SortBy(t) {
t.plan(1);
var out =
'<ogc:SortBy xmlns:ogc="http://www.opengis.net/ogc">'+
'<ogc:SortProperty>'+
'<ogc:PropertyName>Title</ogc:PropertyName>'+
'<ogc:SortOrder>ASC</ogc:SortOrder>'+
'</ogc:SortProperty>'+
'<ogc:SortProperty>'+
'<ogc:PropertyName>Relevance</ogc:PropertyName>'+
'<ogc:SortOrder>DESC</ogc:SortOrder>'+
'</ogc:SortProperty>'+
'</ogc:SortBy>';
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");
}
</script> </script>
</head> </head>
<body> <body>