    import BaseServer from '../BaseServer'
    import { Zondy } from '../../base'
    import { FetchMethod } from '../../base/enum'
    import { defaultValue, isNull } from '../../util'

    /**
     * 地理几何服务
     * @class GeometryServer
     * @moduleEx ServerModule
     * @extends BaseServer
     * @param {Object} options 构造参数
     * @param {String} [options.url = 无] 服务基地址
     * @example
     * // ES5引入方式
     * const { GeometryServer } = Zondy.Service
     * // ES6引入方式
     * import { GeometryServer } from "@mapgis/webclient-common"
     * const geometryServer = new GeometryServer({
     *   url: 'http://localhost:8089/igs/rest/services/system/GeometryServer',
     *   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 GeometryServer extends BaseServer {
      constructor(options) {
        super(options)
      }

      /**
       * 计算面积和周长
       * @param options 查询参数
       * @param {Polygon} [options.polygons] 要计算的多边形，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * // ES6引入方式
       * import { Polygon } from "@mapgis/webclient-common"
       * geometryServer.calculateAreasAndLengths({
       *   polygons: new Polygon({
       *     spatialReference: "EPSG:4326",
       *     coordinates: [
       *       [
       *         [108.9587, 34.2206],
       *         [112.9607, 31.2196],
       *         [110.9598, 30.2181],
       *         [110.9587, 32.2191],
       *         [108.9587, 34.2206]
       *       ]
       *     ]
       *   }),
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateAreasAndLengths({
       *   polygons: new Polygon({
       *     spatialReference: "EPSG:4326",
       *     coordinates: [
       *       [
       *         [108.9587, 34.2206],
       *         [112.9607, 31.2196],
       *         [110.9598, 30.2181],
       *         [110.9587, 32.2191],
       *         [108.9587, 34.2206]
       *       ]
       *     ]
       *   })
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateAreasAndLengths(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          polygons: {
            type: 'Polygon',
            required: true,
            process: 'igsGeometryServer'
          }
        }

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

      /**
       * 计算面积
       * @param options 查询参数
       * @param {Polygon} [options.polygon] 要计算的多边形，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @param {ProjectInfo} [options.projectInfo] 投影参考信息，projectInfo或projectInfoBySrsID二选一
       * @param {ProjectInfoBySrsID} [options.projectInfoBySrsID] 源投影参考系ID，projectInfo或projectInfoBySrsID二选一
       * */
      calculateArea(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          polygon: {
            type: 'Polygon',
            required: true,
            alias: 'Dots',
            process: 'igsDots'
          },
          projectInfo: {
            type: 'Object',
            alias: 'ProjectInfo',
            required: true,
            oneOf: ['projectInfoBySrsID']
          },
          projectInfoBySrsID: {
            type: 'Object',
            alias: 'ProjectInfoBySrsID',
            required: true,
            oneOf: ['projectInfo']
          }
        }

        // 设置请求头，一定要是text/plain;charset=UTF-8
        options.headers = {
          'Content-Type': 'text/plain;charset=UTF-8'
        }
        // 使用post请求
        options.method = FetchMethod.post
        // post参数为Object形式
        options.useObject = true
        // 调用基类的查询信息方法
        return this._queryByParameters(
          options,
          checkPathOpts,
          checkQueryOpts,
          // 拼装返回基地址
          function (url) {
            return `${url}/calArea?f=json`
          }
        )
      }

      /**
       * 计算长度
       * @param options 查询参数
       * @param {LineString} [options.lineString] 要计算的线，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @param {ProjectInfo} [options.projectInfo] 投影参考信息，projectInfo或projectInfoBySrsID二选一
       * @param {ProjectInfoBySrsID} [options.projectInfoBySrsID] 源投影参考系ID，projectInfo或projectInfoBySrsID二选一
       * */
      calculateLength(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          lineString: {
            type: 'LineString',
            required: true,
            alias: 'Dots',
            process: 'igsDots'
          },
          projectInfo: {
            type: 'Object',
            alias: 'ProjectInfo',
            required: true,
            oneOf: ['projectInfoBySrsID']
          },
          projectInfoBySrsID: {
            type: 'Object',
            alias: 'ProjectInfoBySrsID',
            required: true,
            oneOf: ['projectInfo']
          }
        }

        // 设置请求头，一定要是text/plain;charset=UTF-8
        options.headers = {
          'Content-Type': 'text/plain;charset=UTF-8'
        }
        // 使用post请求
        options.method = FetchMethod.post
        // post参数为Object形式
        options.useObject = true
        // 调用基类的查询信息方法
        return this._queryByParameters(
          options,
          checkPathOpts,
          checkQueryOpts,
          // 拼装返回基地址
          function (url) {
            return `${url}/callength?f=json`
          }
        )
      }

      /**
       * 对矩形范围坐标点进行投影转换
       * @param options 查询参数
       * @param {String} [options.gdbsvrName] 数据源名称，必填
       * @param {String} [options.gdbName] 地理数据库名称，必填
       * @param {String} [options.srefID] 源投影参考系ID，必填
       * @param {String} [options.desfID] 目的投影参考系ID，必填
       * @param {Extent} [options.extent] 矩形范围，必填
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @param {String} [options.userName] 地理数据源/地理数据库账户名
       * @param {String} [options.password] 地理数据源/地理数据库密码
       * */
      projectInExtent(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {
          gdbsvrName: {
            type: 'String'
          },
          gdbName: {
            type: 'String'
          },
          srefID: {
            type: 'String'
          },
          desfID: {
            type: 'String'
          }
        }

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          extent: {
            type: 'Extent',
            alias: 'rang',
            required: true,
            process: 'igsRange$'
          },
          userName: {
            type: 'String'
          },
          password: {
            type: 'String'
          }
        }

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

      /**
       * 缓冲分析
       * @param options 查询参数
       * @param {Polygon} [options.polygon] 要计算的多边形
       * @param {Number} [options.distance] 缓冲半径
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Polygon, FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.bufferAnalyse({
       *   geometries: new Polygon({
       *     spatialReference: "EPSG:4326",
       *     coordinates: [
       *       [
       *         [108.9587, 34.2206],
       *         [112.9607, 31.2196],
       *         [110.9598, 30.2181],
       *         [110.9587, 32.2191],
       *         [108.9587, 34.2206]
       *       ]
       *     ]
       *   }),
       *   method: FetchMethod.post,
       *   distance: 1,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.bufferAnalyse({
       *   geometries: new Polygon({
       *     spatialReference: "EPSG:4326",
       *     coordinates: [
       *       [
       *         [108.9587, 34.2206],
       *         [112.9607, 31.2196],
       *         [110.9598, 30.2181],
       *         [110.9587, 32.2191],
       *         [108.9587, 34.2206]
       *       ]
       *     ]
       *   }),
       *   distance: 100,
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      bufferAnalyse(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometries: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          distance: {
            type: 'Number',
            required: true
          }
        }

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

      /**
       * 求差计算
       * @param options 查询参数
       * @param {Geometry} [options.geometry1] 要计算的多边形1，必填
       * @param {Geometry} [options.geometry2] 要计算的多边形2，必填
       * @param {Number} [options.tolerance] 容差，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * // ES6引入方式
       * import { Polygon } from "@mapgis/webclient-common"
       * geometryServer.calculateDifference({
       *   geometry1: new Polygon({
       *     coordinates: [
       *       [
       *         [105.0, 0.0],
       *         [164.0, 0.0],
       *         [164.0, 10.0],
       *         [105.0, 10.0],
       *         [105.0, 0.0]
       *       ]
       *     ]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [
       *       [
       *         [110.0, 5.0],
       *         [170.0, 5.0],
       *         [170.0, 20.0],
       *         [110.0, 20.0],
       *         [110.0, 5.0]
       *       ]
       *     ]
       *   }),
       *   tolerance: 1,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateDifference({
       *   geometry1: new Polygon({
       *     coordinates: [
       *       [
       *         [105.0, 0.0],
       *         [164.0, 0.0],
       *         [164.0, 10.0],
       *         [105.0, 10.0],
       *         [105.0, 0.0]
       *       ]
       *     ]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [
       *       [
       *         [110.0, 5.0],
       *         [170.0, 5.0],
       *         [170.0, 20.0],
       *         [110.0, 20.0],
       *         [110.0, 5.0]
       *       ]
       *     ]
       *   }),
       *   tolerance: 1
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateDifference(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometry1: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          geometry2: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          tolerance: {
            type: 'Number',
            required: true
          }
        }

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

      /**
       * 求距离
       * @param options 查询参数
       * @param {Geometry} [options.geometry1] 要计算的多边形1，必填
       * @param {Geometry} [options.geometry2] 要计算的多边形2，必填
       * @param {Geometry} [options.srs] 参考系，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Point,LineString } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Point,LineString,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateDistance({
       *   geometry1: new Zondy.Geometry.Point({
       *     coordinates: [
       *       105.380859375, 31.57853542647338
       *     ]
       *   }),
       *   geometry2: new LineString({
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       *   srs: "EPSG:4326",
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateDistance({
       *   geometry1: new Point({
       *     coordinates: [
       *       105.380859375, 31.57853542647338
       *     ]
       *   }),
       *   geometry2: new LineString({
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       *   srs: "EPSG:4326"
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateDistance(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometry1: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          geometry2: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          srs: {
            type: 'String',
            required: true
          }
        }

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

      /**
       * 求交计算
       * @param options 查询参数
       * @param {Geometry} [options.geometry1] 要计算的多边形1，必填
       * @param {Geometry} [options.geometry2] 要计算的多边形2，必填
       * @param {Number} [options.tolerance] 容差，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * const { Polygon,FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Polygon,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateIntersect({
       *   geometry1: new Polygon({
       *     coordinates: [[ [105.0, 0.0],[164.0, 0.0],[164.0, 10.0],[105.0, 10.0],[105.0, 0.0] ]]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1,
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateIntersect({
       *   geometry1: new Polygon({
       *     coordinates: [[ [105.0, 0.0],[164.0, 0.0],[164.0, 10.0],[105.0, 10.0],[105.0, 0.0] ]]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateIntersect(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometry1: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          geometry2: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          tolerance: {
            type: 'Number',
            required: true
          }
        }

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

      /**
       * 求label点
       * @param options 查询参数
       * @param {Polygon} [options.polygons] 要计算的多边形，单区或多区几何，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * const { Polygon,FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Polygon,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateLabelPoints({
       *   polygons: new Polygon({
       *     coordinates: [[ [100.0, 0.0],[101.0, 0.0],[101.0, 1.0],[100.0, 1.0],[100.0, 0.0] ]]
       *   }),
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateLabelPoints({
       *   polygons: new Polygon({
       *     coordinates: [[ [100.0, 0.0],[101.0, 0.0],[101.0, 1.0],[100.0, 1.0],[100.0, 0.0] ]]
       *   })
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateLabelPoints(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          polygons: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          }
        }

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

      /**
       * 求长度
       * @param options 查询参数
       * @param {LineString | MultiLineString} [options.lineString] 要计算的线，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { LineString } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { LineString,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateLengths({
       *   polylines: new LineString({
       *     spatialReference: 'EPSG:4326',
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateLengths({
       *   polylines: new LineString({
       *     spatialReference: 'EPSG:4326',
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateLengths(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          polylines: {
            type: 'LineString | MultiLineString',
            required: true,
            process: 'igsGeometryServer'
          }
        }

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

      /**
       * 几何投影
       * @param options 查询参数
       * @param {Geometry} [options.geometries] 要计算的投影几何对象，必填
       * @param {String} [options.inSrs] 原始参考系，必填
       * @param {String} [options.outSrs] 目标参考系，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { LineString } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Polygon,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.geometryProject({
       *   geometries: new LineString({
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       *   inSrs: 'EPSG:4326',
       *   outSrs: 'EPSG:3857',
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.geometryProject({
       *   geometries: new LineString({
       *     coordinates: [[-117,34],[-116,34],[-117,33]]
       *   }),
       *   inSrs: 'EPSG:4326',
       *   outSrs: 'EPSG:3857'
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      geometryProject(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometries: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          inSrs: {
            type: 'String',
            required: true
          },
          outSrs: {
            type: 'String',
            required: true
          }
        }

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

      /**
       * 计算拓扑关系
       * @param options 查询参数
       * @param {Geometry} [options.geometry1] 要计算的多边形1，必填
       * @param {Geometry} [options.geometry2] 要计算的多边形2，必填
       * @param {Number} [options.tolerance] 容差，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { LineString,Polygon } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { LineString,Polygon,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateTopologyRelation({
       *   geometry1: new LineString({
       *     coordinates:  [ [117,0],[117,44] ]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1,
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * //promise方式
       * geometryServer.calculateTopologyRelation({
       *   geometry1: new LineString({
       *     coordinates:  [ [117,0],[117,44] ]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateTopologyRelation(options) {
        let checkPathOpts
        let checkQueryOpts
        if (this.url.indexOf('/igs/rest/mrgs/geomservice')) {
          // 设置PATH PARAMETERS校验
          checkPathOpts = {}

          // 设置QUERY PARAMETERS校验
          checkQueryOpts = {
            distance: {
              type: 'Number',
              alias: 'NearDis',
              default: 0.01
            },
            point: {
              type: 'Point',
              alias: 'Pnt',
              process: 'toOldIGSGeometry'
            },
            lingString: {
              type: 'LineString',
              alias: 'Line',
              process: 'toOldIGSGeometry'
            },
            polygon: {
              type: 'Polygon',
              alias: 'Reg',
              process: 'toOldIGSGeometry'
            },
            topologyPolygon: {
              type: 'Polygon',
              alias: 'RelativeObj',
              process: 'toOldIGSGeometry'
            }
          }

          // 设置请求头，一定要是text/plain;charset=UTF-8
          options.headers = {
            'Content-Type': 'text/plain;charset=UTF-8'
          }
          // 使用post请求
          options.method = FetchMethod.post
          // post参数为Object形式
          options.useObject = true
          // 调用基类的查询信息方法
          return this._queryByParameters(
            options,
            checkPathOpts,
            checkQueryOpts,
            // 拼装返回基地址
            function (url) {
              return `${url}/topanalysis?f=json`
            }
          )
        } else {
          // 设置PATH PARAMETERS校验
          checkPathOpts = {}

          // 设置QUERY PARAMETERS校验
          checkQueryOpts = {
            geometry1: {
              type: 'Geometry',
              required: true,
              process: 'igsGeometryServerNoSRS'
            },
            geometry2: {
              type: 'Geometry',
              required: true,
              process: 'igsGeometryServerNoSRS'
            },
            tolerance: {
              type: 'Number',
              required: true
            }
          }

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

      /**
       * 计算光滑曲线，igs1.0服务
       * @param options 查询参数
       * @param {Number} [options.type] 插值方式，0为二次样条、1为三次样条、2为三次Beizer样条、3为三次B样条，必填
       * @param {LineString} [options.lineString] 要计算的线几何，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @param {Number} [options.tolerance] step
       * */
      smoothLineString(options) {
        options = defaultValue(options, {})

        if (isNull(options.type) || isNull(options.lineString)) {
          return
        }

        options.step = defaultValue(options.step, 1)

        // 设置请求头，一定要是text/plain;charset=UTF-8
        options.headers = {
          'Content-Type': 'text/plain;charset=UTF-8'
        }
        // 使用post请求
        options.method = FetchMethod.post
        options.data = JSON.stringify(options.lineString.toDots())
        // 调用基类的查询信息方法
        return this._postRequest(
          `${this.url}/smooth?f=json&type=${options.type}&step=${options.step}`,
          options
        )
      }

      /**
       * 求并
       * @param options 查询参数
       * @param {Geometry} [options.geometry1] 要计算的多边形1，必填
       * @param {Geometry} [options.geometry2] 要计算的多边形2，必填
       * @param {Number} [options.tolerance] 容差，必填
       * @param {Function} [options.success] 查询成功回调函数，若使用Promise方式则不必填写
       * @param {Function} [options.failure] 查询失败回调函数，若使用Promise方式则不必填写
       * @example
       * // 回调方式
       * // ES5引入方式
       * const { Polygon } = Zondy.Geometry
       * const { FetchMethod } = Zondy.Enum
       * // ES6引入方式
       * import { Polygon,FetchMethod } from "@mapgis/webclient-common"
       * geometryServer.calculateUnion({
       *   geometry1: new Polygon({
       *     coordinates:  [[ [105.0, 0.0],[164.0, 0.0],[164.0, 10.0],[105.0, 10.0],[105.0, 0.0] ]]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1,
       *   method: FetchMethod.post,
       *   success: function (result) {
       *     console.log('请求成功：', result);
       *   },
       *   failure: function (result) {
       *     console.log('请求失败：', result);
       *   }
       * });
       * // promise方式
       * geometryServer.calculateUnion({
       *   geometry1: new Polygon({
       *     coordinates:  [[ [105.0, 0.0],[164.0, 0.0],[164.0, 10.0],[105.0, 10.0],[105.0, 0.0] ]]
       *   }),
       *   geometry2: new Polygon({
       *     coordinates: [[ [110.0, 5.0],[170.0, 5.0],[170.0, 20.0],[110.0, 20.0],[110.0, 5.0] ]]
       *   }),
       *   tolerance: 1,
       * }).then(function (result) {
       *   console.log('请求成功：', result);
       * }).catch(function (result) {
       *   console.log('请求失败：', result);
       * })
       */
      calculateUnion(options) {
        // 设置PATH PARAMETERS校验
        const checkPathOpts = {}

        // 设置QUERY PARAMETERS校验
        const checkQueryOpts = {
          geometry1: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          geometry2: {
            type: 'Geometry',
            required: true,
            process: 'igsGeometryServerNoSRS'
          },
          tolerance: {
            type: 'Number',
            required: true
          }
        }

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

    Zondy.Service.GeometryServer = GeometryServer
    export default GeometryServer