For developers

Trips, sites and time on site

How Fordonskollen turns the vehicle's GPS points into trips in the logbook and into visits at sites, and what that means for the numbers you fetch.

Three kinds of data

  • Positions. The tracker in the vehicle sends a point with position, speed and ignition, about every second while driving and every 30 minutes when parked. The latest position is in /api/v1/positions.
  • Trips. The logbook. A trip follows the ignition: it starts when the ignition is turned on and ends when it is turned off. Available in /api/v1/trips.
  • Sites and visits. Where the vehicle was and for how long. A visit follows the position: it starts when the vehicle arrives at the site and ends when it has left. Available in /api/v1/site_visits and /api/v1/sites.

How a trip is formed

Fordonskollen creates trips by itself. The driver does not need to press anything. Three rules decide where a trip starts and ends:

  1. Ignition on starts, ignition off ends

    started_at is when the ignition was turned on and ended_at when it was turned off. While the trip is in progress, ended_at is empty.

  2. Short stops belong to the trip

    If the ignition is turned on again within 3 minutes, the same trip continues. A quick stop to drop off a parcel or refuel is therefore not a trip of its own.

  3. Very short trips are not saved

    A trip with at most 1 minute of ignition on is discarded, for example when the car is moved in the driveway.

How ignition becomes trips Top: the ignition over 70 minutes. Bottom: the trips that remain. A 2-minute stop is merged into the trip. A 40-second move is discarded. Ignition Trips 2 min 40 s Trip 1 discarded Trip 2 08:00 08:30 09:10
ignition on ignition off · The 2-minute stop becomes part of trip 1. The 40-second move becomes no trip.

What is filled in afterwards

  • Addresses. start_address and end_address are looked up from the GPS position, usually within a minute of the trip starting or ending. The fields start_geokodning_status and end_geokodning_status show whether the lookup is done. If the tracker had no GPS position, for example right after starting in a garage, the address stays empty and the status is ingen_adress.
  • Distance. distance_m is calculated from the tracker's odometer. If the car reports its own odometer reading, it is in start_can_odometer_km and end_can_odometer_km.
  • Classification and driver. The driver classifies the trip as business or private, often afterwards. A trip can therefore change purpose, driver and visible fields several days after it was driven.

If you copy trips into your own system, re-read the last few days of trips now and then instead of only fetching new ones. The trip.ended webhook tells you when a trip is done, but not when it is classified.

Why the times differ

A trip counts time with the ignition on. Time on site counts time inside an area. When the vehicle queues or idles at the destination, the same minutes count in both the trip and the visit.

Example: a vehicle goes through inspection. It drives onto the site at 08:11, queues with the engine running, switches off at 08:20, starts again at 08:28 and drives out at 08:29.

Trips and a visit during an inspection Trip 1 ends at 08:20 and trip 2 starts at 08:28, so 8 minutes between trips. The visit at the site lasts from 08:11 to 08:29, so 18 minutes, 10 of them with the ignition on. Trips Visit Ignition Trip 1 Trip 2 8 min between trips 18 min 07:55 08:11 08:20 08:29 08:40
counted in both the trip and the visit
Question Answer in the example Where to find it
Time between trips 8 min ended_at on trip 1 to started_at on trip 2
Time on site 18 min duration_s on the visit
Of which ignition on (queue, idling) 10 min ignition_on_s on the visit
Of which ignition off 8 min ignition_off_s on the visit
  • The gap between trips is not time on site. It only measures how long the ignition was off. Queueing and idling end up in the trip, so time at a customer counted from the gap comes out too low.
  • Do not add trips and visits together. The minutes with the ignition on at the site are in both. The overlap is exactly ignition_on_s.
  • The logbook does not change. Trips follow the ignition exactly as today, so the logbook for the Swedish Tax Agency is not affected by visits.

Sites

A site is a place where the organisation's vehicles tend to stop: a customer, a warehouse, a workshop. Fordonskollen learns the sites from the stops by itself. Nobody needs to enter them.

  1. The vehicle stops

    A stop is when the ignition is turned off, or when the vehicle stands still with the engine running for at least 3 minutes, for example during a delivery. A red light or a queue is not a stop.

  2. The stop is tied to a site

    If there is a site within 150 metres, the stop becomes a visit there. Otherwise a new site is created. Sites are shared by the whole organisation, so every vehicle visiting the same customer ends up at the same site.

  3. The site gets a centre point and an address

    The centre point is the median of all visits' positions, so it lands where the vehicles actually stand. The address is looked up from the centre point and works as the site's name. You can rename the site, for example to Customer X warehouse.

A site with a centre and two boundaries A site is a centre point with an inner circle of 150 metres and an outer circle of 200 metres. The vehicle counts as arrived inside the inner circle and as gone only outside the outer one. arrived gone 150 m 200 m Centre point median of the visits Address Industrigatan 1, Exempelstad Name Customer X warehouse
Two boundaries mean that a single bad GPS point does not break the visit. The vehicle counts as gone only after two points in a row, or 60 seconds, outside 200 metres.

Visits

A visit is one vehicle at a site or in a geozone, from arrival to departure. Arrival is the first time the vehicle is inside the boundary at low speed, and departure the last time before it has left. Visits shorter than 2 minutes are not saved.

Visits
GET /api/v1/site_visits
Sites
GET /api/v1/sites
MCP tool
list_site_visits, list_sites

Each visit has arrival, departure, total time and how much of it was with the ignition on, idling or switched off. ?address= searches both the site's name and address, and filter[site_id]= returns all visits to one site. Full field list.

Geozones

A geozone is an area you draw yourselves under Map in the app, as a circle or a polygon: a whole site, an industrial area, a depot. A vehicle counts as gone from the zone only 50 metres outside its edge. Zones can be read from /api/v1/geozones, and visits in a zone have the zone's id in geozone_id.

  • A zone takes precedence over a learned site. Two customers closer than 150 metres to each other are merged into one site. Draw one zone per customer to tell them apart.
  • Zones can be nested. A vehicle at a customer site inside an industrial area gets one visit in each zone.
  • Passes can be turned on per zone. With Show passes, visits shorter than 2 minutes are saved too, for example at a weighbridge or a gate.
  • A changed zone applies from now on. If you redraw or remove a zone, earlier visits stay as they were counted.

Private trips

  • Private stops never become sites. A stop on a private trip, such as the driver's home, creates no site and moves no centre point. If the trip is classified as private afterwards, the visit is removed from the site.
  • The visit shows, but not where. If the trip there or from there is private, the times are shared, but never the site, address or position. The same rule as for trips.
  • Geozones are not hidden. A zone is a place you drew yourselves, so a visit there reveals no private address.

Which data should I use?

You want to know Use
Distance driven, mileage allowance, logbook /api/v1/trips
When a trip starts or ends, in real time Webhooks trip.started and trip.ended
Where the vehicles are right now /api/v1/positions
Time at a customer, basis for invoicing /api/v1/site_visits
Idling on site idle_s on the visit

Stuck, or missing something?

Write to us and we will help you get going: info@fordonskollen.com