@opengis/gis 0.2.102 → 0.2.104
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/dist/index.css +1 -1
- package/dist/index.js +506 -506
- package/dist/index.umd.cjs +18 -18
- package/package.json +4 -4
- package/plugin.js +7 -1
- package/server/routes/gis/cartocss/add.cartocss.js +9 -6
- package/server/routes/gis/cartocss/get.cartocss.js +4 -3
- package/server/routes/map/controllers/mapFormat.js +1 -1
- package/server/routes/mapnik/functions/cartoBounds.js +9 -4
- package/server/routes/mapnik/functions/uploadXML.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/gis",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.104",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Softpro",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@opengis/core": "^0.0.23",
|
|
56
|
-
"@opengis/fastify-table": "^2.0.
|
|
56
|
+
"@opengis/fastify-table": "^2.0.146",
|
|
57
57
|
"@opengis/filter": "0.1.33",
|
|
58
58
|
"@opengis/form": "^0.0.103",
|
|
59
59
|
"@opengis/table": "^0.0.27",
|
|
60
60
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
61
|
-
"axios": "^1.13.
|
|
61
|
+
"axios": "^1.13.6",
|
|
62
62
|
"eslint": "^8.57.1",
|
|
63
63
|
"eslint-config-airbnb": "19.0.4",
|
|
64
64
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"sass-embedded": "1.86.3",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
71
|
"vite": "^6.4.1",
|
|
72
|
-
"vue": "^3.5.
|
|
72
|
+
"vue": "^3.5.29",
|
|
73
73
|
"vue-router": "4.5.1",
|
|
74
74
|
"vuedraggable": "^4.1.0"
|
|
75
75
|
}
|
package/plugin.js
CHANGED
|
@@ -16,12 +16,18 @@ execMigrations(join(dir, 'server/migrations'), pgClients.client).catch(err => co
|
|
|
16
16
|
|
|
17
17
|
const columnType = {
|
|
18
18
|
text: 'text',
|
|
19
|
+
'character varying': 'text',
|
|
20
|
+
character: 'text',
|
|
19
21
|
date: 'date',
|
|
20
|
-
|
|
22
|
+
boolean: 'yes/no',
|
|
21
23
|
numeric: 'number',
|
|
22
24
|
integer: 'number',
|
|
25
|
+
'double precision': 'number',
|
|
23
26
|
'timestamp without time zone': 'date',
|
|
24
27
|
'timestamp with time zone': 'date',
|
|
28
|
+
'text[]': 'array',
|
|
29
|
+
'integer[]': 'array',
|
|
30
|
+
'character varying[]': 'array',
|
|
25
31
|
};
|
|
26
32
|
const adminParams = { config: { policy: 'L1', role: 'admin' }, package: 'gis' };
|
|
27
33
|
async function plugin(app, opts = config) {
|
|
@@ -28,12 +28,15 @@ export default async function addCartocss(req, reply) {
|
|
|
28
28
|
uid: user?.uid,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
// if not from static xml file
|
|
32
|
+
if (!data.source_path) {
|
|
33
|
+
await uploadXML({
|
|
34
|
+
id: params.id,
|
|
35
|
+
dataset: config,
|
|
36
|
+
style,
|
|
37
|
+
source_path: sourcePath,
|
|
38
|
+
}, pg);
|
|
39
|
+
}
|
|
37
40
|
|
|
38
41
|
return reply.status(200).send({ message: 'cartocss updated', code: 200 });
|
|
39
42
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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(
|
|
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);
|
|
@@ -97,14 +97,14 @@ export default async function uploadXML({
|
|
|
97
97
|
if (!xmlFileText) {
|
|
98
98
|
throw new Error('xml generation error');
|
|
99
99
|
}
|
|
100
|
-
const { status } = await UploadXML({
|
|
100
|
+
const { status, error } = await UploadXML({
|
|
101
101
|
path: relpath ? `vector/${relpath}` : null,
|
|
102
102
|
name: relpath ? null : id,
|
|
103
103
|
xml: xmlFileText,
|
|
104
|
-
});
|
|
104
|
+
}).catch((err) => ({ error: err.toString() }));
|
|
105
105
|
|
|
106
106
|
if (status !== 'success') {
|
|
107
|
-
throw new Error('xml upload error');
|
|
107
|
+
throw new Error(error || 'xml upload error');
|
|
108
108
|
}
|
|
109
109
|
return xmlFileText;
|
|
110
110
|
}
|