@opengis/gis 0.2.176 → 0.2.178

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.
Files changed (164) hide show
  1. package/README.md +181 -181
  2. package/dist/{CardIcon-c1Q2M3wQ.js → CardIcon-CMRD1LLh.js} +1 -1
  3. package/dist/{EntityTablePage-B5gpkH4S.js → EntityTablePage-XNNCltAN.js} +2 -2
  4. package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-DnGSvmMU.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BqUjKTDY.js} +1 -1
  5. package/dist/{HeaderActions.vue_vue_type_script_setup_true_lang-C2B61JP6.js → HeaderActions.vue_vue_type_script_setup_true_lang-BXQ3hKwa.js} +1 -1
  6. package/dist/{MapSettings-6-Xru5Q8.js → MapSettings-P3h-vHn3.js} +2 -2
  7. package/dist/{RastersTablePage-CXNOcTy-.js → RastersTablePage-DnhGZLiH.js} +2 -2
  8. package/dist/{cartocss-BFVqWvfP.js → cartocss-BkrOeQg4.js} +6 -6
  9. package/dist/{import-utils-uxk4LdUJ.js → import-utils-BCATsbB5.js} +1 -1
  10. package/dist/{index-CahlV-Xs.js → index-cUagVqgA.js} +39 -39
  11. package/dist/index.css +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/index.umd.cjs +5 -5
  14. package/dist/{raster-CEi56f0P.js → raster-CP0tUp3j.js} +3 -3
  15. package/dist/{register-NFAGBNa3.js → register-Cr-uQcby.js} +3 -3
  16. package/dist/{service-BYspag8U.js → service-DwJaKrOd.js} +6 -6
  17. package/dist/{vs-datatable-CHcBr6zy.js → vs-datatable-B9WoVk-b.js} +2 -2
  18. package/module/gis/cls/service_type.json +42 -42
  19. package/module/gis/form/gis.registers.form.json +127 -127
  20. package/module/test/map/addr.json +302 -302
  21. package/module/test/map/addr1.yml +23 -23
  22. package/module/test/select/address.str_id.sql +3 -3
  23. package/package.json +77 -77
  24. package/plugin.js +64 -64
  25. package/server/migrations/array_intersect.sql +13 -13
  26. package/server/migrations/cartocss.sql +27 -27
  27. package/server/migrations/group_list.sql +74 -74
  28. package/server/migrations/maps.sql +30 -30
  29. package/server/migrations/metadata.sql +415 -415
  30. package/server/migrations/ogc.sql +106 -106
  31. package/server/migrations/rasters.sql +265 -265
  32. package/server/migrations/services.sql +247 -247
  33. package/server/migrations/services_users_rel.sql +22 -22
  34. package/server/migrations/widgets.sql +20 -20
  35. package/server/plugins/crons.js +21 -21
  36. package/server/plugins/mapnik/funcs/checkRasterFile.js +107 -107
  37. package/server/plugins/mapnik/funcs/mapnik.js +151 -151
  38. package/server/plugins/mapnik/funcs/rootFolder.mjs +8 -8
  39. package/server/plugins/mapnik/map.proto +437 -437
  40. package/server/plugins/vite.js +74 -74
  41. package/server/routes/cartocss/cartocss.route.js +31 -31
  42. package/server/routes/cartocss/cartocss.route.test.js +78 -78
  43. package/server/routes/cartocss/cartocss.schema.js +73 -73
  44. package/server/routes/cartocss/functions/add.cartocss.js +39 -39
  45. package/server/routes/cartocss/functions/get.cartocss.js +57 -57
  46. package/server/routes/gis/functions/checkXML.js +107 -107
  47. package/server/routes/gis/functions/dashboard.js +24 -24
  48. package/server/routes/gis/gis.route.js +26 -26
  49. package/server/routes/gis/gis.route.test.js +33 -33
  50. package/server/routes/map/functions/clearTiles.js +35 -35
  51. package/server/routes/map/functions/geojson.js +187 -187
  52. package/server/routes/map/functions/gis.convert.js +65 -65
  53. package/server/routes/map/functions/gis.icon.js +220 -220
  54. package/server/routes/map/functions/jsonData.js +206 -206
  55. package/server/routes/map/functions/layerList.js +102 -102
  56. package/server/routes/map/functions/map.js +122 -122
  57. package/server/routes/map/functions/mapCatalog.js +72 -72
  58. package/server/routes/map/functions/mapCatalogAttribute.js +53 -53
  59. package/server/routes/map/functions/mapFeatures.js +133 -133
  60. package/server/routes/map/functions/mapFormat.js +232 -232
  61. package/server/routes/map/functions/mapTiles.js +162 -162
  62. package/server/routes/map/functions/maps.js +15 -15
  63. package/server/routes/map/functions/marker_icon.js +43 -43
  64. package/server/routes/map/functions/parseGeoFile.js +85 -85
  65. package/server/routes/map/functions/pointHeight.js +51 -51
  66. package/server/routes/map/functions/vtile.js +174 -174
  67. package/server/routes/map/functions/vtile1.js +185 -185
  68. package/server/routes/map/map.route.js +280 -280
  69. package/server/routes/map/map.route.test.js +503 -503
  70. package/server/routes/map/map.schema.js +356 -356
  71. package/server/routes/map/pin/circle1.svg +76 -76
  72. package/server/routes/map/pin/circle2.svg +18 -18
  73. package/server/routes/map/pin/none.svg +12 -12
  74. package/server/routes/map/pin/pin.svg +14 -14
  75. package/server/routes/map/pin/pin1.svg +16 -16
  76. package/server/routes/map/pin/pin2.svg +7 -7
  77. package/server/routes/map/pin/pin3.svg +34 -34
  78. package/server/routes/map/pin/pin4.svg +14 -14
  79. package/server/routes/map/pin/pin5.svg +7 -7
  80. package/server/routes/map/pin/pin6.svg +12 -12
  81. package/server/routes/map/pin/pin7.svg +12 -12
  82. package/server/routes/mapnik/functions/cartoBounds.js +32 -32
  83. package/server/routes/mapnik/functions/clearTiles.js +103 -103
  84. package/server/routes/mapnik/functions/convertBoundToTile.js +27 -27
  85. package/server/routes/mapnik/functions/createXml.js +76 -76
  86. package/server/routes/mapnik/functions/createXmlMulti.js +72 -72
  87. package/server/routes/mapnik/functions/fileSearch.js +35 -35
  88. package/server/routes/mapnik/functions/fileStat.js +28 -28
  89. package/server/routes/mapnik/functions/pretile.js +138 -138
  90. package/server/routes/mapnik/functions/rasterInfo.js +66 -66
  91. package/server/routes/mapnik/functions/readDir.js +22 -22
  92. package/server/routes/mapnik/functions/rtile.js +164 -164
  93. package/server/routes/mapnik/functions/uploadRaster.js +152 -152
  94. package/server/routes/mapnik/functions/uploadXML.js +140 -140
  95. package/server/routes/mapnik/mapnik.route.js +102 -102
  96. package/server/routes/mapnik/mapnik.route.test.js +370 -370
  97. package/server/routes/mapnik/mapnik.schema.mjs +195 -195
  98. package/server/routes/mapnik.prefixless/functions/mapnikLogger.js +31 -31
  99. package/server/routes/mapnik.prefixless/functions/mapnikStat.js +21 -21
  100. package/server/routes/mapnik.prefixless/mapnik.prefixless.route.js +20 -20
  101. package/server/routes/mapnik.prefixless/mapnik.prefixless.route.test.js +91 -91
  102. package/server/routes/mapnik.prefixless/mapnik.prefixless.schema.mjs +27 -27
  103. package/server/routes/maps/functions/add.map.js +42 -42
  104. package/server/routes/maps/functions/del.map.js +17 -17
  105. package/server/routes/maps/functions/get.map.js +119 -119
  106. package/server/routes/maps/maps.route.js +58 -58
  107. package/server/routes/maps/maps.route.test.js +231 -231
  108. package/server/routes/maps/maps.schema.js +9 -9
  109. package/server/routes/metadata/functions/editMetadata.js +35 -35
  110. package/server/routes/metadata/functions/metadataXML.js +19 -19
  111. package/server/routes/metadata/metadata.route.js +26 -26
  112. package/server/routes/metadata/metadata.route.test.js +46 -46
  113. package/server/routes/metadata/metadata.schema.js +53 -53
  114. package/server/routes/ogc/functions/map.info.point.js +117 -117
  115. package/server/routes/ogc/ogc.route.js +21 -21
  116. package/server/routes/ogc/ogc.route.test.js +53 -53
  117. package/server/routes/ogc/ogc.schema.js +16 -16
  118. package/server/routes/permissions/functions/catalog.permissions.edit.js +20 -20
  119. package/server/routes/permissions/functions/catalog.permissions.js +12 -12
  120. package/server/routes/permissions/functions/get.permissions.js +59 -59
  121. package/server/routes/permissions/functions/gis.catalog.js +80 -80
  122. package/server/routes/permissions/permissions.route.js +35 -35
  123. package/server/routes/permissions/permissions.route.test.js +35 -35
  124. package/server/routes/permissions/permissions.schema.js +43 -43
  125. package/server/routes/registers/functions/add.registry.js +37 -37
  126. package/server/routes/registers/functions/classifiers.js +100 -100
  127. package/server/routes/registers/functions/columns.js +3 -3
  128. package/server/routes/registers/functions/content.type.js +9 -9
  129. package/server/routes/registers/functions/del.registry.js +14 -14
  130. package/server/routes/registers/functions/get.info.js +93 -93
  131. package/server/routes/registers/functions/getFilterSQLParametrized/formatValue.js +312 -0
  132. package/server/routes/registers/functions/getFilterSQLParametrized/getFilterQuery.js +126 -0
  133. package/server/routes/registers/functions/getFilterSQLParametrized/getRangeQuery.js +353 -0
  134. package/server/routes/registers/functions/getFilterSQLParametrized/index.js +81 -0
  135. package/server/routes/registers/functions/getTableColumnMeta.js +125 -0
  136. package/server/routes/registers/functions/gis.export.js +159 -159
  137. package/server/routes/registers/functions/gis.registry.js +71 -71
  138. package/server/routes/registers/functions/gis.registry.list.js +61 -61
  139. package/server/routes/registers/functions/gis.suggest.js +275 -0
  140. package/server/routes/registers/functions/handleRegistryRequest.js +175 -147
  141. package/server/routes/registers/functions/map.registry.js +87 -87
  142. package/server/routes/registers/registers.route.js +91 -80
  143. package/server/routes/registers/registers.route.test.js +173 -144
  144. package/server/routes/registers/registers.schema.js +275 -246
  145. package/server/routes/root.mjs +3 -3
  146. package/server/routes/services/functions/add.service.js +62 -62
  147. package/server/routes/services/functions/create.route.js +93 -93
  148. package/server/routes/services/functions/del.service.js +12 -12
  149. package/server/routes/services/functions/get.layer.geom.js +27 -27
  150. package/server/routes/services/functions/get.service.users.js +76 -76
  151. package/server/routes/services/functions/get.services.col.js +34 -34
  152. package/server/routes/services/functions/get.services.js +89 -89
  153. package/server/routes/services/functions/legend.auto.js +77 -77
  154. package/server/routes/services/services.route.js +76 -76
  155. package/server/routes/services/services.route.test.js +167 -167
  156. package/server/routes/services/services.schema.js +285 -278
  157. package/server/routes/widgets/functions/add.widget.js +38 -38
  158. package/server/routes/widgets/functions/del.widget.js +17 -17
  159. package/server/routes/widgets/functions/get.widget.js +41 -41
  160. package/server/routes/widgets/widgets.route.js +61 -61
  161. package/server/routes/widgets/widgets.route.test.js +144 -144
  162. package/server/routes/widgets/widgets.schema.js +24 -24
  163. package/server/shared/listFiles.js +14 -14
  164. package/utils.js +13 -13
