@opengis/gis 0.2.129 → 0.2.131

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 (25) hide show
  1. package/dist/{CardIcon-DgpYeKbG.js → CardIcon-Bty3pjDA.js} +1 -1
  2. package/dist/{EntityTablePage-DNdVavT4.js → EntityTablePage-Bx4SIoW8.js} +1 -1
  3. package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-DQnIBCpE.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-DRnlsqEC.js} +24 -22
  4. package/dist/{HeaderActions.vue_vue_type_script_setup_true_lang-Cg2y4sIa.js → HeaderActions.vue_vue_type_script_setup_true_lang-CpDC-v8-.js} +345 -321
  5. package/dist/{MapSettings-CHF3VpUu.js → MapSettings-Bw4WyHXT.js} +12 -12
  6. package/dist/{RastersTablePage-Ci3P3r4c.js → RastersTablePage-Cjb2zg5J.js} +1 -1
  7. package/dist/cartocss-sXf_ZeCv.js +1053 -0
  8. package/dist/{import-utils-ElncWVJV.js → import-utils-DdinjlC4.js} +1 -1
  9. package/dist/{index-UGx54M0Q.js → index-DtOSF_ba.js} +377 -386
  10. package/dist/index.css +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/index.umd.cjs +41 -41
  13. package/dist/raster-D7fESzin.js +792 -0
  14. package/dist/{register-BfNUPbey.js → register-C_mb5TbK.js} +3 -3
  15. package/dist/{service-DsykdHry.js → service-BUb9DRGZ.js} +911 -879
  16. package/dist/{vs-datatable-D6g7tjZo.js → vs-datatable-D-FY2azp.js} +1 -1
  17. package/package.json +2 -2
  18. package/server/routes/gis/cartocss/get.cartocss.js +11 -2
  19. package/server/routes/gis/registers/add.registry.js +3 -4
  20. package/server/routes/gis/registers/funcs/columns.js +2 -4
  21. package/server/routes/mapnik/controllers/pretile.js +7 -9
  22. package/server/routes/mapnik/controllers/rtile.js +13 -1
  23. package/server/routes/mapnik/functions/cartoBounds.js +6 -2
  24. package/dist/cartocss-BsaIlSRb.js +0 -894
  25. package/dist/raster-BDWEafwx.js +0 -663
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as F, mergeModels as O, defineAsyncComponent as I, useModel as R, ref as y, watch as K, openBlock as o, createElementBlock as s, createElementVNode as e, createVNode as $, unref as x, withCtx as S, createStaticVNode as V, useSlots as P, computed as H, Fragment as b, createTextVNode as U, createCommentVNode as N, renderList as A, normalizeStyle as Q, toDisplayString as M, normalizeClass as z, withModifiers as X, createBlock as Y, resolveDynamicComponent as ee, withDirectives as te, renderSlot as ne } from "vue";
2
2
  import { notify as E } from "@opengis/core";
3
3
  import { Edit as le, Trash as oe } from "lucide-vue-next";
