Skip to content

Commit c7b0953

Browse files
author
潘卓然Y7000P
committed
【SDK】【新增】【新增Datastore/Postgis的五类查询接口】
1 parent 0f37f41 commit c7b0953

6 files changed

Lines changed: 343 additions & 39 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { Zondy } from '../../common/Base';
2+
import { DataStoreService } from '../ServiceBase';
3+
4+
/**
5+
* @author 创新中心-潘卓然
6+
* @class module:PostGIS.PostgisCatlogService
7+
* @param {PostgisQueryParameter} option 查询条件
8+
* @param {String} [option.path] 库名称
9+
* @param {Boolean} [option.classify = true] 类别,地址库、时空库等
10+
* @param {String} [option.keyWords] 关键字
11+
*/
12+
export class PostgisCatlogService extends DataStoreService {
13+
constructor(option) {
14+
super(option);
15+
16+
/**
17+
* @member module:PostGIS.PostgisCatlogService.prototype.serviceUrl
18+
* @description 服务地址
19+
*/
20+
this.serviceUrl = '/datastore/rest/catalog/pg/services/';
21+
/**
22+
* @member module:PostGIS.PostgisCatlogService.prototype.path
23+
* @description 库名称
24+
*/
25+
this.path = option.path;
26+
/**
27+
* @member module:PostGIS.PostgisCatlogService.prototype.classify
28+
* @description 类别,地址库、时空库等
29+
*/
30+
this.classify = option.classify;
31+
/**
32+
* @member module:PostGIS.PostgisCatlogService.prototype.keyWords
33+
* @description 关键字
34+
*/
35+
this.keyWords = option.keyWords;
36+
37+
this.fixOption(option);
38+
}
39+
40+
/**
41+
* @private 修正get/post需要的真正参数
42+
*/
43+
fixOption(option) {
44+
this.option = {
45+
classify: option.classify,
46+
keyWords: option.keyWords,
47+
pageSize: option.pageSize,
48+
pageNo: option.pageNo
49+
};
50+
}
51+
52+
/**
53+
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
54+
* @function module:PostGIS.PostgisCatlogService.prototype.query
55+
* @param {Function} onSuccess 查询成功回调函数。
56+
* @param {Function} onError 查询失败回调函数。
57+
*/
58+
query(onSuccess, onError) {
59+
let { serviceUrl, path, option } = this;
60+
serviceUrl += path;
61+
let url = this.getFullUrl(serviceUrl, option);
62+
this.get(url, onSuccess, onError);
63+
}
64+
}
65+
66+
export default PostgisCatlogService;
67+
Zondy.DataStore.PostGIS.PostgisCatlogService = PostgisCatlogService;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Zondy } from '../../common/Base';
2+
import { DataStoreService } from '../ServiceBase';
3+
4+
/**
5+
* @author 创新中心-潘卓然
6+
* @class module:PostGIS.PostgisCustomQueryService
7+
* @param {PostgisQueryParameter} option 查询条件
8+
* @param {String} [option.path] 库名称
9+
* @param {String} [option.queryBody] 查询sql语句,如:select * from hunan01.dltb2005 where 地类编码 == 1011 limit 1
10+
*/
11+
export class PostgisCustomQueryService extends DataStoreService {
12+
constructor(option) {
13+
super(option);
14+
15+
/**
16+
* @member module:PostGIS.PostgisCustomQueryService.prototype.serviceUrl
17+
* @description 服务地址
18+
*/
19+
this.serviceUrl = '/datastore/rest/dataset/pg/query';
20+
/**
21+
* @member module:PostGIS.PostgisCustomQueryService.prototype.path
22+
* @description 库名称
23+
*/
24+
this.path = option.path;
25+
/**
26+
* @member module:PostGIS.PostgisCustomQueryService.prototype.queryBody
27+
* @description 查询sql语句,如:
28+
* select * from hunan01.dltb2005 where 地类编码 == 1011 limit 1
29+
*/
30+
this.queryBody = option.queryBody;
31+
32+
this.fixOption(option);
33+
}
34+
35+
/**
36+
* @private 修正get/post需要的真正参数
37+
*/
38+
fixOption(option) {
39+
this.option = {
40+
queryBody: option.queryBody
41+
};
42+
}
43+
44+
/**
45+
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
46+
* @function module:PostGIS.PostgisCustomQueryService.prototype.query
47+
* @param {Function} onSuccess 查询成功回调函数。
48+
* @param {Function} onError 查询失败回调函数。
49+
*/
50+
query(onSuccess, onError) {
51+
let { serviceUrl, path, option } = this;
52+
serviceUrl += path;
53+
let url = this.getFullUrl(serviceUrl, option);
54+
this.get(url, onSuccess, onError);
55+
}
56+
}
57+
58+
export default PostgisCustomQueryService;
59+
Zondy.DataStore.PostGIS.PostgisCustomQueryService = PostgisCustomQueryService;

