Select to view content in your preferred language

Behavior of StreamLayer.purgeOptions.ageReceived Option

682
2
Jump to solution
04-07-2023 01:58 PM
lawsonkendall
Occasional Contributor

Documentation on the StreamLayer.html.purgeOptions "ageReceived" option only says, "Specifies the maximum age of a feature in minutes since it arrived in the application. The features older than specified ageReceived will be removed."

Some layers which I subscribe to have a START attribute which gets updated when the feature being tracked gets updated.  Currently I'm using that attribute to  change the feature icon to grey when START is some delta from time now (x seconds).  That seems to be working well.  I have a second requirement to remove the feature from the map entirely when there has been no update for another interval (y minutes).

 

I initially assumed I could use the ageReceived option to direct the server to purge the features when there had been no updates for y minutes, but I am less confident of that the more I think about it.  Maybe the server just counts the time from initial observation?  If I'm receiving fresh observations on the feature all day long, I never want it to disappear.  Maybe I'm going to have to keep track of features from within my client app and just remove them (or make them invisible) rather than trying to delegate it to the StreamServer.

 

I wish there was better documentation of that ageReceived option (and maybe the age option as well).  

  • How is ageReceived calculated, and does it update as the feature is updated?  
  • Is that integer minutes?  
    • Could I pass "1.5" and expect features to be purged after 90 seconds.  (I'm guessing that float-type values either get rounded or, more likely, truncated, but I can wish...)

Thanks, in advance, for your thoughts.

 

(As an aside, it would be nice if there were some automated way to test the behavior of the ageReceived option, but I realize this is probably impossible, especially in a unit test where map resources (Maps, Layers, Features, etc.) are always statically mocked.)

 

1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

So the purge takes place on the client-side. The ageReceived does exactly what it says. The client timestamps features as they arrive in the browser and they are cleared after it exceeds the ageReceived time. You can set the ageReceived to be seconds... For example if you set it to 0.1, features will be cleared out once their received age exceeds 6 seconds.

Sounds like you have StreamLayer.timeInfo.startField. If you do then you can set the purgeOptions.age instead. In this case, the client will purge features that exceed the given `age` (in minutes) where `age` refers to the age of the underlying feature (decided by timeInfo.startField).

Setting different parameters on purgeOptions can get confusing as they all take effect. I setup this codepen for you to test the purgeOptions.

1. New features are pushed every second (set parameter) and features are cleared every two seconds since the feature was added on the map (received paramter) and 8 observations are visible at a time(ma parameter): https://codepen.io/U_B_U/pen/ExdPpdy?editors=1000&received=0.03&set=1000&max=8

You can modify the url query params to see different behaviors. I added comments where description was added. Hope this helps.

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

So the purge takes place on the client-side. The ageReceived does exactly what it says. The client timestamps features as they arrive in the browser and they are cleared after it exceeds the ageReceived time. You can set the ageReceived to be seconds... For example if you set it to 0.1, features will be cleared out once their received age exceeds 6 seconds.

Sounds like you have StreamLayer.timeInfo.startField. If you do then you can set the purgeOptions.age instead. In this case, the client will purge features that exceed the given `age` (in minutes) where `age` refers to the age of the underlying feature (decided by timeInfo.startField).

Setting different parameters on purgeOptions can get confusing as they all take effect. I setup this codepen for you to test the purgeOptions.

1. New features are pushed every second (set parameter) and features are cleared every two seconds since the feature was added on the map (received paramter) and 8 observations are visible at a time(ma parameter): https://codepen.io/U_B_U/pen/ExdPpdy?editors=1000&received=0.03&set=1000&max=8

You can modify the url query params to see different behaviors. I added comments where description was added. Hope this helps.

lawsonkendall
Occasional Contributor

That Codepen is beautiful.  Thank you for this great answer!  This helps a lot.

0 Kudos