4
- import { _ as u } from "./index-UGx54M0Q.js";
4
+ import { _ as u } from "./index-DtOSF_ba.js";
5
5
  const se = { class: "flex items-center justify-center col-span-3 gap-2" }, re = { class: "flex justify-end p-[20px] gap-[10px] border-t w-full" }, ie = /* @__PURE__ */ F({
6
6
  __name: "vs-datatable-controls",
7
7
  props: /* @__PURE__ */ O({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.2.129",
3
+ "version": "0.2.131",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "./dist/index.js",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@opengis/core": "^0.0.23",
56
- "@opengis/fastify-table": "^2.0.147",
56
+ "@opengis/fastify-table": "^2.1.1",
57
57
  "@opengis/filter": "0.1.33",
58
58
  "@opengis/form": "^0.0.133",
59
59
  "@opengis/table": "^0.0.27",
@@ -10,13 +10,15 @@ const { prefix = '/api' } = config;
10
10
  const exclude = ['created_at', 'updated_at', 'created_by', 'updated_by'];
11
11
 
12
12
  export default async function checkCarto({
13
- pg = pgClients.client, params,
13
+ pg = pgClients.client, params, query, user,
14
14
  }, reply) {
15
15
  const time = Date.now();
16
16
  if (!config.mapnik?.server) {
17
17
  return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
18
18
  }
19
19
 
20
+ const { sql } = query || {};
21
+
20
22
  // extract all columns, migrations-agnostic
21
23
  const cartocss = await pg.query('select *, ARRAY[ST_XMin(geom), ST_YMin(geom), ST_XMax(geom), ST_YMax(geom)] as bounds, st_asgeojson(geom)::json as geom, source_path from gis.cartocss where cartocss_id=$1', [params.id]).then(el => el.rows?.[0]);
22
24
 
@@ -36,7 +38,13 @@ export default async function checkCarto({
36
38
  }).catch(err => ({ err: err.toString() }));
37
39
 
38
40
  // skip empty bounds[null,null,null,null]
39
- const bounds = cartocss.bounds && cartocss.geom ? cartocss.bounds : await cartoBounds({ id: params.id, dataset: cartocss.config, table: cartocss.card_table }, pg);
41
+ const bounds = cartocss.bounds && cartocss.geom && !(query.nocache && user?.user_type?.includes?.('admin')) ? cartocss.bounds : await cartoBounds({
42
+ id: params.id, dataset: cartocss.config, table: cartocss.card_table, sql,
43
+ }, pg).catch(err => ({ err: err.toString() }));
44
+
45
+ if (!(cartocss.bounds && cartocss.geom) && sql && user?.user_type?.includes?.('admin')) {
46
+ return bounds;
47
+ }
40
48
 
41
49
  return {
42
50
  time: Date.now() - time,
@@ -46,5 +54,6 @@ export default async function checkCarto({
46
54
  bounds,
47
55
  render: !!rtile.base64,
48
56
  renderError: rtile.err && config.local ? rtile.err : !!rtile.err,
57
+ boundsError: bounds?.err && config.local ? bounds.err : !!bounds.err,
49
58
  };
50
59
  }
@@ -4,18 +4,17 @@ export default async function addGisRegistry({
4
4
  method, params = {}, body, pg = pgClients.client, user = {},
5
5
  }, reply) {
6
6
  if (method === 'POST') {
7
-
8
7
  if (!body?.register_key) {
9
8
  return reply.status(400).send('not enough body params: register_key');
10
9
  }
11
10
 
12
- const { rows = [] } = await dataInsert({
11
+ const res = await dataInsert({
13
12
  pg,
14
13
  table: 'gis.registers',
15
14
  data: body,
16
15
  uid: user?.uid,
17
16
  });
18
- return reply.status(200).send(rows[0]);
17
+ return reply.status(200).send(res.data);
19
18
  }
20
19
 
21
20
  if (!params.slug) {
@@ -33,4 +32,4 @@ export default async function addGisRegistry({
33
32
  });
34
33
 
35
34
  return reply.status(200).send(row);
36
- }
35
+ }
@@ -1,5 +1,3 @@
1
1
  export function extractVisibleColumns(columns, mode = "table") {
2
- return columns.filter((col) =>
3
- mode === "card" ? col.hidden_card !== true : col.hidden_register !== true
4
- );
5
- }
2
+ return (columns || []).filter((col) => (mode === "card" ? col.hidden_card !== true : col.hidden_register !== true));
3
+ }
@@ -47,13 +47,17 @@ export default async function pretile({
47
47
  return reply.status(422).send({ error: 'Error: querystring/max must be > querystring/zoom', code: 422 });
48
48
  }
49
49
 
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]);
50
+ 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])
51
+ || 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]);
52
52
 
53
53
  if (!data) {
54
54
  return reply.status(404).send({ error: 'not found', code: 404 });
55
55
  }
56
56
 
57
+ if (!data.bounds || data.bounds === 'BOX(-180 -85.05112877980659,180 85.05112877980659)') {
58
+ return reply.status(400).send({ error: 'geom is not set', code: 400 });
59
+ }
60
+
57
61
  const send = eventStream(reply);
58
62
 
59
63
  try {
@@ -61,16 +65,10 @@ export default async function pretile({
61
65
  const name = data.source_type === 'css' ? ['vector', config.mapnik?.folder || '', data.source_path || params.id].filter(Boolean).join('/') : null;
62
66
 
63
67
  // refresh extent
64
- const bounds = data.source_type === 'css'
65
- ? await cartoBounds({ id: data.cartocss_id, dataset: data.config/* , table: data.card_table */ }, pg)
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)
68
+ const bounds = data.bounds.replace(')', '').substr(4).split(/[, ]/g).map((el) => el - 0);
67
69
 
68
70
  send(`start: ${data.name} ${params.id} ${bounds} ${data.srid} ${data.proj4}`);
69
71
 
70
- if (!bounds) {
71
- return send('geom is not set');
72
- }
73
-
74
72
  bounds[0] = Math.max(bounds[0], maxBounds[0]);
75
73
  bounds[1] = Math.max(bounds[1], maxBounds[1]);
76
74
 
@@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
4
4
  import SphericalMercator from '@mapbox/sphericalmercator';
5
5
 
6
6
  import {
7
- config, logger, pgClients,
7
+ config, logger, pgClients, getRedis,
8
8
  } from '@opengis/fastify-table/utils.js';
9
9
 
10
10
  import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
@@ -13,6 +13,8 @@ const { RenderTile } = mapnik();
13
13
 
14
14
  const mercator = new SphericalMercator({ size: 256 });
15
15
 
16
+ const rclient = getRedis();
17
+
16
18
  /**
17
19
  * Формування растрового tile cartoCss
18
20
  *
@@ -47,6 +49,16 @@ export default async function gisRtile({
47
49
  return reply.status(400).send({ error: 'not enough params: xyz', code: 400 });
48
50
  }
49
51
 
52
+ const isLocked = rclient ? await rclient.get(`rtile:${id}:${x}:${y}:${z}`) : false;
53
+
54
+ if (isLocked) {
55
+ console.log('is locked', `rtile:${id}:${x}:${y}:${z}`);
56
+ return reply.status(400).send({ error: 'tile locked', code: 400 });
57
+ }
58
+
59
+ if (rclient) await rclient.set(`rtile:${id}:${x}:${y}:${z}`, 1, 'EX', 10);
60
+ console.log('not locked', `rtile:${id}:${x}:${y}:${z}`);
61
+
50
62
  const decodedPath = Buffer.from(id, 'base64url').toString('utf-8');
51
63
 
52
64
  const data = pg.pk?.['gis.rasters']
@@ -1,14 +1,18 @@
1
1
  import { pgClients } from "@opengis/fastify-table/utils.js";
2
2
 
3
- export default async function cartoBounds({ id, dataset, table }, pg = pgClients.client) {
3
+ export default async function cartoBounds({
4
+ id, dataset, table, sql,
5
+ }, pg = pgClients.client) {
4
6
  if (!dataset?.length && !table) {
5
7
  return [-180, -85.05112877980659, 180, 85.05112877980659];
6
8
  }
7
9
 
8
10
  const sqlBounds = dataset
9
- ? dataset.map(el => ({ tbl: el.table.replace(/"/g, "").split('.'), geom: el.gcol || 'geom' })).map(({ tbl, geom }) => `select ST_Transform(ST_SetSRID( ST_EstimatedExtent('${tbl[0]}','${tbl[1]}', '${geom}'), (SELECT st_srid(${geom}) from ${tbl[0]}."${tbl[1]}" limit 1)),4326)`)
11
+ ? dataset.filter((el, idx, arr) => el.table && arr.findIndex(item => item.table === el.table && (el.gcol || 'geom') === (item.gcol || 'geom')) === idx).map(el => ({ tbl: el.table.replace(/"/g, "").split('.'), geom: el.gcol || 'geom' })).map(({ tbl, geom }) => `select ST_Transform(ST_SetSRID( ST_EstimatedExtent('${tbl[0]}','${tbl[1]}', '${geom}'), (SELECT st_srid(${geom}) from ${tbl[0]}."${tbl[1]}" limit 1)),4326)`)
10
12
  : [`select ST_Transform(ST_SetSRID(ST_EstimatedExtent('${table.replace(/"/g, "").split('.')[0]}', '${table.replace(/"/g, "").split('.')[1]}', 'geom'),(SELECT st_srid(geom) from ${table.split('.')[0]}."${table.split('.')[1]}" limit 1)),4326)`];
11
13
 
14
+ if (sql) return sqlBounds.join(' \nunion all\n ');
15
+
12
16
  const geom = await pg.query(
13
17
  `update gis.cartocss set
14
18
  geom=(select st_extent(st_transform) from ( ${sqlBounds.join(' union all ')})q )