@opengis/gis 0.1.51 → 0.1.53

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.
@@ -48,12 +48,12 @@
48
48
  "is_public": {
49
49
  "ua": "Чи публічна карта?",
50
50
  "col": 4,
51
- "type": "Radio",
51
+ "type": "Switcher",
52
52
  "data": "yes_no",
53
- "view": "buttons",
54
53
  "validators": [
55
54
  "required"
56
- ]
55
+ ],
56
+ "default": "true"
57
57
  },
58
58
  "image": {
59
59
  "ua": "Фото",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "dist/import-file.js",
@@ -28,20 +28,14 @@
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "dependencies": {
31
- "@grpc/grpc-js": "1.13.4",
32
- "@grpc/proto-loader": "0.7.15",
33
31
  "@mapbox/sphericalmercator": "1.2.0",
34
- "@opengis/fastify-auth": "1.1.0",
35
- "@opengis/fastify-file": "1.1.2",
36
- "@opengis/fastify-table": "1.4.23",
32
+ "@opengis/fastify-auth": "1.1.1",
33
+ "@opengis/fastify-table": "1.4.29",
37
34
  "@opengis/v3-core": "^0.3.196",
38
35
  "@opengis/v3-filter": "^0.1.28",
39
36
  "@turf/turf": "7.2.0",
40
37
  "axios": "1.9.0",
41
38
  "carto": "0.16.3",
42
- "fastify": "5.3.3",
43
- "fastify-plugin": "5.0.1",
44
- "handlebars": "4.7.8",
45
39
  "lucide-vue-next": "^0.514.0",
46
40
  "maplibre-gl": "5.5.0",
47
41
  "marked": "15.0.12",
@@ -49,7 +43,6 @@
49
43
  "vue": "^3.5.13",
50
44
  "vue-router": "4.5.1",
51
45
  "vuedraggable": "^4.1.0",
52
- "dotenv": "^16.5.0",
53
46
  "yaml": "^2.8.0"
54
47
  },
55
48
  "devDependencies": {
@@ -1,11 +1,11 @@
1
- import { createReadStream } from 'fs';
1
+ import { createReadStream } from 'node:fs';
2
2
  import { mkdir, writeFile } from 'node:fs/promises';
3
- import path from 'path';
4
- import { config, getMeta, getFolder } from '@opengis/fastify-table/utils.js';
5
- import { grpc } from '@opengis/fastify-file/utils.js';
6
- import convertJSONToCSV from '@opengis/fastify-file/server/routes/file/controllers/utils/convertJSONToCSV.js';
3
+ import path from 'node:path';
4
+ import { grpc, config, getMeta, getFolder, jsonToCsv } from '@opengis/fastify-table/utils.js';
5
+
7
6
  import getInfo from './funcs/get.info.js';
8
7
  import ContentType from './funcs/content.type.js';
8
+
9
9
  const { jsonToXls, geojsonToShp } = grpc();
10
10
  const rootDir = getFolder(config, 'local');
11
11
 
@@ -25,16 +25,16 @@ export default async function gisExport({ pg, query = {}, params = {} }, reply)
25
25
  }
26
26
  if (!slug) return reply.code(401).send({ message: 'slug is not defined', status: 404 });
27
27
  if (!type) return reply.code(401).send({ message: 'type is not defined', status: 404 });
28
-
28
+
29
29
  let registerInfo;
30
30
  let serviceInfo;
31
31
 
32
- if (type === 'register') {
32
+ if (type === 'register') {
33
33
  registerInfo = await pg.query(
34
34
  `SELECT table_name, columns, query
35
35
  FROM gis.registers
36
36
  WHERE register_key = $1`,
37
- [slug]
37
+ [slug]
38
38
  );
39
39
  }
40
40
  if (type === 'service') {
@@ -75,7 +75,7 @@ export default async function gisExport({ pg, query = {}, params = {} }, reply)
75
75
  json: JSON.stringify(rows),
76
76
  colmodel: JSON.stringify(colmodel),
77
77
  });
78
-
78
+
79
79
  await mkdir(path.dirname(filePath), { recursive: true });
80
80
  await writeFile(filePath, result, 'base64');
81
81
  }
