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

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

  /**
   * 针对地图或地图中一个或多个图层进行属性查询
   * @param options 查询参数
   * @param {String} [options.searchText] 搜索包含该字符串的要素,在该服务下的所有文档中搜索,必填
   * @param {String} [options.layers] 要搜索的图层id,多个图层id以逗号分割,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {Boolean} [options.contains = true] 匹配字符串时,是否是包含匹配,默认为true,即包含匹配,false时进行全词匹配
   * @param {String} [options.searchFields] 要搜索的字段名,多个字段名以逗号分割,不指定则全字段搜索
   * @param {Boolean} [options.returnGeometry = true] 是否返回几何数据
   * @param {Number} [options.geometryPrecision = 3] 返回几何数据的小数点位数
   */
  find(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      searchText: {
        type: 'String',
        required: true
      },
      contains: {
        type: 'Boolean'
      },
      searchFields: {
        type: 'String'
      },
      sr: {
        type: 'String'
      },
      layers: {
        type: 'String',
        required: true
      },
      returnGeometry: {
        type: 'Boolean'
      },
      geometryPrecision: {
        type: 'Number'
      },
      callback: {
        type: 'String'
      }
    }

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

  /**
   * 识别地图中与传入几何要素相交的要素
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  identify(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometry: {
        type: 'String'
      },
      geometryType: {
        type: 'String'
      },
      sr: {
        type: 'String'
      },
      layers: {
        type: 'String'
      },
      layerDefs: {
        type: 'Array'
      },
      tolerance: {
        type: 'String'
      },
      mapExtent: {
        type: 'String'
      },
      imageDisplay: {
        type: 'String'
      },
      returnGeometry: {
        type: 'String'
      },
      geometryPrecision: {
        type: 'String'
      },
      spatialFilter: {
        type: 'String'
      }
    }

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

  /**
   * 获取所有图层资源
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {String} [options.callback]
   */
  getLayers(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      callback: {
        type: 'String'
      }
    }

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

  /**
   * 获取图例
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {Number} [options.dpi = 96] 图例图像的分辨率
   * @param {String} [options.size = '15,15'] 图例图像的大小
   */
  getLegend(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      dpi: {
        type: 'Number'
      },
      size: {
        dpi: 'String'
      },
      callback: {
        dpi: 'String'
      }
    }

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

  /**
   * 查询指定图层信息
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  queryLayerInfo(options) {
    // 调用基类的查询信息方法
    return this._queryInfoByLayerId(
      options,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/${options.layerId}?f=json`
      }
    )
  }

  /**
   * 指定图层的空间和属性查询
   * @param options 查询参数
   * @param {String} [options.layerId] 图层ID,必填
   * @param {String} [options.geometry] 几何查询
   * @param {String} [options.geometryType] 几何查询
   * @param {String} [options.inSR] 查询几何的参考系
   * @param {String} [options.outSR] 返回数据的几何参考系
   * @param {String} [options.spatialRel] 几何查询空间关系
   * @param {String} [options.units] 设置几何数据的单位
   * @param {String} [options.where] where查询语句,类似sql语句
   * @param {String} [options.objectIds] 根据要素ID查询并返回数据,多个id以逗号分割
   * @param {String} [options.outFields] 指定返回数据的显示字段,多个字段名以逗号分割
   * @param {String} [options.orderByFields] 指定排序字段,多个字段名以逗号分割,例如orderByFields=field1 <ORDER>, field2 <ORDER>, field3 <ORDER>,orderByFields=STATE_NAME ASC, RACE DESC, GENDER
   * @param {Array<OutStatistic>} [options.outStatistics] 字段统计参数数组
   * @param {String} [options.groupByFieldsForStatistics]
   * @param {String} [options.geometryPrecision] 指定返回几何数据的小数点位数
   * @param {Number} [options.resultOffset = 0] 查询偏移位数,例如resultOffset=10,则从第11位开始查询
   * @param {Boolean} [options.returnIdsOnly = false] 仅返回查询到的要素id
   * @param {Boolean} [options.returnCountOnly = false] 仅返回查询到的要素的数目
   * @param {Boolean} [options.returnGeometry = true] 是否返几何数据
   * @param {Boolean} [options.returnZ = false] 是否返几何Z轴坐标
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  queryFeatureInLayers(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      layerId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      geometry: {
        type: 'String'
      },
      geometryType: {
        type: 'String'
      },
      geometryPrecision: {
        type: 'Number'
      },
      inSR: {
        type: 'String'
      },
      outSR: {
        type: 'String'
      },
      spatialRel: {
        type: 'String'
      },
      where: {
        type: 'String'
      },
      objectIds: {
        type: 'String'
      },
      distance: {
        type: 'String'
      },
      units: {
        type: 'String'
      },
      outFields: {
        type: 'String'
      },
      returnGeometry: {
        type: 'Boolean'
      },
      returnIdsOnly: {
        type: 'Boolean'
      },
      returnCountOnly: {
        type: 'Boolean'
      },
      orderByFields: {
        type: 'String'
      },
      outStatistics: {
        type: 'OutStatistics'
      },
      groupByFieldsForStatistics: {
        type: 'String'
      },
      resultOffset: {
        type: 'Number'
      },
      resultRecordCount: {
        type: 'String'
      },
      returnZ: {
        type: 'Boolean'
      }
    }

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

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