mapsense / mapsense.js

Mapsense.js
Other
88 stars 22 forks source link

make the fetch function aware of the tile coordinates #20

Closed sttawm closed 9 years ago

sttawm commented 9 years ago

It can be useful for transcoders (AKA the "fetch" function) to be aware of the tile's coordinates. Though they are generally available via the url, this is not standardized and is annoying to parse.

The current use-case is binning. Binning involves quantizing a tile, which (in general) requires knowledge of its bounds. Servers may occassionall provide responses with enough information (i.e. via topojson.q), but in general this cannot be assumed.

The implementation uses the setTile() function of the fetch function if it is available (my limited understanding of javascript is that concurrency is not an issue).

Proposed documentation:

If the fetch function provides a setTile method, it will be invoked with the tile prior to invoking the fetch function. The value passed to setTile should be assumed to be valid only during the subsequent execution of the fetch. That is, the supplied tile should not accessed at a later point in time, most notably in callback functions. The supplied tile should not be modified.

I see-sawed between using a setTile method just adding a parameter. The benefit of the function is that layers extending GeoJson need not worry about correctly passing along arguments. The expense is that it's more complicated to use and easier to misuse. Thoughts?