Class: GeometryServer

GeometryServer

new GeometryServer(options)

service/igs/GeometryServer.js, line 5

地理几何服务

Name Type Description
options Object

构造参数

Name Type Default Description
url String null 可选

服务基地址
IGS1.0: http://{ip}:{port}/igs/rest/mrgs/geomservice
IGS2.0: http://{ip}:{port}/igs/rest/services/system/GeometryServer

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;
    }
  }
});

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

bufferAnalyse(options)

service/igs/GeometryServer.js, line 351

缓冲分析

Name Type Description
options

查询参数

Name Type Description
polygon Polygon 可选

要计算的多边形

distance Number 可选

缓冲半径

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateArea(options)

service/igs/GeometryServer.js, line 136

计算面积

Name Type Description
options

查询参数

Name Type Description
polygon Polygon 可选

要计算的多边形,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用Promise方式则不必填写

projectInfo ProjectInfo 可选

投影参考信息,projectInfo或projectInfoBySrsID二选一

projectInfoBySrsID ProjectInfoBySrsID 可选

源投影参考系ID,projectInfo或projectInfoBySrsID二选一

calculateAreasAndLengths(options)

service/igs/GeometryServer.js, line 98

计算面积和周长

Name Type Description
options

查询参数

Name Type Description
polygons Polygon 可选

要计算的多边形,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateDifference(options)

service/igs/GeometryServer.js, line 460

求差计算

Name Type Description
options

查询参数

Name Type Description
geometry1 Geometry 可选

要计算的多边形1,必填

geometry2 Geometry 可选

要计算的多边形2,必填

tolerance Number 可选

容差,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateDistance(options)

service/igs/GeometryServer.js, line 548

求距离

Name Type Description
options

查询参数

Name Type Description
geometry1 Geometry 可选

要计算的多边形1,必填

geometry2 Geometry 可选

要计算的多边形2,必填

srs Geometry 可选

参考系,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateIntersect(options)

service/igs/GeometryServer.js, line 631

求交计算

Name Type Description
options

查询参数

Name Type Description
geometry1 Geometry 可选

要计算的多边形1,必填

geometry2 Geometry 可选

要计算的多边形2,必填

tolerance Number 可选

容差,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateLabelPoints(options)

service/igs/GeometryServer.js, line 705

求label点

Name Type Description
options

查询参数

Name Type Description
polygons Polygon 可选

要计算的多边形,单区或多区几何,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateLength(options)

service/igs/GeometryServer.js, line 191

计算长度

Name Type Description
options

查询参数

Name Type Description
lineString LineString 可选

要计算的线,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用Promise方式则不必填写

projectInfo ProjectInfo 可选

投影参考信息,projectInfo或projectInfoBySrsID二选一

projectInfoBySrsID ProjectInfoBySrsID 可选

源投影参考系ID,projectInfo或projectInfoBySrsID二选一

calculateLengths(options)

service/igs/GeometryServer.js, line 772

求长度

Name Type Description
options

查询参数

Name Type Description
lineString LineString | MultiLineString 可选

要计算的线,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateTopologyRelation(options)

service/igs/GeometryServer.js, line 926

计算拓扑关系

Name Type Description
options

查询参数

Name Type Description
geometry1 Geometry 可选

要计算的多边形1,必填

geometry2 Geometry 可选

要计算的多边形2,必填

tolerance Number 可选

容差,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

calculateUnion(options)

service/igs/GeometryServer.js, line 1097

求并

Name Type Description
options

查询参数

Name Type Description
geometry1 Geometry 可选

要计算的多边形1,必填

geometry2 Geometry 可选

要计算的多边形2,必填

tolerance Number 可选

容差,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

geometryProject(options)

service/igs/GeometryServer.js, line 843

几何投影

Name Type Description
options

查询参数

Name Type Description
geometries Geometry 可选

要计算的投影几何对象,必填

inSrs String 可选

原始参考系,必填

outSrs String 可选

目标参考系,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
})

projectInExtent(options)

service/igs/GeometryServer.js, line 249

对矩形范围坐标点进行投影转换

Name Type Description
options

查询参数

Name Type Description
gdbsvrName String 可选

数据源名称,必填

gdbName String 可选

地理数据库名称,必填

srefID String 可选

源投影参考系ID,必填

desfID String 可选

目的投影参考系ID,必填

extent Extent 可选

矩形范围,必填

failure function 可选

查询失败回调函数,若使用Promise方式则不必填写

userName String 可选

地理数据源/地理数据库账户名

password String 可选

地理数据源/地理数据库密码

inherited queryServerInfo(options)

service/BaseServer.js, line 151

获取服务信息,IGS2.0新增服务

Name Type Description
options

查询参数

Name Type Default Description
success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用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);
});

smoothLineString(options)

service/igs/GeometryServer.js, line 1028

计算光滑曲线,igs1.0服务

Name Type Description
options

查询参数

Name Type Description
type Number 可选

插值方式,0为二次样条、1为三次样条、2为三次Beizer样条、3为三次B样条,必填

lineString LineString 可选

要计算的线几何,必填

success function 可选

查询成功回调函数,若使用Promise方式则不必填写

failure function 可选

查询失败回调函数,若使用Promise方式则不必填写

tolerance Number 可选

step