@golemio/traffic-common 1.0.1 → 1.0.2-dev.1102723835

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', '20231211102804-pp20231211-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', '20231211102804-pp20231211-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 @@
1
+ Drop FUNCTION get_route;
@@ -0,0 +1,61 @@
1
+ CREATE OR REPLACE FUNCTION get_route(p_route_lcd integer, p_version character varying)
2
+ RETURNS geometry
3
+ LANGUAGE plpgsql
4
+ SET search_path from CURRENT
5
+ /* vrací geom pro route_lcd a versi lokalizačních tabulek */
6
+ AS $function$
7
+ declare
8
+ temprow rsd_tmc_points%rowtype;
9
+ x_id_start integer;
10
+ x_id_next integer;
11
+ x_lat real;
12
+ x_long real;
13
+ x_lat_next real;
14
+ x_long_next real;
15
+ x_final geometry;
16
+ x_return geometry;
17
+ x_geom_txt varchar(5000);
18
+ begin
19
+
20
+ FOR temprow IN
21
+ SELECT * FROM rsd_tmc_points where roa_lcd = p_route_lcd and version_id = p_version and neg_off = 0
22
+ loop
23
+ x_id_start = temprow.lcd;
24
+ x_lat = temprow.wgs84_x;
25
+ x_long = temprow.wgs84_y;
26
+ x_id_next = temprow.pos_off;
27
+
28
+ select wgs84_x, wgs84_y,pos_off
29
+ into x_lat_next,x_long_next,x_id_next
30
+ from rsd_tmc_points
31
+ where lcd = x_id_start
32
+ and version_id = p_version;
33
+
34
+ x_geom_txt = 'linestring ('||x_lat::varchar(150)||' '||x_long::varchar(150)||','||x_lat_next::varchar(150) || ' ' || x_long_next::varchar(150)||')';
35
+ x_final = ST_GEOMETRYFROMTEXT(x_geom_txt,4326);
36
+ while x_id_next <> 0 loop
37
+ x_id_start = x_id_next;
38
+
39
+ select wgs84_x, wgs84_y,pos_off
40
+ into x_lat_next,x_long_next,x_id_next
41
+ from rsd_tmc_points
42
+ where lcd = x_id_start
43
+ and version_id = p_version;
44
+
45
+ x_final = ST_AddPoint(x_final, ST_SetSRID(ST_MakePoint(x_lat_next, x_long_next),4326));
46
+ end loop;
47
+ x_final = ST_AddPoint(x_final, ST_SetSRID(ST_MakePoint(x_lat_next, x_long_next),4326));
48
+
49
+ x_return = ST_collect(x_return, x_final);
50
+ END LOOP;
51
+ if ST_GeometryType(x_return) = 'ST_GeometryCollection' then
52
+ return ST_CollectionExtract(x_return, 2);
53
+ else
54
+ return ST_Multi(x_return);
55
+ end if;
56
+
57
+ END;
58
+ $function$
59
+ ;
60
+
61
+ COMMENT ON FUNCTION get_route IS 'Funkce vrací geometrický objekt pro routu lcd a zvolenou verzi';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/traffic-common",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-dev.1102723835",
4
4
  "description": "Golemio Common Traffic Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -69,4 +69,4 @@
69
69
  "dependencies": {
70
70
  "pg-copy-streams": "^6.0.5"
71
71
  }
72
- }
72
+ }