@tmlmobilidade/geo 20260829.236.0 → 20260829.1045.9

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
@@ -9,4 +9,5 @@ export * from './hashed-shapes-to-geojson.js';
9
9
  export * from './is-point-in-polygon.js';
10
10
  export * from './measurements.js';
11
11
  export * from './polyline.js';
12
+ export * from './vehicle-event-to-geojson.js';
12
13
  export * from '@turf/turf';
package/dist/index.js CHANGED
@@ -9,4 +9,5 @@ export * from './hashed-shapes-to-geojson.js';
9
9
  export * from './is-point-in-polygon.js';
10
10
  export * from './measurements.js';
11
11
  export * from './polyline.js';
12
+ export * from './vehicle-event-to-geojson.js';
12
13
  export * from '@turf/turf';
@@ -0,0 +1,18 @@
1
+ import { type HubVehiclePosition } from '@tmlmobilidade/go-types-hub';
2
+ import { type Vehicle } from '@tmlmobilidade/go-types-operation';
3
+ import { type SimplifiedVehicleEvent } from '@tmlmobilidade/go-types-vehicle-events';
4
+ /**
5
+ * Converts a SimplifiedVehicleEvent object into a GeoJSON Feature of type Point.
6
+ *
7
+ * @param vehiclePositionData - Object containing vehicle position and metadata.
8
+ * @returns A GeoJSON Feature representing the vehicle's geographic location and associated properties.
9
+ *
10
+ * Properties embedded in the feature:
11
+ * - agency_id: ID of the agency the vehicle belongs to
12
+ * - bearing: Heading in degrees
13
+ * - id: Vehicle identifier (duplicated for GeoJSON "properties.id" key)
14
+ * - lat: Vehicle latitude
15
+ * - lon: Vehicle longitude
16
+ * - trip_id: Associated trip identifier
17
+ */
18
+ export declare function transformVehicleDataIntoGeoJsonFeature(event: HubVehiclePosition | 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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/geo",
3
- "version": "20260829.236.0",
3
+ "version": "20260829.1045.9",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"