diff --git a/NEWS b/NEWS index ae5cbca..1ce6554 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ 2.11.1 + - Added getValueForBBox to TorqueLayer's API 2.11.0 - Do not fix values in the edge (#147) diff --git a/doc/API.md b/doc/API.md index 04bbbd5..5166960 100644 --- a/doc/API.md +++ b/doc/API.md @@ -102,6 +102,13 @@ torqueLayer.setSQL("SELECT * FROM table LIMIT 100"); | Method | options | returns | Description | |-----------|:-----------|:----------|:---------------------------------------| | ```getValueForPos(x, y[, step])```| | an object like { bbox:[], value: VALUE } if there is value for the pos, null otherwise | allows to get the value for the coordinate (in map reference system) for a concrete step. If step is not specified the animation one is used. This method is expensive in terms of CPU so be careful. It returns the value from the raster data not the rendered data | +| ```getValueForBBox(xstart, ystart, xend, yend)```| | a number | returns an accumulated numerical value from all the torque areas within the specified bounds | +| ```getActivePointsBBox(step)```| | list of bbox | returns the list of bounding boxes active for ``step`` +| ```invalidate()```| | | forces a reload of the layer data. + +### Interaction methods (only available for Leaflet) +| Method | options | returns | Description | +|-----------|:-----------|:----------|:---------------------------------------| | ```getActivePointsBBox(step)```| | list of bbox | returns the list of bounding boxes active for ``step`` | ```invalidate()```| | | forces a reload of the layer data. diff --git a/examples/data_peek.html b/examples/data_peek.html new file mode 100644 index 0000000..32ce598 --- /dev/null +++ b/examples/data_peek.html @@ -0,0 +1,95 @@ + + + +
+ + + + + + + + + + diff --git a/lib/torque/gmaps/torque.js b/lib/torque/gmaps/torque.js index b49d8aa..a3cd5bd 100644 --- a/lib/torque/gmaps/torque.js +++ b/lib/torque/gmaps/torque.js @@ -297,6 +297,42 @@ GMapsTorqueLayer.prototype = torque.extend({}, this.animator.stop(); this._removeTileLoader(); google.maps.event.removeListener(this._cacheListener); + }, + + getValueForPos: function(x, y, step) { + step = step === undefined ? this.key: step; + var t, tile, pos, value = null, xx, yy; + for(t in this._tiles) { + tile = this._tiles[t]; + pos = this.getTilePos(tile.coord); + xx = x - pos.x; + yy = y - pos.y; + if (xx >= 0 && yy >= 0 && xx < this.renderer.TILE_SIZE && yy <= this.renderer.TILE_SIZE) { + value = this.renderer.getValueFor(tile, step, xx, yy); + } + if (value !== null) { + return value; + } + } + return null; + }, + getValueForBBox: function(x, y, w, h) { + var xf = x + w, yf = y + h; + var sum = 0; + for(_y = y; y