@golemio/pid 6.0.1-dev.2896931404 → 6.0.1-dev.2901184022
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/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.d.ts +2 -1
- package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.js +99 -96
- package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TripWithLastPositionModel } from "#sch/vehicle-positions/models/views/TripWithLastPositionModel";
|
|
2
2
|
import { type IGeoJSONFeature } from "@golemio/core/dist/output-gateway/Geo.js";
|
|
3
3
|
export declare class PositionOutputMapper {
|
|
4
|
-
static
|
|
4
|
+
static buildCoordinatesList(lng: number | null, lat: number | null): Array<number | null>;
|
|
5
|
+
static mapTripModelToDto(data: TripWithLastPositionModel): IGeoJSONFeature;
|
|
5
6
|
}
|
|
@@ -1,102 +1,105 @@
|
|
|
1
1
|
import { GeoCoordinatesType, buildGeojsonFeatureType } from "@golemio/core/dist/output-gateway/Geo.js";
|
|
2
2
|
export class PositionOutputMapper {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
static buildCoordinatesList(lng, lat) {
|
|
4
|
+
return [lng !== null ? Number(lng) : null, lat !== null ? Number(lat) : null];
|
|
5
|
+
}
|
|
6
|
+
static mapTripModelToDto(data) {
|
|
7
|
+
const { vehicle_type, vehicle_descriptor, all_positions = [], ...tripWithPosition } = data.toJSON();
|
|
8
|
+
const tripObject = {
|
|
9
|
+
last_position: {
|
|
10
|
+
bearing: tripWithPosition.bearing,
|
|
11
|
+
delay: {
|
|
12
|
+
actual: tripWithPosition.delay,
|
|
13
|
+
last_stop_arrival: tripWithPosition.delay_stop_arrival,
|
|
14
|
+
last_stop_departure: tripWithPosition.delay_stop_departure,
|
|
15
|
+
},
|
|
16
|
+
is_canceled: tripWithPosition.is_canceled,
|
|
17
|
+
last_stop: {
|
|
18
|
+
arrival_time: tripWithPosition.last_stop_arrival_time_isostring,
|
|
19
|
+
departure_time: tripWithPosition.last_stop_departure_time_isostring,
|
|
20
|
+
id: tripWithPosition.last_stop_id,
|
|
21
|
+
sequence: tripWithPosition.last_stop_sequence,
|
|
22
|
+
},
|
|
23
|
+
next_stop: {
|
|
24
|
+
arrival_time: tripWithPosition.next_stop_arrival_time_isostring,
|
|
25
|
+
departure_time: tripWithPosition.next_stop_departure_time_isostring,
|
|
26
|
+
id: tripWithPosition.next_stop_id,
|
|
27
|
+
sequence: tripWithPosition.next_stop_sequence,
|
|
28
|
+
},
|
|
29
|
+
origin_timestamp: tripWithPosition.origin_timestamp_isostring,
|
|
30
|
+
shape_dist_traveled: tripWithPosition.shape_dist_traveled,
|
|
31
|
+
speed: tripWithPosition.speed,
|
|
32
|
+
state_position: tripWithPosition.state_position || null,
|
|
33
|
+
tracking: tripWithPosition.is_tracked,
|
|
26
34
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
trip: {
|
|
36
|
+
agency_name: {
|
|
37
|
+
real: tripWithPosition.agency_name_real,
|
|
38
|
+
scheduled: tripWithPosition.agency_name_scheduled,
|
|
39
|
+
},
|
|
40
|
+
cis: {
|
|
41
|
+
line_id: tripWithPosition.cis_line_id,
|
|
42
|
+
trip_number: tripWithPosition.cis_trip_number,
|
|
43
|
+
},
|
|
44
|
+
gtfs: {
|
|
45
|
+
route_id: tripWithPosition.gtfs_route_id,
|
|
46
|
+
route_short_name: tripWithPosition.gtfs_route_short_name,
|
|
47
|
+
route_type: tripWithPosition.gtfs_route_type,
|
|
48
|
+
trip_headsign: tripWithPosition.last_stop_headsign ?? tripWithPosition.gtfs_trip_headsign,
|
|
49
|
+
trip_id: tripWithPosition.gtfs_trip_id,
|
|
50
|
+
trip_short_name: tripWithPosition.gtfs_trip_short_name,
|
|
51
|
+
},
|
|
52
|
+
origin_route_name: tripWithPosition.origin_route_name,
|
|
53
|
+
sequence_id: tripWithPosition.run_number,
|
|
54
|
+
start_timestamp: tripWithPosition.start_timestamp_isostring,
|
|
55
|
+
vehicle_registration_number: tripWithPosition.vehicle_registration_number,
|
|
56
|
+
vehicle_type,
|
|
57
|
+
wheelchair_accessible: tripWithPosition.wheelchair_accessible,
|
|
58
|
+
air_conditioned: vehicle_descriptor?.is_air_conditioned ?? null,
|
|
59
|
+
usb_chargers: vehicle_descriptor?.has_usb_chargers ?? null,
|
|
37
60
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
...(all_positions.length && {
|
|
62
|
+
all_positions: {
|
|
63
|
+
features: all_positions.map((position) => buildGeojsonFeatureType("geometry", {
|
|
64
|
+
geometry: {
|
|
65
|
+
type: GeoCoordinatesType.Point,
|
|
66
|
+
coordinates: PositionOutputMapper.buildCoordinatesList(position.lng, position.lat),
|
|
67
|
+
},
|
|
68
|
+
bearing: position.bearing,
|
|
69
|
+
delay: {
|
|
70
|
+
actual: position.delay,
|
|
71
|
+
last_stop_arrival: position.delay_stop_arrival,
|
|
72
|
+
last_stop_departure: position.delay_stop_departure,
|
|
73
|
+
},
|
|
74
|
+
is_canceled: position.is_canceled,
|
|
75
|
+
last_stop: {
|
|
76
|
+
arrival_time: position.last_stop_arrival_time_isostring,
|
|
77
|
+
departure_time: position.last_stop_departure_time_isostring,
|
|
78
|
+
id: position.last_stop_id,
|
|
79
|
+
sequence: position.last_stop_sequence,
|
|
80
|
+
},
|
|
81
|
+
next_stop: {
|
|
82
|
+
arrival_time: position.next_stop_arrival_time_isostring,
|
|
83
|
+
departure_time: position.next_stop_departure_time_isostring,
|
|
84
|
+
id: position.next_stop_id,
|
|
85
|
+
sequence: position.next_stop_sequence,
|
|
86
|
+
},
|
|
87
|
+
origin_timestamp: position.origin_timestamp_isostring,
|
|
88
|
+
shape_dist_traveled: position.shape_dist_traveled,
|
|
89
|
+
speed: position.speed,
|
|
90
|
+
})),
|
|
91
|
+
type: "FeatureCollection",
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
geometry: {
|
|
97
|
+
type: GeoCoordinatesType.Point,
|
|
98
|
+
coordinates: PositionOutputMapper.buildCoordinatesList(tripWithPosition.lng, tripWithPosition.lat),
|
|
41
99
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
trip_id: tripWithPosition.gtfs_trip_id,
|
|
48
|
-
trip_short_name: tripWithPosition.gtfs_trip_short_name,
|
|
49
|
-
},
|
|
50
|
-
origin_route_name: tripWithPosition.origin_route_name,
|
|
51
|
-
sequence_id: tripWithPosition.run_number,
|
|
52
|
-
start_timestamp: tripWithPosition.start_timestamp_isostring,
|
|
53
|
-
vehicle_registration_number: tripWithPosition.vehicle_registration_number,
|
|
54
|
-
vehicle_type,
|
|
55
|
-
wheelchair_accessible: tripWithPosition.wheelchair_accessible,
|
|
56
|
-
air_conditioned: vehicle_descriptor?.is_air_conditioned ?? null,
|
|
57
|
-
usb_chargers: vehicle_descriptor?.has_usb_chargers ?? null,
|
|
58
|
-
},
|
|
59
|
-
...(all_positions.length && {
|
|
60
|
-
all_positions: {
|
|
61
|
-
features: all_positions.map((position) => buildGeojsonFeatureType("geometry", {
|
|
62
|
-
geometry: {
|
|
63
|
-
type: GeoCoordinatesType.Point,
|
|
64
|
-
coordinates: [position.lng, position.lat],
|
|
65
|
-
},
|
|
66
|
-
bearing: position.bearing,
|
|
67
|
-
delay: {
|
|
68
|
-
actual: position.delay,
|
|
69
|
-
last_stop_arrival: position.delay_stop_arrival,
|
|
70
|
-
last_stop_departure: position.delay_stop_departure,
|
|
71
|
-
},
|
|
72
|
-
is_canceled: position.is_canceled,
|
|
73
|
-
last_stop: {
|
|
74
|
-
arrival_time: position.last_stop_arrival_time_isostring,
|
|
75
|
-
departure_time: position.last_stop_departure_time_isostring,
|
|
76
|
-
id: position.last_stop_id,
|
|
77
|
-
sequence: position.last_stop_sequence,
|
|
78
|
-
},
|
|
79
|
-
next_stop: {
|
|
80
|
-
arrival_time: position.next_stop_arrival_time_isostring,
|
|
81
|
-
departure_time: position.next_stop_departure_time_isostring,
|
|
82
|
-
id: position.next_stop_id,
|
|
83
|
-
sequence: position.next_stop_sequence,
|
|
84
|
-
},
|
|
85
|
-
origin_timestamp: position.origin_timestamp_isostring,
|
|
86
|
-
shape_dist_traveled: position.shape_dist_traveled,
|
|
87
|
-
speed: position.speed,
|
|
88
|
-
})),
|
|
89
|
-
type: "FeatureCollection",
|
|
90
|
-
},
|
|
91
|
-
}),
|
|
92
|
-
};
|
|
93
|
-
return {
|
|
94
|
-
geometry: {
|
|
95
|
-
type: GeoCoordinatesType.Point,
|
|
96
|
-
coordinates: [tripWithPosition.lng, tripWithPosition.lat],
|
|
97
|
-
},
|
|
98
|
-
properties: tripObject,
|
|
99
|
-
type: "Feature",
|
|
100
|
-
};
|
|
101
|
-
};
|
|
100
|
+
properties: tripObject,
|
|
101
|
+
type: "Feature",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
102
105
|
//# sourceMappingURL=PositionOutputMapper.js.map
|
package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PositionOutputMapper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAE7H,MAAM,OAAO,oBAAoB
|
|
1
|
+
{"version":3,"file":"PositionOutputMapper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAE7H,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAC,oBAAoB,CAAC,GAAkB,EAAE,GAAkB;QACrE,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC;IAEM,MAAM,CAAC,iBAAiB,CAAC,IAA+B;QAC3D,MAAM,EACF,YAAY,EACZ,kBAAkB,EAClB,aAAa,GAAG,EAAE,EAClB,GAAG,gBAAgB,EACtB,GAAG,IAAI,CAAC,MAAM,EAA+B,CAAC;QAE/C,MAAM,UAAU,GAAG;YACf,aAAa,EAAE;gBACX,OAAO,EAAE,gBAAgB,CAAC,OAAO;gBACjC,KAAK,EAAE;oBACH,MAAM,EAAE,gBAAgB,CAAC,KAAK;oBAC9B,iBAAiB,EAAE,gBAAgB,CAAC,kBAAkB;oBACtD,mBAAmB,EAAE,gBAAgB,CAAC,oBAAoB;iBAC7D;gBACD,WAAW,EAAE,gBAAgB,CAAC,WAAW;gBACzC,SAAS,EAAE;oBACP,YAAY,EAAE,gBAAgB,CAAC,gCAAgC;oBAC/D,cAAc,EAAE,gBAAgB,CAAC,kCAAkC;oBACnE,EAAE,EAAE,gBAAgB,CAAC,YAAY;oBACjC,QAAQ,EAAE,gBAAgB,CAA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