This document provides steps on how to track how long an event has visited a location (geofence). In the below example, a GeoTab Connector has been configured to track vehicle locations. A polygon well pad feature service has been imported as geofences. We’re interested in tracking how long a vehicle spends at each well pad.
1. Create a table (i.e. Trip_Info) in a geodatabase with the following fields:
Field Name | Alias | Data Type | Description |
OBJECTID | OBJECTID | Object ID |
|
vin | VIN | Text | VIN number of the vehicle |
wellpad | Well Pad | Text | Name of the well pad |
wellpad_starttime | Well Pad Start Time | Date | Start Date/Time vehicle enters well pad |
wellpad_endtime | Well Pad End Time | Date | End Date/Time vehicle exits well pad |
unique_id | Unique ID | Text | Unique ID calculated by GeoEvent |
visited | Visited | Text | Text field that will be updated to Yes when a vehicle enters and exits a geofence |
wellpad_totaltime | Well Pad Total Time | Double | Field to calculate total time vehicle spends at well pad |
This table is published to an editable feature service called Trip_Info
1. Previously configured for this example, the GeoTab Connector is writing real-time vehicle data to a feature service called Vehicles_Realtime
2. The Well Pads have also been imported as Geofences. The Category name is Well Pad for all these geofences:
3. Create a GeoEvent Definition by importing the schema from the Trip_Info service published previously.
a. Set the vin field as the TRACK_ID
4. Create a copy of this GeoEvent Definition with the name Trip_Info_Reduced_Enter and keep only the vin, wellpad, wellpad_starttime, and unique_id fields:
5. Create another copy of the Trip_Info GeoEvent Definition with the name Trip_Info_Reduced_Exit and keep only the vin, wellpad, wellpad_endtime, and unique_id fields:
The Trip_Info_Reduced_Enter and Trip_Info_Reduced_Exit GeoEvent Definitions are used to update the wellpad_starttime and wellpad_endtime fields. The other fields are removed so that GeoEvent Services do not populate these fields will NULL/empty values.
6. Create an Update a Feature output that updates the Trip_Info service using the unique_id field as the Unique Feature Identifier Field:
Start the Trip Info Update Output service.
7. Create a new GeoEvent Service, i.e. Vehicle Enters Well Pad
a. Add the geotab-in input
b. Add the GeoTagger processor referencing the Geofences with the Spatial Operator Enter Any. The target field will be a New Field called GeoTags. Specify a new name for the GeoEvent Definition, i.e. Enter Well Pad GeoTagger. Choose No for the option Include Geofence Category in GeoTag
c. Connect the Input to the GeoTagger Processor
d. Add the Trip Info Update Output created previously to the GeoEvent Service, but do not connect it to the GeoTagger Processor. Publish the GeoEvent Service and start it. Let it run until some events enter a geofence. This will create the new GeoEvent Definition created in the GeoTagger Processor.
e. Add a Filter to remove events that have NULL values for the GeoTags field:
f. Add a Field Mapper Processor. The Source GeoEvent Definition will be the GeoEvent Definition created from the GeoTagger Processor. The Target GeoEvent Definition will be Trip_Info_Reduced_Enter. The GeoTags field created by the GeoTagger Processor contains the name of the well pad. This will be mapped to the wellpad field. The $RECEIVED_TIME will be mapped to the wellpad_starttime, and nothing will be mapped to unique_id. This will be calculated next:
g. Add a Field Calculator Processor. Calculate the unique_id by concatenating the vin and wellpad fields:
The unique_id is used in the case the vehicle visits multiple geofences. This field will allow all these visits to be recorded.
The GeoEvent Service should appear as the following:
8. Make a copy of the Vehicle Enters Well Pad GeoEvent Service
a. Rename the GeoEvent Service to Vehicle Exits Well Pad
b. Update the GeoTagger Process and change the Spatial Operator to Exit Any. Also, change the New GeoEvent Definition Name to Exit Well Pad GeoTagger
c. Disconnect the GeoTagger from the Filter, Publish, and start the GeoEvent Service so it creates the new GeoEvent Definition:
d. After the Exit Well Pad GeoTagger geoevent definition has been created, open the Field Mapper Processor. Change the Source GeoEvent Definition to Exit Well Pad GeoTagger and the Target GeoEvent Definition to Trip_Info_Reduced_Exit. GeoTags will be mapped to wellpad, $RECEIVED_TIME will be mapped to wellpad_endtime, and unique_id will be left blank:
e. Connect the GeoTagger Processor back to the Filter, Publish, and start the GeoEvent Service
9. Make a copy of the Trip_Info GeoEvent Definition
10. Make a copy of the Trip_Info_OBJECTID GeoEvent Definition
11. Create a Poll an ArcGIS Server for Features input
This input will be used to see when a location has a start time and end time recorded
12. Create a copy of the Trip Info Update Output and rename it to Trip Info Update Visited Output. Set the Unique Feature Identifier Field to objectid:
Start the Trip Info Update Visited Output service.
13. Create a new GeoEvent Service called Trip Info Visited
c. Add another Filter and set this to when the visited field is NULL
d. Add a Field Mapper Processor:
Source GeoEvent Definition: Trip_Info_OBJECTID
Target GeoEvent Definition: Trip_Info_OBJECTID_Reduced
Map objected, vin, and unique_id fields
e. Add a Field Calculator Processor
Expression: unique_id + ‘ - Visited’
Target Field: Existing Field
Existing Field Name: unique_id
This Field Calculator will update the unique_id field so GeoEvent can accurately record if the same vehicle visits the same well pad multiple times.
f. Add another Field Calculator Processor
Expression: ‘Yes’
Target Field: Existing Field
Existing Field Name: visited
This field will allow the GeoEvent Service to only update rows that have not been visited, instead of updating any row that has a wellpad_endtime. If you recall, we created a filter early to only process events that have a NULL value for the visited field.
g. Add the Trip Info Updated Visited Output
Here is an example of how the data will appear in the Trip Info feature service:
The wellpad_totaltime field can now be calculated to show the total time a vehicle has spent at a well pad. You can easily perform the calculation using ArcGIS Pro’s Field Calculator.
1. Select all records that contain Yes for the visited field
2. Execute the Field Calculator on the wellpad_totaltime field:
Expression Type: Arcade
Expression:
var startDate = Date($feature.wellpad_starttime);
var endDate = Date($feature.wellpad_endtime);
var totalTime = DateDiff(endDate, startDate, 'minutes');
return totalTime;
Result:
Jake, thank you for showing this geoevent configuration. I've been trying to figure out a way to show this using Tracker Tracks within a geofence but to add to this would be sending 1 email if a field worker using Tracker stays within the geofence for 30 minutes (which in my case would be a danger zone) and then send only 1 email after the 30 minute time limit? I've tried several incident detectors and filter scenarios (which didn't work) and what I currently have configured is using the event controller (with the trip info input from this blog) but I don't know if that's exactly what I need. Any ideas?
@CatherineKoerber This is what I think would work:
Thank you!
I have question,
If the car entered the geofence area at 1:00PM and I want to fire an event (email,sms,etc) if it will stay more than 10m. The Car stopped there are no more event are coming to check the status of the car. However I want fire an event after 10 minute not per receiving a location from the car. And I also don't want to save the car location any where, the location will be save in cache when car enter the geofence and every thing will be deleted after hi exit the geofence.
Any help how to do so
@Moi_Nccncc take a look at the Track Idle Detector. This may provide a solution for you.
I am working on a similar need only in Velocity and I just wanted to say thank you for that Link. That's a great very detailed posting.