@opengis/gis 0.2.54 → 0.2.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.2.54",
3
+ "version": "0.2.55",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@ export default async function checkRasterFile({ arr, reply }) {
34
34
  const result = await sequence((arr || []), async ({
35
35
  relpath, idx,
36
36
  }) => {
37
- callback(`${idx + 1}/${arr.length}`);
37
+ callback(`${idx + 1}/${arr.length} (${relpath})`);
38
38
 
39
39
  // check raster upload status, skip for directories
40
40
  const uploadStatus = !path.extname(relpath) ? {} : await GetRasterStatus({ path: relpath });
@@ -71,7 +71,6 @@ export default async function checkRasterFile({ arr, reply }) {
71
71
  const data = await RenderTile({
72
72
  path: relpath,
73
73
  width: 256,
74
- height: 256,
75
74
  bbox: [3713463.7081504324, 6088362.176970857, 3713616.5822070027, 6088515.051027427], // /:id/18/155363/91245.png
76
75
  ttl: '0',
77
76
  }).catch(err => ({ err: err.toString() }));
@@ -46,7 +46,8 @@ export default async function layerList({
46
46
  // parse service style
47
47
  rows.forEach(row => Object.assign(row, { style: row.style ? yml2json(row.style) : null }));
48
48
  // assign service url
49
- rows.filter(row => row.service !== 'ogc').forEach(row => Object.assign(row, { url: `${config.prefix || '/api'}/vtile/${row.id}/ua/{z}/{x}/{y}.vmt` }));
49
+ rows.filter(row => row.service && ['raster', 'cartocss'].includes(row.service)).forEach(row => Object.assign(row, { url: `${config.prefix || '/api'}/gis-rtile/${row.id}/{z}/{x}/{y}.png` }));
50
+ rows.filter(row => !row.url && row.service !== 'ogc').forEach(row => Object.assign(row, { url: `${config.prefix || '/api'}/vtile/${row.id}/ua/{z}/{x}/{y}.vmt` }));
50
51
  // parse extent string to number[]
51
52
  rows.filter(row => row.extent).forEach(row => Object.assign(row, {
52
53
  extent: row.extent.match(/BOX\(([^)]+)\)/)?.[1]
@@ -23,7 +23,6 @@ export default async function checkCarto({
23
23
  const rtile = await RenderTile({
24
24
  name: params.id,
25
25
  width: 256,
26
- height: 256,
27
26
  bbox: [3713463.7081504324, 6088362.176970857, 3713616.5822070027, 6088515.051027427],
28
27
  ttl: '0',
29
28
  // debug: query.debug,
@@ -11,7 +11,7 @@ export default async function mapnikLogger({
11
11
  return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
12
12
  }
13
13
 
14
- if (!['render', 'error', 'info', 'critical'].includes(params.type)) {
14
+ if (params.type && !['render', 'error', 'info', 'critical'].includes(params.type)) {
15
15
  return reply.status(400).send({ error: 'invalid params: type', code: 400 });
16
16
  }
17
17
 
@@ -70,7 +70,6 @@ export default async function rtile({
70
70
  path: cartoExists ? null : raster.source_path, // for rasters only
71
71
  name: id, // required for cartocss
72
72
  width: 256,
73
- height: 256,
74
73
  bbox,
75
74
  ttl: query.nocache ? '0' : '1h',
76
75
  debug: query.debug,
@@ -87,7 +86,7 @@ export default async function rtile({
87
86
 
88
87
  const buffer = Buffer.from(data.base64, 'base64');
89
88
 
90
- return reply.headers({ 'Content-Type': 'image/png', 'Cache-Control': query.nocache ? 'no-cache' : '30d' }).send(buffer);
89
+ return reply.headers({ 'Content-Type': 'image/png', 'Cache-Control': query.nocache ? 'no-store, no-cache, must-revalidate' : 'public, max-age=2592000' }).send(buffer);
91
90
  }
92
91
  catch (err) {
93
92
  logger.file('rtile/error', { error: err.toString(), stack: err.stack });
@@ -16,6 +16,6 @@ export default async function route(app) {
16
16
  app.get('/gis-rtile/:id/:z/:y/:x', publicParams, rtile);
17
17
  app.get('/gis-raster/:id', publicParams, rasterInfo);
18
18
  app.get('/gis-stat/:period?', adminParams, mapnikStat);
19
- app.get('/gis-logger/:type', adminParams, mapnikLogger);
19
+ app.get('/gis-logger/:type?', adminParams, mapnikLogger);
20
20
  app.get('/gis-css/:id', params, checkCarto);
21
21
  }
@@ -1,91 +0,0 @@
1
- import Sphericalmercator from '@mapbox/sphericalmercator';
2
-
3
- import { config, logger, pgClients } from '@opengis/fastify-table/utils.js';
4
-
5
- import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
6
-
7
- const { RenderTile } = mapnik();
8
-
9
- const mercator = new Sphericalmercator({ size: 256 });
10
-
11
- /**
12
- * Формування растрового tile cartoCss
13
- *
14
- * @method GET
15
- * @alias rtile
16
- * @param {String} bbox - bbox
17
- * @param {Number} height - висота по координатам
18
- * @param {Number} width - ширина по координатам
19
- * @param {String} data - стилізація
20
- * @param {String} lang - мова
21
- * @param {String} z - координата z
22
- * @param {String} x - координата y
23
- * @param {String} y - координата x
24
- */
25
-
26
- export default async function rtileMBD({
27
- pg = pgClients.client, params, query,
28
- }, reply) {
29
- if (!RenderTile) {
30
- return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
31
- }
32
-
33
- const { id, z, y } = params;
34
-
35
- const x = params.x.split('.')[0] - 0;
36
-
37
- if (!id) {
38
- return reply.status(400).send({ error: 'not enough params: id', code: 400 });
39
- }
40
-
41
- if (!x || !y || !z) {
42
- return reply.status(400).send({ error: 'not enough params: xyz', code: 400 });
43
- }
44
-
45
- const mbd = pg.pk?.['data_mbd.mbd_existent_detail'] ? await pg.query(`
46
- select
47
- mbd_existent_detail_id as id,
48
- upfile
49
- from data_mbd.mbd_existent_detail a
50
- left join data_mbd.mbd b on a.mbd_id=b.mbd_id
51
- where material_type_id = '3245363247443870877'
52
- and upfile is not null
53
- and upfile ~ '.tif'
54
- and mbd_existent_detail_id=$1
55
- `, [id]).then(el => el.rows?.[0]) : [];
56
-
57
- if (!mbd) {
58
- return reply.status(404).send({ error: 'mbd not found', code: 404 });
59
- }
60
-
61
- const bbox = mercator.bbox(y, x, z, false, '900913');
62
-
63
- try {
64
- const data = await RenderTile({
65
- path: mbd.upfile,
66
- name: id,
67
- width: 256,
68
- height: 256,
69
- bbox,
70
- ttl: query.nocache ? '0' : '1h',
71
- debug: query.debug,
72
- });
73
-
74
- if (query.debug) {
75
- return data;
76
- }
77
-
78
- if (data.err) {
79
- logger.file('rtile/mbd/error', { error: data.err });
80
- return reply.status(500).send({ error: config.local ? data.err : 'render error', code: 500 });
81
- }
82
-
83
- const buffer = Buffer.from(data.base64, 'base64');
84
-
85
- return reply.headers({ 'Content-Type': 'image/png' }).send(buffer);
86
- }
87
- catch (err) {
88
- logger.file('rtile/mbd/error', { error: err.toString(), stack: err.stack });
89
- return reply.status(500).send({ error: config.local ? err.toString() : 'rtile error', code: 500 });
90
- }
91
- }