Best method for enrichment based on If/Then...

2565
2
04-23-2014 04:53 AM
Highlighted
Regular Contributor
Sorry for the horrible title,

I am not a programmer to say the least.

I am looking for the best method to put one of three attributes in a field based on the value of 2 other fields.  To understand the context, the field GPSTime gives the GPS device time in seconds calculated from the satellite data stream.  If that value is 0, then the device is not able to calculate position; maybe because the device cannot see the sky.  If the device is unable to calculate position, it is also unable to produce the values to calculate speed, therefore speed does not matter at that point...

If SPEED > 0 AND GPSTimeSec > 0 then STATUS = "Moving"
If SPEED = 0 AND GPSTimeSec > 0 then STATUS = "Stopped"
If GPSTimeSec = 0 then STATUS = "NoGPS"

I am looking to get the STATUS field updated with one of those three values.  What processor should I use and how should I formulate the statement so that GEP understands?  OR, am I barking up the wrong tree?

Thank you,
--Adam

**Edit for additional information**

For the time being, I have just forked the service 3 ways, adding a filter element to each fork - one for each needed value.  After each filter, I added a simple field calculator for each value (ex: Expression: 'NoGPS') and then pulled each back into the end output.

This just doesn't seem like the most efficient way.
2 Replies
Highlighted
Esri Regular Contributor
Hey Adam -

You are spot on.  With what we've exposed, you really don't have a true if/then/else programming construct. You only have filters which will send the event through for processing if the filter's criteria are satisfied. So you can split the event stream to feed three different filters, and as long as the filters' criteria are mutually exclusive, you can feed events falling in different categories to separate Field Calculators to place a status into either an existing field or a new field. Beware that if an event satisfies two or more filters' criteria you will end up duplicating events as the full event stream is independently considered by each filter.

[ATTACH=CONFIG]33282[/ATTACH]

You will want to be careful, if working with non-integer values, to designate a sufficiently small epsilon value that you can test less-than or greater-equal ... don't test equal-to when using non-integer values as a value '0' might be actually 0.000000000013 behind the scenes (which of course would fail if the filter was testing strictly Speed = 0.

Your only other option is to crack open the SDK and develop a custom processor which accepts an event, performs its own custom business logic, and then outputs a new event which has been stamped with an appropriate status. For such simple attribute tests, I'm not convinced that any gain in performance would be worth the development effort.

- RJ
Reply
0 Kudos
Highlighted
Regular Contributor
As always, thank you RJ.  Great explanation.  Solidifies confidence in my solution.

--Adam
Reply
0 Kudos