@tmlmobilidade/geo 20260330.1756.23 → 20260331.1620.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.
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SimplifiedVehicleEvent, Vehicle } from '@tmlmobilidade/types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a SimplifiedVehicleEvent object into a GeoJSON Feature of type Point.
|
|
4
|
+
*
|
|
5
|
+
* @param vehiclePositionData - Object containing vehicle position and metadata.
|
|
6
|
+
* @returns A GeoJSON Feature representing the vehicle's geographic location and associated properties.
|
|
7
|
+
*
|
|
8
|
+
* Properties embedded in the feature:
|
|
9
|
+
* - agency_id: ID of the agency the vehicle belongs to
|
|
10
|
+
* - bearing: Heading in degrees
|
|
11
|
+
* - id: Vehicle identifier (duplicated for GeoJSON "properties.id" key)
|
|
12
|
+
* - lat: Vehicle latitude
|
|
13
|
+
* - lon: Vehicle longitude
|
|
14
|
+
* - trip_id: Associated trip identifier
|
|
15
|
+
*/
|
|
16
|
+
export declare function transformVehicleDataIntoGeoJsonFeature(event: SimplifiedVehicleEvent, vehicleData?: Vehicle): GeoJSON.Feature<GeoJSON.Point>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
/* * */
|
|
3
|
+
/**
|
|
4
|
+
* Converts a SimplifiedVehicleEvent object into a GeoJSON Feature of type Point.
|
|
5
|
+
*
|
|
6
|
+
* @param vehiclePositionData - Object containing vehicle position and metadata.
|
|
7
|
+
* @returns A GeoJSON Feature representing the vehicle's geographic location and associated properties.
|
|
8
|
+
*
|
|
9
|
+
* Properties embedded in the feature:
|
|
10
|
+
* - agency_id: ID of the agency the vehicle belongs to
|
|
11
|
+
* - bearing: Heading in degrees
|
|
12
|
+
* - id: Vehicle identifier (duplicated for GeoJSON "properties.id" key)
|
|
13
|
+
* - lat: Vehicle latitude
|
|
14
|
+
* - lon: Vehicle longitude
|
|
15
|
+
* - trip_id: Associated trip identifier
|
|
16
|
+
*/
|
|
17
|
+
export function transformVehicleDataIntoGeoJsonFeature(event, vehicleData) {
|
|
18
|
+
return {
|
|
19
|
+
geometry: {
|
|
20
|
+
coordinates: [event.longitude, event.latitude],
|
|
21
|
+
type: 'Point',
|
|
22
|
+
},
|
|
23
|
+
id: `${event.agency_id}-${event.vehicle_id}`,
|
|
24
|
+
properties: {
|
|
25
|
+
...(vehicleData ?? {}),
|
|
26
|
+
...event,
|
|
27
|
+
},
|
|
28
|
+
type: 'Feature',
|
|
29
|
+
};
|
|
30
|
+
}
|