@opengis/gis 0.2.112 → 0.2.113
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/README.md +146 -3
- package/dist/index.css +1 -1
- package/dist/index.js +1840 -1789
- package/dist/index.umd.cjs +28 -28
- package/module/test/cls/doc_status.json +31 -31
- package/module/test/select/core.user_uid.sql +1 -1
- package/package.json +2 -2
- package/server/plugins/vite.js +0 -1
- package/server/routes/map/controllers/clearTiles.js +34 -0
- package/server/routes/map/index.mjs +5 -1
- package/server/routes/map/vtile1.js +14 -11
|
@@ -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
package/server/plugins/vite.js
CHANGED
|
@@ -63,7 +63,6 @@ async function plugin(fastify, opts) {
|
|
|
63
63
|
const { user } = req.session?.passport || {};
|
|
64
64
|
|
|
65
65
|
if (!user && req.url.split('?')[0] !== '/login') {
|
|
66
|
-
console.log(req.url);
|
|
67
66
|
return reply.redirect(`/login?redirect=${req.url}`);
|
|
68
67
|
}
|
|
69
68
|
if (!isProduction) return null; // admin vite
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import {
|
|
4
|
+
rm, stat, readdir, mkdir,
|
|
5
|
+
} from 'node:fs/promises';
|
|
6
|
+
|
|
7
|
+
import rootFolder from '../../../plugins/mapnik/funcs/rootFolder.mjs';
|
|
8
|
+
|
|
9
|
+
export default async function clearTiles({
|
|
10
|
+
params, query, user,
|
|
11
|
+
}, reply) {
|
|
12
|
+
const filepath = path.join(rootFolder, 'vtile', params.id);
|
|
13
|
+
|
|
14
|
+
if (query.debug && user?.user_type?.includes?.('admin')) {
|
|
15
|
+
return filepath;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const exists = existsSync(filepath);
|
|
19
|
+
const isDirectory = exists ? await stat(filepath).then(el => el.isDirectory()) : false;
|
|
20
|
+
|
|
21
|
+
const count = isDirectory ? await readdir(filepath).then(el => el.length) : 0;
|
|
22
|
+
|
|
23
|
+
if (isDirectory && count === 0) {
|
|
24
|
+
return reply.status(404).send({ error: 'Тайли не знайдено', code: 404 });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isDirectory && exists) {
|
|
28
|
+
await rm(filepath, { force: true, recursive: true });
|
|
29
|
+
await mkdir(filepath, { recursive: true });
|
|
30
|
+
return reply.status(200).send({ message: 'Тайли очищено', code: 200 });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return reply.status(400).send({ error: 'Некорректний параметр: id', code: 400 });
|
|
34
|
+
}
|
|
@@ -4,9 +4,10 @@ import mapFeatures from './controllers/mapFeatures.js';
|
|
|
4
4
|
|
|
5
5
|
import mapCatalog from './controllers/mapCatalog.js';
|
|
6
6
|
import mapCatalogAttribute from './controllers/mapCatalogAttribute.js';
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import vtile from './controllers/vtile.js';
|
|
9
9
|
import vtile1 from './vtile1.js';
|
|
10
|
+
import clearTiles from './controllers/clearTiles.js';
|
|
10
11
|
import geojson from './controllers/geojson.js';
|
|
11
12
|
import jsonData from './controllers/jsonData.js';
|
|
12
13
|
import layerList from './controllers/layerList.js';
|
|
@@ -133,6 +134,9 @@ export default async function route(app) {
|
|
|
133
134
|
console.log('\x1b[34m%s\x1b[0m', 'add vtile from gis');
|
|
134
135
|
app.get('/vtile/:layer/:lang/:z/:y/:x', publicParams, vtile1);
|
|
135
136
|
}
|
|
137
|
+
if (!app.hasRoute({ method: 'GET', url: '/api/gis-clear-vtile/:id' })) {
|
|
138
|
+
app.get('/gis-clear-vtile/:id', publicParams, clearTiles);
|
|
139
|
+
}
|
|
136
140
|
|
|
137
141
|
if (!app.hasRoute({ method: 'GET', url: '/api/geojson/:layer' })) {
|
|
138
142
|
console.log('\x1b[34m%s\x1b[0m', 'add geojson from gis');
|
|
@@ -31,7 +31,7 @@ export default async function vtile({
|
|
|
31
31
|
const { y, z } = params;
|
|
32
32
|
const x = params.x.split('.')[0] - 0;
|
|
33
33
|
const {
|
|
34
|
-
type, nocache, sql, clusterZoom, filter,
|
|
34
|
+
type, nocache, sql, clusterZoom, filter, nottl,
|
|
35
35
|
} = query;
|
|
36
36
|
|
|
37
37
|
const hash = [type, clusterZoom, filter].join();
|
|
@@ -41,24 +41,27 @@ export default async function vtile({
|
|
|
41
41
|
`/vtile/${params.layer}/${hash ? `${createHash('md5').update(hash).digest('hex')}/` : ''}${z}/${x}/${y}.vmt`,
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
// layer
|
|
45
|
+
const [map, layer] = params.layer.includes(':') ? params.layer.split(':') : [null, params.layer];
|
|
46
|
+
|
|
47
|
+
// service
|
|
48
|
+
const data = await getTemplate('layer', layer) || await pg.query(`select * from gis.services where ${!user?.uid ? 'is_public and is_active' : '1=1'} and service_id=$1`, [layer]).then(el => el.rows?.[0]);
|
|
49
|
+
const style = typeof data?.style === 'object' ? data?.style : yaml.load(data?.style);
|
|
50
|
+
|
|
51
|
+
const cacheZoom = style?.cacheZoom || 13;
|
|
52
|
+
const ttl = typeof style?.ttl === 'number' && style.ttl >= 0 ? style.ttl : 86400000;
|
|
53
|
+
|
|
54
|
+
if (existsSync(filepath) && +z < cacheZoom && !nocache && !sql && process.env.NODE_ENV !== 'test') {
|
|
45
55
|
const { birthtimeMs = Date.now() } = await stat(filepath);
|
|
46
56
|
const ageInMs = Date.now() - birthtimeMs;
|
|
47
|
-
if (ageInMs <
|
|
57
|
+
if (ageInMs < ttl) {
|
|
48
58
|
const buffer = await readFile(filepath);
|
|
49
59
|
return reply.status(200).headers(headers).send(buffer);
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
// layer
|
|
54
|
-
const [map, layer] = params.layer.includes(':') ? params.layer.split(':') : [null, params.layer];
|
|
55
|
-
|
|
56
|
-
// service
|
|
57
|
-
const data = await getTemplate('layer', layer) || await pg.query(`select * from gis.services where ${!user?.uid ? 'is_public and is_active' : '1=1'} and service_id=$1`, [layer]).then(el => el.rows?.[0]);
|
|
58
|
-
|
|
59
63
|
const geom = data?.geometry_column || 'geom';
|
|
60
64
|
const table = data?.source_path;
|
|
61
|
-
const style = typeof data?.style === 'object' ? data?.style : yaml.load(data?.style);
|
|
62
65
|
const filterList = data?.filters;
|
|
63
66
|
const layerQuery = data?.query;
|
|
64
67
|
|
|
@@ -172,5 +175,5 @@ export default async function vtile({
|
|
|
172
175
|
await writeFile(filepath, buffer, 'binary');
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
return reply.headers({ ...headers, 'Cache-Control': nocache ? 'no-cache' : headers['Cache-Control'] }).send(buffer);
|
|
178
|
+
return reply.headers({ ...headers, 'Cache-Control': nocache || nottl ? 'no-cache' : headers['Cache-Control'] }).send(buffer);
|
|
176
179
|
}
|