@opengis/gis 0.2.0 → 0.2.2

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.
Files changed (47) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.js +5317 -3461
  3. package/dist/index.umd.cjs +53 -38
  4. package/module/cls.json +2 -1
  5. package/module/gis/form/gis.maps.form.json +2 -2
  6. package/module/gis/form/gis.registers.form.json +8 -199
  7. package/module/gis/form/gis.services.form.json +11 -200
  8. package/module/gis/table/gis.maps.table.json +5 -7
  9. package/module/gis/table/gis.ogc_service.table.json +14 -3
  10. package/module/gis/table/gis.registers.table.json +2 -3
  11. package/module/gis/table/gis.services.table.json +19 -6
  12. package/module/test/cls/ts.temp_status.json +18 -0
  13. package/module/test/cls/ts.temp_type.json +10 -0
  14. package/module/test/layer/bp1.yml +33 -0
  15. package/module/test/map/addr.yml +21 -0
  16. package/module/test/map/bp_myo.json +22 -15
  17. package/module/test/map/bpf.json +44 -0
  18. package/module/test/map/mbd.json +13 -13
  19. package/module/test/map/ts.json +15 -11
  20. package/module/test/select/address_id.json +3 -0
  21. package/module/test/select/address_id.sql +8 -0
  22. package/module/test/table/data_bp_myo.bp.table.json +123 -0
  23. package/package.json +11 -5
  24. package/server/migrations/ogc.sql +107 -0
  25. package/server/plugins/vite.js +3 -7
  26. package/server/routes/gis/index.mjs +16 -2
  27. package/server/routes/gis/ogc/map.info.point.js +120 -0
  28. package/server/routes/gis/registers/funcs/classifiers.js +6 -3
  29. package/server/routes/gis/registers/funcs/handleRegistryRequest.js +15 -22
  30. package/server/routes/gis/registers/gis.registry.js +3 -2
  31. package/server/routes/gis/services/add.service.js +5 -5
  32. package/server/routes/gis/services/get.services.col.js +19 -11
  33. package/server/routes/gis/services/get.services.js +25 -12
  34. package/server/routes/map/controllers/layerList.js +14 -2
  35. package/server/routes/map/controllers/mapFeatures.js +11 -2
  36. package/server/routes/map/controllers/mapFormat.js +13 -16
  37. package/server/routes/map/controllers/vtile.js +1 -1
  38. package/server/routes/map/maps/get.map.js +17 -12
  39. package/server/routes/map/vtile1.js +38 -23
  40. package/module/test/map/address/addr.yml +0 -6
  41. package/module/test/map/address/index.yml +0 -22
  42. package/module/test/map/address/street.yml +0 -16
  43. package/module/test/map/address2/addr.json +0 -9
  44. package/module/test/map/address2/index.json +0 -35
  45. package/module/test/map/address2/street.json +0 -19
  46. package/module/test/map/address3.yml +0 -52
  47. package/module/test/map/address4.json +0 -34
@@ -4,37 +4,26 @@ const headers = {
4
4
  };
5
5
  import Sphericalmercator from '@mapbox/sphericalmercator';
6
6
  const mercator = new Sphericalmercator({ size: 256 });
7
- import { getTemplate, getMeta, getFilterSQL } from '@opengis/fastify-table/utils.js';
7
+ import { getColumnCLS, getTemplate, getMeta, getFilterSQL } from '@opengis/fastify-table/utils.js';
8
8
  import yaml from 'js-yaml';
9
9
 
10
+ const propsCache = {};
11
+
10
12
  export default async function vtile({ params = {}, query, pg, user }, reply) {
11
13
  const { y, z } = params;
12
14
  const x = params.x.split('.')[0] - 0;
13
15
 
14
16
  // layer
15
17
  const [map, layer] = params.layer.includes(':') ? params.layer.split(':') : [null, params.layer];
16
- const data = await getTemplate('layer', layer);
18
+
17
19
  // service
18
- const data1 = await pg.query(`select * from gis.services where is_active and ${!user?.uid ? 'is_public' : '1=1'} and service_id=$1`, [layer]).then(el => el.rows?.[0]);
19
- if (!data && !data1) return { status: 404, message: 'not found' }
20
-
21
- // style
22
- const mapData = map ? await getTemplate('map', map) : {};
23
- const mapStyle = mapData?.widgets?.find?.(el => el.type === 'attribute')?.config?.layer?.style;
24
-
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;
37
- const layerQuery = data?.query || data1?.query;
20
+ const data = await getTemplate('layer', layer) || await pg.query(`select * from gis.services where is_active and ${!user?.uid ? 'is_public' : '1=1'} and service_id=$1`, [layer]).then(el => el.rows?.[0]);
21
+
22
+ const geom = data?.geometry_column || 'geom';
23
+ const table = data?.source_path;
24
+ const style = typeof data?.style ==='object'?data?.style: yaml.load(data?.style) ;
25
+ const filterList = data?.filters;
26
+ const layerQuery = data?.query;
38
27
 
39
28
  // bbox
40
29
  const bbox = mercator.bbox(+y, +x, +z, false/* , '900913' */);
@@ -55,6 +44,32 @@ export default async function vtile({ params = {}, query, pg, user }, reply) {
55
44
  return el.type?.[0] === '_' ? `${el.name}[1] as ${el.name}` : `${el.name}${['int4'].includes(el.type) ? '::text' : ''}`;
56
45
  });
