Example #1
0
        internal static VectorTile GetVectorTile(this HeatMap heatMap, ulong tileId, uint resolution)
        {
            var tile = new Tile(tileId);
            var tgt  = new TileGeometryTransform(tile, resolution);

            var vectorTile = new VectorTile()
            {
                TileId = tileId,
                Layers = { new Layer()
                           {
                               Name = "heatmap"
                           } }
            };

            foreach (var(x, y, value) in heatMap.GetValues(tileId, resolution))
            {
                if (value == 0)
                {
                    continue;
                }

                var coordinate = tgt.TransformTo(x, y);
                vectorTile.Layers[0].Features.Add(new Feature(
                                                      new Point(new Coordinate(coordinate.longitude, coordinate.latitude)),
                                                      new AttributesTable {
                    { "cost", value }
                }));
            }

            return(vectorTile);
        }