import { BaseEntity } from '@edr/api-common'; import { Column, Entity, Index } from 'typeorm'; /** One GPS fix from a tracker (append-only history). */ @Entity({ name: 'gps_positions', schema: 'freight' }) @Index(['deviceId', 'gpsTime']) @Index(['vehicleId', 'gpsTime']) export class GpsPosition extends BaseEntity { @Column({ name: 'device_id', type: 'uuid' }) deviceId!: string; @Column({ name: 'imei', type: 'varchar', length: 20 }) imei!: string; @Column({ name: 'vehicle_id', type: 'uuid', nullable: true }) vehicleId?: string | null; @Column({ name: 'lat', type: 'numeric', precision: 10, scale: 6 }) lat!: number; @Column({ name: 'lng', type: 'numeric', precision: 10, scale: 6 }) lng!: number; @Column({ name: 'speed', type: 'numeric', precision: 6, scale: 2, default: 0 }) speed!: number; @Column({ name: 'course', type: 'int', default: 0 }) course!: number; @Column({ name: 'satellites', type: 'int', default: 0 }) satellites!: number; @Column({ name: 'positioned', type: 'boolean', default: false }) positioned!: boolean; /** Fix time reported by the device (UTC). */ @Column({ name: 'gps_time', type: 'timestamptz' }) gpsTime!: Date; /** Non-zero when the fix came in via an alarm packet. */ @Column({ name: 'alarm', type: 'int', default: 0 }) alarm!: number; }