How to use Geofences?

833
3
Jump to solution
10-15-2022 09:36 AM
JonSwoveland
Occasional Contributor

Hi all, I'm fairly new to GeoEvent Server, and I'm having a heck of a time figuring out how to do something that, at least on the surface, seems like it should be straightforward.

I have two feature classes:  one point feature class representing patrol vehicles, and one polygon feature class representing patrol areas.  The goal is to update the patrol area's LAST_PATROLLED_DATE when a patrol vehicle intersects with it.

So far, I have successfully created a stream service reprenting the vehicles, and imported the patrol areas as GeoFences.  Where I'm stuck is actually using the GeoFences (I'm assuming  GeoFences and a stream service is the recommended approach). 

How does one configure a process to be triggered when a vehicle enters a GeoFenced area?  My hope is the input of this process would include the definitions of both the geofence entered, and the vehicle that entered it.

Update 1:
I"ve figured out I should be using a Filter element wired-up to my GeoFences, however I don't see any way to update the feature corresponding to the intersected GeoFence.  Is there a way to query a feature layer in a GeoEvent Service?

Update 2: 

In addition to the reply below I marked as the solution, I found this community post very helpful.  The input connector used in the post is different, but everything else seems to apply.  

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Jordan
by
New Contributor II

Hi @JonSwoveland,

I have a couple of ideas for you, note I have not actually had to do the 'update feature' bit myself:

  • At the start of your geoevent service, use a GeoTagger Processor to tag the 'entry' of a vehicle into a fence. This will add the fence name to the GeoEvent Definition (we use objectid as the fence names when setting up fences, as we know that will always be unique, but we also have an actual 'fence name' on the fence for display purposes). With the GeoTagger, if the event doesn't enter into any geofences, it will tag as NULL, so the example below shows that you then just put in a simple filter to filter out NULL. The GeoTagger also maintains the state of each TRACK_ID within your feed, so once a TRACK_ID enters a fence, GeoEvent maintains that it is inside, until it exits that fence (you may need to have a separate GeoTagger for "exit" to properly achieve this, if you are going to have fences within fences, see the example below). Here is an awesome blog that explains how the GeoTagger works and how to use it: https://community.esri.com/t5/arcgis-geoevent-server-blog/geoevent-enter-exit-events/ba-p/902134
  • To update your fence, you could try using the GeoEvent Output "Update a Feature". I haven't personally used this, but I'm guessing that as long as you know the objectid of the record to update, you should be able to pass the updated GeoEvent into that. You can use the Field Calculator and "currentTime()" to get the time of entry (or you could try and pull it off the input vehicles timestamp). Then for output, you could use the Field Reducer to remove everything except for the objectid and datetime field.

My thinking is: input vehicle event -> geotagger with fence for enter -> filter to only pass events if the fence is not NULL -> field calculator to get currentTime() -> field reducer to remove everything you don't need -> update a feature with the timestamp.

The main thing I'm not sure about is if the "Update a Feature" output will let you update it with only objectid and timestamp, or if it will also require all the other fields in the schema. If it does, you could use the Field Enricher (Feature Service) to lookup all the additional field details for that specific fence using objectid, then just pass them through unaltered to the output.

Let us know how you get on!

View solution in original post

3 Replies
Jordan
by
New Contributor II

Hi @JonSwoveland,

I have a couple of ideas for you, note I have not actually had to do the 'update feature' bit myself:

  • At the start of your geoevent service, use a GeoTagger Processor to tag the 'entry' of a vehicle into a fence. This will add the fence name to the GeoEvent Definition (we use objectid as the fence names when setting up fences, as we know that will always be unique, but we also have an actual 'fence name' on the fence for display purposes). With the GeoTagger, if the event doesn't enter into any geofences, it will tag as NULL, so the example below shows that you then just put in a simple filter to filter out NULL. The GeoTagger also maintains the state of each TRACK_ID within your feed, so once a TRACK_ID enters a fence, GeoEvent maintains that it is inside, until it exits that fence (you may need to have a separate GeoTagger for "exit" to properly achieve this, if you are going to have fences within fences, see the example below). Here is an awesome blog that explains how the GeoTagger works and how to use it: https://community.esri.com/t5/arcgis-geoevent-server-blog/geoevent-enter-exit-events/ba-p/902134
  • To update your fence, you could try using the GeoEvent Output "Update a Feature". I haven't personally used this, but I'm guessing that as long as you know the objectid of the record to update, you should be able to pass the updated GeoEvent into that. You can use the Field Calculator and "currentTime()" to get the time of entry (or you could try and pull it off the input vehicles timestamp). Then for output, you could use the Field Reducer to remove everything except for the objectid and datetime field.

My thinking is: input vehicle event -> geotagger with fence for enter -> filter to only pass events if the fence is not NULL -> field calculator to get currentTime() -> field reducer to remove everything you don't need -> update a feature with the timestamp.

The main thing I'm not sure about is if the "Update a Feature" output will let you update it with only objectid and timestamp, or if it will also require all the other fields in the schema. If it does, you could use the Field Enricher (Feature Service) to lookup all the additional field details for that specific fence using objectid, then just pass them through unaltered to the output.

Let us know how you get on!

JonSwoveland
Occasional Contributor

Thanks Jordan! 

You were right on the money with the GeoTagger suggestion.  I've got a simple service working by distilling the process shown in this post.  My plan is to update the service so a patrol area is only marked as patrolled when a vehicle is within it for a certain length of time (which is exactly what the post I linked explains how to do).

0 Kudos
JonSwoveland
Occasional Contributor

One more thing...

The GeoEvent Service model is as follows:

  1. patrolcar-input (Polls feature service) ->
  2. GeoTagger  (this performs the geofence detection & filtering)  ->
  3. Field Mapper (Populates a GeoEvent Definition from the preceeding)
  4. Update Feature Output Connector (using the GeoEvent Definition from #3)