类名 GeometryServer

# new GeometryServer(options)

地理几何服务

参数:

名称 类型 默认值 描述
options Object

构造参数

url String

服务基地址

示例
// 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;
    }
  }
});

继承关系

成员变量

Boolean

# clientId

客户端id

Inherited From:
Boolean

# enableGlobeFetch

是否使用确据唯一的fetch对象,默认为true,当设为false时,会使用自己私有的fetch对象,所有的请求设置不会影响全局

Inherited From:
示例
//设置请求基地址
// 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;
String

# headers

请求头参数

Inherited From:
示例
//设置请求头参数
// 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';
function

# requestInterceptor

请求发送拦截器

Inherited From:
示例
//设置拦截器,任何一个继承自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() {};
String

# requestTimeout

请求超时时间,默认45000ms,即45s

Inherited From:
示例
//设置超时时间
//初始化AddressServer服务对象
// ES5引入方式
const { BaseServer } = zondy.service
// ES6引入方式
import { BaseServer } from "@mapgis/webclient-common"
let BaseServer = new BaseServer({
  //超时时间
  requestTimeout: 2000
});
//动态修改
BaseServer.requestTimeout = 3000;
function

# responseInterceptor

请求响应拦截器

Inherited From:
示例
//设置拦截器,任何一个继承自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() {};
TokenAttachType

# tokenAttachType

指定token附加到何处

Inherited From:
示例
//设置token值
// ES5引入方式
const { BaseServer } = zondy.service
const { TokenAttachType } = zondy.enum
// ES6引入方式
import { BaseServer,TokenAttachType } from "@mapgis/webclient-common"
let BaseServer = new BaseServer({
  //token名
  tokenValue: '你的token值',
  //token值
  tokenValue: '你的token值',
  //指定token附加到url后面
  tokenAttachType: TokenAttachType.url
});
//动态修改
BaseServer.tokenAttachType = TokenAttachType.header;
String

# tokenKey

token名

Inherited From:
示例
//设置token名
// ES5引入方式
const { BaseServer } = zondy.service
// ES6引入方式
import { BaseServer } from "@mapgis/webclient-common"
let BaseServer = new BaseServer({
  //token名
  tokenKey: '你的tokenKey'
});
//动态修改
BaseServer.tokenKey = '新tokenKey';
String

# tokenValue

token值

Inherited From:
示例
//设置token值
// ES5引入方式
const { BaseServer } = zondy.service
// ES6引入方式
import { BaseServer } from "@mapgis/webclient-common"
let BaseServer = new BaseServer({
  //token值
  tokenValue: '你的token值'
});
//动态修改
BaseServer.tokenValue = '新token值';
String

# url

服务基地址

Inherited From:
示例
//设置请求基地址
// ES5引入方式
const { BaseServer } = zondy.service
// ES6引入方式
import { BaseServer } from "@mapgis/webclient-common"
let BaseServer = new BaseServer({
  //请求基地址
  url: '你的URL'
});
//动态修改
BaseServer.url = '新URL';

方法

# bufferAnalyse(options)

缓冲分析

参数:

名称 类型 描述
options

查询参数

polygon Polygon

要计算的多边形

distance Number

缓冲半径

success function

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

failure function

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

示例
// 回调方式
// 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)

计算面积

参数:

名称 类型 描述
options

查询参数

polygon Polygon

要计算的多边形,必填

success function

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

failure function

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

projectInfo ProjectInfo

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

projectInfoBySrsID ProjectInfoBySrsID

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

# calculateAreasAndLengths(options)

计算面积和周长

参数:

名称 类型 描述
options

查询参数

polygons Polygon

要计算的多边形,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

求差计算

参数:

名称 类型 描述
options

查询参数

geometry1 Geometry

要计算的多边形1,必填

geometry2 Geometry

要计算的多边形2,必填

tolerance Number

容差,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

求距离

参数:

名称 类型 描述
options

查询参数

geometry1 Geometry

要计算的多边形1,必填

geometry2 Geometry

要计算的多边形2,必填

srs Geometry

参考系,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

求交计算

参数:

名称 类型 描述
options

查询参数

geometry1 Geometry

要计算的多边形1,必填

geometry2 Geometry

要计算的多边形2,必填

tolerance Number

容差,必填

success function

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

failure function

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

示例
// 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)

求label点

参数:

名称 类型 描述
options

查询参数

polygons Polygon

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

success function

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

failure function

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

示例
// 回调方式
// 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)

计算长度

参数:

名称 类型 描述
options

查询参数

lineString LineString

要计算的线,必填

success function

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

failure function

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

projectInfo ProjectInfo

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

projectInfoBySrsID ProjectInfoBySrsID

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

# calculateLengths(options)

求长度

参数:

名称 类型 描述
options

查询参数

lineString LineString | MultiLineString

要计算的线,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

计算拓扑关系

参数:

名称 类型 描述
options

查询参数

geometry1 Geometry

要计算的多边形1,必填

geometry2 Geometry

要计算的多边形2,必填

tolerance Number

容差,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

求并

参数:

名称 类型 描述
options

查询参数

geometry1 Geometry

要计算的多边形1,必填

geometry2 Geometry

要计算的多边形2,必填

tolerance Number

容差,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

几何投影

参数:

名称 类型 描述
options

查询参数

geometries Geometry

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

inSrs String

原始参考系,必填

outSrs String

目标参考系,必填

success function

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

failure function

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

示例
// 回调方式
// 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)

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

参数:

名称 类型 描述
options

查询参数

gdbsvrName String

数据源名称,必填

gdbName String

地理数据库名称,必填

srefID String

源投影参考系ID,必填

desfID String

目的投影参考系ID,必填

extent Extent

矩形范围,必填

failure function

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

userName String

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

password String

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

# queryServerInfo(options)

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

参数:

名称 类型 默认值 描述
options

查询参数

success function

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

failure function

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

Inherited From:
示例

获取服务信息-回调方式

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)

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

参数:

名称 类型 描述
options

查询参数

type Number

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

lineString LineString

要计算的线几何,必填

success function

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

failure function

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

tolerance Number

step

构造函数
成员变量
方法
事件