src/service/datastore/postgis/PostgisQueryService.js

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,109 @@ import { DataStoreService } from '../ServiceBase';
55
* @author 创新中心-潘卓然
66
* @class module:PostGIS.PostgisQueryService
77
* @param {PostgisQueryParameter} option 查询条件
8-
* @param {String} [option.gdbp] 发布在igs上的pg图层gdbp地址,可以从中解析libName(数据库名)、schemas(工作空间名)、tableName(表名)
9-
* @param {Boolean} [option.includeProperites = true] 查询结果中是否包含属性
10-
* @param {String} [option.where] 属性条件 (例如:id>5,id<10)
11-
* @param {String} [option.fields] 统计计算中用于分组字段名列表
12-
* @param {String} [option.geometry] 几何信息,圆、多边形等
13-
* @param {String} [option.geoFormat="wkt"] 几何类型,wkt、wkb、geojson、自定义等
14-
* @param {String} [option.sref] 动态投影坐标系 ID,支持 MapGIS 和 EPSG 标准编号,其中 MapGIS 只支持当前库中自带的坐标系的 ID,EPSG 标准请 使用 EPSG:4326 格式,若指定了该参数,则系统认为 geometry 的坐标系为此坐标系
8+
* @param {String} option.path 库名称/工作空间
9+
* @param {String} option.tableNames 表名,多个用逗号分隔,如:X431102TDXZ2005GDLTB,dltb2005
1510
*/
1611
export class PostgisQueryService extends DataStoreService {
1712
constructor(option) {
1813
super(option);
1914

2015
/**
21-
* @member module:PostGIS.PostgisQueryService.prototype.gdbp
22-
* @description 发布在igs上的pg图层gdbp地址,可以从中解析libName(数据库名)、schemas(工作空间名)、tableName(表名)
23-
* @type String
16+
* @member module:PostGIS.PostgisQueryService.prototype.serviceUrl
17+
* @description 服务地址
2418
*/
25-
this.gdbp = option.gdbp;
19+
this.serviceUrl = '/datastore/rest/dataset/pg/query';
2620
/**
27-
* @member module:PostGIS.PostgisQueryService.prototype.includeProperites
28-
* @description 查询结果中是否包含属性
29-
* @type Boolean
30-
* @default true
21+
* @member module:PostGIS.PostgisQueryService.prototype.path
22+
* @description 库名称/工作空间
3123
*/
32-
this.includeProperites = option.includeProperites;
24+
this.path = option.path;
25+
/**
26+
* @member module:PostGIS.PostgisQueryService.prototype.geometry
27+
* @description 几何信息,wkt、geojson、自定义等字符串
28+
*/
29+
this.geometry = option.geometry;
30+
/**
31+
* @member module:PostGIS.PostgisQueryService.prototype.geoFormat
32+
* @description 几何类型,支持wkt、geojson、circle、rect四种,
33+
* 其中当为circle时,geometry格式为:x坐标,y坐标,半径;
34+
* 当为rect时,geometry格式为:xmin,ymin,xmax,ymax
35+
*/
36+
this.geoFormat = option.geoFormat;
37+
/**
38+
* @member module:PostGIS.PostgisQueryService.prototype.sref
39+
* @description 动态投影坐标系ID,支持MapGIS和EPSG标准编号,
40+
* 其中MapGIS只支持当前库中自带的坐标系的ID,EPSG标准请使用EPSG:4326格式,
41+
* 若指定了该参数,则系统认为geometry的坐标系为此坐标系
42+
*/
43+
this.sref = option.sref;
3344
/**
34-
* @member module:PostGIS.PostgisQueryService.prototype.where
45+
* @member module:PostGIS.PostgisQueryService.prototype.filter
3546
* @description 属性条件 (例如:id>5,id<10)
36-
* @type String
3747
*/
38-
this.where = option.where;
48+
this.filter = option.filter;
3949
/**
4050
* @member module:PostGIS.PostgisQueryService.prototype.fields
41-
* @description 统计计算中用于分组字段名列表
42-
* @type String
51+
* @description 统计计算中用于分组字段名列表,用逗号分隔
4352
*/
4453
this.fields = option.fields;
54+
4555
/**
46-
* @member module:PostGIS.PostgisQueryService.prototype.geometry
47-
* @description 几何信息,圆、多边形等
48-
* @type String
56+
* @member module:PostGIS.PostgisQueryService.prototype.segments
57+
* @description 分段分组条件,如["银行<1000","银行 between 1000 and 4000"]
4958
*/
50-
this.geometry = option.geometry;
59+
this.segments = option.segments;
5160
/**
52-
* @member module:PostGIS.PostgisQueryService.prototype.geoFormat
53-
* @description 几何类型,wkt、wkb、geojson、自定义等
54-
* @type String
61+
* @member module:PostGIS.PostgisQueryService.prototype.statisticFields
62+
* @description Json格式,[field] 方法类型:count,min,max,mean,sum,variance(方差),stddev(标准差)
5563
*/
56-
this.geoFormat = option.geoFormat;
64+
this.statisticFields = option.statisticFields;
5765
/**
58-
* @member module:PostGIS.PostgisQueryService.prototype.sref
59-
* @description 动态投影坐标系 ID,支持 MapGIS 和 EPSG 标准编号,
60-
* 其中 MapGIS 只支持当前库中自带的坐标系的 ID,EPSG 标准请 使用 EPSG:4326 格式,
61-
* 若指定了该参数,则系统认为 geometry 的坐标系为此坐标系
62-
* @type String
66+
* @member module:PostGIS.PostgisQueryService.prototype.includeProperites
67+
* @description 返回结果是否包含属性
68+
* @default false
6369
*/
64-
this.sref = option.sref;
70+
this.includeProperites = option.includeProperites;
71+
/**
72+
* @member module:PostGIS.PostgisQueryService.prototype.includeGeometry
73+
* @description 返回结果是否包含几何
74+
* @default true*
75+
*/
76+
this.includeGeometry = option.includeGeometry;
77+
78+
this.fixOption(option);
6579
}
80+
81+
/**
82+
* @private 修正get/post需要的真正参数
83+
*/
84+
fixOption(option) {
85+
this.option = {
86+
geometry: option.geometry,
87+
geoFormat: option.geoFormat,
88+
sref: option.sref,
89+
filter: option.filter,
90+
fields: option.fields,
91+
segments: option.segments,
92+
statisticFields: option.statisticFields,
93+
includeProperites: option.includeProperites,
94+
propertyNames: option.propertyNames,
95+
includeGeometry: option.includeGeometry,
96+
pageSize: option.pageSize,
97+
pageNo: option.pageNo
98+
};
99+
}
100+
66101
/**
67102
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
68103
* @function module:PostGIS.PostgisQueryService.prototype.query
69104
* @param {Function} onSuccess 查询成功回调函数。
70105
* @param {Function} onError 查询失败回调函数。
71106
*/
72107
query(onSuccess, onError) {
73-
let { serviceUrl, options } = this;
74-
let url = this.getFullUrl(serviceUrl, options);
108+
let { serviceUrl, path, option } = this;
109+
serviceUrl += path;
110+
let url = this.getFullUrl(serviceUrl, option);
75111
this.get(url, onSuccess, onError);
76112
}
77113
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Zondy } from '../../common/Base';
2+
import { DataStoreService } from '../ServiceBase';
3+
4+
/**
5+
* @author 创新中心-潘卓然
6+
* @class module:PostGIS.PostgisTableService
7+
* @param {PostgisQueryParameter} option 查询条件
8+
* @param {String} option.path 库名称/工作空间
9+
* @param {String} option.tableNames 表名,多个用逗号分隔,如:X431102TDXZ2005GDLTB,dltb2005
10+
*/
11+
export class PostgisTableService extends DataStoreService {
12+
constructor(option) {
13+
super(option);
14+
15+
/**
16+
* @member module:PostGIS.PostgisTableService.prototype.serviceUrl
17+
* @description 服务地址
18+
*/
19+
this.serviceUrl = '/datastore/rest/dataset/pg/schema/';
20+
/**
21+
* @member module:PostGIS.PostgisTableService.prototype.path
22+
* @description 库名称/工作空间
23+
*/
24+
this.path = option.path;
25+
/**
26+
* @member module:PostGIS.PostgisTableService.prototype.tableNames
27+
* @description 表名,多个用逗号分隔,如:X431102TDXZ2005GDLTB,dltb2005
28+
*/
29+
this.tableNames = option.tableNames;
30+
31+
this.fixOption(option);
32+
}
33+
34+
/**
35+
* @private 修正get/post需要的真正参数
36+
*/
37+
fixOption(option) {
38+
this.option = {
39+
tableNames: option.tableNames,
40+
pageSize: option.pageSize,
41+
pageNo: option.pageNo
42+
};
43+
}
44+
45+
/**
46+
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
47+
* @function module:PostGIS.PostgisTableService.prototype.query
48+
* @param {Function} onSuccess 查询成功回调函数。
49+
* @param {Function} onError 查询失败回调函数。
50+
*/
51+
query(onSuccess, onError) {
52+
let { serviceUrl, path, option } = this;
53+
serviceUrl += path;
54+
let url = this.getFullUrl(serviceUrl, option);
55+
this.get(url, onSuccess, onError);
56+
}
57+
}
58+
59+
export default PostgisTableService;
60+
Zondy.DataStore.PostGIS.PostgisTableService = PostgisTableService;

0 commit comments

Comments
 (0)