@golemio/rush-hour-aggregation 1.1.6 → 1.1.7-dev.1043460629
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.
- package/db/migrations/postgresql/20231017071347-pp20231017.js +53 -0
- package/db/migrations/postgresql/sqls/20231017071347-pp20231017-down.sql +3 -0
- package/db/migrations/postgresql/sqls/20231017071347-pp20231017-up.sql +145 -0
- package/dist/integration-engine/service/aggregators/WazeJamsAggregator.js +2 -2
- package/dist/integration-engine/service/aggregators/WazeJamsAggregator.js.map +1 -1
- package/dist/integration-engine/service/aggregators/WazeReconstructionsAggregator.js +1 -4
- package/dist/integration-engine/service/aggregators/WazeReconstructionsAggregator.js.map +1 -1
- package/package.json +1 -1
- package/templates/sqlQueries/WazeJamsAggregation.sql +1 -1
- package/templates/sqlQueries/WazeReconstructionsAggregation.sql +1 -1
|
@@ -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', '20231017071347-pp20231017-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', '20231017071347-pp20231017-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,145 @@
|
|
|
1
|
+
CREATE TABLE fcd_geos_praha_dopravni (
|
|
2
|
+
source_identification varchar(100) NOT NULL,
|
|
3
|
+
oriented_route public.geometry NULL,
|
|
4
|
+
"version" varchar(50) NULL,
|
|
5
|
+
CONSTRAINT fcd_geos_90_praha_dopravni PRIMARY KEY (source_identification)
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE OR REPLACE FUNCTION fcd_get_route(p_source_id character varying,p_version character varying)
|
|
9
|
+
RETURNS geometry
|
|
10
|
+
LANGUAGE plpgsql
|
|
11
|
+
AS $function$
|
|
12
|
+
declare
|
|
13
|
+
x_id_start integer;
|
|
14
|
+
x_id_end integer;
|
|
15
|
+
x_id_next integer;
|
|
16
|
+
x_point geometry;
|
|
17
|
+
x_lat real;
|
|
18
|
+
x_long real;
|
|
19
|
+
x_lat_next real;
|
|
20
|
+
x_long_next real;
|
|
21
|
+
x_final geometry;
|
|
22
|
+
x_geom_txt varchar(5000);
|
|
23
|
+
begin
|
|
24
|
+
-- na vstupu očekávám takový řetězec - TS01243T01245
|
|
25
|
+
-- kde první číslo se cíl, druhé start
|
|
26
|
+
-- pokud na vstupu něco jiného vracím null a končím.
|
|
27
|
+
-- if p_source_id not like 'TS_____T_____' then
|
|
28
|
+
if p_source_id not like 'TS%T%' then
|
|
29
|
+
return null::geometry;
|
|
30
|
+
end if;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
-- x_id_start = substring(p_source_id,9,5)::integer;
|
|
34
|
+
-- x_id_end = substring(p_source_id,3,5)::integer;
|
|
35
|
+
x_id_start = substring(p_source_id,position('T' in substring(p_source_id,2,50))+2,50);
|
|
36
|
+
x_id_end = substring(p_source_id,3,position('T' in substring(p_source_id,2,50))-2);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
-- positivní větev
|
|
40
|
+
|
|
41
|
+
select wgs84_x, wgs84_y,pos_off
|
|
42
|
+
into x_lat,x_long,x_id_next
|
|
43
|
+
-- from public.fcd_lt_points
|
|
44
|
+
from public.rsd_tmc_points
|
|
45
|
+
where lcd = x_id_start
|
|
46
|
+
and version_id = p_version;
|
|
47
|
+
|
|
48
|
+
select wgs84_x, wgs84_y,pos_off
|
|
49
|
+
into x_lat_next,x_long_next
|
|
50
|
+
from public.rsd_tmc_points
|
|
51
|
+
where lcd = x_id_next
|
|
52
|
+
and version_id = p_version;
|
|
53
|
+
|
|
54
|
+
x_geom_txt = 'linestring ('||x_lat::varchar(150)||' '||x_long::varchar(150)||','||x_lat_next::varchar(150) || ' ' || x_long_next::varchar(150)||')';
|
|
55
|
+
x_final = ST_GEOMETRYFROMTEXT(x_geom_txt,4326);
|
|
56
|
+
|
|
57
|
+
while x_id_next != x_id_end loop
|
|
58
|
+
-- přidání dalšího bodu
|
|
59
|
+
select wgs84_x, wgs84_y,pos_off
|
|
60
|
+
into x_lat_next,x_long_next,x_id_next
|
|
61
|
+
from public.rsd_tmc_points
|
|
62
|
+
where lcd = x_id_next
|
|
63
|
+
and version_id = p_version;
|
|
64
|
+
|
|
65
|
+
x_final = ST_AddPoint(x_final, ST_SetSRID(ST_MakePoint(x_lat_next, x_long_next),4326));
|
|
66
|
+
end loop;
|
|
67
|
+
|
|
68
|
+
if x_id_next = x_id_end then
|
|
69
|
+
return x_final;
|
|
70
|
+
end if;
|
|
71
|
+
|
|
72
|
+
-- negativní větev
|
|
73
|
+
select wgs84_x, wgs84_y,neg_off
|
|
74
|
+
into x_lat,x_long,x_id_next
|
|
75
|
+
from public.rsd_tmc_points
|
|
76
|
+
where lcd = x_id_start
|
|
77
|
+
and version_id = p_version;
|
|
78
|
+
|
|
79
|
+
select wgs84_x, wgs84_y,neg_off
|
|
80
|
+
into x_lat_next,x_long_next
|
|
81
|
+
from public.rsd_tmc_points
|
|
82
|
+
where lcd = x_id_next
|
|
83
|
+
and version_id = p_version;
|
|
84
|
+
|
|
85
|
+
x_geom_txt = 'linestring ('||x_lat::varchar(150)||' '||x_long::varchar(150)||','||x_lat_next::varchar(150) || ' ' || x_long_next::varchar(150)||')';
|
|
86
|
+
-- x_final = x_geom_txt::geometry;
|
|
87
|
+
x_final = ST_GEOMETRYFROMTEXT(x_geom_txt,4326);
|
|
88
|
+
|
|
89
|
+
while x_id_next != x_id_end loop
|
|
90
|
+
-- přidání dalšího bodu
|
|
91
|
+
select wgs84_x, wgs84_y,neg_off
|
|
92
|
+
into x_lat_next,x_long_next,x_id_next
|
|
93
|
+
from public.rsd_tmc_points
|
|
94
|
+
where lcd = x_id_next
|
|
95
|
+
and version_id = p_version;
|
|
96
|
+
|
|
97
|
+
-- x_final = ST_AddPoint(x_final, ST_MakePoint(x_lat_next, x_long_next));
|
|
98
|
+
x_final = ST_AddPoint(x_final, ST_SetSRID(ST_MakePoint(x_lat_next, x_long_next),4326));
|
|
99
|
+
end loop;
|
|
100
|
+
|
|
101
|
+
if x_id_next = x_id_end then
|
|
102
|
+
return x_final;
|
|
103
|
+
end if;
|
|
104
|
+
|
|
105
|
+
return null::geometry;
|
|
106
|
+
END;
|
|
107
|
+
$function$
|
|
108
|
+
;
|
|
109
|
+
|
|
110
|
+
CREATE OR REPLACE FUNCTION fcd_geos_fill(p_version character varying)
|
|
111
|
+
RETURNS void
|
|
112
|
+
LANGUAGE plpgsql
|
|
113
|
+
AS $function$
|
|
114
|
+
declare
|
|
115
|
+
x_id_start integer;
|
|
116
|
+
x_id_end integer;
|
|
117
|
+
x_id_next integer;
|
|
118
|
+
x_point geometry;
|
|
119
|
+
x_lat real;
|
|
120
|
+
x_long real;
|
|
121
|
+
x_lat_next real;
|
|
122
|
+
x_long_next real;
|
|
123
|
+
x_final geometry;
|
|
124
|
+
x_line geometry;
|
|
125
|
+
x_geom_txt varchar(5000);
|
|
126
|
+
x_x varchar(5000);
|
|
127
|
+
query_dataset record;
|
|
128
|
+
begin
|
|
129
|
+
FOR query_dataset IN
|
|
130
|
+
select lcd
|
|
131
|
+
from public.rsd_tmc_roads rtp
|
|
132
|
+
where version_id = 'v10.1'
|
|
133
|
+
loop
|
|
134
|
+
insert into praha_dopravni.fcd_geos_praha_dopravni
|
|
135
|
+
select --rtp.lcd,rtp2.lcd,
|
|
136
|
+
'TS'||repeat('0',5-length(rtp.lcd::varchar))||rtp.lcd||'T'||repeat('0',5-length(rtp2.lcd::varchar))||rtp2.lcd,
|
|
137
|
+
praha_dopravni.fcd_get_route('TS'||rtp.lcd||'T'||rtp2.lcd,p_version ),p_version
|
|
138
|
+
from public.rsd_tmc_points rtp,public.rsd_tmc_points rtp2
|
|
139
|
+
where rtp.roa_lcd = query_dataset.lcd and rtp2.roa_lcd = query_dataset.lcd and rtp.version_id = p_version and rtp2.version_id = p_version
|
|
140
|
+
and rtp.lcd != rtp2.lcd;
|
|
141
|
+
end loop;
|
|
142
|
+
-- return null;
|
|
143
|
+
END;
|
|
144
|
+
$function$
|
|
145
|
+
;
|
|
@@ -23,8 +23,8 @@ class WazeAggregator extends AbstractAggregator_1.default {
|
|
|
23
23
|
super();
|
|
24
24
|
this.aggregate = (from, to) => __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const result = yield AggregationRepository_1.default.getInstance().aggregationQuery(AggregationTaskType_1.AggregationTaskType.WAZEJ, {
|
|
26
|
-
from
|
|
27
|
-
to
|
|
26
|
+
from,
|
|
27
|
+
to,
|
|
28
28
|
});
|
|
29
29
|
return this.mapToDto(result);
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WazeJamsAggregator.js","sourceRoot":"","sources":["../../../../src/integration-engine/service/aggregators/WazeJamsAggregator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mGAAyE;AACzE,6FAAmE;AACnE,iGAAuE;AACvE,kHAAmE;AACnE,qGAAsD;AACtD,8EAAsD;AAEtD,MAAqB,cAAe,SAAQ,4BAA4B;IAGpE;QACI,KAAK,EAAE,CAAC;QAIF,cAAS,GAAG,CAAO,IAAU,EAAE,EAAQ,EAAuB,EAAE;YACtE,MAAM,MAAM,GAAG,MAAM,+BAAqB,CAAC,WAAW,EAAE,CAAC,gBAAgB,CAAY,yCAAmB,CAAC,KAAK,EAAE;gBAC5G,IAAI
|
|
1
|
+
{"version":3,"file":"WazeJamsAggregator.js","sourceRoot":"","sources":["../../../../src/integration-engine/service/aggregators/WazeJamsAggregator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mGAAyE;AACzE,6FAAmE;AACnE,iGAAuE;AACvE,kHAAmE;AACnE,qGAAsD;AACtD,8EAAsD;AAEtD,MAAqB,cAAe,SAAQ,4BAA4B;IAGpE;QACI,KAAK,EAAE,CAAC;QAIF,cAAS,GAAG,CAAO,IAAU,EAAE,EAAQ,EAAuB,EAAE;YACtE,MAAM,MAAM,GAAG,MAAM,+BAAqB,CAAC,WAAW,EAAE,CAAC,gBAAgB,CAAY,yCAAmB,CAAC,KAAK,EAAE;gBAC5G,IAAI;gBACJ,EAAE;aACL,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;QAVE,IAAI,CAAC,UAAU,GAAG,IAAI,4BAAkB,EAAE,CAAC;IAC/C,CAAC;IAWS,QAAQ,CAAC,IAAW;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACxB,OAAO;gBACH,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;gBACjD,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,UAAU,EAAE,OAAO,CAAC,UAAU;aACrB,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA7BD,iCA6BC"}
|
|
@@ -23,10 +23,7 @@ class WazeReconstructionsAggregator extends AbstractAggregator_1.default {
|
|
|
23
23
|
super();
|
|
24
24
|
this.maxAggregationDuration = { hours: 2 };
|
|
25
25
|
this.aggregate = (from, to) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const result = yield AggregationRepository_1.default.getInstance().aggregationQuery(AggregationTaskType_1.AggregationTaskType.WAZER, {
|
|
27
|
-
from: from.getTime(),
|
|
28
|
-
to: to.getTime(),
|
|
29
|
-
});
|
|
26
|
+
const result = yield AggregationRepository_1.default.getInstance().aggregationQuery(AggregationTaskType_1.AggregationTaskType.WAZER, { from, to });
|
|
30
27
|
return this.mapToDto(result);
|
|
31
28
|
});
|
|
32
29
|
this.repository = new WazeReconstructionsRepository_1.default();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WazeReconstructionsAggregator.js","sourceRoot":"","sources":["../../../../src/integration-engine/service/aggregators/WazeReconstructionsAggregator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mGAAyE;AACzE,mHAAyF;AACzF,iGAAuE;AACvE,wIAAyF;AACzF,2HAA4E;AAE5E,8EAAsD;AAEtD,MAAqB,6BAA8B,SAAQ,4BAAuC;IAI9F;QACI,KAAK,EAAE,CAAC;QAJO,2BAAsB,GAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAQ7D,cAAS,GAAG,CAAO,IAAU,EAAE,EAAQ,EAAkC,EAAE;YACjF,MAAM,MAAM,GAAG,MAAM,+BAAqB,CAAC,WAAW,EAAE,CAAC,gBAAgB,CACrE,yCAAmB,CAAC,KAAK,EACzB
|
|
1
|
+
{"version":3,"file":"WazeReconstructionsAggregator.js","sourceRoot":"","sources":["../../../../src/integration-engine/service/aggregators/WazeReconstructionsAggregator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mGAAyE;AACzE,mHAAyF;AACzF,iGAAuE;AACvE,wIAAyF;AACzF,2HAA4E;AAE5E,8EAAsD;AAEtD,MAAqB,6BAA8B,SAAQ,4BAAuC;IAI9F;QACI,KAAK,EAAE,CAAC;QAJO,2BAAsB,GAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAQ7D,cAAS,GAAG,CAAO,IAAU,EAAE,EAAQ,EAAkC,EAAE;YACjF,MAAM,MAAM,GAAG,MAAM,+BAAqB,CAAC,WAAW,EAAE,CAAC,gBAAgB,CACrE,yCAAmB,CAAC,KAAK,EACzB,EAAE,IAAI,EAAE,EAAE,EAAE,CACf,CAAC;YAEF,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;QAVE,IAAI,CAAC,UAAU,GAAG,IAAI,uCAA6B,EAAE,CAAC;IAC1D,CAAC;IAWS,QAAQ,CAAC,IAAW;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACxB,OAAO;gBACH,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;gBACjD,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,UAAU,EAAE,OAAO,CAAC,UAAU;aACV,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA7BD,gDA6BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
select
|
|
2
2
|
w.id,
|
|
3
|
-
(round(w.downloaded_at::numeric /
|
|
3
|
+
(round(extract(epoch from w.downloaded_at)::numeric / 120.0) * 120000::numeric)::bigint as measured_at,
|
|
4
4
|
st_geomfromtext(concat('LINESTRING(', regexp_replace(replace(w.line::text, ', "y"'::text, ' '::text), '[{"xy:\[\]}]'::text, ''::text, 'g'::text), ')'),
|
|
5
5
|
4326) as geom_origin,
|
|
6
6
|
st_startpoint(st_geomfromtext(concat('LINESTRING(', regexp_replace(replace(w.line::text, ', "y"'::text, ' '::text), '[{"xy:\[\]}]'::text, ''::text, 'g'::text), ')'),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
select
|
|
2
2
|
w.id,
|
|
3
|
-
|
|
3
|
+
(round(extract(epoch from w.downloaded_at)::numeric / 120.0) * 120000::numeric)::bigint as measured_at,
|
|
4
4
|
st_geomfromtext(concat('LINESTRING(', regexp_replace(replace(w.line::text, ', "y"'::text, ' '::text), '[{"xy:\[\]}]'::text, ''::text, 'g'::text), ')'),
|
|
5
5
|
4326) as geom_origin,
|
|
6
6
|
st_startpoint(st_geomfromtext(concat('LINESTRING(', regexp_replace(replace(w.line::text, ', "y"'::text, ' '::text), '[{"xy:\[\]}]'::text, ''::text, 'g'::text), ')'),
|