tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.22k stars 290 forks source link

make tile available in source transform function #675

Closed meetar closed 6 years ago

meetar commented 6 years ago

This makes per-tile data transformations possible, including debugging data. For example, this creates a polygon at the tile boundaries, named for its source tile:

transform: |
    function(data) {
        t = this.tile;
        c = Tangram.debug.Geo.metersToLatLng;
        min = c([t.min.x, t.min.y]);
        max = c([t.max.x, t.max.y]);
        return {
            type: 'FeatureCollection',
            features: [{
                type: 'Feature',
                geometry: {
                    type: 'Polygon',
                    coordinates: [[
                        [min[0], min[1]], [max[0], min[1]],
                        [max[0], max[1]], [min[0], max[1]],
                        [min[0], min[1]]
                    ]]
                },
                properties: {
                    name: this.tile.coords.key
                }
            }]
        };
    }

Addresses https://github.com/tangrams/tangram/issues/354.

nvkelso commented 6 years ago

name: this.tile.coords.key

👍

bcamper commented 6 years ago

@meetar did you want to follow up on the (relatively small) updates described above?