@opengis/gis 0.2.78 → 0.2.80
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 +5564 -5216
- package/dist/index.umd.cjs +67 -56
- package/module/gis/select/admin.cls.name.sql +1 -1
- package/module/gis/table/gis.group_list.table.json +25 -2
- package/package.json +3 -3
- package/server/routes/map/controllers/layerList.js +1 -1
- package/server/routes/map/maps/get.map.js +64 -31
- package/server/routes/mapnik/controllers/rasterInfo.js +1 -1
|
@@ -18,19 +18,42 @@
|
|
|
18
18
|
"export",
|
|
19
19
|
"add"
|
|
20
20
|
],
|
|
21
|
+
"sql": [
|
|
22
|
+
{
|
|
23
|
+
"sql": "select sum(count) as count from ( select count(*) from gis.cartocss where group_id=t.group_id union all select count(*) from gis.ogc_service where group_id=t.group_id union all select count(*) from gis.rasters where group_id=t.group_id union all select count(*) from gis.services where group_id=t.group_id )q",
|
|
24
|
+
"name": "count_sql"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
21
27
|
"form": "gis.group_list.form",
|
|
22
28
|
"columns": [
|
|
23
29
|
{
|
|
24
30
|
"ua": "Назва",
|
|
25
31
|
"name": "group_name",
|
|
26
|
-
"width": 200,
|
|
27
32
|
"format": "text"
|
|
28
33
|
},
|
|
29
34
|
{
|
|
30
|
-
"ua": "
|
|
35
|
+
"ua": "Кількість георесурсів",
|
|
36
|
+
"name": "count",
|
|
37
|
+
"format": "text"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"ua": "Вкл/Викл",
|
|
31
41
|
"name": "enabled",
|
|
32
42
|
"format": "boolean",
|
|
33
43
|
"edit": true
|
|
34
44
|
}
|
|
45
|
+
],
|
|
46
|
+
"filters": [
|
|
47
|
+
{
|
|
48
|
+
"name": "group_name",
|
|
49
|
+
"ua": "Назва",
|
|
50
|
+
"type": "Text"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "enabled",
|
|
54
|
+
"ua": "Вкл/Викл",
|
|
55
|
+
"data": "yes_no",
|
|
56
|
+
"type": "Check"
|
|
57
|
+
}
|
|
35
58
|
]
|
|
36
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/gis",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.80",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Softpro",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@opengis/core": "^0.0.23",
|
|
55
|
-
"@opengis/fastify-table": "^2.0.
|
|
55
|
+
"@opengis/fastify-table": "^2.0.135",
|
|
56
56
|
"@opengis/filter": "0.1.31",
|
|
57
57
|
"@opengis/form": "^0.0.103",
|
|
58
58
|
"@opengis/table": "^0.0.27",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint-plugin-import": "^2.32.0",
|
|
64
64
|
"eslint-plugin-vue": "^9.33.0",
|
|
65
65
|
"@vue/eslint-config-typescript": "^12.0.0",
|
|
66
|
-
"vue-eslint-parser": "^10.
|
|
66
|
+
"vue-eslint-parser": "^10.4.0",
|
|
67
67
|
"lucide-vue-next": "^0.514.0",
|
|
68
68
|
"sass-embedded": "1.86.3",
|
|
69
69
|
"typescript": "^5.9.3",
|
|
@@ -41,7 +41,7 @@ export default async function layerList({
|
|
|
41
41
|
from gis.rasters s where is_active and ${!user.uid ? 'is_public' : '1=1'}
|
|
42
42
|
union all
|
|
43
43
|
select cartocss_id as id, name, null as category, style, geom::box2d as bbox, st_asgeojson(geom)::json as geom,
|
|
44
|
-
coalesce('/api/gis-rtile/'||cartocss_id||'/{z}/{x}/{y}.png
|
|
44
|
+
coalesce('/api/gis-rtile/'||cartocss_id||'/{z}/{x}/{y}.png',null) as url, 'cartocss' as service, group_id,
|
|
45
45
|
null as popup, null as card, null as filters, source_path
|
|
46
46
|
from gis.cartocss where enabled and ${!user.uid ? 'is_public' : '1=1'}
|
|
47
47
|
`;
|
|
@@ -17,49 +17,89 @@ const columnType = {
|
|
|
17
17
|
export default async function getMap({ params = {}, pg = pgClients.client }, reply) {
|
|
18
18
|
const { columns = [] } = await getMeta({ pg, table }) || {};
|
|
19
19
|
|
|
20
|
-
const fields = columns.map(({ name, dataTypeID, title }) => ({
|
|
20
|
+
const fields = columns.map(({ name, dataTypeID, title }) => ({
|
|
21
|
+
name,
|
|
22
|
+
type: columnType[pg.pgType?.[dataTypeID] || 'text'],
|
|
23
|
+
label: title || name
|
|
24
|
+
}));
|
|
25
|
+
|
|
21
26
|
const mapList = getTemplates('map').map(el => el[0]);
|
|
22
27
|
|
|
23
28
|
const rows = pg.pk?.['gis.maps'] ? await pg.query(
|
|
24
|
-
`SELECT map_id as id, *
|
|
29
|
+
`SELECT map_id as id, * FROM gis.maps where ${params.id ? '$1 in (map_id,map_key)' : '1=1'}`,
|
|
25
30
|
[params.id].filter(Boolean),
|
|
26
31
|
).then(el => el.rows || []) : [];
|
|
27
32
|
|
|
28
33
|
if (params.id && !mapList?.includes(params.id) && !rows[0]) {
|
|
29
|
-
return { status: 404, message: 'map not found' };
|
|
34
|
+
return reply.status(404).send({ status: 404, message: 'map not found' });
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
const totals = pg.queryCache ? await pg.queryCache('select json_object_agg(oid::regclass, reltuples) from pg_class')
|
|
33
38
|
.then(el => el.rows?.[0]?.json_object_agg || {}) : {};
|
|
39
|
+
|
|
34
40
|
const maps = pg.pk?.['gis.maps'] ? await pg.query(
|
|
35
|
-
'SELECT map_id as id, map_key as slug, name
|
|
41
|
+
'SELECT map_id as id, map_key as slug, name FROM gis.maps where is_active and is_public order by name',
|
|
36
42
|
).then(el => el.rows || []) : [];
|
|
37
43
|
|
|
38
44
|
if (params.id) {
|
|
39
45
|
const map = rows[0] || {};
|
|
40
46
|
const loadTemplate = await getTemplate('map', params.id) || await getTemplate('map', map.map_key);
|
|
41
|
-
|
|
42
47
|
const obj = loadTemplate || map;
|
|
43
48
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const rawIds = [
|
|
50
|
+
...(Array.isArray(obj?.layers) ? obj.layers : []),
|
|
51
|
+
...(Array.isArray(obj?.ogc) ? obj.ogc : []),
|
|
52
|
+
...(Array.isArray(obj?.cartocss) ? obj.cartocss : []),
|
|
53
|
+
...(Array.isArray(obj?.rasters) ? obj.rasters : [])
|
|
54
|
+
];
|
|
55
|
+
const layerIds = [...new Set(rawIds.map(id => id?.toString().trim()).filter(Boolean))];
|
|
56
|
+
|
|
57
|
+
let layers = [];
|
|
58
|
+
|
|
59
|
+
if (layerIds.length > 0) {
|
|
60
|
+
const [resServices, resOgc, resRasters, resCarto] = await Promise.all([
|
|
61
|
+
pg.query(`SELECT service_id::text as id, *, st_asgeojson(bbox)::json as bbox, st_asgeojson(center)::json as center FROM gis.services WHERE is_active = true AND is_public = true AND service_id::text = ANY($1)`, [layerIds]),
|
|
62
|
+
pg.query(`SELECT ogc_service_id::text as id, url as service_url, * FROM gis.ogc_service WHERE enabled = true AND isadmin = false AND ogc_service_id::text = ANY($1)`, [layerIds]),
|
|
63
|
+
pg.query(`SELECT raster_id::text as id, *, st_asgeojson(bbox)::json as bbox, st_asgeojson(center)::json as center FROM gis.rasters WHERE is_active = true AND ispublic = true AND isadmin = false AND raster_id::text = ANY($1)`, [layerIds]),
|
|
64
|
+
pg.query(`SELECT cartocss_id::text as id, *, st_asgeojson(geom)::json as bbox FROM gis.cartocss WHERE enabled = true AND is_public = true AND cartocss_id::text = ANY($1)`, [layerIds])
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
const allFetchedLayers = [
|
|
68
|
+
...resServices.rows.map(row => ({ ...row, type: row.service_type || 'layer' })),
|
|
69
|
+
...resOgc.rows.map(row => ({ ...row, type: 'ogc', source_path: row.table_name })),
|
|
70
|
+
...resRasters.rows.map(row => ({ ...row, type: 'raster' })),
|
|
71
|
+
...resCarto.rows.map(row => ({ ...row, type: 'cartocss' }))
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const dbLayersMap = new Map(allFetchedLayers.map(l => [String(l.id), l]));
|
|
75
|
+
|
|
76
|
+
const layersResults = await Promise.all(layerIds.map(async (id) => {
|
|
77
|
+
const idStr = String(id);
|
|
78
|
+
|
|
79
|
+
if (!dbLayersMap.has(idStr)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const dbData = dbLayersMap.get(idStr);
|
|
84
|
+
const templateData = await getTemplate('layer', idStr);
|
|
85
|
+
|
|
86
|
+
const layerData = { ...dbData, ...(templateData || {}) };
|
|
87
|
+
|
|
88
|
+
layerData.count = totals[layerData.source_path || ''] || 0;
|
|
89
|
+
layerData.visible = true;
|
|
90
|
+
|
|
91
|
+
if (layerData.style && typeof layerData.style === 'string') {
|
|
92
|
+
if (layerData.type === 'cartocss') {
|
|
93
|
+
layerData.style = layerData.style.replace(/\s+/g, ' ').trim();
|
|
94
|
+
} else if (layerData.type !== 'ogc') {
|
|
95
|
+
layerData.style = yml2json(layerData.style);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return layerData;
|
|
52
100
|
}));
|
|
53
|
-
}
|
|
54
101
|
|
|
55
|
-
|
|
56
|
-
await Promise.all(obj.layers.map(async (layer) => {
|
|
57
|
-
const layerData = await getTemplate('layer', layer);
|
|
58
|
-
const serviceData = layerData || await pg.query('select service_id as id, *, st_asgeojson(bbox)::json as bbox, st_asgeojson(center)::json as center from gis.services where service_id=$1', [layer]).then(el => el.rows?.[0]);
|
|
59
|
-
Object.assign(serviceData || {}, { count: totals[serviceData?.source_path || ''] || 0 });
|
|
60
|
-
if (serviceData) { serviceData.style = typeof serviceData.style === 'object' ? serviceData.style : yml2json(serviceData.style); }
|
|
61
|
-
layers.push({ ...(serviceData || {}), id: layer, visible: !!serviceData });
|
|
62
|
-
}));
|
|
102
|
+
layers = layersResults.filter(Boolean);
|
|
63
103
|
}
|
|
64
104
|
|
|
65
105
|
return reply.status(200).send({ maps, ...obj, layers });
|
|
@@ -69,12 +109,5 @@ export default async function getMap({ params = {}, pg = pgClients.client }, rep
|
|
|
69
109
|
return reply.status(404).send('map not found');
|
|
70
110
|
}
|
|
71
111
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return reply.status(200).send({
|
|
77
|
-
rows,
|
|
78
|
-
fields,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
112
|
+
return reply.status(200).send(params.id ? { ...rows[0], fields } : { rows, fields });
|
|
113
|
+
}
|