@opengis/gis 0.2.103 → 0.2.105

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.
@@ -1,32 +1,32 @@
1
- [
2
- {
3
- "id": "1",
4
- "text": "Діючий",
5
- "color": "#1ab394"
6
- },
7
- {
8
- "id": "2",
9
- "text": "Зупинений",
10
- "color": "#ed82c8"
11
- },
12
- {
13
- "id": "3",
14
- "text": "Скасований",
15
- "color": "#4a4a4a"
16
- },
17
- {
18
- "id": "5",
19
- "text": "Проектний",
20
- "color": "#6495ed"
21
- },
22
- {
23
- "id": "7",
24
- "text": "Очікує розгляду",
25
- "color": "#92b8ef"
26
- },
27
- {
28
- "id": "10",
29
- "text": "Архівний",
30
- "color": "#d48428"
31
- }
1
+ [
2
+ {
3
+ "id": "1",
4
+ "text": "Діючий",
5
+ "color": "#1ab394"
6
+ },
7
+ {
8
+ "id": "2",
9
+ "text": "Зупинений",
10
+ "color": "#ed82c8"
11
+ },
12
+ {
13
+ "id": "3",
14
+ "text": "Скасований",
15
+ "color": "#4a4a4a"
16
+ },
17
+ {
18
+ "id": "5",
19
+ "text": "Проектний",
20
+ "color": "#6495ed"
21
+ },
22
+ {
23
+ "id": "7",
24
+ "text": "Очікує розгляду",
25
+ "color": "#92b8ef"
26
+ },
27
+ {
28
+ "id": "10",
29
+ "text": "Архівний",
30
+ "color": "#d48428"
31
+ }
32
32
  ]
@@ -1 +1 @@
1
- select uid, coalesce(coalesce(sur_name,'')||coalesce(' '||user_name,'') ||coalesce(' '||father_name,''),login) as text from admin.users
1
+ select uid, coalesce(coalesce(sur_name,'')||coalesce(' '||user_name,'') ||coalesce(' '||father_name,''),login) as text from admin.users
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.2.103",
3
+ "version": "0.2.105",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "./dist/index.js",
@@ -33,6 +33,7 @@ message RenderTileRequest {
33
33
  int32 width = 4;
34
34
  string ttl = 5; // "5m", "1h", "1d" or "0"
35
35
  string debug = 6;
36
+ optional bool skipSubdir = 7;
36
37
  }
37
38
 
38
39
  message RenderTileOut {
@@ -114,6 +115,7 @@ message CreateXMLRequest {
114
115
  string debug = 7;
115
116
  string nocache = 8;
116
117
  string proj4 = 9;
118
+ bool skipSubdir = 10;
117
119
  }
118
120
 
119
121
  message UploadXMLRequest {
@@ -185,6 +187,7 @@ message GetRasterInfoRequest {
185
187
  string ttl = 2;
186
188
  int64 srid = 3;
187
189
  string proj4 = 4;
190
+ bool skipSubdir = 5;
188
191
  }
189
192
 
190
193
  message FileItem {
@@ -18,7 +18,7 @@ export default async function checkCarto({
18
18
  }
19
19
 
20
20
  // extract all columns, migrations-agnostic
21
- 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 from gis.cartocss where cartocss_id=$1', [params.id]).then(el => el.rows?.[0]);
21
+ 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
22
 
23
23
  if (!cartocss) {
24
24
  return reply.status(404).send({ error: `cartocss not found: ${params.id}`, code: 404 });
@@ -28,14 +28,15 @@ export default async function checkCarto({
28
28
  Object.keys(cartocss).filter(key => exclude.includes(key)).forEach(key => delete cartocss[key]);
29
29
 
30
30
  const rtile = await RenderTile({
31
- name: params.id,
31
+ name: cartocss.source_path ? `vector/${cartocss.source_path}` : params.id, // required for cartocss
32
32
  width: 256,
33
33
  bbox: [3713463.7081504324, 6088362.176970857, 3713616.5822070027, 6088515.051027427],
34
34
  ttl: '0',
35
35
  // debug: query.debug,
36
36
  }).catch(err => ({ err: err.toString() }));
37
37
 
38
- const bounds = cartocss.bounds || await cartoBounds({ id: params.id, dataset: cartocss.config }, pg);
38
+ // 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);
39
40
 
40
41
  return {
41
42
  time: Date.now() - time,
@@ -1,12 +1,17 @@
1
1
  import { pgClients } from "@opengis/fastify-table/utils.js";
2
2
 
3
- export default async function cartoBounds({ id, dataset }, pg = pgClients.client) {
4
- const sqlBounds = dataset.map(el => ({ tbl: el.table.replace(/"/g, "").split('.'), geom: el.gcol || 'geom' })).map(({ tbl, geom }) => `select ST_EstimatedExtent('${tbl[0]}','${tbl[1]}', '${geom}')`);
5
- // const sqlBounds = dataset.map(el => ({ srid: el.srid || 4326, tbl: el.table.split('.'), geom: el.gcol || 'geom' })).map(({ tbl, geom, srid }) => `select st_transform(st_setsrid(ST_EstimatedExtent('${tbl[0]}','${tbl[1]}', '${geom}'),${srid}),4326) as st_estimatedextent`);
3
+ export default async function cartoBounds({ id, dataset, table }, pg = pgClients.client) {
4
+ if (!dataset?.length && !table) {
5
+ return [-180, -85.05112877980659, 180, 85.05112877980659];
6
+ }
7
+
8
+ 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.join('.')} limit 1)),4326)`)
10
+ : [`select ST_Transform(ST_SetSRID(ST_EstimatedExtent('${table.split('.')[0]}', '${table.split('.')[1]}', 'geom'),(SELECT st_srid(geom) from ${table} limit 1)),4326)`];
6
11
 
7
12
  const geom = await pg.query(
8
13
  `update gis.cartocss set
9
- geom=(select st_extent(st_estimatedextent) from ( ${sqlBounds.join(' union all ')})q )
14
+ geom=(select st_extent(st_transform) from ( ${sqlBounds.join(' union all ')})q )
10
15
  where cartocss_id=$1 returning geom::box2d`,
11
16
  [id],
12
17
  ).then(e => e.rows?.[0]?.geom);
@@ -91,8 +91,8 @@ export default async function uploadXML({
91
91
  }],
92
92
  };
93
93
 
94
- // generate
95
- const res = new carto.Renderer().render(configJson);
94
+ // generate mapnik_version: 3,
95
+ const res = new carto.Renderer({ mapnik_version: 3, cache_resources: true, strict: false }).render(configJson);
96
96
  const xmlFileText = typeof res === 'string' ? res : res?.data;
97
97
  if (!xmlFileText) {
98
98
  throw new Error('xml generation error');