Skip to main content

Overview

The Point entity represents a single AVL telemetry reading from a vehicle tracking device. It contains 50+ attributes covering geospatial data, movement metrics, hardware status, and contextual information.

Table Configuration

@Entity({ name: 'points', synchronize: false })
  • Table name: points
  • Synchronize: false (schema managed manually)
  • Partitioning: RANGE partitioned by timestamp

Composite Primary Key

PostgreSQL requires the partition key (timestamp) to be part of the primary key in RANGE partitioned tables. This ensures uniqueness across partitions.
id
string (uuid)
required
Unique identifier for the point. Auto-generated using gen_random_uuid().
timestamp
number (bigint)
required
Unix timestamp in milliseconds when the telemetry point was captured. Used as the partition key.

Device Identification

trackerDeviceImei
number (bigint)
required
IMEI (International Mobile Equipment Identity) number of the tracking device.
trackerDeviceLicensePlate
string
License plate number of the vehicle equipped with this tracker.
trackerDeviceAlias
string
Human-friendly alias or name for the tracked vehicle (e.g., “Truck 42”, “Patrol Unit Alpha”).

Geospatial Data

PostGIS Geometry

location
geometry(Point, 4326)
PostGIS POINT geometry representing the vehicle location. Uses SRID 4326 (WGS 84).Usage example:
-- Find points within 500m of a location
SELECT * FROM points
WHERE ST_DWithin(
  location::geography,
  ST_MakePoint(-99.1332, 19.4326)::geography,
  500
);

Coordinate Components

trackerDeviceLatitude
number (double precision)
required
Latitude in decimal degrees (WGS 84). Range: -90 to 90.
trackerDeviceLongitude
number (double precision)
required
Longitude in decimal degrees (WGS 84). Range: -180 to 180.
trackerDeviceAltitude
number (double precision)
Altitude in meters above sea level.

Movement & Speed

trackerDeviceAngle
number (smallint)
Vehicle heading/bearing in degrees. Range: 0-360, where 0 is North, 90 is East, 180 is South, 270 is West.
trackerDeviceSpeedMs
number (real)
default:"0"
Current speed in meters per second.
trackerDeviceSpeedKh
number (real)
default:"0"
Current speed in kilometers per hour.
trackerDeviceMovement
boolean
default:"false"
Whether the vehicle is currently moving. Typically true when speed exceeds a threshold (e.g., 5 km/h).
trackerDeviceIgnition
boolean
default:"false"
Engine ignition status. true when the engine is on.

Distance Tracking

trackerDeviceDistance
number (double precision)
default:"0"
Distance traveled since the last point, in meters.
trackerDeviceTotalDistance
number (double precision)
default:"0"
Cumulative total distance traveled by the vehicle, in meters. This odometer value persists across device resets.

Daily Kilometer Metrics

trackerDeviceKmDay
number (real)
default:"0"
Total kilometers traveled today (resets at midnight).
trackerDeviceJurisdictionKmDay
number (real)
default:"0"
Kilometers traveled today within jurisdiction boundaries.
trackerDeviceNoJurisdictionKmDay
number (real)
default:"0"
Kilometers traveled today outside jurisdiction boundaries.

Time Tracking (in seconds)

Driving Time

trackerDeviceDrivingTimeInJurisdiction
number (integer)
default:"0"
Total seconds spent driving within jurisdiction boundaries today.
trackerDeviceDrivingTimeOutOfJurisdiction
number (integer)
default:"0"
Total seconds spent driving outside jurisdiction boundaries today.

Parking Time

trackerDeviceParkingTimeInJurisdiction
number (integer)
default:"0"
Total seconds spent parked (ignition off) within jurisdiction today.
trackerDeviceParkingTimeOutOfJurisdiction
number (integer)
default:"0"
Total seconds spent parked outside jurisdiction today.
trackerDeviceTacticalParking
number (integer)
default:"0"
Total seconds spent in tactical parking mode (stopped with ignition on).

Engine Hours

trackerDeviceEngineHours
number (real)
default:"0"
Engine hours accumulated today, in hours.
trackerDeviceTotalEngineHours
number (real)
default:"0"
Total cumulative engine hours since device installation.
trackerDeviceEngineHoursBasedOnIgnition
number (real)
default:"0"
Engine hours calculated based on ignition state (may differ from ECU-reported hours).
trackerDeviceEngineHoursBasedOnIgnitionAndStopped
number (real)
default:"0"
Engine hours when vehicle is stopped with ignition on (idle time).

Hardware & Network Status

Signal & Battery

trackerDeviceGsmSignal
number (smallint)
GSM signal strength (typically 0-31, where higher is better). 99 indicates no signal.
trackerDeviceBattery
number (smallint)
Device battery level as a percentage (0-100), or voltage in millivolts depending on device.
trackerDeviceBatteryCurrentAmps
number (real)
Current battery draw in amperes. Positive values indicate charging, negative indicate discharging.

Device State

trackerDeviceStatus
number (smallint)
Device status code. Interpretation varies by tracker manufacturer.
trackerDeviceDataMode
number (smallint)
Data transmission mode (e.g., 0 = Home On Stop, 1 = Home On Moving, 2 = Roaming).
trackerDeviceNetworkType
number (smallint)
Mobile network type: 0 = GSM, 1 = UMTS, 2 = LTE, etc.

Cellular Network Info

trackerDeviceGsmAreaCode
number (integer)
Location Area Code (LAC) from the GSM/LTE network.
trackerDeviceActiveGsmOperator
number (bigint)
Mobile Country Code + Mobile Network Code (MCC+MNC) of the active operator.
trackerDeviceCellId
number (integer)
Cell tower ID the device is currently connected to.

Protocol Info

trackerDevicePacketId
number (smallint)
Sequential packet ID for tracking data integrity.
trackerDeviceCodecId
number (smallint)
Protocol codec identifier (e.g., Codec 8, Codec 16 for Teltonika devices).

GNSS Quality

trackerAccuracy
number (smallint)
GPS accuracy/precision in meters. Lower values indicate better accuracy.
trackerDeviceGnssState
number (smallint)
GNSS fix state: 0 = No fix, 1 = 2D fix, 2 = 3D fix.
trackerDeviceNumberOfSatellites
number (smallint)
Number of satellites used for the GNSS fix. More satellites generally means better accuracy.
trackerDeviceGnssPdop
number (real)
Position Dilution of Precision. Values < 5 are good, > 10 indicate poor geometry.
trackerDeviceGnssHdop
number (real)
Horizontal Dilution of Precision. Lower values indicate better horizontal accuracy.

Geocoding & Administrative Zones

trackerDeviceGeocode
string (text)
Reverse-geocoded address or location name (e.g., “Av. Insurgentes Sur 1602, CDMX”).
trackerDeviceIdMunicipality
string (uuid)
UUID of the municipality where this point is located.
trackerPlotUuid
string (uuid)
UUID of the plot/parcel where this point is located.

Geofences & Sectors

Boolean Flags

trackerDeviceInsideGeofence
boolean
default:"false"
Whether the point is inside any assigned geofence.
trackerDeviceInsideQuadrant
boolean
default:"false"
Whether the point is inside an assigned quadrant.
trackerDeviceInsideSector
boolean
default:"false"
Whether the point is inside the vehicle’s assigned sector.
trackerDeviceInsideAnySector
boolean
default:"false"
Whether the point is inside any sector (not necessarily the assigned one).

Sector Details

trackerDeviceInsideAnySectorName
string
Name of the sector the vehicle is currently inside (if any).
trackerDeviceInsideAnySectorId
string (uuid)
UUID of the sector the vehicle is currently inside.

Quadrant Information

trackerDeviceQuadrant
object (jsonb)
JSONB object containing quadrant details when the vehicle is inside a quadrant.Example:
{
  "quadrant_id": "q_norte_12",
  "quadrant_name": "Norte Sector 12"
}

Trip & Alerts

trackerDeviceTripId
number (integer)
Identifier of the current trip. A trip typically starts when ignition turns on and ends when it turns off.
trackerDeviceAlarm
string
Active alarm/alert type (e.g., “SPEEDING”, “HARSH_BRAKING”, “GEOFENCE_EXIT”, “POWER_CUT”).

Fuel Consumption

trackerDeviceGallonsPerKm
number (real)
Fuel efficiency in gallons per kilometer.
trackerDeviceFuelConsumedPerDay
number (real)
Total fuel consumed today in gallons.

Timestamps

trackerDeviceShippingDate
Date (timestamptz)
When the telemetry data was transmitted from the device to the server.
createdAt
Date (timestamptz)
When this record was inserted into the database. Auto-populated by TypeORM.
updatedAt
Date (timestamptz)
When this record was last updated. Auto-populated by TypeORM on every update.

Usage Example

import { Point } from './model/point.model';
import { Repository } from 'typeorm';

// Query recent points for a specific vehicle
const recentPoints = await pointsRepository.find({
  where: {
    trackerDeviceImei: 123456789012345,
    timestamp: MoreThan(Date.now() - 3600000) // Last hour
  },
  order: { timestamp: 'DESC' },
  take: 100
});

// Access geospatial data
const point = recentPoints[0];
console.log(`Vehicle at ${point.trackerDeviceLatitude}, ${point.trackerDeviceLongitude}`);
console.log(`Speed: ${point.trackerDeviceSpeedKh} km/h`);
console.log(`Inside quadrant: ${point.trackerDeviceQuadrant?.quadrant_name}`);

Build docs developers (and LLMs) love