v1_1_0.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
  2. * full list of contributors). Published under the 2-clause BSD license.
  3. * See license.txt in the OpenLayers distribution or repository for the
  4. * full text of the license. */
  5. /**
  6. * @requires OpenLayers/Protocol/WFS/v1.js
  7. * @requires OpenLayers/Format/WFST/v1_1_0.js
  8. */
  9. /**
  10. * Class: OpenLayers.Protocol.WFS.v1_1_0
  11. * A WFS v1.1.0 protocol for vector layers. Create a new instance with the
  12. * <OpenLayers.Protocol.WFS.v1_1_0> constructor.
  13. *
  14. * Differences from the v1.0.0 protocol:
  15. * - uses Filter Encoding 1.1.0 instead of 1.0.0
  16. * - uses GML 3 instead of 2 if no format is provided
  17. *
  18. * Inherits from:
  19. * - <OpenLayers.Protocol.WFS.v1>
  20. */
  21. OpenLayers.Protocol.WFS.v1_1_0 = OpenLayers.Class(OpenLayers.Protocol.WFS.v1, {
  22. /**
  23. * Property: version
  24. * {String} WFS version number.
  25. */
  26. version: "1.1.0",
  27. /**
  28. * Constructor: OpenLayers.Protocol.WFS.v1_1_0
  29. * A class for giving layers WFS v1.1.0 protocol.
  30. *
  31. * Parameters:
  32. * options - {Object} Optional object whose properties will be set on the
  33. * instance.
  34. *
  35. * Valid options properties:
  36. * featureType - {String} Local (without prefix) feature typeName (required).
  37. * featureNS - {String} Feature namespace (optional).
  38. * featurePrefix - {String} Feature namespace alias (optional - only used
  39. * if featureNS is provided). Default is 'feature'.
  40. * geometryName - {String} Name of geometry attribute. Default is 'the_geom'.
  41. * outputFormat - {String} Optional output format to use for WFS GetFeature
  42. * requests. This can be any format advertized by the WFS's
  43. * GetCapabilities response. If set, an appropriate readFormat also
  44. * has to be provided, unless outputFormat is GML3, GML2 or JSON.
  45. * readFormat - {<OpenLayers.Format>} An appropriate format parser if
  46. * outputFormat is none of GML3, GML2 or JSON.
  47. */
  48. initialize: function(options) {
  49. OpenLayers.Protocol.WFS.v1.prototype.initialize.apply(this, arguments);
  50. if (this.outputFormat && !this.readFormat) {
  51. if (this.outputFormat.toLowerCase() == "gml2") {
  52. this.readFormat = new OpenLayers.Format.GML.v2({
  53. featureType: this.featureType,
  54. featureNS: this.featureNS,
  55. geometryName: this.geometryName
  56. });
  57. } else if (this.outputFormat.toLowerCase() == "json") {
  58. this.readFormat = new OpenLayers.Format.GeoJSON();
  59. }
  60. }
  61. },
  62. CLASS_NAME: "OpenLayers.Protocol.WFS.v1_1_0"
  63. });