]> dev.renevier.net Git - syp.git/blob - openlayers/lib/OpenLayers/Protocol/SQL.js
initial commit
[syp.git] / openlayers / lib / OpenLayers / Protocol / SQL.js
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. */
4
5 /**
6  * @requires OpenLayers/Protocol.js
7  */
8
9 /**
10  * Class: OpenLayers.Protocol.SQL
11  * Abstract SQL protocol class.  Not to be instantiated directly.  Use
12  *     one of the SQL protocol subclasses instead.
13  *
14  * Inherits from:
15  *  - <OpenLayers.Protocol>
16  */
17 OpenLayers.Protocol.SQL = OpenLayers.Class(OpenLayers.Protocol, {
18
19     /**
20      * APIProperty: databaseName
21      * {String}
22      */
23     databaseName: 'ol',
24
25     /**
26      * APIProperty: tableName
27      * Name of the database table into which Features should be saved.
28      */
29     tableName: "ol_vector_features",
30
31     /**
32      * Property: postReadFiltering
33      * {Boolean} Whether the filter (if there's one) must be applied after
34      *      the features have been read from the database; for example the
35      *      BBOX strategy passes the read method a BBOX spatial filter, if
36      *      postReadFiltering is true every feature read from the database
37      *      will go through the BBOX spatial filter, which can be costly;
38      *      defaults to true.
39      */
40     postReadFiltering: true,
41
42     /**
43      * Constructor: OpenLayers.Protocol.SQL
44      */
45     initialize: function(options) {
46         OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
47     },
48
49     /**
50      * APIMethod: destroy
51      * Clean up the protocol.
52      */
53     destroy: function() {
54         OpenLayers.Protocol.prototype.destroy.apply(this);
55     },
56
57     /**
58      * APIMethod: supported
59      * This should be overridden by specific subclasses
60      *
61      * Returns:
62      * {Boolean} Whether or not the browser supports the SQL backend
63      */
64     supported: function() {
65         return false;
66     },
67
68     /**
69      * Method: evaluateFilter
70      * If postReadFiltering is true evaluate the filter against the feature
71      * and return the result of the evaluation, otherwise return true.
72      *
73      * Parameters:
74      * {<OpenLayers.Feature.Vector>} The feature.
75      * {<OpenLayers.Filter>} The filter.
76      *
77      * Returns:
78      * {Boolean} true if postReadFiltering if false, the result of the
79      * filter evaluation otherwise.
80      */
81     evaluateFilter: function(feature, filter) {
82         return filter && this.postReadFiltering ?
83             filter.evaluate(feature) : true;
84     },
85
86     CLASS_NAME: "OpenLayers.Protocol.SQL"
87 });