@@ -1,280 +1,280 @@
1
- import map from './functions/map.js';
2
- import mapTiles from './functions/mapTiles.js';
3
- import mapFeatures from './functions/mapFeatures.js';
4
-
5
- import mapCatalog from './functions/mapCatalog.js';
6
- import mapCatalogAttribute from './functions/mapCatalogAttribute.js';
7
-
8
- // import vtile from './functions/vtile.js';
9
- import vtile1 from './functions/vtile1.js';
10
- import clearTiles from './functions/clearTiles.js';
11
- import geojson from './functions/geojson.js';
12
- import jsonData from './functions/jsonData.js';
13
- import layerList from './functions/layerList.js';
14
-
15
- import mapFormat from './functions/mapFormat.js';
16
- import parseGeoFile from './functions/parseGeoFile.js';
17
- import maps from './functions/maps.js';
18
- import gisIconApi from './functions/gis.icon.js';
19
- // import markerIconApi from './controllers/marker_icon.js';
20
-
21
- import gisConvert from './functions/gis.convert.js';
22
- import pointHeight from './functions/pointHeight.js';
23
-
24
- import {
25
- gisConvertSchema,
26
- mapFormatSchema,
27
- pointHeightSchema,
28
- getIconSchema,
29
- mapSchema,
30
- mapTilesSchema,
31
- mapFeaturesSchema,
32
- mapFeaturesPointSchema,
33
- mapCatalogAttributeSchema,
34
-
35
- vtileSchema,
36
- clearTilesSchema,
37
- geojsonSchema,
38
- jsonDataSchema,
39
- layerListSchema,
40
- parseGeoFileSchema,
41
- } from './map.schema.js';
42
-
43
- const publicParams = {
44
- config: { policy: 'L0' },
45
- package: 'gis',
46
- }; // * L0 === public
47
-
48
- const privateParams = {
49
- config: { policy: 'L1' },
50
- package: 'gis',
51
- }; // require authorized user
52
-
53
- export default function route(app) {
54
- if (!app.hasRoute({ method: 'GET', url: '/maps' })) {
55
- app.get('/maps', publicParams, maps);
56
- }
57
-
58
- if (!app.hasRoute({ method: 'GET', url: '/map/:slug' })) {
59
- app.get('/map/:slug', { ...publicParams, schema: mapSchema }, async ({ params, pg }) => {
60
- const result = await map({ slug: params.slug }, pg);
61
- return result;
62
- });
63
- }
64
-
65
- if (!app.hasRoute({ method: 'GET', url: '/map-tiles/:slug/:z/:y/:x' })) {
66
- app.get('/map-tiles/:slug/:z/:y/:x', { ...publicParams, schema: mapTilesSchema }, async ({ params, query, pg }, reply) => {
67
- const result = await mapTiles({
68
- slug: params.slug,
69
- z: params.z,
70
- x: params.x?.split?.('.')?.[0] - 0,
71
- y: params.y,
72
- sql: query.sql,
73
- nocache: query.nocache,
74
- filter: query.filter,
75
- pointZoom: query.pointZoom,
76
- type: query.type,
77
- layers: query.layers,
78
- layer: query.layer,
79
- }, pg);
80
- return reply.headers(result.headers).send(result.data);
81
- });
82
- }
83
-
84
- if (!app.hasRoute({ method: 'GET', url: '/map-features/:slug/:id' })) {
85
- app.get('/map-features/:slug/:id', { ...publicParams, schema: mapFeaturesSchema }, async ({ params, query, pg }) => {
86
- const result = await mapFeatures({
87
- slug: params.slug, id: params.id, x: query.x, y: query.y, sql: query.sql
88
- }, pg);
89
- return result;
90
- });
91
- }
92
-
93
- if (!app.hasRoute({ method: 'GET', url: '/map-features-point/:slug' })) {
94
- app.get('/map-features-point/:slug', { ...publicParams, schema: mapFeaturesPointSchema }, async ({ params, query, pg }) => {
95
- const result = await mapFeatures({
96
- slug: params.slug, id: params.id, x: query.x, y: query.y, sql: query.sql
97
- }, pg);
98
- return result;
99
- });
100
- }
101
-
102
- if (!app.hasRoute({ method: 'GET', url: '/map-catalog' })) {
103
- app.get('/map-catalog', publicParams, async () => {
104
- const result = await mapCatalog();
105
- return result;
106
- });
107
- }
108
-
109
- if (!app.hasRoute({ method: 'GET', url: '/map-catalog/:service/:attr' })) {
110
- app.get('/map-catalog/:service/:attr', { ...publicParams, schema: mapCatalogAttributeSchema }, async ({ params, query, pg }) => {
111
- const result = await mapCatalogAttribute({
112
- service: params.service,
113
- attr: params.attr,
114
- cls: query.cls
115
- }, pg);
116
- return result;
117
- });
118
- }
119
-
120
- /*if (!app.hasRoute({ method: 'GET', url: '/layer-rtile/:id/:z/:y/:x' })) {
121
- app.get('/layer-rtile/:id/:z/:y/:x', publicParams, rtile);
122
- }*/
123
-
124
- /*if (!app.hasRoute({ method: 'GET', url: '/layer-vtile/:id/:z/:y/:x' })) {
125
- app.get('/layer-vtile/:id/:z/:y/:x', publicParams, vtile);
126
- }*/
127
-
128
- if (
129
- !app.hasRoute({ method: 'GET', url: '/api/vtile/:layer/:lang/:z/:y/:x' })
130
- ) {
131
- console.log('\x1b[34m%s\x1b[0m', 'add vtile from gis');
132
- app.get('/vtile/:layer/:lang/:z/:y/:x', { ...publicParams, schema: vtileSchema }, async ({ params, query, user, pg }, reply) => {
133
- const x = params.x.split('.')[0] - 0;
134
- const result = await vtile1({
135
- layer: params.layer,
136
- lang: params.lang,
137
- z: params.z,
138
- x,
139
- y: params.y,
140
-
141
- uid: user?.uid,
142
-
143
- type: query.type,
144
- nocache: query.nocache,
145
- clusterZoom: query.clusterZoom,
146
- filter: query.filter,
147
- nottl: query.nottl,
148
- all: query.all,
149
- sql: query.sql,
150
- pointZoom: query.pointZoom,
151
- }, pg);
152
- return reply.headers(result.headers).send(result.data);
153
- });
154
- }
155
-
156
- if (!app.hasRoute({ method: 'GET', url: '/api/gis-clear-vtile/:id' })) {
157
- app.get('/gis-clear-vtile/:id', { ...privateParams, schema: clearTilesSchema }, async ({ params, query, user }) => {
158
- const result = await clearTiles({
159
- id: params.id,
160
- debug: query.debug && user?.user_type?.includes?.('admin')
161
- });
162
- return result;
163
- });
164
- }
165
-
166
- if (!app.hasRoute({ method: 'GET', url: '/api/geojson/:layer' })) {
167
- console.log('\x1b[34m%s\x1b[0m', 'add geojson from gis');
168
- app.get('/geojson/:layer', { ...publicParams, schema: geojsonSchema }, async ({ params, query, pg }, reply) => {
169
- const result = await geojson({
170
- layer: params.layer,
171
- sql: query.sql,
172
- nocache: query.nocache,
173
- srid: query.srid,
174
- type: query.type,
175
- extent: query.extent,
176
- }, pg);
177
- if (query.sql && typeof result === 'string') {
178
- return result;
179
- }
180
- return reply.headers(result.headers).send(result.data);
181
- });
182
- }
183
-
184
- if (!app.hasRoute({ method: 'GET', url: '/api/json/:layer' })) {
185
- console.log('\x1b[34m%s\x1b[0m', 'add json from gis');
186
- app.get('/json/:layer', { ...publicParams, schema: jsonDataSchema }, async ({ params, query, pg }, reply) => {
187
- const result = await jsonData({
188
- layer: params.layer,
189
- sql: query.sql,
190
- nocache: query.nocache,
191
- page: query.page,
192
- limit: query.limit,
193
- // where: query.where,
194
- }, pg);
195
- if (query.sql && typeof result === 'string') {
196
- return result;
197
- }
198
- return reply.headers(result.headers).send(result.data);
199
- });
200
- }
201
-
202
- if (!app.hasRoute({ method: 'GET', url: '/api/gis-layer-list' })) {
203
- console.log('\x1b[34m%s\x1b[0m', 'add gis-layer-list from gis');
204
- app.get('/gis-layer-list', { ...publicParams, schema: layerListSchema }, async ({ user, query, pg }) => {
205
- const result = await layerList({ uid: user?.uid, sql: query.sql }, pg);
206
- return result;
207
- });
208
- }
209
-
210
- if (!app.hasRoute({ method: 'GET', url: '/gis-icon/*' })) {
211
- app.get('/gis-icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
212
- const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
213
- return reply.headers(result.headers).send(result.data);
214
- });
215
- }
216
-
217
- if (!app.hasRoute({ method: 'GET', url: '/icon/*' })) {
218
- app.get('/icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
219
- const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
220
- return reply.headers(result.headers).send(result.data);
221
- });
222
- }
223
-
224
- if (!app.hasRoute({ method: 'GET', url: '/marker-icon/*' })) {
225
- app.get('/marker-icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
226
- const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
227
- return reply.headers(result.headers).send(result.data);
228
- });
229
- }
230
-
231
- if (!app.hasRoute({ method: 'GET', url: '/api/map-format' })) {
232
- app.get(
233
- '/map-format',
234
- { ...publicParams, schema: mapFormatSchema },
235
- async ({ query, user, pg }) => {
236
- const result = await mapFormat({
237
- layer: query.layer,
238
- id: query.id,
239
- lat: query.lat,
240
- lng: query.lng,
241
- nogeom: query.nogeom,
242
- radius: query.radius,
243
- uid: user?.uid
244
- }, pg);
245
- return result;
246
- }
247
- );
248
- }
249
-
250
- if (!app.hasRoute({ method: 'GET', url: '/api/coords/height' })) {
251
- app.get(
252
- '/coords/height',
253
- { ...publicParams, schema: pointHeightSchema },
254
- async ({ query }) => {
255
- const result = await pointHeight({ lat: query.lat, lng: query.lng });
256
- return result;
257
- }
258
- );
259
- }
260
-
261
- if (!app.hasRoute({ method: 'POST', url: '/api/gis-parse-geo' })) {
262
- app.post('/gis-parse-geo', { ...publicParams, schema: parseGeoFileSchema }, async ({ body }) => {
263
- const result = await parseGeoFile({ content: body.content, filename: body.filename });
264
- return result;
265
- });
266
- }
267
-
268
- if (!app.hasRoute({ method: 'POST', url: '/api/gis-convert' })) {
269
- app.post(
270
- '/gis-convert',
271
- { ...publicParams, schema: gisConvertSchema },
272
- async ({ body }) => {
273
- const result = await gisConvert({
274
- file: body.file, filename: body.filename, filepath: body.filepath, encoding: body.encoding
275
- });
276
- return result;
277
- },
278
- );
279
- }
280
- }
1
+ import map from './functions/map.js';
2
+ import mapTiles from './functions/mapTiles.js';
3
+ import mapFeatures from './functions/mapFeatures.js';
4
+
5
+ import mapCatalog from './functions/mapCatalog.js';
6
+ import mapCatalogAttribute from './functions/mapCatalogAttribute.js';
7
+
8
+ // import vtile from './functions/vtile.js';
9
+ import vtile1 from './functions/vtile1.js';
10
+ import clearTiles from './functions/clearTiles.js';
11
+ import geojson from './functions/geojson.js';
12
+ import jsonData from './functions/jsonData.js';
13
+ import layerList from './functions/layerList.js';
14
+
15
+ import mapFormat from './functions/mapFormat.js';
16
+ import parseGeoFile from './functions/parseGeoFile.js';
17
+ import maps from './functions/maps.js';
18
+ import gisIconApi from './functions/gis.icon.js';
19
+ // import markerIconApi from './controllers/marker_icon.js';
20
+
21
+ import gisConvert from './functions/gis.convert.js';
22
+ import pointHeight from './functions/pointHeight.js';
23
+
24
+ import {
25
+ gisConvertSchema,
26
+ mapFormatSchema,
27
+ pointHeightSchema,
28
+ getIconSchema,
29
+ mapSchema,
30
+ mapTilesSchema,
31
+ mapFeaturesSchema,
32
+ mapFeaturesPointSchema,
33
+ mapCatalogAttributeSchema,
34
+
35
+ vtileSchema,
36
+ clearTilesSchema,
37
+ geojsonSchema,
38
+ jsonDataSchema,
39
+ layerListSchema,
40
+ parseGeoFileSchema,
41
+ } from './map.schema.js';
42
+
43
+ const publicParams = {
44
+ config: { policy: 'L0' },
45
+ package: 'gis',
46
+ }; // * L0 === public
47
+
48
+ const privateParams = {
49
+ config: { policy: 'L1' },
50
+ package: 'gis',
51
+ }; // require authorized user
52
+
53
+ export default function route(app) {
54
+ if (!app.hasRoute({ method: 'GET', url: '/maps' })) {
55
+ app.get('/maps', publicParams, maps);
56
+ }
57
+
58
+ if (!app.hasRoute({ method: 'GET', url: '/map/:slug' })) {
59
+ app.get('/map/:slug', { ...publicParams, schema: mapSchema }, async ({ params, pg }) => {
60
+ const result = await map({ slug: params.slug }, pg);
61
+ return result;
62
+ });
63
+ }
64
+
65
+ if (!app.hasRoute({ method: 'GET', url: '/map-tiles/:slug/:z/:y/:x' })) {
66
+ app.get('/map-tiles/:slug/:z/:y/:x', { ...publicParams, schema: mapTilesSchema }, async ({ params, query, pg }, reply) => {
67
+ const result = await mapTiles({
68
+ slug: params.slug,
69
+ z: params.z,
70
+ x: params.x?.split?.('.')?.[0] - 0,
71
+ y: params.y,
72
+ sql: query.sql,
73
+ nocache: query.nocache,
74
+ filter: query.filter,
75
+ pointZoom: query.pointZoom,
76
+ type: query.type,
77
+ layers: query.layers,
78
+ layer: query.layer,
79
+ }, pg);
80
+ return reply.headers(result.headers).send(result.data);
81
+ });
82
+ }
83
+
84
+ if (!app.hasRoute({ method: 'GET', url: '/map-features/:slug/:id' })) {
85
+ app.get('/map-features/:slug/:id', { ...publicParams, schema: mapFeaturesSchema }, async ({ params, query, pg }) => {
86
+ const result = await mapFeatures({
87
+ slug: params.slug, id: params.id, x: query.x, y: query.y, sql: query.sql
88
+ }, pg);
89
+ return result;
90
+ });
91
+ }
92
+
93
+ if (!app.hasRoute({ method: 'GET', url: '/map-features-point/:slug' })) {
94
+ app.get('/map-features-point/:slug', { ...publicParams, schema: mapFeaturesPointSchema }, async ({ params, query, pg }) => {
95
+ const result = await mapFeatures({
96
+ slug: params.slug, id: params.id, x: query.x, y: query.y, sql: query.sql
97
+ }, pg);
98
+ return result;
99
+ });
100
+ }
101
+
102
+ if (!app.hasRoute({ method: 'GET', url: '/map-catalog' })) {
103
+ app.get('/map-catalog', publicParams, async () => {
104
+ const result = await mapCatalog();
105
+ return result;
106
+ });
107
+ }
108
+
109
+ if (!app.hasRoute({ method: 'GET', url: '/map-catalog/:service/:attr' })) {
110
+ app.get('/map-catalog/:service/:attr', { ...publicParams, schema: mapCatalogAttributeSchema }, async ({ params, query, pg }) => {
111
+ const result = await mapCatalogAttribute({
112
+ service: params.service,
113
+ attr: params.attr,
114
+ cls: query.cls
115
+ }, pg);
116
+ return result;
117
+ });
118
+ }
119
+
120
+ /*if (!app.hasRoute({ method: 'GET', url: '/layer-rtile/:id/:z/:y/:x' })) {
121
+ app.get('/layer-rtile/:id/:z/:y/:x', publicParams, rtile);
122
+ }*/
123
+
124
+ /*if (!app.hasRoute({ method: 'GET', url: '/layer-vtile/:id/:z/:y/:x' })) {
125
+ app.get('/layer-vtile/:id/:z/:y/:x', publicParams, vtile);
126
+ }*/
127
+
128
+ if (
129
+ !app.hasRoute({ method: 'GET', url: '/api/vtile/:layer/:lang/:z/:y/:x' })
130
+ ) {
131
+ console.log('\x1b[34m%s\x1b[0m', 'add vtile from gis');
132
+ app.get('/vtile/:layer/:lang/:z/:y/:x', { ...publicParams, schema: vtileSchema }, async ({ params, query, user, pg }, reply) => {
133
+ const x = params.x.split('.')[0] - 0;
134
+ const result = await vtile1({
135
+ layer: params.layer,
136
+ lang: params.lang,
137
+ z: params.z,
138
+ x,
139
+ y: params.y,
140
+
141
+ uid: user?.uid,
142
+
143
+ type: query.type,
144
+ nocache: query.nocache,
145
+ clusterZoom: query.clusterZoom,
146
+ filter: query.filter,
147
+ nottl: query.nottl,
148
+ all: query.all,
149
+ sql: query.sql,
150
+ pointZoom: query.pointZoom,
151
+ }, pg);
152
+ return reply.headers(result.headers).send(result.data);
153
+ });
154
+ }
155
+
156
+ if (!app.hasRoute({ method: 'GET', url: '/api/gis-clear-vtile/:id' })) {
157
+ app.get('/gis-clear-vtile/:id', { ...privateParams, schema: clearTilesSchema }, async ({ params, query, user }) => {
158
+ const result = await clearTiles({
159
+ id: params.id,
160
+ debug: query.debug && user?.user_type?.includes?.('admin')
161
+ });
162
+ return result;
163
+ });
164
+ }
165
+
166
+ if (!app.hasRoute({ method: 'GET', url: '/api/geojson/:layer' })) {
167
+ console.log('\x1b[34m%s\x1b[0m', 'add geojson from gis');
168
+ app.get('/geojson/:layer', { ...publicParams, schema: geojsonSchema }, async ({ params, query, pg }, reply) => {
169
+ const result = await geojson({
170
+ layer: params.layer,
171
+ sql: query.sql,
172
+ nocache: query.nocache,
173
+ srid: query.srid,
174
+ type: query.type,
175
+ extent: query.extent,
176
+ }, pg);
177
+ if (query.sql && typeof result === 'string') {
178
+ return result;
179
+ }
180
+ return reply.headers(result.headers).send(result.data);
181
+ });
182
+ }
183
+
184
+ if (!app.hasRoute({ method: 'GET', url: '/api/json/:layer' })) {
185
+ console.log('\x1b[34m%s\x1b[0m', 'add json from gis');
186
+ app.get('/json/:layer', { ...publicParams, schema: jsonDataSchema }, async ({ params, query, pg }, reply) => {
187
+ const result = await jsonData({
188
+ layer: params.layer,
189
+ sql: query.sql,
190
+ nocache: query.nocache,
191
+ page: query.page,
192
+ limit: query.limit,
193
+ // where: query.where,
194
+ }, pg);
195
+ if (query.sql && typeof result === 'string') {
196
+ return result;
197
+ }
198
+ return reply.headers(result.headers).send(result.data);
199
+ });
200
+ }
201
+
202
+ if (!app.hasRoute({ method: 'GET', url: '/api/gis-layer-list' })) {
203
+ console.log('\x1b[34m%s\x1b[0m', 'add gis-layer-list from gis');
204
+ app.get('/gis-layer-list', { ...publicParams, schema: layerListSchema }, async ({ user, query, pg }) => {
205
+ const result = await layerList({ uid: user?.uid, sql: query.sql }, pg);
206
+ return result;
207
+ });
208
+ }
209
+
210
+ if (!app.hasRoute({ method: 'GET', url: '/gis-icon/*' })) {
211
+ app.get('/gis-icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
212
+ const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
213
+ return reply.headers(result.headers).send(result.data);
214
+ });
215
+ }
216
+
217
+ if (!app.hasRoute({ method: 'GET', url: '/icon/*' })) {
218
+ app.get('/icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
219
+ const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
220
+ return reply.headers(result.headers).send(result.data);
221
+ });
222
+ }
223
+
224
+ if (!app.hasRoute({ method: 'GET', url: '/marker-icon/*' })) {
225
+ app.get('/marker-icon/*', { ...publicParams, schema: getIconSchema }, async (req, reply) => {
226
+ const result = await gisIconApi({ name: req.params['*'], nocache: !!req.query.nocache });
227
+ return reply.headers(result.headers).send(result.data);
228
+ });
229
+ }
230
+
231
+ if (!app.hasRoute({ method: 'GET', url: '/api/map-format' })) {
232
+ app.get(
233
+ '/map-format',
234
+ { ...publicParams, schema: mapFormatSchema },
235
+ async ({ query, user, pg }) => {
236
+ const result = await mapFormat({
237
+ layer: query.layer,
238
+ id: query.id,
239
+ lat: query.lat,
240
+ lng: query.lng,
241
+ nogeom: query.nogeom,
242
+ radius: query.radius,
243
+ uid: user?.uid
244
+ }, pg);
245
+ return result;
246
+ }
247
+ );
248
+ }
249
+
250
+ if (!app.hasRoute({ method: 'GET', url: '/api/coords/height' })) {
251
+ app.get(
252
+ '/coords/height',
253
+ { ...publicParams, schema: pointHeightSchema },
254
+ async ({ query }) => {
255
+ const result = await pointHeight({ lat: query.lat, lng: query.lng });
256
+ return result;
257
+ }
258
+ );
259
+ }
260
+
261
+ if (!app.hasRoute({ method: 'POST', url: '/api/gis-parse-geo' })) {
262
+ app.post('/gis-parse-geo', { ...publicParams, schema: parseGeoFileSchema }, async ({ body }) => {
263
+ const result = await parseGeoFile({ content: body.content, filename: body.filename });
264
+ return result;
265
+ });
266
+ }
267
+
268
+ if (!app.hasRoute({ method: 'POST', url: '/api/gis-convert' })) {
269
+ app.post(
270
+ '/gis-convert',
271
+ { ...publicParams, schema: gisConvertSchema },
272
+ async ({ body }) => {
273
+ const result = await gisConvert({
274
+ file: body.file, filename: body.filename, filepath: body.filepath, encoding: body.encoding
275
+ });
276
+ return result;
277
+ },
278
+ );
279
+ }
280
+ }