类名 common/service/igs/arcgis/ArcGISGeometryServer.js
import BaseServer from '../../BaseServer'
import { Zondy } from '../../../base'
import { FetchMethod } from '../../../base/enum'

/**
 * ArcGIS的GeometryServer服务
 * @class ArcGISGeometryServer
 * @moduleEx ServiceModule
 * @extends BaseServer
 * @param {Object} options 构造参数
 * @param {String} [options.url = 无] 服务基地址
 */
class ArcGISGeometryServer extends BaseServer {
  constructor(options) {
    super(options)
  }

  /**
   * 缓冲分析
   * @param options 查询参数
   * @param {Geometry} [options.geometries] 要计算的几何,必填
   * @param {SpatialReference} [options.inSR] 原始参考系,必填
   * @param {Number} [options.distances] 缓冲半径,必填
   * @param {SpatialReference} [options.outSR] 输出参考系,优先级bufferSR>outSR>inSR
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {SpatialReference} [options.bufferSR] 缓冲分析参考系,优先级bufferSR>outSR>inSR
   * @param {String} [options.unit] 单位
   * @param {String} [options.callback]
   */
  bufferAnalyse(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&geometries=${JSON.stringify(geometries)}`
        }
      },
      inSR: {
        type: 'String',
        required: true
      },
      distances: {
        type: 'Number',
        required: true
      },
      outSR: {
        type: 'String'
      },
      unit: {
        type: 'String'
      },
      bufferSR: {
        type: 'String'
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/buffer?f=json`
      }
    )
  }

  /**
   * 几何裁剪
   * @param options 查询参数
   * @param {Object} [options.cutter] 裁剪几何的线对象,必填
   * @param {Object} [options.target] 被裁剪的线或多边形对象,必填
   * @param {String} [options.sr] 被裁剪的线或多边形对象的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  cutGeometry(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      cutter: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&cutter=${JSON.stringify(geometries)}`
        }
      },
      target: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&target=${JSON.stringify(geometries)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/cut?f=json`
      }
    )
  }

  /**
   * 求差计算
   * @param options 查询参数
   * @param {Object} [options.geometries] 要求差的多边形集合,必填
   * @param {Object} [options.geometry] 被求差的几何,必填
   * @param {String} [options.sr] 几何的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  calculateDifference(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&geometries=${JSON.stringify(geometries)}`
        }
      },
      geometry: {
        type: 'Object',
        required: true,
        process(geometry) {
          return `&geometry=${JSON.stringify(geometry)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/difference?f=json`
      }
    )
  }

  /**
   * 计算距离
   * @param options 查询参数
   * @param {Object} [options.geometry1] 要计算距离的多边形1,必填
   * @param {Object} [options.geometry2] 要计算距离的多边形2,必填
   * @param {String} [options.sr] 几何的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {String} [options.distanceUnit] 单位
   */
  calculateDistance(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometry1: {
        type: 'Object',
        required: true,
        process(geometry1) {
          return `&geometry1=${JSON.stringify(geometry1)}`
        }
      },
      geometry2: {
        type: 'Object',
        required: true,
        process(geometry2) {
          return `&geometry2=${JSON.stringify(geometry2)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      },
      distanceUnit: {
        type: 'String'
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/distance?f=json`
      }
    )
  }

  /**
   * 求交计算
   * @param options 查询参数
   * @param {Object} [options.geometries] 要求交的几何集合,必填
   * @param {Object} [options.geometry] 被求交的几何,必填
   * @param {String} [options.sr] 被求交的几何的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  calculateIntersect(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&geometries=${JSON.stringify(geometries)}`
        }
      },
      geometry: {
        type: 'Object',
        required: true,
        process(geometry) {
          return `&geometry=${JSON.stringify(geometry)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/intersect?f=json`
      }
    )
  }

  /**
   * 计算拓扑关系
   * @param options 查询参数
   * @param {Object} [options.geometries1] 被求交的几何的坐标系,必填
   * @param {Object} [options.geometries2] 被求交的几何的坐标系,必填
   * @param {String} [options.sr] 几何的坐标系,必填
   * @param {String} [options.relation] 设置拓扑关系,必填
   * @param {Object} [options.relationParam] 必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  calculateTopologyRelation(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries1: {
        type: 'Object',
        required: true,
        process(geometries1) {
          return `&geometries1=${JSON.stringify(geometries1)}`
        }
      },
      geometries2: {
        type: 'Object',
        required: true,
        process(geometries2) {
          return `&geometries2=${JSON.stringify(geometries2)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      },
      relation: {
        type: 'String',
        required: true
      },
      relationParam: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/relation?f=json`
      }
    )
  }

  /**
   * @function ArcGISFeatureServer.prototype.simplifyGeometry
   * @description 化简几何,后端接口/igs/rest/services/system/arcgis/GeometryServer/simplify
   * @param options 查询参数
   * @param {Object} [options.geometries] 要化简的几何对象,必填
   * @param {String} [options.sr] 几何对象的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  simplifyGeometry(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&geometries=${JSON.stringify(geometries)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/simplify?f=json`
      }
    )
  }

  /**
   * 求并
   * @param options 查询参数
   * @param {Object} [options.geometries] 要合并的几何对象,必填
   * @param {String} [options.sr] 几何对象的坐标系,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  calculateUnion(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometries: {
        type: 'Object',
        required: true,
        process(geometries) {
          return `&geometries=${JSON.stringify(geometries)}`
        }
      },
      sr: {
        type: 'String',
        required: true
      }
    }

    options.method = FetchMethod.get
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/union?f=json`
      }
    )
  }
}

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