Skip to content

Commit 60a56eb

Browse files
author
潘卓然Y7000P
committed
【SDK】【新增】【实现DataStore的数据库查询功能】
1 parent eb3b6a0 commit 60a56eb

10 files changed

Lines changed: 204 additions & 23 deletions

File tree

src/service/datastore/ServiceBase.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class DataStoreService extends ServiceBase {
2121
delete this.params.port;
2222
delete this.params.domain;
2323
delete this.params.baseUrl;
24-
delete this.params.protocol;
24+
delete this.params.networkProtocol;
2525
delete this.params.partUrl;
2626
}
2727

@@ -31,13 +31,13 @@ export class DataStoreService extends ServiceBase {
3131
*/
3232
getBaseUrl() {
3333
let url = '';
34-
const { baseUrl, ip, port, domain, protocol } = this;
34+
const { baseUrl, ip, port, domain, networkProtocol } = this;
3535
if (baseUrl) {
3636
url = baseUrl;
3737
} else if (domain) {
3838
url = domain;
39-
} else if (protocol && ip && port) {
40-
url = `${protocol}://${ip}:${port}`;
39+
} else if (networkProtocol && ip && port) {
40+
url = `${networkProtocol}://${ip}:${port}`;
4141
}
4242
return url;
4343
}

src/service/datastore/ServiceParameter.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@ import { Zondy } from '../common/Base';
22

33
/**
44
* @author 创新中心-潘卓然
5-
* @class module:PostGIS.ServiceParameter
5+
* @class module:DataStore.ServiceParameter
66
* @param option - {Object} 查询条件
77
* @param {string} [option.domain=null] dataStore服务地址域名 (domain和[protocol,ip,port],二选一)
88
* @param {string} [option.protocol="http"] dataStore服务地址网络协议 (domain和[protocol,ip,port],二选一)
99
* @param {string} [option.ip =null] dataStore服务地址ip (domain和[protocol,ip,port],二选一)
1010
* @param {string} [option.port=null] dataStore服务地址port (domain和[protocol,ip,port],二选一)
11-
* @param {String} [option.pageSize = 10] 每页大小。默认10
11+
* @param {String} [option.pageSize = 100] 每页大小。默认10
1212
* @param {String} [option.pageNo] 页码,从1开始
1313
*/
1414
export class ServiceParameter {
1515
constructor(option) {
1616
/**
17-
* @member module:PostGIS.ServiceParameter.prototype.domain
17+
* @member module:DataStore.ServiceParameter.prototype.domain
1818
* @description 域地址
1919
*/
2020
this.domain = option.domain;
2121
/**
22-
* @member module:PostGIS.ServiceParameter.prototype.protocol
22+
* @member module:DataStore.ServiceParameter.prototype.protocol
2323
* @description 网络协议
2424
*/
2525
this.protocol = option.protocol;
2626
/**
27-
* @member module:PostGIS.ServiceParameter.prototype.ip
27+
* @member module:DataStore.ServiceParameter.prototype.ip
2828
* @description IP地址
2929
*/
3030
this.ip = option.ip;
3131
/**
32-
* @member module:PostGIS.ServiceParameter.prototype.port
32+
* @member module:DataStore.ServiceParameter.prototype.port
3333
* @description 端口
3434
*/
3535
this.port = option.port;
3636
/**
37-
* @member module:PostGIS.ServiceParameter.prototype.pageSize
37+
* @member module:DataStore.ServiceParameter.prototype.pageSize
3838
* @description 页大小
3939
*/
40-
this.pageSize = option.pageSize || 10;
40+
this.pageSize = option.pageSize || 100;
4141
/**
42-
* @member module:PostGIS.ServiceParameter.prototype.pageNo
42+
* @member module:DataStore.ServiceParameter.prototype.pageNo
4343
* @description 页数量
4444
*/
45-
this.pageNo = option.pageNo;
45+
this.pageNo = option.pageNo || 1;
4646
}
4747
}
4848

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Zondy } from '../../common/Base';
2+
import BaseQueryParameter from '../ServiceParameter';
3+
4+
/**
5+
* @author 创新中心-潘卓然
6+
* @class module:弹性搜索服务.EsGeocodeParameter
7+
* @param gdbp 发布在igs上的pg图层gdbp地址,可以从中解析libName(数据库名)、schemas(工作空间名)、tableName(表名)
8+
* @param option - {Object} 查询条件
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 的坐标系为此坐标系
15+
*/
16+
export class EsGeocodeParameter extends BaseQueryParameter {
17+
constructor(option) {
18+
super(option);
19+
/**
20+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.includeProperites
21+
* @description 查询结果中是否包含属性
22+
* @type Boolean
23+
* @default true
24+
*/
25+
this.includeProperites = option.includeProperites;
26+
/**
27+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.where
28+
* @description 属性条件 (例如:id>5,id<10)
29+
* @type String
30+
*/
31+
this.where = option.where;
32+
/**
33+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.fields
34+
* @description 统计计算中用于分组字段名列表
35+
* @type String
36+
*/
37+
this.fields = option.fields;
38+
/**
39+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.geometry
40+
* @description 几何信息,圆、多边形等
41+
* @type String
42+
*/
43+
this.geometry = option.geometry;
44+
/**
45+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.geoFormat
46+
* @description 几何类型,wkt、wkb、geojson、自定义等
47+
* @type String
48+
*/
49+
this.geoFormat = option.geoFormat;
50+
/**
51+
* @member module:弹性搜索服务.EsGeocodeParameter.prototype.sref
52+
* @description 动态投影坐标系 ID,支持 MapGIS 和 EPSG 标准编号,
53+
* 其中 MapGIS 只支持当前库中自带的坐标系的 ID,EPSG 标准请 使用 EPSG:4326 格式,
54+
* 若指定了该参数,则系统认为 geometry 的坐标系为此坐标系
55+
* @type String
56+
*/
57+
this.sref = option.sref;
58+
}
59+
}
60+
61+
export default EsGeocodeParameter;
62+
Zondy.DataStore.ElasticSearch.EsGeocodeParameter = EsGeocodeParameter;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { Zondy } from '../../common/Base';
2+
import { DataStoreService } from '../ServiceBase';
3+
4+
/**
5+
* @author 创新中心-潘卓然
6+
* @class module:弹性搜索服务.EsGeocodeService
7+
* @param gdbp 发布在igs上的pg图层gdbp地址,可以从中解析libName(数据库名)、schemas(工作空间名)、tableName(表名)
8+
* @param {EsGeocodeParameter} option 查询条件
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 的坐标系为此坐标系
15+
*/
16+
export default class EsGeocodeService extends DataStoreService {
17+
constructor(option) {
18+
super(option);
19+
20+
/**
21+
* @member module:弹性搜索服务.EsGeocodeService.prototype.includeProperites
22+
* @description 查询结果中是否包含属性
23+
* @type Boolean
24+
* @default true
25+
*/
26+
this.includeProperites = option.includeProperites;
27+
/**
28+
* @member module:弹性搜索服务.EsGeocodeService.prototype.where
29+
* @description 属性条件 (例如:id>5,id<10)
30+
* @type String
31+
*/
32+
this.where = option.where;
33+
/**
34+
* @member module:弹性搜索服务.EsGeocodeService.prototype.fields
35+
* @description 统计计算中用于分组字段名列表
36+
* @type String
37+
*/
38+
this.fields = option.fields;
39+
/**
40+
* @member module:弹性搜索服务.EsGeocodeService.prototype.geometry
41+
* @description 几何信息,圆、多边形等
42+
* @type String
43+
*/
44+
this.geometry = option.geometry;
45+
/**
46+
* @member module:弹性搜索服务.EsGeocodeService.prototype.geoFormat
47+
* @description 几何类型,wkt、wkb、geojson、自定义等
48+
* @type String
49+
*/
50+
this.geoFormat = option.geoFormat;
51+
/**
52+
* @member module:弹性搜索服务.EsGeocodeService.prototype.sref
53+
* @description 动态投影坐标系 ID,支持 MapGIS 和 EPSG 标准编号,
54+
* 其中 MapGIS 只支持当前库中自带的坐标系的 ID,EPSG 标准请 使用 EPSG:4326 格式,
55+
* 若指定了该参数,则系统认为 geometry 的坐标系为此坐标系
56+
* @type String
57+
*/
58+
this.sref = option.sref;
59+
}
60+
/**
61+
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
62+
* @function module:弹性搜索服务.EsGeocodeService.prototype.query
63+
* @param {Function} onSuccess 查询成功回调函数。
64+
* @param {Function} onError 查询失败回调函数。
65+
*/
66+
query(onSuccess, onError) {
67+
let { serviceUrl, options } = this;
68+
let url = this.getFullUrl(serviceUrl, options);
69+
this.get(url, onSuccess, onError);
70+
}
71+
}

