From 8d8ee2087fe2075df42b78d9738878b67f8c199c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 12 Sep 2008 16:06:55 +0000 Subject: [PATCH] these two files were erroneously not committed as part of [8005], thanks Erik for catching this (See #1699) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8008 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Protocol/SQL.js | 87 ++++++++++++++++++++++++++++++++++ tests/Protocol/SQL.html | 23 +++++++++ 2 files changed, 110 insertions(+) create mode 100644 lib/OpenLayers/Protocol/SQL.js create mode 100644 tests/Protocol/SQL.html diff --git a/lib/OpenLayers/Protocol/SQL.js b/lib/OpenLayers/Protocol/SQL.js new file mode 100644 index 0000000000..27072cb0b0 --- /dev/null +++ b/lib/OpenLayers/Protocol/SQL.js @@ -0,0 +1,87 @@ +/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD + * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @requires OpenLayers/Protocol.js + */ + +/** + * Class: OpenLayers.Protocol.SQL + * Abstract SQL protocol class. Not to be instantiated directly. Use + * one of the SQL protocol subclasses instead. + * + * Inherits from: + * - + */ +OpenLayers.Protocol.SQL = OpenLayers.Class(OpenLayers.Protocol, { + + /** + * APIProperty: databaseName + * {String} + */ + databaseName: 'ol', + + /** + * APIProperty: tableName + * Name of the database table into which Features should be saved. + */ + tableName: "ol_vector_features", + + /** + * Property: postReadFiltering + * {Boolean} Whether the filter (if there's one) must be applied after + * the features have been read from the database; for example the + * BBOX strategy passes the read method a BBOX spatial filter, if + * postReadFiltering is true every feature read from the database + * will go through the BBOX spatial filter, which can be costly; + * defaults to true. + */ + postReadFiltering: true, + + /** + * Constructor: OpenLayers.Protocol.SQL + */ + initialize: function(options) { + OpenLayers.Protocol.prototype.initialize.apply(this, [options]); + }, + + /** + * APIMethod: destroy + * Clean up the protocol. + */ + destroy: function() { + OpenLayers.Protocol.prototype.destroy.apply(this); + }, + + /** + * APIMethod: supported + * This should be overridden by specific subclasses + * + * Returns: + * {Boolean} Whether or not the browser supports the SQL backend + */ + supported: function() { + return false; + }, + + /** + * Method: evaluateFilter + * If postReadFiltering is true evaluate the filter against the feature + * and return the result of the evaluation, otherwise return true. + * + * Parameters: + * {} The feature. + * {} The filter. + * + * Returns: + * {Boolean} true if postReadFiltering if false, the result of the + * filter evaluation otherwise. + */ + evaluateFilter: function(feature, filter) { + return filter && this.postReadFiltering ? + filter.evaluate(feature) : true; + }, + + CLASS_NAME: "OpenLayers.Protocol.SQL" +}); diff --git a/tests/Protocol/SQL.html b/tests/Protocol/SQL.html new file mode 100644 index 0000000000..01377e0dd3 --- /dev/null +++ b/tests/Protocol/SQL.html @@ -0,0 +1,23 @@ + + + + + + + +