@opengis/gis 0.1.36 → 0.1.37

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.
@@ -11,6 +11,10 @@
11
11
  "id": "features",
12
12
  "text": "Опис"
13
13
  },
14
+ {
15
+ "id": "tags",
16
+ "text": "Ключові слова"
17
+ },
14
18
  {
15
19
  "id": "other",
16
20
  "text": "Інше"
@@ -15,6 +15,16 @@
15
15
  {
16
16
  "sql": "select json_agg(q) as metadata_all from (select scale, katottg,srid, region, name, purpose, source,keywords,update_frequency,year,date_created,size,access_constraints,license from gis.metadata where layer_id=t.service_id limit 1)q ",
17
17
  "name": "metadata_list_sql"
18
+ },
19
+ {
20
+ "name": "is_export_sql",
21
+ "sql": "select jsonb_path_exists(attributes, '$[*] ? (@.is_export == true)') as is_export"
22
+ },
23
+ {
24
+ "ua": "Наявність колонок для експорту",
25
+ "name": "is_export",
26
+ "data": "yes_no",
27
+ "format": "badge"
18
28
  }
19
29
  ],
20
30
  "title": "Сервіси",
@@ -101,4 +111,4 @@
101
111
  "type": "Text"
102
112
  }
103
113
  ]
104
- }
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "dist/import-file.js",
@@ -11,9 +11,9 @@ export default async function getInfo({ finalInfo, format }, reply) {
11
11
  const exportable = columns.filter(c => c.is_export);
12
12
  const selectNames = exportable.map(c => `"${c.name}"`);
13
13
  const selectSQL = `
14
- SELECT ${selectNames?.length ? selectNames.join(', ') : ''} ${format === 'geojson' || format === 'shp'? `, ST_AsGeoJSON(geom)::json as geom` : ``}
14
+ SELECT ${selectNames?.length ? selectNames.join(', ') : ''} ${format === 'geojson' || format === 'shp' ? `${selectNames?.length ? ',' : ''} ST_AsGeoJSON(geom)::json as geom` : ``}
15
15
  FROM ${table}
16
- WHERE ${queryCondition} ${format === 'geojson' || format === 'shp'? `and geom is not null` : ``}
16
+ WHERE ${queryCondition} ${format === 'geojson' || format === 'shp' ? `and geom is not null` : ``}
17
17
  `;
18
18
 
19
19
  if (format === 'shp') {
@@ -23,18 +23,18 @@ export default async function getInfo({ finalInfo, format }, reply) {
23
23
  WHERE geom IS NOT NULL
24
24
  `);
25
25
  const geometryTypes = geomTypeRows.map(row => row.geom_type);
26
-
26
+
27
27
  const sqlList = geometryTypes.map(type => {
28
28
  return {
29
29
  type,
30
30
  query: `
31
- SELECT ${selectNames.join(', ')}, ST_AsGeoJSON(geom)::json as geom
31
+ SELECT ${selectNames.join(', ')} ${selectNames?.length ? ',' : ''} ST_AsGeoJSON(geom)::json as geom
32
32
  FROM ${table}
33
33
  WHERE ${queryCondition} AND ST_GeometryType(geom) = '${type}' AND geom IS NOT NULL
34
34
  `,
35
35
  };
36
36
  });
37
-
37
+
38
38
  const { rows: [{ srid }] } = await pg.query(`
39
39
  SELECT ST_SRID(geom) AS srid
40
40
  FROM ${table}
@@ -53,7 +53,7 @@ export default async function getInfo({ finalInfo, format }, reply) {
53
53
 
54
54
  const { rows } = await pg.query(selectSQL);
55
55
  if (!rows?.length) {
56
- return reply.status(404).send({ message: 'Немає даних, які можна експортувати', status: 404 });
56
+ return reply.status(404).send({ message: 'Немає даних, які можна експортувати', status: 404 });
57
57
  }
58
58
 
59
59
  const classifiers = exportable
@@ -66,20 +66,20 @@ export default async function getInfo({ finalInfo, format }, reply) {
66
66
  const newRow = { ...row };
67
67
 
68
68
  for (const key of Object.keys(newRow)) {
69
- if (key.endsWith('_data') && typeof newRow[key]?.text === 'string') {
70
- const baseKey = key.replace(/_data$/, '');
71
- newRow[baseKey] = newRow[key].text;
72
- }
69
+ if (key.endsWith('_data') && typeof newRow[key]?.text === 'string') {
70
+ const baseKey = key.replace(/_data$/, '');
71
+ newRow[baseKey] = newRow[key].text;
72
+ }
73
73
 
74
- if (key.endsWith('_text') && typeof newRow[key] === 'string') {
75
- const baseKey = key.replace(/_text$/, '');
76
- newRow[baseKey] = newRow[key];
77
- }
74
+ if (key.endsWith('_text') && typeof newRow[key] === 'string') {
75
+ const baseKey = key.replace(/_text$/, '');
76
+ newRow[baseKey] = newRow[key];
78
77
  }
78
+ }
79
79
 
80
80
  return newRow;
81
81
  });
82
-
82
+
83
83
  return {
84
84
  rows: simplifiedRows,
85
85
  data: rows,