Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

Batching lat,lon data to see if its in a geofence zone

I have to process a list of latitude and longitude co-ordinates to see if a device has moved in/out of a geo zone

Previously, the app was single threaded, and we delayed processing this information for a few minutes, then we ordered the list by the dateTime and then checked each item in date order to see if it entered / exited a zone

i.e.
12:00:01 - not in zone
12:00:02 - not in zone
12:00:03 -  in zone
12:00:04 -  in zone
12:00:05 -  in zone
12:00:06 -  in zone
12:00:07 -  in zone
12:00:08 - not in zone
12:00:09 - not in zone

Open in new window


this then saves date to db like
12:00:03 - entered the zone
12:00:08 - exited the zone

Open in new window


We have since made the console app multithreaded and we are now seeing race conditions where the data is processed in the wrong order, and its causing data integrity issues where sometimes exits the zone too early, and then the next record see's its inside the zone, therefore its creating data like this

12:00:06 - entered the zone
12:00:08 - exited the zone

12:00:04 - entered the zone
12:00:09 - exited the zone

Open in new window


the user then thinks the device entered the zone twice, when it was infact just once


Due to the high volume of data we process we need to stick with multithreaded solution
We currently check the next item in the list against the in memory "lastPosition" object

I'm now thinking we need to change the approach where we check 1 record against another, and batch the records to speed up performance (however i've no idea how we would do this)

Does anyone have any thoughts on this, and how we might accomplish this?
The data is all in a .net 4.6 console app.

If there are any latitude longitude performance stuff worth knowing about, it would also be helpful

the "zones" are a collection of latitude/longitude points which is essentially a drawn on polygon on a map
Each position is a single lat & lon set
ASKER CERTIFIED SOLUTION
Avatar of louisfr
louisfr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial