59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';
|
|
|
|
export enum AssetGeometryType {
|
|
POINT = 'POINT',
|
|
LINESTRING = 'LINESTRING',
|
|
POLYGON = 'POLYGON',
|
|
}
|
|
|
|
export enum AssetGeometrySource {
|
|
WEB = 'WEB',
|
|
ANDROID = 'ANDROID',
|
|
IMPORT = 'IMPORT',
|
|
SURVEY = 'SURVEY',
|
|
}
|
|
|
|
@Entity({ name: 'asset_geometries' })
|
|
@Index('idx_asset_geometries_geometry', ['geometry'], { spatial: true })
|
|
@Index('idx_asset_geometries_type', ['geometryType'])
|
|
export class AssetGeometry {
|
|
@PrimaryColumn({ name: 'asset_id', type: 'uuid' })
|
|
assetId!: string;
|
|
|
|
@Column({
|
|
type: 'geometry',
|
|
spatialFeatureType: 'Geometry',
|
|
srid: 4326,
|
|
})
|
|
geometry!: { type: AssetGeometryType; coordinates: unknown };
|
|
|
|
@Column({ name: 'geometry_type', type: 'varchar', length: 20 })
|
|
geometryType!: AssetGeometryType;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: AssetGeometrySource,
|
|
enumName: 'asset_geometry_source',
|
|
default: AssetGeometrySource.WEB,
|
|
})
|
|
source!: AssetGeometrySource;
|
|
|
|
@Column({ name: 'accuracy_m', type: 'numeric', precision: 12, scale: 3, nullable: true })
|
|
accuracyM!: string | null;
|
|
|
|
@Column({ name: 'captured_at', type: 'timestamptz', nullable: true })
|
|
capturedAt!: Date | null;
|
|
|
|
@Column({ name: 'device_label', type: 'varchar', length: 255, nullable: true })
|
|
deviceLabel!: string | null;
|
|
|
|
@Column({ name: 'created_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@Column({ name: 'updated_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|