src/service/datastore/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* @module DataStore
3+
*/
14
import { EsCatlogType, EsCatlogName, EsGeoHashType, EsCatlogService, EsTableService, EsSpaceTimeQueryByAgg } from './elasticsearch';
25

36
export { EsCatlogType, EsCatlogName, EsGeoHashType, EsCatlogService, EsTableService, EsSpaceTimeQueryByAgg };
7+
8+
import { PostgisCatlogService, PostgisCustomQueryService, PostgisQueryService, PostgisTableService, PostgisVectorTileService } from './postgis';
9+
10+
export { PostgisCatlogService, PostgisCustomQueryService, PostgisQueryService, PostgisTableService, PostgisVectorTileService };

src/service/datastore/postgis/PostgisCustomQueryService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class PostgisCustomQueryService extends DataStoreService {
1616
* @member module:PostGIS.PostgisCustomQueryService.prototype.serviceUrl
1717
* @description 服务地址
1818
*/
19-
this.serviceUrl = '/datastore/rest/dataset/pg/query';
19+
this.serviceUrl = '/datastore/rest/dataset/pg/executequery/';
2020
/**
2121
* @member module:PostGIS.PostgisCustomQueryService.prototype.path
2222
* @description 库名称

src/service/datastore/postgis/PostgisQueryService.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export class PostgisQueryService extends DataStoreService {
1919
this.serviceUrl = '/datastore/rest/dataset/pg/query/';
2020
/**
2121
* @member module:PostGIS.PostgisQueryService.prototype.path
22-
* @description 库名称/工作空间
22+
* @description 库名称/工作空间/表名称
23+
* @see 映射平台的pglink/hdf/layer
2324
*/
2425
this.path = option.path;
2526
/**
@@ -49,17 +50,19 @@ export class PostgisQueryService extends DataStoreService {
4950
/**
5051
* @member module:PostGIS.PostgisQueryService.prototype.fields
5152
* @description 统计计算中用于分组字段名列表,用逗号分隔
53+
* @see 该属性与segments冲突,不能同时存在
5254
*/
5355
this.fields = option.fields;
54-
5556
/**
5657
* @member module:PostGIS.PostgisQueryService.prototype.segments
5758
* @description 分段分组条件,如["银行<1000","银行 between 1000 and 4000"]
59+
* @see 该属性与fields冲突,不能同时存在
5860
*/
5961
this.segments = option.segments;
6062
/**
6163
* @member module:PostGIS.PostgisQueryService.prototype.statisticFields
6264
* @description Json格式,[field] 方法类型:count,min,max,mean,sum,variance(方差),stddev(标准差)
65+
* @see 激活属性统计信息后,由于一些特定的统计聚类函数,几何字段会丢失
6366
*/
6467
this.statisticFields = option.statisticFields;
6568
/**

src/service/datastore/postgis/PostgisVectorTileService.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class PostgisVectorTileService extends DataStoreService {
1919
* @member module:PostGIS.PostgisVectorTileService.prototype.serviceUrl
2020
* @description 服务地址
2121
*/
22-
this.serviceUrl = '/datastore/rest/dataset/pg/query/';
22+
this.serviceUrl = '/datastore/rest/dataset/pg/vectortile/';
2323
/**
2424
* @member module:PostGIS.PostgisVectorTileService.prototype.path
2525
* @description 库名称
@@ -61,6 +61,18 @@ export class PostgisVectorTileService extends DataStoreService {
6161
};
6262
}
6363

64+
/**
65+
* @function module:PostGIS.PostgisVectorTileService.prototype.getWmtsUrl
66+
* @description 获取实时矢量瓦片的WMTS的实时WMTS接口
67+
*/
68+
getWmtsUrl() {
69+
let { serviceUrl, path, option } = this;
70+
serviceUrl += path;
71+
let url = this.getFullUrl(serviceUrl, option);
72+
url = decodeURI(url);
73+
return url;
74+
}
75+
6476
/**
6577
* @description 查询函数,向服务器发送请求,返回地名地址格式数据
6678
* @function module:PostGIS.PostgisVectorTileService.prototype.query
@@ -69,7 +81,7 @@ export class PostgisVectorTileService extends DataStoreService {
6981
*/
7082
query(onSuccess, onError) {
7183
let { serviceUrl, path, option } = this;
72-
serviceUrl += path;
84+
serviceUrl += path;
7385
let url = this.getFullUrl(serviceUrl, option);
7486
this.get(url, onSuccess, onError);
7587
}

src/service/index.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ import {
250250
QueryLayerFeature,
251251
QueryParameter,
252252
QueryParameterBase,
253-
QueryServiceBase
253+
QueryServiceBase,
254+
QueryUnifyParameter
254255
} from './MRFS';
255256

256257
export const MRFS = {
@@ -268,7 +269,8 @@ export const MRFS = {
268269
QueryLayerFeature,
269270
QueryParameter,
270271
QueryParameterBase,
271-
QueryServiceBase
272+
QueryServiceBase,
273+
QueryUnifyParameter
272274
};
273275

274276
import {
@@ -423,7 +425,31 @@ export const OGC = {
423425
OGCWMSInfo
424426
};
425427

426-
import { EsCatlogType, EsCatlogName, EsGeoHashType, EsCatlogService, EsTableService, EsSpaceTimeQueryByAgg } from './datastore';
428+
import { EsCatlogType, EsCatlogName, EsGeoHashType, EsCatlogService, EsTableService, EsSpaceTimeQueryByAgg } from './datastore/elasticsearch';
429+
import {
430+
PostgisCatlogService,
431+
PostgisCustomQueryService,
432+
PostgisQueryService,
433+
PostgisTableService,
434+
PostgisVectorTileService
435+
} from './datastore/postgis';
436+
437+
export const ElasticSearch = {
438+
EsCatlogType,
439+
EsCatlogName,
440+
EsGeoHashType,
441+
EsCatlogService,
442+
EsTableService,
443+
EsSpaceTimeQueryByAgg
444+
};
445+
446+
export const PostGIS = {
447+
PostgisCatlogService,
448+
PostgisCustomQueryService,
449+
PostgisQueryService,
450+
PostgisTableService,
451+
PostgisVectorTileService
452+
};
427453

428454
export const DataStore = {
429455
EsCatlogType,

src/service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mapgis/webclient-es6-service",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "中地数码基于ES6语法针对igserver的服务封装",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)