@opengis/gis 0.1.78 → 0.1.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +4721 -1553
- package/dist/index.umd.cjs +54 -22
- package/module/gis/table/gis.registers.table.json +12 -3
- package/module/gis/table/gis.services.table.json +12 -28
- package/module/test/cls/doc_status.json +31 -31
- package/module/test/select/core.user_uid.sql +1 -1
- package/package.json +59 -61
- package/server/plugins/mapnik/funcs/map.proto +241 -241
- package/server/routes/gis/index.mjs +8 -0
- package/server/routes/gis/registers/add.registry.js +36 -0
- package/server/routes/gis/registers/del.registry.js +15 -0
- package/server/routes/gis/registers/funcs/handleRegistryRequest.js +29 -11
- package/server/routes/gis/registers/gis.registry.js +2 -2
- package/server/routes/gis/services/get.services.col.js +24 -0
- package/server/routes/map/vtile1.js +1 -1
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
message render_in {
|
|
5
|
-
string path = 1;
|
|
6
|
-
string name = 2;
|
|
7
|
-
repeated double bbox = 3 [packed=true];
|
|
8
|
-
string tile = 4;
|
|
9
|
-
string xml = 5;
|
|
10
|
-
int32 width = 6;
|
|
11
|
-
int32 height = 7;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
message render_out {
|
|
16
|
-
string err = 1;
|
|
17
|
-
string base64 = 2;
|
|
18
|
-
string tile = 3;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
message xml_in {
|
|
22
|
-
string path = 1;
|
|
23
|
-
string name = 2;
|
|
24
|
-
string xml = 3;
|
|
25
|
-
bool reload = 4;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
message xml_out {
|
|
29
|
-
string err = 1;
|
|
30
|
-
bool is_ok = 2;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
message cmd_in {
|
|
34
|
-
string cmd = 1;
|
|
35
|
-
string svg = 2;
|
|
36
|
-
string filename = 3;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
message cmd_out {
|
|
40
|
-
string err = 1;
|
|
41
|
-
string base64 = 2;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
message gdal_in {
|
|
45
|
-
string name = 1;
|
|
46
|
-
string path = 2;
|
|
47
|
-
string out = 3;
|
|
48
|
-
string params = 4;
|
|
49
|
-
}
|
|
50
|
-
message gdal_out {
|
|
51
|
-
string result = 1;
|
|
52
|
-
string err = 2;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
message clear_tiles_in {
|
|
56
|
-
string path = 1;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
message clear_tiles_out {
|
|
60
|
-
oneof clear_message {
|
|
61
|
-
bool ok = 1;
|
|
62
|
-
string err = 2;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
message empty {}
|
|
67
|
-
|
|
68
|
-
message statusRenderInfo {
|
|
69
|
-
string name = 1;
|
|
70
|
-
bool isActive = 2;
|
|
71
|
-
float workTime = 3;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
message statusInfo {
|
|
75
|
-
repeated statusRenderInfo info = 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
message printMapOut {
|
|
79
|
-
string map = 1;
|
|
80
|
-
string err = 2;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
message xyz {
|
|
84
|
-
float x = 1;
|
|
85
|
-
float y = 2;
|
|
86
|
-
float z = 3;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
message printMapIn {
|
|
90
|
-
string baseurl = 1;
|
|
91
|
-
string baseImg = 2;
|
|
92
|
-
repeated string xml = 3;
|
|
93
|
-
string overlayXml = 4;
|
|
94
|
-
string overlay = 5;
|
|
95
|
-
int32 width = 6;
|
|
96
|
-
int32 height = 7;
|
|
97
|
-
repeated double bbox = 8;
|
|
98
|
-
xyz pos = 9;
|
|
99
|
-
string geojsonSettings = 10;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
message log_in {
|
|
103
|
-
uint32 rows = 1;
|
|
104
|
-
string level = 2;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
message log_out {
|
|
108
|
-
repeated string logs = 1;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
message sqlToShpIn {
|
|
112
|
-
string db = 1;
|
|
113
|
-
string host = 2;
|
|
114
|
-
string port = 3;
|
|
115
|
-
string sql = 4;
|
|
116
|
-
string savePath = 5;
|
|
117
|
-
string shpName = 6;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
message shapeOut {
|
|
121
|
-
string zipPath = 1;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
message fileIn {
|
|
125
|
-
bytes fileBytes = 1;
|
|
126
|
-
string relativeFilepath = 2;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
message deleteFileIn {
|
|
130
|
-
string dir = 1;
|
|
131
|
-
repeated string objectList = 2;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
message fileManagerOut {
|
|
135
|
-
bool status = 1;
|
|
136
|
-
string operation = 2;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
message checkFilesDir {
|
|
140
|
-
string dir = 1;
|
|
141
|
-
repeated string filesSearch = 2;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
enum status {
|
|
145
|
-
LOADING = 0;
|
|
146
|
-
OK = 1;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
message filesStatus {
|
|
150
|
-
status fileLoadingStatus = 1;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
message fileListIn {
|
|
154
|
-
string dir = 1;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
message fileInfo {
|
|
158
|
-
repeated fileInfoL fileInfoList = 1;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
message fileInfoL {
|
|
162
|
-
oneof fileInfo {
|
|
163
|
-
fileInfoObj file = 1;
|
|
164
|
-
dirInfoObj dir = 2;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
message fileInfoObj {
|
|
169
|
-
string type = 1;
|
|
170
|
-
string birthtime = 2;
|
|
171
|
-
string name = 3;
|
|
172
|
-
uint64 size = 4;
|
|
173
|
-
string ext = 5;
|
|
174
|
-
string server = 6;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
message dirInfoObj {
|
|
178
|
-
string type = 1;
|
|
179
|
-
string birthtime = 2;
|
|
180
|
-
string name = 3;
|
|
181
|
-
uint64 size = 4;
|
|
182
|
-
uint64 count = 5;
|
|
183
|
-
string server = 6;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
message deleteOut {
|
|
187
|
-
repeated deleteObjSuccess success = 1;
|
|
188
|
-
repeated deleteObjError error = 2;
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
message deleteObjSuccess {
|
|
193
|
-
string object = 1;
|
|
194
|
-
string type = 2;
|
|
195
|
-
string status = 3;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
message deleteObjError {
|
|
199
|
-
string object = 1;
|
|
200
|
-
string fullPath = 2;
|
|
201
|
-
string result = 3;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
message readDirIn {
|
|
205
|
-
string dir = 1;
|
|
206
|
-
repeated string filter = 2;
|
|
207
|
-
string fullPath = 3;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
message readDirOut {
|
|
211
|
-
repeated string res = 1;
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
message downloadFileIn {
|
|
216
|
-
string filePath = 1;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
message downloadFileOut {
|
|
220
|
-
bytes chunk_data = 1;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
service Map {
|
|
225
|
-
rpc Render(render_in) returns (render_out) {}
|
|
226
|
-
rpc RenderXML(render_in) returns (render_out) {}
|
|
227
|
-
rpc LoadXML(xml_in) returns (xml_out) {}
|
|
228
|
-
rpc MarkerIcon(cmd_in) returns (cmd_out) {}
|
|
229
|
-
rpc Gdal(gdal_in) returns (gdal_out) {}
|
|
230
|
-
rpc ClearTiles(clear_tiles_in) returns (clear_tiles_out) {}
|
|
231
|
-
rpc RenderStatus(empty) returns (statusInfo) {}
|
|
232
|
-
rpc PrintMap(printMapIn) returns (printMapOut) {}
|
|
233
|
-
rpc Log(log_in) returns (log_out) {}
|
|
234
|
-
rpc SqlToShp(sqlToShpIn) returns (shapeOut) {}
|
|
235
|
-
rpc uploadFile(fileIn) returns (fileManagerOut) {}
|
|
236
|
-
rpc deleteFiles(deleteFileIn) returns (deleteOut) {}
|
|
237
|
-
rpc checkFiles(checkFilesDir) returns (filesStatus) {}
|
|
238
|
-
rpc fileList(fileListIn) returns (fileInfo) {}
|
|
239
|
-
rpc readDir(readDirIn) returns (readDirOut) {}
|
|
240
|
-
rpc downloadFile(downloadFileIn) returns (stream downloadFileOut) {}
|
|
241
|
-
}
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
message render_in {
|
|
5
|
+
string path = 1;
|
|
6
|
+
string name = 2;
|
|
7
|
+
repeated double bbox = 3 [packed=true];
|
|
8
|
+
string tile = 4;
|
|
9
|
+
string xml = 5;
|
|
10
|
+
int32 width = 6;
|
|
11
|
+
int32 height = 7;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
message render_out {
|
|
16
|
+
string err = 1;
|
|
17
|
+
string base64 = 2;
|
|
18
|
+
string tile = 3;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message xml_in {
|
|
22
|
+
string path = 1;
|
|
23
|
+
string name = 2;
|
|
24
|
+
string xml = 3;
|
|
25
|
+
bool reload = 4;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
message xml_out {
|
|
29
|
+
string err = 1;
|
|
30
|
+
bool is_ok = 2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message cmd_in {
|
|
34
|
+
string cmd = 1;
|
|
35
|
+
string svg = 2;
|
|
36
|
+
string filename = 3;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message cmd_out {
|
|
40
|
+
string err = 1;
|
|
41
|
+
string base64 = 2;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message gdal_in {
|
|
45
|
+
string name = 1;
|
|
46
|
+
string path = 2;
|
|
47
|
+
string out = 3;
|
|
48
|
+
string params = 4;
|
|
49
|
+
}
|
|
50
|
+
message gdal_out {
|
|
51
|
+
string result = 1;
|
|
52
|
+
string err = 2;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message clear_tiles_in {
|
|
56
|
+
string path = 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message clear_tiles_out {
|
|
60
|
+
oneof clear_message {
|
|
61
|
+
bool ok = 1;
|
|
62
|
+
string err = 2;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
message empty {}
|
|
67
|
+
|
|
68
|
+
message statusRenderInfo {
|
|
69
|
+
string name = 1;
|
|
70
|
+
bool isActive = 2;
|
|
71
|
+
float workTime = 3;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
message statusInfo {
|
|
75
|
+
repeated statusRenderInfo info = 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
message printMapOut {
|
|
79
|
+
string map = 1;
|
|
80
|
+
string err = 2;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
message xyz {
|
|
84
|
+
float x = 1;
|
|
85
|
+
float y = 2;
|
|
86
|
+
float z = 3;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message printMapIn {
|
|
90
|
+
string baseurl = 1;
|
|
91
|
+
string baseImg = 2;
|
|
92
|
+
repeated string xml = 3;
|
|
93
|
+
string overlayXml = 4;
|
|
94
|
+
string overlay = 5;
|
|
95
|
+
int32 width = 6;
|
|
96
|
+
int32 height = 7;
|
|
97
|
+
repeated double bbox = 8;
|
|
98
|
+
xyz pos = 9;
|
|
99
|
+
string geojsonSettings = 10;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
message log_in {
|
|
103
|
+
uint32 rows = 1;
|
|
104
|
+
string level = 2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
message log_out {
|
|
108
|
+
repeated string logs = 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
message sqlToShpIn {
|
|
112
|
+
string db = 1;
|
|
113
|
+
string host = 2;
|
|
114
|
+
string port = 3;
|
|
115
|
+
string sql = 4;
|
|
116
|
+
string savePath = 5;
|
|
117
|
+
string shpName = 6;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message shapeOut {
|
|
121
|
+
string zipPath = 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
message fileIn {
|
|
125
|
+
bytes fileBytes = 1;
|
|
126
|
+
string relativeFilepath = 2;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
message deleteFileIn {
|
|
130
|
+
string dir = 1;
|
|
131
|
+
repeated string objectList = 2;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
message fileManagerOut {
|
|
135
|
+
bool status = 1;
|
|
136
|
+
string operation = 2;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
message checkFilesDir {
|
|
140
|
+
string dir = 1;
|
|
141
|
+
repeated string filesSearch = 2;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
enum status {
|
|
145
|
+
LOADING = 0;
|
|
146
|
+
OK = 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
message filesStatus {
|
|
150
|
+
status fileLoadingStatus = 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
message fileListIn {
|
|
154
|
+
string dir = 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
message fileInfo {
|
|
158
|
+
repeated fileInfoL fileInfoList = 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
message fileInfoL {
|
|
162
|
+
oneof fileInfo {
|
|
163
|
+
fileInfoObj file = 1;
|
|
164
|
+
dirInfoObj dir = 2;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
message fileInfoObj {
|
|
169
|
+
string type = 1;
|
|
170
|
+
string birthtime = 2;
|
|
171
|
+
string name = 3;
|
|
172
|
+
uint64 size = 4;
|
|
173
|
+
string ext = 5;
|
|
174
|
+
string server = 6;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
message dirInfoObj {
|
|
178
|
+
string type = 1;
|
|
179
|
+
string birthtime = 2;
|
|
180
|
+
string name = 3;
|
|
181
|
+
uint64 size = 4;
|
|
182
|
+
uint64 count = 5;
|
|
183
|
+
string server = 6;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
message deleteOut {
|
|
187
|
+
repeated deleteObjSuccess success = 1;
|
|
188
|
+
repeated deleteObjError error = 2;
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
message deleteObjSuccess {
|
|
193
|
+
string object = 1;
|
|
194
|
+
string type = 2;
|
|
195
|
+
string status = 3;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
message deleteObjError {
|
|
199
|
+
string object = 1;
|
|
200
|
+
string fullPath = 2;
|
|
201
|
+
string result = 3;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
message readDirIn {
|
|
205
|
+
string dir = 1;
|
|
206
|
+
repeated string filter = 2;
|
|
207
|
+
string fullPath = 3;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
message readDirOut {
|
|
211
|
+
repeated string res = 1;
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
message downloadFileIn {
|
|
216
|
+
string filePath = 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
message downloadFileOut {
|
|
220
|
+
bytes chunk_data = 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
service Map {
|
|
225
|
+
rpc Render(render_in) returns (render_out) {}
|
|
226
|
+
rpc RenderXML(render_in) returns (render_out) {}
|
|
227
|
+
rpc LoadXML(xml_in) returns (xml_out) {}
|
|
228
|
+
rpc MarkerIcon(cmd_in) returns (cmd_out) {}
|
|
229
|
+
rpc Gdal(gdal_in) returns (gdal_out) {}
|
|
230
|
+
rpc ClearTiles(clear_tiles_in) returns (clear_tiles_out) {}
|
|
231
|
+
rpc RenderStatus(empty) returns (statusInfo) {}
|
|
232
|
+
rpc PrintMap(printMapIn) returns (printMapOut) {}
|
|
233
|
+
rpc Log(log_in) returns (log_out) {}
|
|
234
|
+
rpc SqlToShp(sqlToShpIn) returns (shapeOut) {}
|
|
235
|
+
rpc uploadFile(fileIn) returns (fileManagerOut) {}
|
|
236
|
+
rpc deleteFiles(deleteFileIn) returns (deleteOut) {}
|
|
237
|
+
rpc checkFiles(checkFilesDir) returns (filesStatus) {}
|
|
238
|
+
rpc fileList(fileListIn) returns (fileInfo) {}
|
|
239
|
+
rpc readDir(readDirIn) returns (readDirOut) {}
|
|
240
|
+
rpc downloadFile(downloadFileIn) returns (stream downloadFileOut) {}
|
|
241
|
+
}
|
|
@@ -12,12 +12,19 @@ import getServices from './services/get.services.js';
|
|
|
12
12
|
import deleteService from './services/del.service.js';
|
|
13
13
|
import addService from './services/add.service.js';
|
|
14
14
|
|
|
15
|
+
import addGisRegistry from './registers/add.registry.js';
|
|
16
|
+
import deleteGisRegistry from './registers/del.registry.js';
|
|
17
|
+
import getServicesCol from './services/get.services.col.js';
|
|
18
|
+
|
|
15
19
|
async function route(app) {
|
|
16
20
|
app.put('/insert-columns/:token', insertColumns);
|
|
17
21
|
app.put('/insert-filters/:token', insertFilters);
|
|
18
22
|
app.get('/gis-registry/:slug', { config: { policy: ['public'] } }, gisRegistry);
|
|
19
23
|
app.get('/gis-registry/:slug/:objectId', { config: { policy: ['public'] } }, gisRegistry);
|
|
20
24
|
app.get('/gis-registry', { config: { policy: ['public'] } }, gisRegistryList);
|
|
25
|
+
app.post('/gis-registry', { config: { policy: ['public'] } }, addGisRegistry);
|
|
26
|
+
app.put('/gis-registry/:slug', { config: { policy: ['public'] } }, addGisRegistry);
|
|
27
|
+
app.delete('/gis-registry/:slug', { config: { policy: ['public'] } }, deleteGisRegistry);
|
|
21
28
|
app.get('/map-registry/:slug/:id', { config: { policy: ['public'] } }, mapRegistry);
|
|
22
29
|
|
|
23
30
|
app.get('/xml/:id', { config: { policy: ['public'] } }, metadataXML);
|
|
@@ -27,6 +34,7 @@ async function route(app) {
|
|
|
27
34
|
app.get('/gis-export/:type/:slug', { config: { policy: ['public'] } }, gisExport);
|
|
28
35
|
|
|
29
36
|
app.get('/gis-service/:id?', { config: { policy: ['public'] } }, getServices);
|
|
37
|
+
app.get('/gis-service/:id/:col', { config: { policy: ['public'] } }, getServicesCol);
|
|
30
38
|
app.post('/gis-service/:id?', { config: { policy: ['public'] } }, addService);
|
|
31
39
|
app.put('/gis-service/:id', { config: { policy: ['public'] } }, addService);
|
|
32
40
|
app.delete('/gis-service/:id', { config: { policy: ['public'] } }, deleteService);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
export default async function addGisRegistry({
|
|
4
|
+
method, params = {}, body, pg = pgClients.client, user = {},
|
|
5
|
+
}, reply) {
|
|
6
|
+
if (method === 'POST') {
|
|
7
|
+
|
|
8
|
+
if (!body?.register_key) {
|
|
9
|
+
return reply.status(400).send('not enough body params: register_key');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { rows = [] } = await dataInsert({
|
|
13
|
+
pg,
|
|
14
|
+
table: 'gis.registers',
|
|
15
|
+
data: body,
|
|
16
|
+
uid: user?.uid,
|
|
17
|
+
});
|
|
18
|
+
return reply.status(200).send(rows[0]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!params.slug) {
|
|
22
|
+
return reply.status(400).send('not enough params: slug');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const id = await pg.query('select register_id from gis.registers where register_key=$1', [params.slug]).then(el => el.rows?.[0]?.register_id) || params.slug;
|
|
26
|
+
|
|
27
|
+
const row = await dataUpdate({
|
|
28
|
+
pg,
|
|
29
|
+
id,
|
|
30
|
+
table: 'gis.registers',
|
|
31
|
+
data: body,
|
|
32
|
+
uid: user?.uid,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return reply.status(200).send(row);
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
export default async function deleteGisRegistry({
|
|
4
|
+
params = {}, pg = pgClients.client, user = {},
|
|
5
|
+
}, reply) {
|
|
6
|
+
const id = await pg.query('select register_id from gis.registers where register_key=$1', [params.slug]).then(el => el.rows?.[0]?.register_id) || params.slug;
|
|
7
|
+
|
|
8
|
+
const row = await dataDelete({
|
|
9
|
+
pg,
|
|
10
|
+
id,
|
|
11
|
+
table: 'gis.registers',
|
|
12
|
+
uid: user?.uid,
|
|
13
|
+
});
|
|
14
|
+
return reply.status(200).send(row);
|
|
15
|
+
}
|
|
@@ -2,15 +2,27 @@ import { attachClassifiers, populateFilterOptions } from './classifiers.js';
|
|
|
2
2
|
import { extractVisibleColumns } from './columns.js';
|
|
3
3
|
import { getMeta, getFilterSQL } from "@opengis/fastify-table/utils.js";
|
|
4
4
|
|
|
5
|
+
const columnType = {
|
|
6
|
+
text: 'text',
|
|
7
|
+
date: 'date',
|
|
8
|
+
bool: 'yes/no',
|
|
9
|
+
numeric: 'number',
|
|
10
|
+
integer: 'number',
|
|
11
|
+
'timestamp without time zone': 'date',
|
|
12
|
+
'timestamp with time zone': 'date',
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
export async function handleRegistryRequest({ settings, query, object_id, offset = 0, limit = 16, page = 1, pg }) {
|
|
6
|
-
const { name, table_name, columns, filters, query: whereQuery, order, pk, register_id, is_files, view } = settings;
|
|
16
|
+
const { name, table_name, description, card, columns, filters, query: whereQuery, order, pk, register_id, is_files, view } = settings;
|
|
7
17
|
const parsedColumns = Array.isArray(columns) ? columns : JSON.parse(columns);
|
|
8
18
|
const filtersParsed = Array.isArray(filters) ? filters : JSON.parse(filters);
|
|
9
|
-
const activeFilters = filtersParsed.filter((f) => f.disabled !== true);
|
|
10
|
-
const { geom } = await getMeta({ pg, table: table_name });
|
|
19
|
+
const activeFilters = (filtersParsed || []).filter((f) => f.disabled !== true);
|
|
20
|
+
const { columns: fields1, geom } = await getMeta({ pg, table: table_name });
|
|
21
|
+
|
|
22
|
+
const fields = fields1?.map?.(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'] || 'text', label: title || name }));
|
|
11
23
|
|
|
12
24
|
const mode = object_id ? "card" : "table";
|
|
13
|
-
const visibleColumns = extractVisibleColumns(parsedColumns, mode);
|
|
25
|
+
const visibleColumns = parsedColumns ? extractVisibleColumns(parsedColumns, mode) : [];
|
|
14
26
|
const selectColumns = visibleColumns.map((col) => col.name);
|
|
15
27
|
/*const columnsInfo = visibleColumns.map((col) => ({
|
|
16
28
|
name: col.name,
|
|
@@ -26,7 +38,7 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
|
|
|
26
38
|
|
|
27
39
|
if (object_id) {
|
|
28
40
|
const sql = `
|
|
29
|
-
SELECT "${pk}" as id,*
|
|
41
|
+
SELECT "${pk}" as id,* ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''}
|
|
30
42
|
FROM ${table_name}
|
|
31
43
|
WHERE ${pk} = $1
|
|
32
44
|
`;
|
|
@@ -60,13 +72,12 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
|
|
|
60
72
|
: { q: '1=1' };
|
|
61
73
|
|
|
62
74
|
const whereConditions = [whereQuery, sqlFilter].filter(Boolean).join(' AND ');
|
|
63
|
-
const whereClause = whereConditions ? `WHERE ${whereConditions}` : '';
|
|
64
75
|
|
|
65
|
-
const sqlBase = `FROM ${table_name} ${
|
|
76
|
+
const sqlBase = `FROM ${table_name} WHERE ${whereConditions || 'true'}`;
|
|
66
77
|
const sqlOrder = order ? `ORDER BY ${order}` : "";
|
|
67
78
|
const sqlLimit = `LIMIT $1 OFFSET $2`;
|
|
68
79
|
|
|
69
|
-
const sqlSelect = `SELECT "${pk}" as id
|
|
80
|
+
const sqlSelect = `SELECT "${pk}" as id ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''} ${sqlBase}`;
|
|
70
81
|
const dataQuery = `${sqlSelect} ${sqlOrder} ${sqlLimit}`;
|
|
71
82
|
const totalQuery = `SELECT COUNT(*) ${sqlBase}`;
|
|
72
83
|
|
|
@@ -79,9 +90,12 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
|
|
|
79
90
|
const total = parseInt(countRes.rows[0]?.count || 0, 10);
|
|
80
91
|
|
|
81
92
|
const listConfig = {};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
|
|
94
|
+
if (parsedColumns?.length) {
|
|
95
|
+
for (const col of parsedColumns) {
|
|
96
|
+
if (col.view_type === 'title') listConfig.title = col.name;
|
|
97
|
+
if (col.view_type === 'subtitle') listConfig.subtitle = col.name;
|
|
98
|
+
}
|
|
85
99
|
}
|
|
86
100
|
|
|
87
101
|
await populateFilterOptions({
|
|
@@ -95,10 +109,14 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
|
|
|
95
109
|
return {
|
|
96
110
|
register_id,
|
|
97
111
|
name,
|
|
112
|
+
card,
|
|
113
|
+
table_name,
|
|
114
|
+
description,
|
|
98
115
|
rows,
|
|
99
116
|
total,
|
|
100
117
|
columns: visibleColumns,
|
|
101
118
|
filters: activeFilters,
|
|
119
|
+
fields,
|
|
102
120
|
limit,
|
|
103
121
|
page,
|
|
104
122
|
view,
|
|
@@ -19,9 +19,9 @@ export default async function gisRegistry({
|
|
|
19
19
|
const {
|
|
20
20
|
rows: [registry],
|
|
21
21
|
} = await pg.query(
|
|
22
|
-
`SELECT register_id, name, table_name, columns, filters, query, "order", pk, register_key, is_files, view
|
|
22
|
+
`SELECT register_id, name, description, card, table_name, columns, filters, query, "order", pk, register_key, is_files, view
|
|
23
23
|
FROM gis.registers
|
|
24
|
-
WHERE register_key
|
|
24
|
+
WHERE $1 in (register_key,register_id)`,
|
|
25
25
|
[slug]
|
|
26
26
|
);
|
|
27
27
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getMeta, pgClients, yml2json } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default async function getServicesCol({ params = {}, pg = pgClients.client }, reply) {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const row = await pg.query(`
|
|
9
|
+
SELECT
|
|
10
|
+
service_id, source_path
|
|
11
|
+
FROM gis.services where ${params.id ? 'service_id=$1' : '1=1'}
|
|
12
|
+
`, [params.id].filter(Boolean)).then(el => el.rows[0] || {});
|
|
13
|
+
|
|
14
|
+
if (!row.source_path) return { status: 404, message: 'source not found' }
|
|
15
|
+
const fields = await pg.query(` SELECT * FROM ${row.source_path} limit 0`).then(el => el.fields);
|
|
16
|
+
const field = fields.find(el => el.name == params.col);
|
|
17
|
+
if (!field) return {
|
|
18
|
+
status: 404, message: { error: 'col not found', fields }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rows = await pg.query(`SELECT ${params.col} as id, count(*) FROM ${row.source_path} where ${params.col} is not null group by ${params.col} order by count(*) desc limit 10`).then(el => el.rows);
|
|
22
|
+
|
|
23
|
+
return { rows, field, fields }
|
|
24
|
+
}
|