Example #1
0
        static void Main(string[] args)
        {
            var features = (new GeoJsonReader()).Read <FeatureCollection>(
                File.ReadAllText(@"/data/ANYWAYS Dropbox/data/bike-data-project/test-belgium.geojson"));

            Console.WriteLine("Adding features...");
            var heatmap = new HeatMap(14, 1024);

            foreach (var feature in features)
            {
                heatmap.Add(feature, 1);
            }

            // convert to a vector tile tree.d
            var tree = heatmap.ToVectorTiles(14, 14, i =>
            {
                if (i == 14)
                {
                    return(1024);
                }

                return(256);
            });

            // write the tiles to disk as mvt.
            Console.WriteLine("Writing tiles...");
            tree.Write("tiles");
        }
        public GameStateViewModel([NotNull] States.GameState state, Genes.ActorChromosome brain)
        {
            _state = state ?? throw new ArgumentNullException(nameof(state));

            foreach (var actor in _state.World.Actors.Where(a => a.IsActive))
            {
                Actors.Add(new ActorViewModel(actor));
            }

            var values = new Dictionary <WorldPos.WorldPos, double>();

            for (int y = 1; y <= state.World.MaxY; y++)
            {
                for (int x = 1; x <= state.World.MaxX; x++)
                {
                    var pos = new WorldPos.WorldPos(x, y);
                    values[pos] = Genes.evaluateTile(brain, state.World, pos);
                }
            }

            var min = values.Values.Min();
            var max = values.Values.Max();

            foreach (var(pos, value) in values)
            {
                HeatMap.Add(new HeatMapViewModel(pos, value, min, max));
            }
        }