Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Format/Filter/v1_1_0.js @ 76

Revision 76, 7.0 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the Clear BSD license. 
3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4 * full text of the license. */
5
6/**
7 * @requires OpenLayers/Format/Filter/v1.js
8 * @requires OpenLayers/Format/GML/v3.js
9 */
10
11/**
12 * Class: OpenLayers.Format.Filter.v1_1_0
13 * Write ogc:Filter version 1.1.0.
14 *
15 * Differences from the v1.0.0 parser:
16 *  - uses GML v3 instead of GML v2
17 *  - reads matchCase attribute on ogc:PropertyIsEqual and
18 *        ogc:PropertyIsNotEqualelements.
19 *  - writes matchCase attribute from comparison filters of type EQUAL_TO and
20 *        type NOT_EQUAL_TO.
21 *
22 * Inherits from:
23 *  - <OpenLayers.Format.Filter.v1>
24 */
25OpenLayers.Format.Filter.v1_1_0 = OpenLayers.Class(
26    OpenLayers.Format.GML.v3, OpenLayers.Format.Filter.v1, {
27   
28    /**
29     * Constant: VERSION
30     * {String} 1.1.0
31     */
32    VERSION: "1.1.0",
33   
34    /**
35     * Property: schemaLocation
36     * {String} http://www.opengis.net/ogc/filter/1.1.0/filter.xsd
37     */
38    schemaLocation: "http://www.opengis.net/ogc/filter/1.1.0/filter.xsd",
39
40    /**
41     * Constructor: OpenLayers.Format.Filter.v1_1_0
42     * Instances of this class are not created directly.  Use the
43     *     <OpenLayers.Format.Filter> constructor instead.
44     *
45     * Parameters:
46     * options - {Object} An optional object whose properties will be set on
47     *     this instance.
48     */
49    initialize: function(options) {
50        OpenLayers.Format.GML.v3.prototype.initialize.apply(
51            this, [options]
52        );
53    },
54
55    /**
56     * Property: readers
57     * Contains public functions, grouped by namespace prefix, that will
58     *     be applied when a namespaced node is found matching the function
59     *     name.  The function will be applied in the scope of this parser
60     *     with two arguments: the node being read and a context object passed
61     *     from the parent.
62     */
63    readers: {
64        "ogc": OpenLayers.Util.applyDefaults({
65            "PropertyIsEqualTo": function(node, obj) {
66                var matchCase = node.getAttribute("matchCase");
67                var filter = new OpenLayers.Filter.Comparison({
68                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
69                    matchCase: !(matchCase === "false" || matchCase === "0")
70                });
71                this.readChildNodes(node, filter);
72                obj.filters.push(filter);
73            },
74            "PropertyIsNotEqualTo": function(node, obj) {
75                var matchCase = node.getAttribute("matchCase");
76                var filter = new OpenLayers.Filter.Comparison({
77                    type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
78                    matchCase: !(matchCase === "false" || matchCase === "0")
79                });
80                this.readChildNodes(node, filter);
81                obj.filters.push(filter);
82            },
83            "PropertyIsLike": function(node, obj) {
84                var filter = new OpenLayers.Filter.Comparison({
85                    type: OpenLayers.Filter.Comparison.LIKE
86                });
87                this.readChildNodes(node, filter);
88                var wildCard = node.getAttribute("wildCard");
89                var singleChar = node.getAttribute("singleChar");
90                var esc = node.getAttribute("escapeChar");
91                filter.value2regex(wildCard, singleChar, esc);
92                obj.filters.push(filter);
93            }
94        }, OpenLayers.Format.Filter.v1.prototype.readers["ogc"]),
95        "gml": OpenLayers.Format.GML.v3.prototype.readers["gml"],
96        "feature": OpenLayers.Format.GML.v3.prototype.readers["feature"]       
97    },
98
99    /**
100     * Property: writers
101     * As a compliment to the readers property, this structure contains public
102     *     writing functions grouped by namespace alias and named like the
103     *     node names they produce.
104     */
105    writers: {
106        "ogc": OpenLayers.Util.applyDefaults({
107            "PropertyIsEqualTo": function(filter) {
108                var node = this.createElementNSPlus("ogc:PropertyIsEqualTo", {
109                    attributes: {matchCase: filter.matchCase}
110                });
111                // no ogc:expression handling for now
112                this.writeNode("PropertyName", filter, node);
113                this.writeNode("Literal", filter.value, node);
114                return node;
115            },
116            "PropertyIsNotEqualTo": function(filter) {
117                var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo", {
118                    attributes: {matchCase: filter.matchCase}
119                });
120                // no ogc:expression handling for now
121                this.writeNode("PropertyName", filter, node);
122                this.writeNode("Literal", filter.value, node);
123                return node;
124            },
125            "PropertyIsLike": function(filter) {
126                var node = this.createElementNSPlus("ogc:PropertyIsLike", {
127                    attributes: {
128                        wildCard: "*", singleChar: ".", escapeChar: "!"
129                    }
130                });
131                // no ogc:expression handling for now
132                this.writeNode("PropertyName", filter, node);
133                // convert regex string to ogc string
134                this.writeNode("Literal", filter.regex2value(), node);
135                return node;
136            },
137            "BBOX": function(filter) {
138                var node = this.createElementNSPlus("ogc:BBOX");
139                this.writeNode("PropertyName", filter, node);
140                var box = this.writeNode("gml:Envelope", filter.value);
141                if(filter.projection) {
142                    box.setAttribute("srsName", filter.projection);
143                }
144                node.appendChild(box); 
145                return node;
146            }}, OpenLayers.Format.Filter.v1.prototype.writers["ogc"]),
147           
148        "gml": OpenLayers.Format.GML.v3.prototype.writers["gml"],
149        "feature": OpenLayers.Format.GML.v3.prototype.writers["feature"]
150    },
151
152    /**
153     * Method: writeSpatial
154     *
155     * Read a {<OpenLayers.Filter.Spatial>} filter and converts it into XML.
156     *
157     * Parameters:
158     * filter - {<OpenLayers.Filter.Spatial>} The filter.
159     * name - {String} Name of the generated XML element.
160     *
161     * Returns:
162     * {DOMElement} The created XML element.
163     */
164    writeSpatial: function(filter, name) {
165        var node = this.createElementNSPlus("ogc:"+name);
166        this.writeNode("PropertyName", filter, node);
167        var child;
168        if(filter.value instanceof OpenLayers.Geometry) {
169            child = this.writeNode("feature:_geometry", filter.value).firstChild;
170        } else {
171            child = this.writeNode("gml:Envelope", filter.value);
172        }
173        if(filter.projection) {
174            child.setAttribute("srsName", filter.projection);
175        }
176        node.appendChild(child);
177        return node;
178    },
179
180    CLASS_NAME: "OpenLayers.Format.Filter.v1_1_0" 
181
182});
Note: See TracBrowser for help on using the repository browser.