geojs
geojs copied to clipboard
Provide an API to update the data array stored in a feature
Add ability to update geo.featurelayer data without having to call .clear and .createFeature again. That way, it wouldn't have to redraw all of the points that don't change. Application is plotting a streaming path, where the last 1000 points are shown -- at each step we want to remove the first datapoint and append a new one to the end, but we don't want to have to redraw the 999 data points that are the same.
(Apologies if this is already possible -- I'm new to the project and any guidance would be helpful.)
If you are using a vgl rendered layer, you can change the data points (or any of the style parameters) without clearing and creating. This is done in another project that uses geojs to animate points. See https://github.com/XDATA-Year-3/geoapp/blob/master/client/js/layersTaxi.js#L652 . The same technique can be used for point positions.
It would still be nice to make this have an easier interface, as this technique relies on knowing something about the internal memory storage.
@bkj +1 for creating this issue. I agree with @manthey. Will see if if we can provide a general API. Any ideas are welcome.
@bkj let us know if you need any help. Any contribution is welcome as well.
Great thanks everyone!
I have thought of a fairly clean way to do this. It would ideally be implemented per GL feature, and will require a change to vgl.
VGL currently discards and reallocates buffers whenever a feature changes. Rather, we can track when a geomData source or primitive is updated, and then use bufferSubData
with a partial array to update the data. The features in geojs would need to detect when values have altered and indicate that to the source buffer. The update would only need to update the range of values that have changed for each parameter. If the first and last values changed, we would still update all of them (as updating sparse changes is probably too complicated to be worth tracking).
@manthey +1. I guess we will the following cases:
- Size has changed --> discard and create a new one
- First and last value changed --> update but don't create a new one
- Continuous change --> update but don't create a new one
- Sparse change (same as 2 and 3)