34 lines
832 B
TypeScript
34 lines
832 B
TypeScript
import { Entity, Column, PrimaryColumn, Index } from 'typeorm';
|
|
|
|
@Entity('road_segment_stats')
|
|
@Index('idx_segment_congestion', ['congestionFactor'], { where: '"congestionFactor" > 1.1' })
|
|
export class RoadSegmentStat {
|
|
@PrimaryColumn()
|
|
segmentId: string; // OSM Way ID or similar
|
|
|
|
@Column('float', { default: 0 })
|
|
averageSpeed: number;
|
|
|
|
@Column('float', { default: 1.0 })
|
|
congestionFactor: number; // 1.0 = Free flow, >1.0 = Congested
|
|
|
|
@Column('boolean', { default: false })
|
|
@Index()
|
|
isClosed: boolean;
|
|
|
|
@Column('int', { default: 0 })
|
|
sampleCount: number;
|
|
|
|
@Column({
|
|
type: 'geography',
|
|
spatialFeatureType: 'LineString',
|
|
srid: 4326,
|
|
nullable: true,
|
|
})
|
|
@Index({ spatial: true })
|
|
geometry: any;
|
|
|
|
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
lastUpdated: Date;
|
|
}
|