@opengis/bi 1.0.39 → 1.0.40
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pgClients, getFilterSQL } from '@opengis/fastify-table/utils.js';
|
|
1
|
+
import { pgClients, getFilterSQL, getSelectVal } from '@opengis/fastify-table/utils.js';
|
|
2
2
|
|
|
3
3
|
import { getWidget } from '../../../../utils.js';
|
|
4
4
|
|
|
@@ -29,6 +29,12 @@ export default async function map(req) {
|
|
|
29
29
|
const { rows = [] } = await pg.query(
|
|
30
30
|
`select count(*), "${data.color}" as val from ${data.table} where ${data.query || '1=1'} group by "${data.color}"`
|
|
31
31
|
);
|
|
32
|
+
if (data?.cls) {
|
|
33
|
+
const vals = await getSelectVal({
|
|
34
|
+
pg, name: data.cls, values: rows.map(el => el.val),
|
|
35
|
+
});
|
|
36
|
+
rows.forEach(row => Object.assign(row, { val: vals?.[row.val || ''] || row.val }));
|
|
37
|
+
}
|
|
32
38
|
Object.assign(res, { colors: rows }); // кольори для легенди
|
|
33
39
|
}
|
|
34
40
|
if (data?.metrics?.length) {
|
|
@@ -40,13 +46,13 @@ export default async function map(req) {
|
|
|
40
46
|
PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY "${metric}") as "100" from ${data.table} where ${data.query || '1=1'} and ${q || '1=1'}`;
|
|
41
47
|
const sizes = await pg
|
|
42
48
|
.query(q1)
|
|
43
|
-
.then(
|
|
49
|
+
.then(el => Object.values(el.rows?.[0] || {}));
|
|
44
50
|
Object.assign(res, { sizes }); // розміри для легенди
|
|
45
51
|
}
|
|
46
52
|
const { bounds, extentStr } = await pg.query(`select count(*),
|
|
47
53
|
st_asgeojson(st_extent(geom))::json as bounds,
|
|
48
54
|
replace(regexp_replace(st_extent(geom)::box2d::text,'BOX\\(|\\)','','g'),' ',',') as "extentStr"
|
|
49
|
-
from ${data.table} where ${data.query || '1=1'}`).then(
|
|
55
|
+
from ${data.table} where ${data.query || '1=1'}`).then(el => el.rows?.[0] || {});
|
|
50
56
|
const extent = extentStr ? extentStr.split(',') : undefined;
|
|
51
57
|
|
|
52
58
|
Object.assign(res, {
|