Skip to main content

Tracking Service Models

Database Tables

positions

GPS position data from devices.

ColumnTypeNullableDescription
idBIGINTNoPrimary key
deviceidBIGINTNoReference to device
protocolVARCHAR(128)YesProtocol name (s21l, gt06, etc.)
servertimeDATETIMEYesWhen server received
devicetimeDATETIMEYesWhen device reported
fixtimeDATETIMEYesGPS fix time
validINTEGERNoGPS fix validity (0/1)
latitudeDOUBLENoLatitude degrees
longitudeDOUBLENoLongitude degrees
altitudeDOUBLENoAltitude in meters
speedDOUBLENoSpeed in knots
courseDOUBLENoHeading in degrees
accuracyDOUBLENoGPS accuracy
addressVARCHAR(512)YesReverse geocoded address
attributesTEXTYesJSON attributes
networkTEXTYesJSON network info

events

System events (overspeed, geofence, alarms, etc.).

ColumnTypeNullableDescription
idBIGINTNoPrimary key
typeVARCHAR(128)NoEvent type
eventtimeDATETIMEYesWhen event occurred
deviceidBIGINTNoReference to device
positionidBIGINTYesReference to position
geofenceidBIGINTYesReference to geofence
maintenanceidBIGINTYesReference to maintenance
attributesTEXTYesJSON attributes

geofences

Geographic boundaries for monitoring.

ColumnTypeNullableDescription
idBIGINTNoPrimary key
nameVARCHAR(128)NoGeofence name
descriptionVARCHAR(512)YesDescription
areaTEXTYesWKT geometry
calendaridBIGINTYesCalendar reference
attributesTEXTYesJSON attributes

user_geofence

User-Geofence permission links.

ColumnTypeNullableDescription
useridBIGINTNoUser ID (PK)
geofenceidBIGINTNoGeofence ID (PK)

device_geofence

Device-Geofence links.

ColumnTypeNullableDescription
deviceidBIGINTNoDevice ID (PK)
geofenceidBIGINTNoGeofence ID (PK)

user_device

User-device permission model with sharing support.

ColumnTypeNullableDescription
useridBIGINTNoUser ID (PK)
deviceidBIGINTNoDevice ID (PK)
is_ownerINTEGERNo1=owner, 0=shared user
shared_byBIGINTYesUser ID who shared this device
permission_positionINTEGERNoCan view positions (default 1)
permission_eventsINTEGERNoCan view events (default 1)
permission_geofencesINTEGERNoCan view geofences (default 1)
permission_notificationsINTEGERNoReceives notifications (default 1)
permission_commandsINTEGERNoCan send commands (default 0)
created_atDATETIMEYesWhen access was granted

Event Types

TypeDescription
deviceOnlineDevice came online
deviceOfflineDevice went offline
deviceUnknownDevice status unknown
deviceInactiveDevice inactive for extended period
deviceMovingDevice started moving
deviceStoppedDevice stopped
deviceOverspeedDevice exceeded speed limit
deviceFuelDropFuel level dropped suddenly
deviceFuelIncreaseFuel level increased (refuel)
geofenceEnterDevice entered geofence
geofenceExitDevice exited geofence
alarmDevice alarm triggered (see alarmType in attributes)
ignitionOnIgnition turned on
ignitionOffIgnition turned off
maintenanceMaintenance reminder triggered
textMessageText message received
driverChangedDriver ID changed
commandResultCommand result received

Alarm Types (in event attributes)

AlarmDescription
sosSOS/Emergency button pressed
vibrationVibration detected
movementMovement detected
overspeedOverspeed alarm
lowPowerLow external power
lowBatteryLow battery
powerOffPower disconnected
powerOnPower connected
gpsAntennaCutGPS antenna cut/tampered
accidentAccident detected
towVehicle towing detected
hardAccelerationHard acceleration
hardBrakingHard braking
hardCorneringHard cornering
jammingGPS jamming detected
tamperingDevice tampering

Geofence Area Formats (WKT)

Circle

CIRCLE (latitude longitude, radius)
  • latitude: Center latitude in degrees
  • longitude: Center longitude in degrees
  • radius: Radius in meters

Example: CIRCLE (45.4654 9.1859, 100) - 100m radius circle

Polygon

POLYGON ((lat1 lon1, lat2 lon2, lat3 lon3, lat1 lon1))
  • List of coordinate pairs
  • First and last point must be the same (closed polygon)
  • Minimum 4 points (triangle + closing point)

Example: POLYGON ((45.4654 9.1859, 45.4655 9.1860, 45.4656 9.1858, 45.4654 9.1859))

Linestring (Corridor)

LINESTRING (lat1 lon1, lat2 lon2, lat3 lon3)
  • Used for route corridors
  • Requires additional radius in attributes

Example: LINESTRING (45.4654 9.1859, 45.4700 9.1900, 45.4750 9.1920)

Position Attributes (Common)

AttributeTypeDescription
satintSatellites in use
hdopfloatHorizontal dilution of precision
ignitionboolIgnition state
motionboolMotion state
batteryfloatBattery voltage
batteryLevelintBattery percentage (0-100)
fuelfloatFuel level (liters)
odometerfloatOdometer (meters)
distancefloatDistance traveled (meters)
totalDistancefloatTotal distance (meters)
hoursintEngine hours (milliseconds)
alarmstringAlarm type if active