B4J Question Geo-code question - how do I...

Harris

Expert
Licensed User
Longtime User
Here is the issue:

I have 15 heavy haul trucks that travel the SAME road every day. They record the GPS position and vehicle speed every second - for each truck (stored in a flat file - not a table - but could be put into a table for processing).

I need to know when two trucks are at the same lat/lon at the same time (or 30 second sliding window).
The corporate policy is that trucks that meet (one going north - the other going south) must reduce their road speed to under 20 mph during this meeting.

Let's say unit number 74202 heads south. He will meet (at least) 4 trucks heading north during his trip segment (52 miles). When did each cross paths?

What kind of funcky formula would one need to cook up to solve this riddle?

Thanks (and happy new year to you all)!
 

derez

Expert
Licensed User
Longtime User
May be like this:
- make 3 lists for each truck, holding time,lat and long.
- separate to two groups - one going north direction and the other going south.
Algorithm:
- for each truck in group A do:
... - for each truck in group B do:
...... - find time-overlapping sequences and mark the start index in one list and the end index in the other
...... - if there is overlap then:
......... - Check the range between the trucks for the first overlapping time
......... - start loop
............ - jump forward in time(the index) (create some relation between the range and the expected meeting time and make the jump smaller so not to jump over the meeting time)
............ - starting at certain small range - check one by one until range get larger and
.................log that time as meeting and exit this B truck
......... end loop
......-end if
... -next
-next

The formula for expected meeting by range is
time jump to meet = 0.5 * range / mean speed, so take less than that in order to check again before. You have to use the correct set of units(e.g. meter-sec)
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
geo.jpg


As I am pondering this problem...

It is multi-step. I do not think it can be accomplished in a single pass. WAY beyond what I have ever tried to accomplish... but here I go...
After all, it's only math and MUCH logic. Hopefully you smart folks can help contribute to this logic...
Otherwise, if not, it helps ME conceptualize and lay it out - as best I can - hoping to gain (get) insight.

Currently:
I have created and use Geo-Zones in my app for real time processing on the device. It will determine if speed is above set param while in this geo-zone (see pic above) - and create a record if it is... (reports speed violations - this zone is 30 MPH).

I am thinking, if I geo-zone the entire road (all 52 miles), in, let's say, 2 mile zones (26 in all)... I can then build a result set (for a 24 hour period - or whatever) that would tell me what vehicles were in each zone at every hour of the given day. Now I have a result set that tells me vehicles A,B,C were in Zone 1 between 8 - 9 am.
From this, were any of these vehicles AT the SAME lat/lon during this 1 hour time frame (give or take x seconds)? And, during this "meeting" was either vehicles speed > than "x"?

Why I ponder this at 11:55 pm (5 mins before 2017 - BC, Canada time) - is beyond me...
Anyway - HAPPY NEW YEAR!
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
May be like this:
- make 3 lists for each truck, holding time,lat and long.
- separate to two groups - one going north direction and the other going south.
Algorithm:
- for each truck in group A do:
... - for each truck in group B do:
...... - find time-overlapping sequences and mark the start index in one list and the end index in the other
...... - if there is overlap then:
......... - Check the range between the trucks for the first overlapping time
......... - start loop
............ - jump forward in time(the index) (create some relation between the range and the expected meeting time and make the jump smaller so not to jump over the meeting time)
............ - starting at certain small range - check one by one until range get larger and
.................log that time as meeting and exit this B truck
......... end loop
......-end if
... -next
-next

The formula for expected meeting by range is
time jump to meet = 0.5 * range / mean speed, so take less than that in order to check again before. You have to use the correct set of units(e.g. meter-sec)

While I was writing my own retort - you responded... Thanks @derez... Shall take it up in the am.. Time to DRINK and be merry! it is 2017!!!!!!
 
Upvote 0
Top