@opengis/gis 0.2.97 → 0.2.99
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 +7774 -6984
- package/dist/index.umd.cjs +102 -67
- package/module/test/cls/doc_status.json +31 -31
- package/module/test/map/main.json +1 -0
- package/module/test/map/mbd.json +1 -0
- package/module/test/map/ts.json +1 -0
- package/module/test/select/core.user_uid.sql +1 -1
- package/package.json +1 -1
- package/server/routes/mapnik/controllers/rtile.js +40 -29
|
@@ -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
|
]
|
package/module/test/map/mbd.json
CHANGED
package/module/test/map/ts.json
CHANGED
|
@@ -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
|
@@ -2,7 +2,9 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
|
|
3
3
|
import Sphericalmercator from '@mapbox/sphericalmercator';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
config, logger, pgClients, dataUpdate,
|
|
7
|
+
} from '@opengis/fastify-table/utils.js';
|
|
6
8
|
|
|
7
9
|
import mapnik from '../../../plugins/mapnik/funcs/mapnik.js';
|
|
8
10
|
|
|
@@ -26,7 +28,7 @@ const mercator = new Sphericalmercator({ size: 256 });
|
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
30
|
export default async function rtile({
|
|
29
|
-
pg = pgClients.client, params, query,
|
|
31
|
+
pg = pgClients.client, params, query, user,
|
|
30
32
|
}, reply) {
|
|
31
33
|
if (!RenderTile) {
|
|
32
34
|
return reply.status(400).send({ error: 'mapnik server address needed', code: 400 });
|
|
@@ -44,26 +46,35 @@ export default async function rtile({
|
|
|
44
46
|
return reply.status(400).send({ error: 'not enough params: xyz', code: 400 });
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const decodedPath = Buffer.from(id, 'base64url').toString('utf-8');
|
|
50
|
+
|
|
51
|
+
const data = pg.pk?.['gis.rasters']
|
|
52
|
+
? await pg.queryCache(`select raster_id as id, source_path, is_public, 'raster' as type from gis.rasters where raster_id=$1::text or source_path=$2::text`, { args: [id, decodedPath], table: 'gis.rasters' })
|
|
49
53
|
.then(el => el.rows?.[0] || {})
|
|
50
54
|
: {};
|
|
51
55
|
|
|
52
|
-
// const relpath = raster ? `/map/raster/${raster.source_path}` : null;
|
|
53
|
-
|
|
54
56
|
const carto = pg.pk?.['gis.cartocss']
|
|
55
|
-
? await pg.
|
|
56
|
-
.then(el => el.rows?.[0] || {})
|
|
57
|
+
? await pg.queryCache('select cartocss_id, source_path, is_public from gis.cartocss where cartocss_id=$1::text', { args: [id], table: 'gis.cartocss' }).then(el => el.rows?.[0] || {})
|
|
57
58
|
: {};
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
if (carto.cartocss_id) {
|
|
61
|
+
Object.assign(data, {
|
|
62
|
+
id: carto.cartocss_id,
|
|
63
|
+
source_path: carto.source_path,
|
|
64
|
+
is_public: carto.is_public,
|
|
65
|
+
type: 'css',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!user?.uid && data.is_public === false) {
|
|
70
|
+
return reply.status(403).send({ error: 'access restricted', code: 403 });
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
if (!
|
|
62
|
-
|
|
63
|
-
Object.assign(raster, { source_path: decodedPath });
|
|
73
|
+
if (!data.id && data.type !== 'css') {
|
|
74
|
+
Object.assign(data, { source_path: decodedPath });
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
if (!
|
|
77
|
+
if (!data.source_path && data.type !== 'css') {
|
|
67
78
|
return reply.status(404).send({ error: 'raster / cartocss not found', code: 404 });
|
|
68
79
|
}
|
|
69
80
|
|
|
@@ -71,51 +82,51 @@ export default async function rtile({
|
|
|
71
82
|
|
|
72
83
|
try {
|
|
73
84
|
const ttl = (query.nocache ? '0' : null)
|
|
74
|
-
|| (
|
|
85
|
+
|| (data.type === 'css' ? '1h' : null);
|
|
75
86
|
|
|
76
|
-
const md5 =
|
|
77
|
-
? createHash('md5').update(
|
|
87
|
+
const md5 = data.source_path
|
|
88
|
+
? createHash('md5').update(data.source_path).digest('hex')
|
|
78
89
|
: undefined;
|
|
79
|
-
const base64 =
|
|
80
|
-
? Buffer.from(
|
|
90
|
+
const base64 = data.source_path
|
|
91
|
+
? Buffer.from(data.source_path).toString('base64url')
|
|
81
92
|
: undefined;
|
|
82
93
|
|
|
83
94
|
const param = {
|
|
84
|
-
path:
|
|
85
|
-
name:
|
|
95
|
+
path: data.type === 'css' ? null : data.source_path, // for rasters only
|
|
96
|
+
name: data.type === 'css' && data.source_path ? `vector/${data.source_path}` : id, // required for cartocss
|
|
86
97
|
width: 256,
|
|
87
98
|
bbox,
|
|
88
99
|
ttl,
|
|
89
100
|
debug: query.debug,
|
|
90
101
|
};
|
|
91
102
|
// console.log(param);
|
|
92
|
-
const
|
|
103
|
+
const result = await RenderTile(param);
|
|
93
104
|
|
|
94
105
|
if (query.debug) {
|
|
95
106
|
return {
|
|
96
|
-
...
|
|
107
|
+
...result,
|
|
97
108
|
ttl,
|
|
98
109
|
md5_path: md5,
|
|
99
110
|
base64_path: base64,
|
|
100
|
-
raster: !!
|
|
101
|
-
carto:
|
|
111
|
+
raster: !!data.id,
|
|
112
|
+
carto: data.type === 'css',
|
|
102
113
|
};
|
|
103
114
|
}
|
|
104
115
|
|
|
105
|
-
if (
|
|
116
|
+
if (result.err) {
|
|
106
117
|
logger.file('rtile/error', {
|
|
107
|
-
error:
|
|
118
|
+
error: result.err, x, y, z, id: data.id, type: data.type,
|
|
108
119
|
});
|
|
109
|
-
return reply.status(500).send({ error: config.local ?
|
|
120
|
+
return reply.status(500).send({ error: config.local ? result.err : 'render error', code: 500 });
|
|
110
121
|
}
|
|
111
122
|
|
|
112
|
-
const buffer = Buffer.from(
|
|
123
|
+
const buffer = Buffer.from(result.base64, 'base64');
|
|
113
124
|
|
|
114
125
|
return reply.headers({ 'Content-Type': 'image/png', 'Cache-Control': query.nocache || query.nottl ? 'no-store, no-cache, must-revalidate' : 'public, max-age=2592000' }).send(buffer);
|
|
115
126
|
}
|
|
116
127
|
catch (err) {
|
|
117
128
|
logger.file('rtile/error', {
|
|
118
|
-
error: err.toString(), stack: err.stack, x, y, z, id:
|
|
129
|
+
error: err.toString(), stack: err.stack, x, y, z, id: data.id, type: data.type,
|
|
119
130
|
});
|
|
120
131
|
return reply.status(500).send({ error: config.local ? err.toString() : 'rtile error', code: 500 });
|
|
121
132
|
}
|