@opengis/gis 0.1.82 → 0.2.0
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 +4665 -5874
- package/dist/index.umd.cjs +40 -56
- package/module/gis/table/gis.group_list.table.json +36 -0
- package/module/test/cls/doc_status.json +31 -31
- package/module/test/cls/ts.temp_structure.ts_class.json +50 -0
- package/module/test/layer/bp.json +60 -0
- package/module/test/map/address4.json +2 -42
- package/module/test/map/bp_myo.json +37 -0
- package/module/test/map/main.json +44 -0
- package/module/test/map/mbd.json +24 -176
- package/module/test/map/ts.json +20 -129
- package/module/test/select/core.user_uid.sql +1 -1
- package/package.json +61 -61
- package/server/migrations/widgets.sql +21 -0
- package/server/routes/gis/index.mjs +2 -0
- package/server/routes/gis/services/get.services.js +4 -2
- package/server/routes/gis/services/legend.auto.js +78 -0
- package/server/routes/map/controllers/mapFormat.js +4 -5
- package/server/routes/map/index.mjs +36 -17
- package/server/routes/map/maps/add.map.js +42 -0
- package/server/routes/map/maps/del.map.js +19 -0
- package/server/routes/map/maps/get.map.js +65 -0
- package/server/routes/map/vtile1.js +12 -4
- package/server/routes/map/widgets/add.widget.js +39 -0
- package/server/routes/map/widgets/del.widget.js +23 -0
- package/server/routes/map/widgets/get.widget.js +41 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import yaml from 'js-yaml';
|
|
3
|
+
import { getMeta, getTemplate, pgClients, getTemplates, getTemplateSync } from "@opengis/fastify-table/utils.js";
|
|
4
|
+
|
|
5
|
+
const table = 'gis.maps';
|
|
6
|
+
|
|
7
|
+
const columnType = {
|
|
8
|
+
text: 'text',
|
|
9
|
+
date: 'date',
|
|
10
|
+
bool: 'yes/no',
|
|
11
|
+
numeric: 'number',
|
|
12
|
+
integer: 'number',
|
|
13
|
+
'timestamp without time zone': 'date',
|
|
14
|
+
'timestamp with time zone': 'date',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default async function getMap({ params = {}, pg = pgClients.client }, reply) {
|
|
18
|
+
const { columns = [] } = await getMeta({ pg, table }) || {};
|
|
19
|
+
|
|
20
|
+
const fields = columns.map(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'], label: title || name }));
|
|
21
|
+
const mapList = getTemplates('map').map(el => el[0]);
|
|
22
|
+
|
|
23
|
+
const rows = pg.pk?.['gis.maps'] ? await pg.query(
|
|
24
|
+
`SELECT map_id as id, * FROM gis.maps where ${params.id ? 'map_id=$1' : '1=1'}`,
|
|
25
|
+
[params.id].filter(Boolean),
|
|
26
|
+
).then(el => el.rows || []) : [];
|
|
27
|
+
|
|
28
|
+
if (params.id && !mapList.includes(params.id) && !rows[0]) {
|
|
29
|
+
return { status: 404, message: 'map not found'}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (params.id) {
|
|
33
|
+
const map = rows[0] || {};
|
|
34
|
+
const loadTemplate = await getTemplate('map', params.id) || await getTemplate('map', map.map_key);
|
|
35
|
+
|
|
36
|
+
const obj = loadTemplate;
|
|
37
|
+
|
|
38
|
+
if (Array.isArray(obj?.layers) && typeof obj?.layers?.[0] === 'string') {
|
|
39
|
+
const layers = await Promise.all(obj.layers.map(async (layer) => {
|
|
40
|
+
const layerData = await getTemplate('layer', layer);
|
|
41
|
+
const serviceData = layerData || await pg.query('select service_id as id, * from gis.services where service_id=$1', [layer]).then(el => el.rows?.[0]);
|
|
42
|
+
serviceData.style = yaml.load(serviceData.style);
|
|
43
|
+
return { ...serviceData, id: layer,visible:true };
|
|
44
|
+
}));
|
|
45
|
+
return { ...rows[0],...obj, layers };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return reply.status(200).send({ ...rows[0], ...loadTemplate });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (params.id && !rows.length) {
|
|
52
|
+
return reply.status(404).send('map not found');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (params.id) {
|
|
56
|
+
return reply.status(200).send({ ...rows[0], fields });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
maps.filter(el => Object.keys(el).length > 1).forEach(el => rows.push(el));
|
|
60
|
+
return reply.status(200).send({
|
|
61
|
+
template,
|
|
62
|
+
rows,
|
|
63
|
+
fields,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -22,10 +22,18 @@ export default async function vtile({ params = {}, query, pg, user }, reply) {
|
|
|
22
22
|
const mapData = map ? await getTemplate('map', map) : {};
|
|
23
23
|
const mapStyle = mapData?.widgets?.find?.(el => el.type === 'attribute')?.config?.layer?.style;
|
|
24
24
|
|
|
25
|
-
const geom =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
25
|
+
const geom = data?.geometry_column
|
|
26
|
+
|| data1?.geometry_column
|
|
27
|
+
|| 'geom';
|
|
28
|
+
const table = data?.source_path
|
|
29
|
+
|| data?.table_name
|
|
30
|
+
|| data1?.source_path;
|
|
31
|
+
const style = mapStyle
|
|
32
|
+
|| data?.style
|
|
33
|
+
|| (data1?.style ? yaml.load(data1?.style) : null);
|
|
34
|
+
const filterList = data?.filters
|
|
35
|
+
|| data?.filter_list
|
|
36
|
+
|| data1?.filters;
|
|
29
37
|
const layerQuery = data?.query || data1?.query;
|
|
30
38
|
|
|
31
39
|
// bbox
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
export default async function addWidget({
|
|
3
|
+
method, params = {}, body, pg = pgClients.client, user = {},
|
|
4
|
+
}, reply) {
|
|
5
|
+
const { uid } = user;
|
|
6
|
+
|
|
7
|
+
if (!uid) {
|
|
8
|
+
return reply.status(401).send('unauthorized');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!params.map) {
|
|
12
|
+
return reply.status(400).send('not enough params: map id');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (method === 'PUT' && !params.id) {
|
|
16
|
+
return reply.status(400).send('not enough params: id');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (method === 'POST') {
|
|
20
|
+
Object.assign(body, { map_id: params.map });
|
|
21
|
+
const { rows = [] } = await dataInsert({
|
|
22
|
+
pg,
|
|
23
|
+
id: params.id,
|
|
24
|
+
table: 'gis.widgets',
|
|
25
|
+
data: body,
|
|
26
|
+
uid,
|
|
27
|
+
});
|
|
28
|
+
return reply.status(200).send(rows[0]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const row = await dataUpdate({
|
|
32
|
+
pg,
|
|
33
|
+
id: params.id,
|
|
34
|
+
table: 'gis.widgets',
|
|
35
|
+
data: body,
|
|
36
|
+
uid,
|
|
37
|
+
});
|
|
38
|
+
return reply.status(200).send(row);
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
export default async function delWidget({
|
|
4
|
+
params = {}, pg = pgClients.client, user = {},
|
|
5
|
+
}, reply) {
|
|
6
|
+
const { uid } = user;
|
|
7
|
+
|
|
8
|
+
if (!uid) {
|
|
9
|
+
return reply.status(401).send('unauthorized');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!params.map) {
|
|
13
|
+
return reply.status(400).send('not enough params: map id');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const row = await dataDelete({
|
|
17
|
+
pg,
|
|
18
|
+
id: params.id,
|
|
19
|
+
table: 'gis.widgets',
|
|
20
|
+
uid,
|
|
21
|
+
});
|
|
22
|
+
return reply.status(200).send(row);
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getMeta, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
const table = 'gis.widgets';
|
|
4
|
+
|
|
5
|
+
const columnType = {
|
|
6
|
+
text: 'text',
|
|
7
|
+
date: 'date',
|
|
8
|
+
bool: 'yes/no',
|
|
9
|
+
numeric: 'number',
|
|
10
|
+
integer: 'number',
|
|
11
|
+
'timestamp without time zone': 'date',
|
|
12
|
+
'timestamp with time zone': 'date',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default async function getWidget({ params = {}, pg = pgClients.client }, reply) {
|
|
16
|
+
if (!params.map) {
|
|
17
|
+
return reply.status(400).send('not enough params: map id');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { columns = [] } = await getMeta({ pg, table }) || {};
|
|
21
|
+
|
|
22
|
+
const fields = columns.map(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'], label: title || name }));
|
|
23
|
+
|
|
24
|
+
const rows = pg.pk?.['gis.maps'] && pg.pk?.['gis.widgets'] ? await pg.query(
|
|
25
|
+
`SELECT widget_id as id, * FROM gis.widgets where map_id=$1 and ${params.id ? 'widget_id=$2' : '1=1'}`,
|
|
26
|
+
[params.map, params.id].filter(Boolean),
|
|
27
|
+
).then(el => el.rows || []) : [];
|
|
28
|
+
|
|
29
|
+
if (params.id && !rows.length) {
|
|
30
|
+
return reply.status(404).send('widget not found');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (params.id) {
|
|
34
|
+
return reply.status(200).send({ ...rows[0], fields });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return reply.status(200).send({
|
|
38
|
+
rows,
|
|
39
|
+
fields,
|
|
40
|
+
});
|
|
41
|
+
}
|