import BaseServer from '../BaseServer'
import { Zondy } from '../../base'
/**
* 影像服务,服务地址:/igs/rest/services/{folder}/{serviceName}/ImageServer
* @class ImageServer
* @moduleEx ServiceModule
* @extends BaseServer
* @param {Object} options 构造参数
* @param {String} [options.url = 无] 服务基地址
* @example
* //初始化ImageServer服务对象
* // ES5引入方式
* const { ImageServer } = Zondy.Service
* // ES6引入方式
* import { ImageServer } from "@mapgis/webclient-common"
* const imageServer = new ImageServer({
* //服务基地址
* url: 'http://localhost:8089/igs/rest/services/whole_hk_dtm_wgs84_5m/ImageServer'
* })
*/
class ImageServer extends BaseServer {
constructor(options) {
super(options)
}
/**
* @function ImageServer.prototype.queryImageInfo
* @description 获取栅格数据信息 后端接口:/igs/rest/services/{serviceName}/ImageServer/info
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.queryImageInfo({
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.queryImageInfo({
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
queryImageInfo(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/info?f=json`
}
)
}
/**
* @function ImageServer.prototype.getColorMap
* @description 获取色表,后端接口:/igs/rest/services/{serviceName}/ImageServer/colorMap
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.getColorMap({
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.getColorMap({
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
getColorMap(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/colorMap?f=json`
}
)
}
/**
* @function ImageServer.prototype.getHistograms
* @description 获取直方图,后端接口:/igs/rest/services/{serviceName}/ImageServer/histograms
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.getHistograms({
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.getHistograms({
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
getHistograms(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/histograms?f=json`
}
)
}
/**
* @function ImageServer.prototype.getLegend
* @description 获取图例,后端接口:/igs/rest/services/{serviceName}/ImageServer/legend
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {String} [options.size=15,15] 图例大小,格式:width,height
* @param {String} [options.bandIds = 无 ] 波段id列表
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.getLegend({
* bandIds:'2',
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.getHistograms({
* bandIds:'2',
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
getLegend(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {
size: {
type: 'String'
},
bandIds: {
type: 'String'
}
}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/legend?f=json`
}
)
}
/**
* @function ImageServer.prototype.getRasterValue
* @description 获取栅格值,后端接口:/igs/rest/services/{serviceName}/ImageServer/rasterValue
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @param {Number} [options.x = 0] 将查询的地理位置的x坐标值,必填
* @param {Number} [options.y = 0] 将查询的地理位置的y坐标值,必填
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.getRasterValue({
* x:113.82174801481621,
* y:22.573404544364156,
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.getRasterValue({
* x:113.82174801481621,
* y:22.573404544364156,
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
getRasterValue(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {
x: {
type: 'Number',
required: true
},
y: {
type: 'Number',
required: true
}
}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/rasterValue/?f=json`
}
)
}
/**
* @function ImageServer.prototype.getStatistics
* @description 获取统计信息,后端接口:/igs/rest/services/{serviceName}/ImageServer/statistics
* @param options 查询参数
* @param {String} [options.method = FetchMethod.get ] 请求类型
* @param {Function} [options.success = 无] 查询成功回调函数,若使用Promise方式则不必填写
* @param {Function} [options.failure = 无] 查询失败回调函数,若使用Promise方式则不必填写
* @returns {Promise<Object>}
* @example
* //回调方式
* imageServer.getStatistics({
* success: function (result) {
* console.log('请求成功:', result)
* }
* })
* //promise方式
* imageServer.getStatistics({
* }).then(function (result) {
* console.log('请求成功:', result);
* }).catch(function (result) {
* console.log('请求失败:', result);
* });
*/
getStatistics(options) {
// 设置PATH PARAMETERS校验
const checkPathOpts = {}
// 设置QUERY PARAMETERS校验
const checkQueryOpts = {}
// 调用基类的查询信息方法
return this._queryByParameters(
options,
checkPathOpts,
checkQueryOpts,
// 拼装返回基地址
function (url) {
return `${url}/statistics?f=json`
}
)
}
}
Zondy.Service.ImageServer = ImageServer
export default ImageServer