@@ -83,55 +83,55 @@ export default async function gisExport({ pg, query = {}, params = {} }, reply)
83
83
  if (format === 'csv') {
84
84
  await mkdir(path.dirname(filePathJSON), { recursive: true });
85
85
  await writeFile(filePathJSON, JSON.stringify(rows));
86
-
87
- await convertJSONToCSV({
86
+
87
+ await jsonToCsv({
88
88
  filePath: filePathJSON, colmodel, columnList: colmodel.map(c => c.name),
89
89
  });
90
90
  }
91
91
 
92
- if (['shp', 'geojson'].includes(format)) {
92
+ if (['shp', 'geojson'].includes(format)) {
93
93
  if (format === 'geojson') {
94
- const geojson = {
95
- type: 'FeatureCollection',
96
- features: rows.map((row) => ({
97
- type: 'Feature',
98
- geometry: row.geom,
99
- properties: Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'geom')),
100
- })),
101
- };
102
- filePath = filePathJSON.replace('.json', '.geojson');
103
- await mkdir(path.dirname(filePath), { recursive: true });
104
- await writeFile(filePath, JSON.stringify(geojson));
105
- }
106
-
107
- if (format === 'shp') {
108
- const proj = `EPSG:${srid || 4326}`;
109
- for (const { type, query } of sqlList) {
110
- const { rows } = await pg.query(query);
111
- if (!rows.length) continue;
112
-
113
94
  const geojson = {
114
95
  type: 'FeatureCollection',
115
- features: rows.map(row => ({
96
+ features: rows.map((row) => ({
116
97
  type: 'Feature',
117
98
  geometry: row.geom,
118
- properties: Object.fromEntries(Object.entries(row).filter(([k]) => k !== 'geom')),
99
+ properties: Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'geom')),
119
100
  })),
120
101
  };
121
- const geomShort = type.toLowerCase().replace('st_', '');
122
- const typedPath = filePath.replace('.zip', `_${geomShort}.zip`);
123
-
124
- const filePathTyped = filePath.replace('.zip', `_${type.toLowerCase().replace('st_', '')}.zip`);
125
- const { result: shpZipBuffer } = await geojsonToShp({
126
- geojson: JSON.stringify(geojson),
127
- proj,
128
- });
129
-
130
- await mkdir(path.dirname(filePathTyped), { recursive: true });
131
- await writeFile(filePathTyped, Buffer.from(shpZipBuffer, 'base64'));
132
-
133
- exportedZipPaths.push(typedPath);
102
+ filePath = filePathJSON.replace('.json', '.geojson');
103
+ await mkdir(path.dirname(filePath), { recursive: true });
104
+ await writeFile(filePath, JSON.stringify(geojson));
134
105
  }
106
+
107
+ if (format === 'shp') {
108
+ const proj = `EPSG:${srid || 4326}`;
109
+ for (const { type, query } of sqlList) {
110
+ const { rows } = await pg.query(query);
111
+ if (!rows.length) continue;
112
+
113
+ const geojson = {
114
+ type: 'FeatureCollection',
115
+ features: rows.map(row => ({
116
+ type: 'Feature',
117
+ geometry: row.geom,
118
+ properties: Object.fromEntries(Object.entries(row).filter(([k]) => k !== 'geom')),
119
+ })),
120
+ };
121
+ const geomShort = type.toLowerCase().replace('st_', '');
122
+ const typedPath = filePath.replace('.zip', `_${geomShort}.zip`);
123
+
124
+ const filePathTyped = filePath.replace('.zip', `_${type.toLowerCase().replace('st_', '')}.zip`);
125
+ const { result: shpZipBuffer } = await geojsonToShp({
126
+ geojson: JSON.stringify(geojson),
127
+ proj,
128
+ });
129
+
130
+ await mkdir(path.dirname(filePathTyped), { recursive: true });
131
+ await writeFile(filePathTyped, Buffer.from(shpZipBuffer, 'base64'));
132
+
133
+ exportedZipPaths.push(typedPath);
134
+ }
135
135
  }
136
136
  }
137
137
 
@@ -140,7 +140,7 @@ export default async function gisExport({ pg, query = {}, params = {} }, reply)
140
140
  if (format === 'shp' && exportedZipPaths?.length > 0) {
141
141
  exportFilePath = exportedZipPaths[0];
142
142
  }
143
-
143
+
144
144
  reply.header('Content-Disposition', `attachment; filename=${encodeURIComponent(path.basename(exportFilePath))}`);
145
145
  reply.header('Content-Type', ContentType[format]);
146
146