57
46
 
47
+ const obj = (data.card || []).concat(data.popup || []).filter(el => el.data).reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {});
48
+
49
+ const propsWithCls = propsCache[layer] ?? await Promise.all(props.map(async (key, idx) => {
50
+ const { name, type, sql } = getColumnCLS(table, key) || {};
51
+ if (name && type === 'cls') {
52
+ return `(select name from admin.cls where parent='${name}' and code::text="${key}"::text limit 1) as "${key}_text","${key}"::text`;
53
+ }
54
+ if (type === 'select' && sql) {
55
+ const { fields = [] } = await pg.query(sql + ' limit 0');
56
+ return `(select "${fields[1].name}" from (${sql})s${idx} where "${fields[0].name}"="${key}" limit 1) as "${key}_text","${key}"::text`
57
+ }
58
+
59
+ if (obj[key]) {
60
+ const clsdata = await pg.query('select name, type, data as sql from admin.cls where name=$1', [obj[key]]).then(el => el.rows?.[0] || {});
61
+ if (clsdata.name && clsdata.type === 'json') {
62
+ return `(select name from admin.cls where parent='${clsdata.name}' and code::text="${key}"::text limit 1) as "${key}_text","${key}"::text`;
63
+ }
64
+ if (clsdata.type === 'sql' && clsdata.sql) {
65
+ const { fields = [] } = await pg.query(clsdata.sql + ' limit 0');
66
+ return `(select "${fields[1].name}" from (${clsdata.sql})s${idx} where "${fields[0].name}"="${key}" limit 1) as "${key}_text","${key}"::text`
67
+ }
68
+ }
69
+ return `"${key}"::text`;
70
+ }));
71
+ if (!propsCache[layer]) { propsCache[layer] = propsWithCls; }
72
+
58
73
  const geomCol = (style?.type === 'point' ? `ST_Centroid(${geom})` : null)
59
74
  || (parseInt(z, 10) < parseInt(query.pointZoom || style?.pointZoom || style?.iconZoom || '0', 10) ? `ST_Centroid(${geom})` : geom);
60
75
 
