new ImageServer(options)
影像服务,服务地址:/igs/rest/services/{folder}/{serviceName}/ImageServer
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
构造参数
|
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'
})
Extends
Members
-
clientIdBoolean
-
客户端id
-
enableGlobeFetchBoolean
-
是否使用确据唯一的fetch对象,默认为true,当设为false时,会使用自己私有的fetch对象,所有的请求设置不会影响全局
Example
//设置请求基地址 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求基地址 url: '你的URL', //使用私有的fetch对象 enableGlobeFetch: false, //此时设置token等属性,不会影响全局的fetch对象 tokenValue: '你的token' }); //继续使用全局fetch BaseServer.enableGlobeFetch = true; -
headersString
-
请求头参数
Example
//设置请求头参数 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求头 headers: { //设置Content-Type为multipart/form-data 'Content-Type': 'multipart/form-data', //设置token 'token': '你的token' } }); //动态修改 BaseServer.headers.token = '新token'; -
requestInterceptorfunction
-
请求发送拦截器
Example
//设置拦截器,任何一个继承自BaseServer的对象都可以设置,全局唯一 // ES5引入方式 const { BaseServer,RequestInterceptor } = zondy.service // ES6引入方式 import { BaseServer,RequestInterceptor } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //设置请求发送拦截器 requestInterceptor: new RequestInterceptor({ //请求发送前进行统一处理 before: function(config) { //执行你的业务逻辑 //注意必须显示返回config对象,如果返回为空,则不发送请求 return config; }, //请求发送失败时进行统一处理 failure: function(error) { //执行你的业务逻辑 } }) }); //动态修改 BaseServer.requestInterceptor.before = function() {}; -
requestTimeoutString
-
请求超时时间,默认45000ms,即45s
Example
//设置超时时间 //初始化AddressServer服务对象 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //超时时间 requestTimeout: 2000 }); //动态修改 BaseServer.requestTimeout = 3000; -
responseInterceptorfunction
-
请求响应拦截器
Example
//设置拦截器,任何一个继承自BaseServer的对象都可以设置,全局唯一 // ES5引入方式 const { BaseServer,ResponseInterceptor } = zondy.service // ES6引入方式 import { BaseServer,ResponseInterceptor } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //设置请求响应拦截器 responseInterceptor: new ResponseInterceptor({ //执行请求响应,接口调用成功时会执行的回调 success: function(result) { //执行你的业务逻辑 //注意必须显示返回result对象,如果返回为空,则不执行请求响应成功回调 return result; }, //请求响应成功,接口调用失败时会执行的函数 failure: function(result) { //执行你的业务逻辑 //注意必须显示返回result对象,如果返回为空,则不执行回调韩式 return result; } }) }); //动态修改 BaseServer.responseInterceptor.success = function() {}; -
tokenAttachTypeTokenAttachType
-
指定token附加到何处
Example
//设置token值 // ES5引入方式 const { BaseServer } = zondy.service const { TokenAttachType } = zondy.enum // ES6引入方式 import { BaseServer,TokenAttachType } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token名 tokenKey: '你的token key', //token值 tokenValue: '你的token值', //指定token附加到url后面 tokenAttachType: TokenAttachType.url }); //动态修改 BaseServer.tokenAttachType = TokenAttachType.header; -
tokenKeyString
-
token名
Example
//设置token名 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token名 tokenKey: '你的tokenKey' }); //动态修改 BaseServer.tokenKey = '新tokenKey'; -
tokenValueString
-
token值
Example
//设置token值 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //token值 tokenValue: '你的token值' }); //动态修改 BaseServer.tokenValue = '新token值'; -
urlString
-
服务基地址
Example
//设置请求基地址 // ES5引入方式 const { BaseServer } = zondy.service // ES6引入方式 import { BaseServer } from "@mapgis/webclient-common" let BaseServer = new BaseServer({ //请求基地址 url: '你的URL' }); //动态修改 BaseServer.url = '新URL';
Methods
-
exportImage(options)
service/igs/ImageServer.js, line 317 -
根据参数出图,详细说明请参考IGS的API文档
Name Type Description optionsName Type Default Description methodFetchMethod FetchMethod.post 可选 请求方式
bboxExtent 可选 出图范围,格式:xmin,ymin,xmax,ymax,如果设置了imageSR参数,确保bbox是imageSR参照系的范围
sizeString 可选 图片大小,格式:width,height,默认512,512
formatString 可选 返回图片格式,支持PNG/JPG/MIXED,默认PNG
imageSRSpatialReference 可选 投影空间参照系,支持MapGIS参照系名称、EPSG格式参考系、WKT格式参考系
interpolationString 可选 重采样方式,NearestNeighbor(最邻近显示)、BilinearInterpolation(双线性显示)
bandIdsArray.<Number> 可选 波段id列表,例如[2,0,1]
maskBoundaryGeometry 可选 掩膜几何,空间参考系需要保证和imageSR参照系一致
renderingRuleRasterFunction 可选 渲染规则,NDVI应用于多光谱影像数据,HILLSHADE应用于DEM高程数据。例如renderingRule={type:HILLSHADE,altitude:75,azimuth:120,zFactor:1.0}或renderingRule={type:NDVI,redIndex:0,nirIndex:2}
fString 可选 返回格式
-
getColorMap(options){Promise.<Object>}
service/igs/ImageServer.js, line 71 -
获取色表,后端接口:/igs/rest/services/{serviceName}/ImageServer/colorMap
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Returns:
Type Description 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); }); -
getHistograms(options){Promise.<Object>}
service/igs/ImageServer.js, line 111 -
获取直方图,后端接口:/igs/rest/services/{serviceName}/ImageServer/histograms
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Returns:
Type Description 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); }); -
getImage(options)
service/igs/ImageServer.js, line 396 -
根据参数出图,详细说明请参考IGS的API文档
Name Type Description optionsName Type Default Description bboxExtent 可选 出图范围,如果设置了imageSR参数,确保bbox是imageSR参照系的范围
sizeString '512,512' 可选 图片大小,格式:width,height,默认512,512
formatString 'PNG' 可选 返回图片格式,支持PNG/JPG/MIXED,默认PNG
imageSRSpatialReference 可选 投影空间参照系,支持MapGIS参照系名称、EPSG格式参考系、WKT格式参考系
interpolationString '' 可选 重采样方式,NearestNeighbor(最邻近显示)、BilinearInterpolation(双线性显示)
bandIdsArray.<Number> 可选 波段id列表,例如[2,0,1]
maskBoundaryGeometry 可选 掩膜几何,空间参考系需要保证和imageSR参照系一致
renderingRuleRasterFunction 可选 渲染规则,NDVI应用于多光谱影像数据,HILLSHADE应用于DEM高程数据。例如renderingRule={type:HILLSHADE,altitude:75,azimuth:120,zFactor:1.0}或renderingRule={type:NDVI,redIndex:0,nirIndex:2}
fString 'image' 可选 请求返回格式,html或image
formatModeString 'normal' 可选 生成参数格式,normal: 按照默认逻辑设置参数,replace: 将部分参数设置为可替换的模版字符串
-
getLegend(options){Promise.<Object>}
service/igs/ImageServer.js, line 151 -
获取图例,后端接口:/igs/rest/services/{serviceName}/ImageServer/legend
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
sizeString 15,15 可选 图例大小,格式:width,height
bandIdsString 无 可选 波段id列表
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Returns:
Type Description 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); }); -
getRasterValue(options){Promise.<Object>}
service/igs/ImageServer.js, line 204 -
获取栅格值,后端接口:/igs/rest/services/{serviceName}/ImageServer/rasterValue
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
xNumber 0 可选 将查询的地理位置的x坐标值,必填
yNumber 0 可选 将查询的地理位置的y坐标值,必填
Returns:
Type Description 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); }); -
getStatistics(options){Promise.<Object>}
service/igs/ImageServer.js, line 261 -
获取统计信息,后端接口:/igs/rest/services/{serviceName}/ImageServer/statistics
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Returns:
Type Description 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); }); -
getTile(options){String}
service/igs/ImageServer.js, line 470 -
根据IGS版本获取出图地址,会根据IGS版本挑选出图参数
Name Type Description optionsObject 出图参数
Name Type Default Description lvlString | Number '{z}' 可选 瓦片级数
rowString | Number '{y}' 可选 瓦片行号
colString | Number '{x}' 可选 瓦片列号
fString 'image' 可选 请求返回格式,支持html和image,IGS2.0参数
blankTileBoolean true 可选 当没有瓦片数据时,是否返回空白图,IGS2.0参数
Returns:
Type Description String 出图地址,格式为: IGS2.0: http://{ip}:{port}/igs/rest/services/{服务名称}/ImageServer/{z}/{y}/{x}?f=image&blankTile=true -
queryImageInfo(options){Promise.<Object>}
service/igs/ImageServer.js, line 31 -
获取栅格数据信息 后端接口:/igs/rest/services/{serviceName}/ImageServer/info
Name Type Description options查询参数
Name Type Default Description methodString FetchMethod.get 可选 请求类型
successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Returns:
Type Description 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); }); -
inherited queryServerInfo(options)
service/BaseServer.js, line 151 -
获取服务信息,IGS2.0新增服务
Name Type Description options查询参数
Name Type Default Description successfunction 无 可选 查询成功回调函数,若使用Promise方式则不必填写
failurefunction 无 可选 查询失败回调函数,若使用Promise方式则不必填写
Examples
获取服务信息-回调方式
server.queryServerInfo({ success: function (result) { console.log('请求成功:', result); }, failure: function (result) { console.log('请求失败:', result); } });获取服务信息-promise方式
server.queryServerInfo({ }) .then(function (result) { console.log('请求成功:', result); }).catch(function (result) { console.log('请求失败:', result); });