@golemio/microclimate 1.1.9 → 1.1.10-dev.925928693
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.
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dbm;
|
|
4
|
+
var type;
|
|
5
|
+
var seed;
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
var Promise;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
+
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
+
*/
|
|
14
|
+
exports.setup = function(options, seedLink) {
|
|
15
|
+
dbm = options.dbmigrate;
|
|
16
|
+
type = dbm.dataType;
|
|
17
|
+
seed = seedLink;
|
|
18
|
+
Promise = options.Promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.up = function(db) {
|
|
22
|
+
var filePath = path.join(__dirname, 'sqls', '20230710061502-pp20230710-up.sql');
|
|
23
|
+
return new Promise( function( resolve, reject ) {
|
|
24
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
+
if (err) return reject(err);
|
|
26
|
+
console.log('received data: ' + data);
|
|
27
|
+
|
|
28
|
+
resolve(data);
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.then(function(data) {
|
|
32
|
+
return db.runSql(data);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.down = function(db) {
|
|
37
|
+
var filePath = path.join(__dirname, 'sqls', '20230710061502-pp20230710-down.sql');
|
|
38
|
+
return new Promise( function( resolve, reject ) {
|
|
39
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
+
if (err) return reject(err);
|
|
41
|
+
console.log('received data: ' + data);
|
|
42
|
+
|
|
43
|
+
resolve(data);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.then(function(data) {
|
|
47
|
+
return db.runSql(data);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports._meta = {
|
|
52
|
+
"version": 1
|
|
53
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
drop VIEW v_sensor_points;
|
|
2
|
+
|
|
3
|
+
ALTER TABLE sensor_devices_import
|
|
4
|
+
ALTER COLUMN lat TYPE float4,
|
|
5
|
+
ALTER COLUMN lng TYPE float4;
|
|
6
|
+
|
|
7
|
+
CREATE OR REPLACE VIEW v_sensor_points
|
|
8
|
+
AS SELECT DISTINCT s.point_id,
|
|
9
|
+
s.point_name,
|
|
10
|
+
s.location_id,
|
|
11
|
+
s.location,
|
|
12
|
+
s.loc_description,
|
|
13
|
+
s.loc_orientation,
|
|
14
|
+
s.loc_surface,
|
|
15
|
+
s.lat,
|
|
16
|
+
s.lng,
|
|
17
|
+
NULL::text AS x_jtsk,
|
|
18
|
+
NULL::text AS y_jtsk,
|
|
19
|
+
NULL::text AS elevation_m,
|
|
20
|
+
s.sensor_position,
|
|
21
|
+
s.sensor_position_detail,
|
|
22
|
+
concat(unpivot.measure, unpivot.height_cm) AS measure,
|
|
23
|
+
CASE
|
|
24
|
+
WHEN unpivot.measure = 'air_temp'::text THEN 'Teplota vzduchu'::text
|
|
25
|
+
WHEN unpivot.measure = 'air_hum'::text THEN 'Vlhkost vzduchu'::text
|
|
26
|
+
WHEN unpivot.measure = 'pressure'::text THEN 'Atmosférický tlak'::text
|
|
27
|
+
WHEN unpivot.measure = 'wind_dir'::text THEN 'Směr větru'::text
|
|
28
|
+
WHEN unpivot.measure = 'wind_impact'::text THEN 'Náraz větru'::text
|
|
29
|
+
WHEN unpivot.measure = 'wind_speed'::text THEN 'Rychlost větru'::text
|
|
30
|
+
WHEN unpivot.measure = 'precip'::text THEN 'Úhrn srážek'::text
|
|
31
|
+
WHEN unpivot.measure = 'sun_irr'::text THEN 'Sluneční záření'::text
|
|
32
|
+
WHEN unpivot.measure = 'soil_temp'::text THEN 'Teplota půdy'::text
|
|
33
|
+
WHEN unpivot.measure = 'water_pot'::text THEN 'Vodní potenciál půdy'::text
|
|
34
|
+
WHEN unpivot.measure = 'dendro_circ'::text THEN 'Obvod stromu'::text
|
|
35
|
+
WHEN unpivot.measure = 'dendro_gain'::text THEN 'Přírůstek obvodu stromu'::text
|
|
36
|
+
ELSE NULL::text
|
|
37
|
+
END AS measure_cz,
|
|
38
|
+
CASE
|
|
39
|
+
WHEN unpivot.measure = 'air_temp'::text THEN '°C'::text
|
|
40
|
+
WHEN unpivot.measure = 'air_hum'::text THEN '%'::text
|
|
41
|
+
WHEN unpivot.measure = 'pressure'::text THEN 'Pa'::text
|
|
42
|
+
WHEN unpivot.measure = 'wind_dir'::text THEN '°'::text
|
|
43
|
+
WHEN unpivot.measure = 'wind_impact'::text THEN 'km/h'::text
|
|
44
|
+
WHEN unpivot.measure = 'wind_speed'::text THEN 'km/h'::text
|
|
45
|
+
WHEN unpivot.measure = 'precip'::text THEN 'mm'::text
|
|
46
|
+
WHEN unpivot.measure = 'sun_irr'::text THEN 'lux'::text
|
|
47
|
+
WHEN unpivot.measure = 'soil_temp'::text THEN '°C'::text
|
|
48
|
+
WHEN unpivot.measure = 'water_pot'::text THEN 'kPa'::text
|
|
49
|
+
WHEN unpivot.measure = 'dendro_circ'::text THEN 'mm'::text
|
|
50
|
+
WHEN unpivot.measure = 'dendro_gain'::text THEN 'µm'::text
|
|
51
|
+
ELSE NULL::text
|
|
52
|
+
END AS unit
|
|
53
|
+
FROM microclimate.sensor_devices_import s,
|
|
54
|
+
LATERAL ( VALUES ('air_temp'::text,s.air_temp), ('air_hum'::text,s.air_hum), ('pressure'::text,s.pressure), ('wind_dir'::text,s.wind_dir), ('wind_impact'::text,s.wind_impact), ('wind_speed'::text,s.wind_speed), ('precip'::text,s.precip), ('sun_irr'::text,s.sun_irr), ('soil_temp'::text,s.soil_temp), ('water_pot'::text,s.water_pot), ('dendro_circ'::text,s.dendro_circ), ('dendro_gain'::text,s.dendro_gain)) unpivot(measure, height_cm)
|
|
55
|
+
WHERE unpivot.height_cm IS NOT NULL
|
|
56
|
+
ORDER BY s.point_id;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
drop VIEW v_sensor_points;
|
|
2
|
+
|
|
3
|
+
ALTER TABLE sensor_devices_import
|
|
4
|
+
ALTER COLUMN lat TYPE float8,
|
|
5
|
+
ALTER COLUMN lng TYPE float8;
|
|
6
|
+
|
|
7
|
+
CREATE OR REPLACE VIEW v_sensor_points
|
|
8
|
+
AS SELECT DISTINCT s.point_id,
|
|
9
|
+
s.point_name,
|
|
10
|
+
s.location_id,
|
|
11
|
+
s.location,
|
|
12
|
+
s.loc_description,
|
|
13
|
+
s.loc_orientation,
|
|
14
|
+
s.loc_surface,
|
|
15
|
+
s.lat,
|
|
16
|
+
s.lng,
|
|
17
|
+
NULL::text AS x_jtsk,
|
|
18
|
+
NULL::text AS y_jtsk,
|
|
19
|
+
NULL::text AS elevation_m,
|
|
20
|
+
s.sensor_position,
|
|
21
|
+
s.sensor_position_detail,
|
|
22
|
+
concat(unpivot.measure, unpivot.height_cm) AS measure,
|
|
23
|
+
CASE
|
|
24
|
+
WHEN unpivot.measure = 'air_temp'::text THEN 'Teplota vzduchu'::text
|
|
25
|
+
WHEN unpivot.measure = 'air_hum'::text THEN 'Vlhkost vzduchu'::text
|
|
26
|
+
WHEN unpivot.measure = 'pressure'::text THEN 'Atmosférický tlak'::text
|
|
27
|
+
WHEN unpivot.measure = 'wind_dir'::text THEN 'Směr větru'::text
|
|
28
|
+
WHEN unpivot.measure = 'wind_impact'::text THEN 'Náraz větru'::text
|
|
29
|
+
WHEN unpivot.measure = 'wind_speed'::text THEN 'Rychlost větru'::text
|
|
30
|
+
WHEN unpivot.measure = 'precip'::text THEN 'Úhrn srážek'::text
|
|
31
|
+
WHEN unpivot.measure = 'sun_irr'::text THEN 'Sluneční záření'::text
|
|
32
|
+
WHEN unpivot.measure = 'soil_temp'::text THEN 'Teplota půdy'::text
|
|
33
|
+
WHEN unpivot.measure = 'water_pot'::text THEN 'Vodní potenciál půdy'::text
|
|
34
|
+
WHEN unpivot.measure = 'dendro_circ'::text THEN 'Obvod stromu'::text
|
|
35
|
+
WHEN unpivot.measure = 'dendro_gain'::text THEN 'Přírůstek obvodu stromu'::text
|
|
36
|
+
ELSE NULL::text
|
|
37
|
+
END AS measure_cz,
|
|
38
|
+
CASE
|
|
39
|
+
WHEN unpivot.measure = 'air_temp'::text THEN '°C'::text
|
|
40
|
+
WHEN unpivot.measure = 'air_hum'::text THEN '%'::text
|
|
41
|
+
WHEN unpivot.measure = 'pressure'::text THEN 'Pa'::text
|
|
42
|
+
WHEN unpivot.measure = 'wind_dir'::text THEN '°'::text
|
|
43
|
+
WHEN unpivot.measure = 'wind_impact'::text THEN 'km/h'::text
|
|
44
|
+
WHEN unpivot.measure = 'wind_speed'::text THEN 'km/h'::text
|
|
45
|
+
WHEN unpivot.measure = 'precip'::text THEN 'mm'::text
|
|
46
|
+
WHEN unpivot.measure = 'sun_irr'::text THEN 'lux'::text
|
|
47
|
+
WHEN unpivot.measure = 'soil_temp'::text THEN '°C'::text
|
|
48
|
+
WHEN unpivot.measure = 'water_pot'::text THEN 'kPa'::text
|
|
49
|
+
WHEN unpivot.measure = 'dendro_circ'::text THEN 'mm'::text
|
|
50
|
+
WHEN unpivot.measure = 'dendro_gain'::text THEN 'µm'::text
|
|
51
|
+
ELSE NULL::text
|
|
52
|
+
END AS unit
|
|
53
|
+
FROM microclimate.sensor_devices_import s,
|
|
54
|
+
LATERAL ( VALUES ('air_temp'::text,s.air_temp), ('air_hum'::text,s.air_hum), ('pressure'::text,s.pressure), ('wind_dir'::text,s.wind_dir), ('wind_impact'::text,s.wind_impact), ('wind_speed'::text,s.wind_speed), ('precip'::text,s.precip), ('sun_irr'::text,s.sun_irr), ('soil_temp'::text,s.soil_temp), ('water_pot'::text,s.water_pot), ('dendro_circ'::text,s.dendro_circ), ('dendro_gain'::text,s.dendro_gain)) unpivot(measure, height_cm)
|
|
55
|
+
WHERE unpivot.height_cm IS NOT NULL
|
|
56
|
+
ORDER BY s.point_id;
|