1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Format/GML/v2.js
7 * @requires OpenLayers/Format/Filter/v1.js
11 * Class: OpenLayers.Format.Filter.v1_0_0
12 * Write ogc:Filter version 1.0.0.
15 * - <OpenLayers.Format.GML.v2>
16 * - <OpenLayers.Format.Filter.v1>
18 OpenLayers.Format.Filter.v1_0_0 = OpenLayers.Class(
19 OpenLayers.Format.GML.v2, OpenLayers.Format.Filter.v1, {
28 * Property: schemaLocation
29 * {String} http://www.opengis.net/ogc/filter/1.0.0/filter.xsd
31 schemaLocation: "http://www.opengis.net/ogc/filter/1.0.0/filter.xsd",
34 * Constructor: OpenLayers.Format.Filter.v1_0_0
35 * Instances of this class are not created directly. Use the
36 * <OpenLayers.Format.Filter> constructor instead.
39 * options - {Object} An optional object whose properties will be set on
42 initialize: function(options) {
43 OpenLayers.Format.GML.v2.prototype.initialize.apply(
50 * Contains public functions, grouped by namespace prefix, that will
51 * be applied when a namespaced node is found matching the function
52 * name. The function will be applied in the scope of this parser
53 * with two arguments: the node being read and a context object passed
57 "ogc": OpenLayers.Util.applyDefaults({
58 "PropertyIsEqualTo": function(node, obj) {
59 var filter = new OpenLayers.Filter.Comparison({
60 type: OpenLayers.Filter.Comparison.EQUAL_TO
62 this.readChildNodes(node, filter);
63 obj.filters.push(filter);
65 "PropertyIsNotEqualTo": function(node, obj) {
66 var filter = new OpenLayers.Filter.Comparison({
67 type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO
69 this.readChildNodes(node, filter);
70 obj.filters.push(filter);
72 }, OpenLayers.Format.Filter.v1.prototype.readers["ogc"]),
73 "gml": OpenLayers.Format.GML.v2.prototype.readers["gml"],
74 "feature": OpenLayers.Format.GML.v2.prototype.readers["feature"]
79 * As a compliment to the readers property, this structure contains public
80 * writing functions grouped by namespace alias and named like the
81 * node names they produce.
84 "ogc": OpenLayers.Util.applyDefaults({
85 "PropertyIsEqualTo": function(filter) {
86 var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");
87 // no ogc:expression handling for now
88 this.writeNode("PropertyName", filter, node);
89 this.writeNode("Literal", filter.value, node);
92 "PropertyIsNotEqualTo": function(filter) {
93 var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
94 // no ogc:expression handling for now
95 this.writeNode("PropertyName", filter, node);
96 this.writeNode("Literal", filter.value, node);
99 "BBOX": function(filter) {
100 var node = this.createElementNSPlus("ogc:BBOX");
101 this.writeNode("PropertyName", filter, node);
102 var box = this.writeNode("gml:Box", filter.value, node);
103 if(filter.projection) {
104 box.setAttribute("srsName", filter.projection);
107 }}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]),
109 "gml": OpenLayers.Format.GML.v2.prototype.writers["gml"],
110 "feature": OpenLayers.Format.GML.v2.prototype.writers["feature"]
115 * Method: writeSpatial
117 * Read a {<OpenLayers.Filter.Spatial>} filter and converts it into XML.
120 * filter - {<OpenLayers.Filter.Spatial>} The filter.
121 * name - {String} Name of the generated XML element.
124 * {DOMElement} The created XML element.
126 writeSpatial: function(filter, name) {
127 var node = this.createElementNSPlus("ogc:"+name);
128 this.writeNode("PropertyName", filter, node);
130 if(filter.value instanceof OpenLayers.Geometry) {
131 child = this.writeNode("feature:_geometry", filter.value).firstChild;
133 child = this.writeNode("gml:Box", filter.value);
135 if(filter.projection) {
136 child.setAttribute("srsName", filter.projection);
138 node.appendChild(child);
143 CLASS_NAME: "OpenLayers.Format.Filter.v1_0_0"