类名 common/service/igs/ogc/WFSServer.js
import BaseServer from '../../BaseServer'
import { Zondy } from '../../../base'

/**
 * IGS的WFS服务
 * @class WFSServer
 * @moduleEx ServiceModule
 * @extends BaseServer
 * @param {Object} options 构造参数
 * @param {String} [options.url] 服务基地址
 * @example
 * // ES5引入方式
 * const { WFSServer } = Zondy.Service
 * // ES6引入方式
 * import { WFSServer } from "@mapgis/webclient-common"
 * WFSServer = new WFSServer({
 *   url: 'http://localhost:8089/igs/rest/services/%E5%8A%A8%E6%80%81%E8%A3%81%E5%9B%BE_WFS/WFSServer',
 *   requestInterceptor: {
 *     before: function (config) {
 *       return config;
 *     },
 *     failure: function (error) {
 *       console.log("请求发送失败(拦截器):", error)
 *     }
 *   },
 *   responseInterceptor: {
 *     success: function (result) {
 *       console.log("请求成功拦截响应")
 *       return result;
 *     },
 *     failure: function (result) {
 *       console.log("请求失败拦截响应")
 *       return result;
 *     }
 *   }
 * });
 */
class WFSServer extends BaseServer {
  constructor(options) {
    super(options)
  }

  /**
   * 获取服务元信息
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @example
   * // 回调方式
   * WFSServer.getCapabitities({
   *   success: function (result) {
   *     console.log('请求成功:', result);
   *   },
   *   failure: function (result) {
   *     console.log('请求失败:', result);
   *   }
   * });
   * // promise方式
   * WFSServer.getCapabitities().then(function (result) {
   *   console.log('请求成功:', result);
   * }).catch(function (result) {
   *   console.log('请求失败:', result);
   * })
   */
  getCapabitities(options) {
    // 调用基类的查询信息方法
    return this._querySimpleInfo(options, function (url) {
      // 拼装返回基地址
      return `${url}?request=GetCapabilities&service=WFS&version=2.0.0`
    })
  }

  /**
   * 要素查询
   * @param options 查询参数(注释不明,请找igs服务部门)
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  queryFeatures(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      maxfeatures: {
        type: 'Number',
        default: 1000
      },
      typename: {
        type: 'String',
        required: true
      }
    }

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}?request=GetFeature&service=WFS&version=2.0.0`
      }
    )
  }
}

Zondy.Service.WFSServer = WFSServer
export default WFSServer
构造函数
成员变量
方法
事件