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/Protocol.js @ 76

Revision 76, 7.7 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 * Class: OpenLayers.Protocol
8 * Abstract vector layer protocol class.  Not to be instantiated directly.  Use
9 *     one of the protocol subclasses instead.
10 */
11OpenLayers.Protocol = OpenLayers.Class({
12   
13    /**
14     * Property: format
15     * {<OpenLayers.Format>} The format used by this protocol.
16     */
17    format: null,
18   
19    /**
20     * Property: options
21     * {Object} Any options sent to the constructor.
22     */
23    options: null,
24
25    /**
26     * Property: autoDestroy
27     * {Boolean} The creator of the protocol can set autoDestroy to false
28     *      to fully control when the protocol is destroyed. Defaults to
29     *      true.
30     */
31    autoDestroy: true,
32   
33    /**
34     * Property: defaultFilter
35     * {OpenLayers.Filter} Optional default filter to read requests
36     */
37    defaultFilter: null,
38   
39    /**
40     * Constructor: OpenLayers.Protocol
41     * Abstract class for vector protocols.  Create instances of a subclass.
42     *
43     * Parameters:
44     * options - {Object} Optional object whose properties will be set on the
45     *     instance.
46     */
47    initialize: function(options) {
48        options = options || {};
49        OpenLayers.Util.extend(this, options);
50        this.options = options;
51    },
52
53    /**
54     * Method: mergeWithDefaultFilter
55     * Merge filter passed to the read method with the default one
56     *
57     * Parameters:
58     * filter - {OpenLayers.Filter}
59     */
60    mergeWithDefaultFilter: function(filter) {
61        var merged;
62        if (filter && this.defaultFilter) {
63            merged = new OpenLayers.Filter.Logical({
64                type: OpenLayers.Filter.Logical.AND,
65                filters: [this.defaultFilter, filter]
66            });
67        } else {
68            merged = filter || this.defaultFilter || undefined;
69        }
70        return merged;
71    },
72
73    /**
74     * APIMethod: destroy
75     * Clean up the protocol.
76     */
77    destroy: function() {
78        this.options = null;
79        this.format = null;
80    },
81   
82    /**
83     * APIMethod: read
84     * Construct a request for reading new features.
85     *
86     * Parameters:
87     * options - {Object} Optional object for configuring the request.
88     *
89     * Returns:
90     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
91     * object, the same object will be passed to the callback function passed
92     * if one exists in the options object.
93     */
94    read: function(options) {
95        options = options || {};
96        options.filter = this.mergeWithDefaultFilter(options.filter);
97    },
98   
99   
100    /**
101     * APIMethod: create
102     * Construct a request for writing newly created features.
103     *
104     * Parameters:
105     * features - {Array({<OpenLayers.Feature.Vector>})} or
106     *            {<OpenLayers.Feature.Vector>}
107     * options - {Object} Optional object for configuring the request.
108     *
109     * Returns:
110     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
111     * object, the same object will be passed to the callback function passed
112     * if one exists in the options object.
113     */
114    create: function() {
115    },
116   
117    /**
118     * APIMethod: update
119     * Construct a request updating modified features.
120     *
121     * Parameters:
122     * features - {Array({<OpenLayers.Feature.Vector>})} or
123     *            {<OpenLayers.Feature.Vector>}
124     * options - {Object} Optional object for configuring the request.
125     *
126     * Returns:
127     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
128     * object, the same object will be passed to the callback function passed
129     * if one exists in the options object.
130     */
131    update: function() {
132    },
133   
134    /**
135     * APIMethod: delete
136     * Construct a request deleting a removed feature.
137     *
138     * Parameters:
139     * feature - {<OpenLayers.Feature.Vector>}
140     * options - {Object} Optional object for configuring the request.
141     *
142     * Returns:
143     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
144     * object, the same object will be passed to the callback function passed
145     * if one exists in the options object.
146     */
147    "delete": function() {
148    },
149
150    /**
151     * APIMethod: commit
152     * Go over the features and for each take action
153     * based on the feature state. Possible actions are create,
154     * update and delete.
155     *
156     * Parameters:
157     * features - {Array({<OpenLayers.Feature.Vector>})}
158     * options - {Object} Object whose possible keys are "create", "update",
159     *      "delete", "callback" and "scope", the values referenced by the
160     *      first three are objects as passed to the "create", "update", and
161     *      "delete" methods, the value referenced by the "callback" key is
162     *      a function which is called when the commit operation is complete
163     *      using the scope referenced by the "scope" key.
164     *
165     * Returns:
166     * {Array({<OpenLayers.Protocol.Response>})} An array of
167     * <OpenLayers.Protocol.Response> objects.
168     */
169    commit: function() {
170    },
171
172    /**
173     * Method: abort
174     * Abort an ongoing request.
175     *
176     * Parameters:
177     * response - {<OpenLayers.Protocol.Response>}
178     */
179    abort: function(response) {
180    },
181   
182    /**
183     * Method: createCallback
184     * Returns a function that applies the given public method with resp and
185     *     options arguments.
186     *
187     * Parameters:
188     * method - {Function} The method to be applied by the callback.
189     * response - {<OpenLayers.Protocol.Response>} The protocol response object.
190     * options - {Object} Options sent to the protocol method
191     */
192    createCallback: function(method, response, options) {
193        return OpenLayers.Function.bind(function() {
194            method.apply(this, [response, options]);
195        }, this);
196    },
197   
198    CLASS_NAME: "OpenLayers.Protocol" 
199});
200
201/**
202 * Class: OpenLayers.Protocol.Response
203 * Protocols return Response objects to their users.
204 */
205OpenLayers.Protocol.Response = OpenLayers.Class({
206    /**
207     * Property: code
208     * {Number} - OpenLayers.Protocol.Response.SUCCESS or
209     *            OpenLayers.Protocol.Response.FAILURE
210     */
211    code: null,
212
213    /**
214     * Property: requestType
215     * {String} The type of request this response corresponds to. Either
216     *      "create", "read", "update" or "delete".
217     */
218    requestType: null,
219
220    /**
221     * Property: last
222     * {Boolean} - true if this is the last response expected in a commit,
223     * false otherwise, defaults to true.
224     */
225    last: true,
226
227    /**
228     * Property: features
229     * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
230     * The features returned in the response by the server.
231     */
232    features: null,
233
234    /**
235     * Property: reqFeatures
236     * {Array({<OpenLayers.Feature.Vector>})} or {<OpenLayers.Feature.Vector>}
237     * The features provided by the user and placed in the request by the
238     *      protocol.
239     */
240    reqFeatures: null,
241
242    /**
243     * Property: priv
244     */
245    priv: null,
246
247    /**
248     * Constructor: OpenLayers.Protocol.Response
249     *
250     * Parameters:
251     * options - {Object} Optional object whose properties will be set on the
252     *     instance.
253     */
254    initialize: function(options) {
255        OpenLayers.Util.extend(this, options);
256    },
257
258    /**
259     * Method: success
260     *
261     * Returns:
262     * {Boolean} - true on success, false otherwise
263     */
264    success: function() {
265        return this.code > 0;
266    },
267
268    CLASS_NAME: "OpenLayers.Protocol.Response"
269});
270
271OpenLayers.Protocol.Response.SUCCESS = 1;
272OpenLayers.Protocol.Response.FAILURE = 0;
Note: See TracBrowser for help on using the repository browser.