SQL.js 2.5 KB

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