geojs icon indicating copy to clipboard operation
geojs copied to clipboard

Provide an API to update the data array stored in a feature

Open bkj opened this issue 9 years ago • 6 comments

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.)

bkj avatar Jun 26 '15 03:06 bkj

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.

manthey avatar Jun 26 '15 12:06 manthey

@bkj +1 for creating this issue. I agree with @manthey. Will see if if we can provide a general API. Any ideas are welcome.

aashish24 avatar Jun 26 '15 12:06 aashish24

@bkj let us know if you need any help. Any contribution is welcome as well.

aashish24 avatar Jul 02 '15 12:07 aashish24

Great thanks everyone!

bkj avatar Jul 09 '15 02:07 bkj

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 avatar Jun 28 '16 14:06 manthey

@manthey +1. I guess we will the following cases:

  1. Size has changed --> discard and create a new one
  2. First and last value changed --> update but don't create a new one
  3. Continuous change --> update but don't create a new one
  4. Sparse change (same as 2 and 3)

aashish24 avatar Jun 29 '16 15:06 aashish24