@@ -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 */
1611export 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}
0 commit comments