@@ -90,7 +105,7 @@ export default async function vtile({ params = {}, query, pg, user }, reply) {
90
105
 
91
106
  floor(random() * 100000 + 1)::int + row_number() over() as row,
92
107
 
93
- ${props?.length ? `${props.map(el => `"${el}"::text`).join(',')},` : ''}
108
+ ${props?.length ? `${propsWithCls.join(',')},` : ''}
94
109
 
95
110
  ${pkey} as id,
96
111
  ST_AsMVTGeom(st_transform(${geomCol},3857),ST_TileEnvelope(${z},${y},${x})::box2d,4096,256,false) geom
@@ -1,6 +0,0 @@
1
- label: Адреси
2
- source_path: data_address.address
3
- style:
4
- color: "#555"
5
- weight: 1.5
6
- visible: false
@@ -1,22 +0,0 @@
1
- ---
2
- id: address
3
- name: address
4
- title: Адресний реєстр
5
- description: Адресний реєстр
6
- center:
7
- - 30.5234
8
- - 50.4501
9
- zoom: 12
10
- basemap: osm
11
- sources: []
12
- widgets:
13
- - type: legend
14
- position: bottom-right
15
- config:
16
- items:
17
- - label: Житлова зона
18
- color: "#4caf50"
19
- - label: Комерційна зона
20
- color: "#2196f3"
21
- - label: Промислова зона
22
- color: "#f44336"
@@ -1,16 +0,0 @@
1
- label: Вулиці
2
- source_path: data_address.street.table
3
- style:
4
- attribute: type
5
- colors:
6
- "1": "#4caf50"
7
- "2": "#2196f3"
8
- "3": "#f44336"
9
- "4": "#4caf50"
10
- "5": "#2196f3"
11
- "6": "#f44336"
12
- "8": "#4caf50"
13
- "9": "#2196f3"
14
- "11": "#f44336"
15
- "16": "#4caf50"
16
- visible: true
@@ -1,9 +0,0 @@
1
- {
2
- "label": "Адреси",
3
- "source_path": "data_address.address",
4
- "style": {
5
- "color": "#555",
6
- "weight": 1.5
7
- },
8
- "visible": false
9
- }
@@ -1,35 +0,0 @@
1
- {
2
- "id": "address3",
3
- "name": "address",
4
- "title": "Адресний реєстр",
5
- "description": "Адресний реєстр",
6
- "center": [
7
- 30.5234,
8
- 50.4501
9
- ],
10
- "zoom": 12,
11
- "basemap": "osm",
12
- "sources": [],
13
- "widgets": [
14
- {
15
- "type": "legend",
16
- "position": "bottom-right",
17
- "config": {
18
- "items": [
19
- {
20
- "label": "Житлова зона",
21
- "color": "#4caf50"
22
- },
23
- {
24
- "label": "Комерційна зона",
25
- "color": "#2196f3"
26
- },
27
- {
28
- "label": "Промислова зона",
29
- "color": "#f44336"
30
- }
31
- ]
32
- }
33
- }
34
- ]
35
- }
@@ -1,19 +0,0 @@
1
- {
2
- "label": "Вулиці",
3
- "source_path": "data_address.street.table",
4
- "style": {
5
- "attribute": "type",
6
- "colors": {
7
- "1": "#4caf50",
8
- "2": "#2196f3",
9
- "3": "#f44336",
10
- "4": "#4caf50",
11
- "5": "#2196f3",
12
- "6": "#f44336",
13
- "8": "#4caf50",
14
- "9": "#2196f3",
15
- "11": "#f44336",
16
- "16": "#4caf50"
17
- }
18
- }
19
- }
@@ -1,52 +0,0 @@
1
- ---
2
- id: address1
3
- name: address1
4
- title: Адресний реєстр
5
- description: Адресний реєстр.
6
- center:
7
- - 30.5234
8
- - 50.4501
9
- zoom: 12
10
- basemap: osm
11
- sources: []
12
- layers:
13
- - id: address3
14
- label: Адреси
15
- source_path: data_address.address
16
- style:
17
- attribute: type
18
- colors:
19
- build: "Будівля / Споруда"
20
- countrySeat: "Садибний / Садовий / Дачний будинок"
21
- landPlot: "Земельна ділянка"
22
- complex: "Комплекс будівель і споруд"
23
- undergroundObject: "Підземний об’єкт"
24
- visible: true
25
- - id: street3
26
- label: Вулиці
27
- source_path: data_address.street.table
28
- style:
29
- attribute: type
30
- colors:
31
- "1": "#4caf50"
32
- "2": "#2196f3"
33
- "3": "#f44336"
34
- "4": "#4caf50"
35
- "5": "#2196f3"
36
- "6": "#f44336"
37
- "8": "#4caf50"
38
- "9": "#2196f3"
39
- "11": "#f44336"
40
- "16": "#4caf50"
41
- visible: true
42
- widgets:
43
- - type: legend
44
- position: bottom-right
45
- config:
46
- items:
47
- - label: Житлова зона
48
- color: "#4caf50"
49
- - label: Комерційна зона
50
- color: "#2196f3"
51
- - label: Промислова зона
52
- color: "#f44336"
@@ -1,34 +0,0 @@
1
- {
2
- "id": "address2",
3
- "name": "address",
4
- "title": "Адресний реєстр",
5
- "description": "Адресний реєстр.",
6
- "center": [
7
- 30.5234,
8
- 50.4501
9
- ],
10
- "zoom": 12,
11
- "layers": [],
12
- "widgets": [
13
- {
14
- "type": "legend",
15
- "position": "bottom-right",
16
- "config": {
17
- "items": [
18
- {
19
- "label": "Житлова зона",
20
- "color": "#4caf50"
21
- },
22
- {
23
- "label": "Комерційна зона",
24
- "color": "#2196f3"
25
- },
26
- {
27
- "label": "Промислова зона",
28
- "color": "#f44336"
29
- }
30
- ]
31
- }
32
- }
33
- ]
34
- }