@opengis/gis 0.2.49 → 0.2.51

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "scripts": {
18
18
  "dump": "bun ./node_modules/@opengis/fastify-table/dist/script/dump.js",
19
19
  "migrate": "MIGRATE=true bun ./node_modules/@opengis/fastify-table/dist/script/migrate.js",
20
- "start1": "bun server",
20
+ "start": "bun server",
21
21
  "start:kyiv-demo": "bun --env-file=.env.kyiv-demo server",
22
22
  "start:kamyanske": "bun --env-file=.env.kamyanske server",
23
23
  "start:kr": "bun --env-file=.env.kr server",
@@ -18,6 +18,7 @@ service MapService {
18
18
  rpc GetStat(GetStatRequest) returns (GetStatOut);
19
19
  rpc GetRender(GetRenderRequest) returns (GetRenderOut);
20
20
  rpc GetLogs(GetLogsRequest) returns (GetLogsOut);
21
+ rpc GetRasterInfo(GetRasterInfoRequest) returns (GetRasterInfoOut);
21
22
  }
22
23
 
23
24
  // ----------------------------
@@ -138,6 +139,37 @@ message GetLogsOut {
138
139
  repeated string result = 1;
139
140
  }
140
141
 
142
+ message GetRasterInfoRequest {
143
+ string path = 1;
144
+ string ttl = 2;
145
+ }
146
+
147
+ message FileItem {
148
+ string name = 1;
149
+ string size = 2;
150
+ }
151
+
152
+ message GetRasterInfoData {
153
+ string total_size = 1;
154
+ string extension = 2;
155
+ int64 srid = 3;
156
+ string proj4 = 4;
157
+ repeated float extent = 5;
158
+ repeated FileItem files = 6;
159
+ int64 width = 7;
160
+ int64 height = 8;
161
+ int64 bands_count = 9;
162
+ string resolution = 10;
163
+ repeated string bands = 11;
164
+ int64 color_depth = 12;
165
+ string compression = 13;
166
+ }
167
+
168
+ message GetRasterInfoOut {
169
+ GetRasterInfoData data = 1;
170
+ bool cache = 2;
171
+ }
172
+
141
173
  // ----------------------------
142
174
  // Job Service Messages
143
175
  // ----------------------------
@@ -0,0 +1,14 @@
1
+ import { config } from '@opengis/fastify-table/utils.js';
2
+
3
+ import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
4
+
5
+ const { GetLogs } = mapnik();
6
+
7
+ export default async function mapnikLogger({
8
+ params,
9
+ }, reply) {
10
+ if (!config.mapServerAddress) {
11
+ return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
12
+ }
13
+ return reply.status(200).send({ test: params });
14
+ }
@@ -0,0 +1,14 @@
1
+ import { config } from '@opengis/fastify-table/utils.js';
2
+
3
+ import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
4
+
5
+ const { GetStat } = mapnik();
6
+
7
+ export default async function mapnikStat({
8
+ params,
9
+ }, reply) {
10
+ if (!config.mapServerAddress) {
11
+ return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
12
+ }
13
+ return reply.status(200).send({ test: params });
14
+ }
@@ -0,0 +1,36 @@
1
+ import { config, pgClients } from '@opengis/fastify-table/utils.js';
2
+
3
+ import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
4
+
5
+ const { GetRasterInfo } = mapnik();
6
+
7
+ const { prefix = '/api' } = config;
8
+
9
+ export default async function rtile({
10
+ pg = pgClients.client, params, query,
11
+ }, reply) {
12
+ if (!config.mapServerAddress) {
13
+ return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
14
+ }
15
+
16
+ const raster = pg.pk?.['gis.rasters']
17
+ ? await pg.query('select raster_id, source_path from gis.rasters where raster_id=$1::text', [params.id])
18
+ .then(el => el.rows?.[0] || {})
19
+ : {};
20
+
21
+ if (raster.raster_id && !raster.source_path) {
22
+ return reply.status(400).send({ error: 'empty source_path', code: 400 });
23
+ }
24
+
25
+ if (!raster.raster_id) {
26
+ const decodedPath = Buffer.from(params.id, 'base64url').toString('utf-8');
27
+ Object.assign(raster, { source_path: decodedPath });
28
+ }
29
+
30
+ const data = await GetRasterInfo({
31
+ path: raster.source_path,
32
+ ttl: query.nocache ? '0' : '1h',
33
+ });
34
+
35
+ return { ...data, url: `${prefix}/gis-rtile/${Buffer.from(raster.source_path).toString('base64url')}/{z}/{x}/{y}.png` };
36
+ }
@@ -1,11 +1,10 @@
1
- import path from 'node:path';
2
1
  import Sphericalmercator from '@mapbox/sphericalmercator';
3
2
 
4
3
  import { config, logger, pgClients } from '@opengis/fastify-table/utils.js';
5
4
 
6
5
  import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
7
6
 
8
- const { RenderTile, GetRasterStatus } = mapnik();
7
+ const { RenderTile } = mapnik();
9
8
 
10
9
  const mercator = new Sphericalmercator({ size: 256 });
11
10
 
@@ -27,7 +26,7 @@ const mercator = new Sphericalmercator({ size: 256 });
27
26
  export default async function rtile({
28
27
  pg = pgClients.client, params, query,
29
28
  }, reply) {
30
- if (!RenderTile || !GetRasterStatus) {
29
+ if (!RenderTile) {
31
30
  return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
32
31
  }
33
32
 
@@ -57,19 +56,10 @@ export default async function rtile({
57
56
 
58
57
  if (!raster.raster_id && !cartoExists) {
59
58
  const decodedPath = Buffer.from(id, 'base64url').toString('utf-8');
60
- const uploadStatus = path.extname(decodedPath) ? await GetRasterStatus({ path: decodedPath }) : {};
61
-
62
- if (uploadStatus.exists === false) {
63
- return reply.status(400).send({ error: 'raster not uploaded', code: 400 });
64
- }
65
-
66
- if (uploadStatus.finished === false) {
67
- return reply.status(400).send({ error: 'upload not finished', code: 400 });
68
- }
69
59
  Object.assign(raster, { source_path: decodedPath });
70
60
  }
71
61
 
72
- if (!raster && !cartoExists) {
62
+ if (!raster.source_path && !cartoExists) {
73
63
  return reply.status(404).send({ error: 'raster / cartocss not found', code: 404 });
74
64
  }
75
65
 
@@ -1,16 +1,19 @@
1
1
  import uploadRaster from './controllers/uploadRaster.js';
2
2
  import createXml from './controllers/createXml.js';
3
3
  import rtile from './controllers/rtile.js';
4
+ import rasterInfo from './controllers/rasterInfo.js';
5
+ import mapnikStat from './controllers/mapnikStat.js';
6
+ import mapnikLogger from './controllers/mapnikLogger.js';
4
7
 
5
8
  const publicParams = { config: { policy: 'L0' }, package: 'gis' }; // L0 === public
9
+ const adminParams = { config: { policy: 'L1', role: 'admin' }, package: 'gis' };
6
10
  const params = { config: { policy: 'L1' }, package: 'gis' }; // L1 === authorized only
7
11
 
8
12
  export default async function route(app) {
9
- app.get('/raster-upload/:id', params, uploadRaster);
10
- app.get('/raster-xml/:id', publicParams, createXml);
11
- app.get('/raster-tile/:id/:z/:y/:x', publicParams, rtile);
12
- // temporary support of old alias
13
- if (!app.hasRoute({ method: 'GET', url: '/layer-rtile/:id/:z/:y/:x' })) {
14
- app.get('/layer-rtile/:id/:z/:y/:x', publicParams, rtile);
15
- }
13
+ app.get('/gis-upload-raster/:id', params, uploadRaster);
14
+ app.get('/gis-xml/:id', publicParams, createXml);
15
+ app.get('/gis-rtile/:id/:z/:y/:x', publicParams, rtile);
16
+ app.get('/gis-raster/:id', publicParams, rasterInfo);
17
+ app.get('/gis-stat/:period?', adminParams, mapnikStat);
18
+ app.get('/gis-logger/:type', adminParams, mapnikLogger);
16
19
  }