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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Apr 5 15:23:28 EDT 2011


Author: bartvde
Date: 2011-04-05 12:23:23 -0700 (Tue, 05 Apr 2011)
New Revision: 11878

Modified:
   trunk/openlayers/lib/OpenLayers/Filter/Comparison.js
   trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
   trunk/openlayers/tests/Format/Filter/v1_1_0.html
Log:
add matchCase attribute for PropertyIsLike, r=tschaub (closes #3247)

Modified: trunk/openlayers/lib/OpenLayers/Filter/Comparison.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Filter/Comparison.js	2011-04-05 11:38:13 UTC (rev 11877)
+++ trunk/openlayers/lib/OpenLayers/Filter/Comparison.js	2011-04-05 19:23:23 UTC (rev 11878)
@@ -55,7 +55,7 @@
      *     elements.  This property will be serialized with those elements only
      *     if using the v1.1.0 filter format. However, when evaluating filters
      *     here, the matchCase property will always be respected (for EQUAL_TO
-     *     and NOT_EQUAL_TO).  Default is true.
+     *     and NOT_EQUAL_TO).  Default is true. 
      */
     matchCase: true,
     
@@ -90,6 +90,12 @@
      */
     initialize: function(options) {
         OpenLayers.Filter.prototype.initialize.apply(this, [options]);
+        // since matchCase on PropertyIsLike is not schema compliant, we only
+        // want to use this if explicitly asked for
+        if (this.type === OpenLayers.Filter.Comparison.LIKE 
+            && options.matchCase === undefined) {
+                this.matchCase = null;
+        }
     },
 
     /**

Modified: trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-04-05 11:38:13 UTC (rev 11877)
+++ trunk/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-04-05 19:23:23 UTC (rev 11878)
@@ -15,9 +15,9 @@
  * Differences from the v1.0.0 parser:
  *  - uses GML v3 instead of GML v2
  *  - reads matchCase attribute on ogc:PropertyIsEqual and
- *        ogc:PropertyIsNotEqualelements.
- *  - writes matchCase attribute from comparison filters of type EQUAL_TO and
- *        type NOT_EQUAL_TO.
+ *        ogc:PropertyIsNotEqual elements.
+ *  - writes matchCase attribute from comparison filters of type EQUAL_TO,
+ *        NOT_EQUAL_TO and LIKE.
  * 
  * Inherits from:
  *  - <OpenLayers.Format.Filter.v1>
@@ -127,6 +127,7 @@
             "PropertyIsLike": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsLike", {
                     attributes: {
+                        matchCase: filter.matchCase,
                         wildCard: "*", singleChar: ".", escapeChar: "!"
                     }
                 });
@@ -185,4 +186,4 @@
 
     CLASS_NAME: "OpenLayers.Format.Filter.v1_1_0" 
 
-});
\ No newline at end of file
+});

Modified: trunk/openlayers/tests/Format/Filter/v1_1_0.html
===================================================================
--- trunk/openlayers/tests/Format/Filter/v1_1_0.html	2011-04-05 11:38:13 UTC (rev 11877)
+++ trunk/openlayers/tests/Format/Filter/v1_1_0.html	2011-04-05 19:23:23 UTC (rev 11878)
@@ -314,9 +314,39 @@
         t.xml_eq(node, out, "spatial dwithin filter with nested functions correctly written");
     }
 
+    function test_write_like_matchcase(t) {
+        t.plan(1);
 
+        var filter = new OpenLayers.Filter.Comparison({
+            type: OpenLayers.Filter.Comparison.LIKE,
+            property: "person",
+            value: "*me*",
+            matchCase: false
+        });
+
+        var format = new OpenLayers.Format.Filter.v1_1_0();
+        
+        var got = format.write(filter);
+        var exp = readXML("LikeMatchCase");
+        t.xml_eq(got, exp, "wrote matchCase attribute on PropertyIsLike");
+    }
+
+    function readXML(id) {
+        var xml = document.getElementById(id).firstChild.nodeValue;
+        return new OpenLayers.Format.XML().read(xml).documentElement;
+    }
+
+
     </script> 
 </head> 
 <body>
+<div id="LikeMatchCase"><!--
+<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
+    <ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!" matchCase="false">
+        <ogc:PropertyName>person</ogc:PropertyName>
+        <ogc:Literal>*me*</ogc:Literal>
+    </ogc:PropertyIsLike>
+</ogc:Filter>
+--></div>
 </body> 
 </html> 



More information about the Commits mailing list