[OpenLayers-Commits] r11957 - in trunk/openlayers: lib/OpenLayers/Format/CSWGetRecords lib/OpenLayers/Format/Filter tests/Format/Filter

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon May 9 03:16:43 EDT 2011


Author: erilem
Date: 2011-05-09 00:16:39 -0700 (Mon, 09 May 2011)
New Revision: 11957

Modified:
   trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js
   trunk/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js
   trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
   trunk/openlayers/tests/Format/Filter/v1_1_0.html
Log:
SWGetRecords format additions for sorting, p=fvanderbiest, r=me,bartvde (closes #2952)

Modified: trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js	2011-05-07 00:45:02 UTC (rev 11956)
+++ trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js	2011-05-09 07:16:39 UTC (rev 11957)
@@ -32,7 +32,8 @@
         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 @@
                         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 @@
                 }
                 return node;
             }
-        }
+        },
+        "ogc": OpenLayers.Format.Filter.v1_1_0.prototype.writers["ogc"]
     },
    
     CLASS_NAME: "OpenLayers.Format.CSWGetRecords.v2_0_2" 

Modified: trunk/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js	2011-05-07 00:45:02 UTC (rev 11956)
+++ trunk/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js	2011-05-09 07:16:39 UTC (rev 11957)
@@ -130,11 +130,10 @@
                     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"]
-        
     },
 
     /**

Modified: trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-05-07 00:45:02 UTC (rev 11956)
+++ trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-05-09 07:16:39 UTC (rev 11957)
@@ -146,8 +146,39 @@
                 }
                 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<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"],
         "feature": OpenLayers.Format.GML.v3.prototype.writers["feature"]
     },

Modified: trunk/openlayers/tests/Format/Filter/v1_1_0.html
===================================================================
--- trunk/openlayers/tests/Format/Filter/v1_1_0.html	2011-05-07 00:45:02 UTC (rev 11956)
+++ trunk/openlayers/tests/Format/Filter/v1_1_0.html	2011-05-09 07:16:39 UTC (rev 11957)
@@ -336,7 +336,32 @@
         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> 
 </head> 
 <body>



More information about the Commits mailing list