@opengis/gis 0.2.128 → 0.2.129

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.128",
3
+ "version": "0.2.129",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "./dist/index.js",
@@ -7,6 +7,7 @@ import {
7
7
  import convertBoundToTile from '../functions/convertBoundToTile.js';
8
8
  import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
9
9
  import cartoBounds from '../functions/cartoBounds.js';
10
+ import rasterInfo from './rasterInfo.js';
10
11
 
11
12
  const { RenderTile } = mapnik();
12
13
 
@@ -46,8 +47,8 @@ export default async function pretile({
46
47
  return reply.status(422).send({ error: 'Error: querystring/max must be > querystring/zoom', code: 422 });
47
48
  }
48
49
 
49
- const data = await pg.query(`select *, geom::box2d as bounds, 'raster' as source_type from gis.rasters where raster_id=$1`, [params.id]).then(el => el.rows?.[0])
50
- || await pg.query(`select *, geom::box2d as bounds, 'css' as source_type from gis.cartocss where cartocss_id=$1`, [params.id]).then(el => el.rows?.[0]);
50
+ const data = await pg.query(`select *, 'raster' as source_type from gis.rasters where raster_id=$1`, [params.id]).then(el => el.rows?.[0])
51
+ || await pg.query(`select *, 'css' as source_type from gis.cartocss where cartocss_id=$1`, [params.id]).then(el => el.rows?.[0]);
51
52
 
52
53
  if (!data) {
53
54
  return reply.status(404).send({ error: 'not found', code: 404 });
@@ -62,7 +63,7 @@ export default async function pretile({
62
63
  // refresh extent
63
64
  const bounds = data.source_type === 'css'
64
65
  ? await cartoBounds({ id: data.cartocss_id, dataset: data.config/* , table: data.card_table */ }, pg)
65
- : data.bounds?.replace?.(')', '').substr(4).split(/[, ]/g).map((el) => el - 0);
66
+ : await rasterInfo({ pg, params: { id: data.raster_id }, query: {} }).then(el => el?.extent); // data.bounds?.replace?.(')', '').substr(4).split(/[, ]/g).map((el) => el - 0)
66
67
 
67
68
  send(`start: ${data.name} ${params.id} ${bounds} ${data.srid} ${data.proj4}`);
68
69
 
@@ -16,7 +16,7 @@ export default async function rasterInfo({
16
16
  }
17
17
 
18
18
  const raster = pg.pk?.['gis.rasters']
19
- ? await pg.query('select raster_id, source_path, name, description, raster_key, is_active, is_public, srid, proj4 from gis.rasters where raster_id=$1::text', [params.id])
19
+ ? await pg.query('select raster_id, source_path, name, description, raster_key, is_active, is_public, srid, proj4, geom from gis.rasters where raster_id=$1::text', [params.id])
20
20
  .then(el => el.rows?.[0] || {})
21
21
  : {};
22
22
 
@@ -42,6 +42,10 @@ export default async function rasterInfo({
42
42
  return { data, cache, raster };
43
43
  }
44
44
 
45
+ if (!raster.geom && Array.isArray(data?.extent)) {
46
+ await pg.query(`update gis.rasters set geom = ST_MakeEnvelope(${data.extent.join(',')}) where raster_id = $1`, [raster.raster_id]);
47
+ }
48
+
45
49
  return {
46
50
  time: Date.now() - time,
47
51
  ...data || {},