Source: modules/WFS.js

  1. /**
  2. * @module modules/WFS.js
  3. * @name WFS
  4. * @copyright 2023 3Liz
  5. * @license MPL-2.0
  6. */
  7. import { Utils } from './Utils.js';
  8. /**
  9. * @class
  10. * @name WFS
  11. */
  12. export default class WFS {
  13. constructor() {
  14. this._defaultGetFeatureParameters = {
  15. repository: globalThis['lizUrls'].params.repository,
  16. project: globalThis['lizUrls'].params.project,
  17. SERVICE: 'WFS',
  18. REQUEST: 'GetFeature',
  19. VERSION: '1.0.0',
  20. OUTPUTFORMAT: 'GeoJSON'
  21. };
  22. this._defaultDescribeFeatureTypeParameters = {
  23. repository: globalThis['lizUrls'].params.repository,
  24. project: globalThis['lizUrls'].params.project,
  25. SERVICE: 'WFS',
  26. REQUEST: 'DescribeFeatureType',
  27. VERSION: '1.0.0',
  28. OUTPUTFORMAT: 'JSON'
  29. };
  30. }
  31. /**
  32. * Get feature from WFS
  33. * @param {object} options - optional parameters which can override this._defaultParameters
  34. * @returns {Promise} Promise object represents data
  35. * @memberof WFS
  36. */
  37. async getFeature(options) {
  38. return Utils.fetchJSON(globalThis['lizUrls'].wms, {
  39. method: "POST",
  40. body: new URLSearchParams({
  41. ...this._defaultGetFeatureParameters,
  42. ...options
  43. })
  44. });
  45. }
  46. /**
  47. * Describe feature type
  48. * @param {object} options - optional parameters which can override this._defaultParameters
  49. * @returns {Promise} Promise object represents data
  50. * @memberof WFS
  51. */
  52. async describeFeatureType(options) {
  53. return Utils.fetchJSON(globalThis['lizUrls'].wms, {
  54. method: "POST",
  55. body: new URLSearchParams({
  56. ...this._defaultDescribeFeatureTypeParameters,
  57. ...options
  58. })
  59. });
  60. }
  61. }