Avatar

upgrading from 5.6 to 5.7: Trip

0

In 5.6 we had LastPoint and FirstPoint. We were able to access...

  • LastPoint.IsStop
  • LastPoint.DateTime
  • FirstPoint.DateTime

It looks like in 5.7 we have stopPoint (is this the same as LastPoint)? And what about FirstPoint.DateTime? Can we just use the Trip.start?

Mark Faucher

Please sign in to leave a comment.

22 comments

Avatar

Hi Mark,

  • LastPoint.IsStop: Trip.StopPoint has the stop coordinates populated or if you want the position at any point in time of a trip you can query for a LogRecord with the device and datetime.
  • LastPoint.DateTime: Trip.Stop
  • FirstPoint.DateTime: Trip.Start

Thanks,

Steve

 

0
Comment actions Permalink
Steve Hansen 0 votes
Avatar

Thanks Steve. Could you elaborate on LastPoint.IsStop? It appears that we have a need to query all trips where the last point is a stop point. We were able to evaluate LastPoint.IsStop in the past.

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Hi Mark, Steve:

I will contradict Steve on "LastPoint.DateTime: Trip.Stop". It has to be read as "StopDrive.DateTime: Trip.Stop"

To get the points for the trip retrieve logs in the date range between Trip.Start and Trip.NextTripStart. Then do further checks, for instance whether the last point's date equals Trip.Stop or not.

Thanks,

Serge

0
Comment actions Permalink
Serge Pavlov 0 votes
Avatar

So, while we had the boolean LastPoint.IsStop in 5.6, we can now use StopPoint.DateTime == Trip.Stop? 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

tripLogs[tripLogs.Count-1].DateTime == Trip.Stop

if that makes sense

0
Comment actions Permalink
Serge Pavlov 0 votes
Avatar

So, to provide one example where we have 5.6 code that uses IsStop...

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.EntityIdentifier == id && (t.LastPoint.IsStop ?? false)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

What would we replace "(t.LastPoint.IsStop ?? false)" with? (ignoring all of the other EntityIdentifier stuff that needs to be replaced) 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Can you explain what you are trying to do? Are you trying to exclude trips that are incomplete?

Thanks,

Steve

0
Comment actions Permalink
Steve Hansen 0 votes
Avatar

Hi Steve. Maybe this would help me. In 5.5 and 5.6, Trip had LastPoint.IsStop. From Geotab's perspective, what did that property represent? 

 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Looking at the 5.6 documentation for LogRecord, the IsStop property states: "Is the log marked as a stop?

What does/did that mean from Geotab's perspective? What did it mean for the log to be marked as a stop? If we can figure this out, I'm sure we can determine how to work around this in 5.7.

Thanks

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Hi Mark,

a logrecord that IsStop property value is true specifies the location and time when the corresponding trip's driving section ended as the vehicle became stationary. For a trip in progress this may change if the vehicle starts moving again: the value would be reset back to false until a "real" stop, that would generally happen multiple times per a trip in progress. A record would become permanently associated with the trip's stop when the trip becomes historic, i.e. new trip starts. Note: there is only one logrecord per trip where IsStop is true. In 5.7 terms, this is a log at the trip's Stop time.   

0
Comment actions Permalink
Serge Pavlov 0 votes
Avatar

So, in 5.5 and 5.6 we would do this...

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.EntityIdentifier == id && (t.LastPoint.IsStop ?? false)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

So, the above would effectively filter out incomplete trips, right? That is, if the LastPoint.IsStop is false, the trip is incomplete?

"In 5.7 terms, this is a log at the trip's Stop time."

So, how can I determine if the trip is complete? 

 

 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Mark,

I think there is confusion. Trip.StopPoint is the *stop point*, has nothing to do with Trip.LastPoint. last point is just a last point in the trip. The trip could be ending next morning after the car parked on a night before. Therefore, the StopPoint was when it stopped (parked), LastPoint - the last GPS fix just before it started the next trip the morning after.

Complete/Incomlete trip: 

in 5.6:

The trip is incomplete Trip.StopTime == TimeSpan.Zero

in 5.7.0:

The trip is incomplete Trip.StopDuration == TimeSpan.Zero

 

0
Comment actions Permalink
Serge Pavlov 0 votes
Avatar

5.5 & 5.6

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.EntityIdentifier == id && (t.LastPoint.IsStop ?? false)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

5.7

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.Id == id && (______________________?)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Serge. This solution isn't working after all. Can you confirm? Are you sure this is correct? I am not getting the trips I need to calculate idle time. 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

To anyone there at Geotab. I need to resolve this. I was told (above) that swapping in t.StopDuration == TimeSpan.Zero for LastPoint.IsStop would be equivalent.

I'm trying to adjust for this...I don't want to grab every trip for a vehicle. Consider Friday PM bus stopped at 4:00pm, idled for 5 minutes, shut down. Monday morning idled for 5 minutes and started a trip. 

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Just to summarize - in my idle time calculation, I used to filter my trips by...

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.EntityIdentifier == id && (t.LastPoint.IsStop ?? false)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

With the loss of LastPoint.IsStop, I asked what I could use instead....

5.7

// Get all trips for this vehicle where last point is a stop point
var result = (from t in trips
                    where t.Device.Id == id && (______________________?)
                    select t).OrderBy(o => o.LastPoint.DateTime.GetValueOrDefault(DateTime.Now)).ToList();

...and was told that "t.StopDuration == TimeSpan.Zero" will work. Unfortunately, it doesn't. I can see 

I'm attaching a screenshot. My goal is to be able to identify and store that 5m 57s idle time. We have a 3-minute threshold, so I need to be able identify trips* and calculate the idle time. 

* I can't just use IdlingDuration for every trip, because of the scenario I described above: "I don't want to grab every trip for a vehicle. Consider Friday PM bus stopped at 4:00pm, idled for 5 minutes, shut down. Monday morning idled for 5 minutes and started a trip." 

I believe that the LastPoint.IsStop filtered the list so that I had what I needed. In 5.5 and 5.6, the above select with LastPoint.IsStop gave us what we needed. I need to duplicate this in 5.7, and I need to have it done tonight (or tomorrow). Thanks!




geotab.jpg
0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

(^ and just to be clear - "trips" in that query == a list of Trips for all devices for a datetime range.)

0
Comment actions Permalink
Mark Faucher 0 votes
Avatar

Hi Mark,

please explain in what way using t.StopDuration == TimeSpan.Zero fails you? Is this not picking any trips, or other issue?

For all device trips ordered by start time or stop time, the last is the one you need. That trip should have  zero StopDuration.

Serge.

 

0
Comment actions Permalink
Serge Pavlov 0 votes