public void CalculateHeat() { if (HeatMap == null || HeatMap.GetLength(0) != SoilMap.GetLength(0) || HeatMap.GetLength(1) != SoilMap.GetLength(1)) { HeatMap = new float[SoilMap.GetLength(0), SoilMap.GetLength(1)]; } switch (Type) { case HeatTypes.SoilDepth: CalculateSoilDepth(); break; case HeatTypes.WaterDepth: CalculateWaterDepth(); break; case HeatTypes.SoilHumidity: CalculateSoilHumidity(); break; case HeatTypes.Inclination: CalculateInclination(); break; } }
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); }
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 void EndGame() { //screenManager.Toggle_RetryMenu(true); GameActive = false; Collectibles.Clear(); if (score > highscore) { highscore = score; //highScore.text = "New High\nScore:\n" + highscore.ToString(); //currScoreRetry.enabled = false; } else { //highScore.text = "High\nScore:\n" + highscore.ToString(); //currScoreRetry.enabled = true; //currScoreRetry.text = "current score: " + score.ToString(); } //Connecting to AWS servers to feed data HeatMap sessionData = new HeatMap { ID = System.Guid.NewGuid().ToString(), User = PlayerPrefs.GetString("User"), Time = System.DateTime.UtcNow.ToString(), GameType = "Abstract", Spawned = SpawnedArray, Collect = CollectArray, }; AWSMan aws = new AWSMan(); aws.CreateItem(sessionData); }
public void DrawMapInEditor() { textureData.ApplyToMaterial(terrainMaterial); textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight); HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero); HeatMap heatMap = HeatMapGenerator.GenerateHeatMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMapSettings, Vector2.zero); TreeMap treeMap = TreeMapGenerator.generateVegetationMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMap, treeMapSettings, Vector2.zero); DestroyTrees(); //temporary fix if (drawMode == DrawMode.HeightMap) { DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap)); } else if (drawMode == DrawMode.Mesh) { DrawMesh(MeshGenerator.GenerateTerrainMesh2(heightMap.values, meshSettings, editorPreviewLOD, heatMap.values)); DrawTrees(heightMap.values, meshSettings, treeMap.values); } else if (drawMode == DrawMode.FalloffMap) { DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1))); } else if (drawMode == DrawMode.HeatMap) { DrawTexture(TextureGenerator.TextureColorizedFromHeatMap(heatMap)); } else if (drawMode == DrawMode.TreeMap) { DrawTexture(TextureGenerator.TextureFromTreeMap(treeMap)); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); // HeatMap class values HeatMap myTarget = (HeatMap)target; EditorGUILayout.Separator(); // Button Controls if (GUILayout.Button(myTarget.GridCreated() ? "Reload" : "Build")) { myTarget.ReloadGrid(); } if (GUILayout.Button("Clear")) { myTarget.ClearGrid(); } EditorGUILayout.Separator(); // Type & Scale HeatMap.HeatmapSHOW current_type = myTarget.type; myTarget.SetType((HeatMap.HeatmapSHOW)EditorGUILayout.EnumPopup("Type", current_type)); myTarget.UpdateYScale(EditorGUILayout.FloatField("Y Scale", myTarget.y_scale)); EditorGUILayout.Separator(); // Normalize myTarget.ToggleNormalized(GUILayout.Toggle(current = myTarget.normalized, "Normalize")); EditorGUILayout.Separator(); // Hide Empty myTarget.ToggleHideEmpty(GUILayout.Toggle(current = myTarget.hide_empty, "Hide Empty")); EditorGUILayout.Separator(); // Data info GUILayout.Label("Total Entries: " + myTarget.entries_count); GUILayout.Label("Max Speed: " + myTarget.max_speed); GUILayout.Label("Max Entries per cell: " + myTarget.max_entries_per_grid); GUILayout.Label("Max Average Speed per cell: " + myTarget.max_average_speed); }
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)); } }
void UpdateHeatMap() { float boost = _slider.Value; _imageView.Image = HeatMap.HeatMapForMapView(_mapView, boost, _locations, _weights); UIView.Animate(0.2, () => _imageView.Alpha = 1, () => _imageView.Hidden = false); }
private void POnMouseEnter(object sender, MouseEventArgs mouseEventArgs) { var path = (Path)sender; path.Opacity = .8; var land = Lands.Values.FirstOrDefault(x => x.Shape == sender); if (land == null) { return; } double value; if (!HeatMap.TryGetValue(land.Id, out value)) { return; } GeoMapTooltip.Visibility = Visibility.Visible; GeoMapTooltip.GeoData = new GeoData { Name = land.Name, Value = value }; }
public async Task <IActionResult> Post(int?id, [FromBody] HeatMapDto heatMap) { if (id == null || id <= 0) { return(NotFound()); } if (ModelState.IsValid) { Project projectToUpdate = await context.Projects .SingleOrDefaultAsync(p => p.ProjectId == id); if (projectToUpdate == null) { return(NotFound()); } HeatMap heatMapToInsert = mapper.Map <HeatMap>(heatMap); context.HeatMaps.Add(heatMapToInsert); projectToUpdate.DateUpdated = DateTime.Now; await context.SaveChangesAsync(); return(Ok(mapper.Map <HeatMapDto>(heatMapToInsert))); } return(BadRequest(ModelState)); }
private void Button1_Click(object sender, EventArgs e) { var width = pictureBox1.Width; var height = pictureBox1.Height; var hp = new HeatMap(width, height); pictureBox1.Image = hp.MapGenerate(pictureBox1, HeatPoints); }
private void updatePositionProbability(int x, int y) { if (x < ((HeatMap.GetLength(0) - 1) / 2) && y < ((HeatMap.GetLength(1) - 1) / 2)) { HeatMap[x + ((HeatMap.GetLength(0) - 1) / 2), y + ((HeatMap.GetLength(1) - 1) / 2)]++; IterationCount++; } }
private void Awake() { agentRef = FindObjectOfType <BilliardAgent>(); gameSystemRef = FindObjectOfType <BilliardGameSystem>(); heatmapRef = FindObjectOfType <HeatMap>(); trainerRef = FindObjectOfType <TrainerMimic>(); agentDecisionRef = agentRef.GetComponent <DecisionMAES>(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Color c = HeatMap.ColorFromTemperature(5); Console.WriteLine(c); }
public void IntVector2AddLinearGradientEightWay() { var map = new HeatMap(); map.AddLinearGradientEightWay(new IntVector2(0, 0), 10, 10, -1); map.AddLinearGradientEightWay(new IntVector2(1, 1), 2, 2, -1); Assert.AreEqual(11, map[0, 0]); Assert.AreEqual(11, map[1, 1]); Assert.AreEqual(0, map[99, 99]); }
public void CreateItem(HeatMap map) { Context.SaveAsync(map, (result) => { if (result.Exception != null) { resultText.text += result.Exception.Message; return; } }); }
public Playground() { initInputs(); initDatasets(); this.heatMap = new HeatMap(DENSITY, xDomain, xDomain); this.lineChart = new Linechart(256, 128); generateData(); reset(); }
void ShowMatrix(float[][] M) { double[][] m = MathUtil.NewMatrix(M.Length, M[0].Length); for (int row = 0; row < M.Length; row++) { Array.Copy(M[row], m[row], M[0].Length); } var nt = NumberTable.CreateFromMatrix(m); var hm = new HeatMap(nt); Root.FormMgr.ShowForm(hm); }
public static IEnumerable <VectorTile> ToVectorTiles(this HeatMap tree, uint minZoom, uint maxZoom, ToResolution?toResolution = null) { for (var z = minZoom; z <= maxZoom; z++) { var resolution = toResolution?.Invoke(z) ?? 256; foreach (var tile in tree.EnumerateTilesAt(z)) { yield return(tree.GetVectorTile(tile, resolution)); } } }
public List <HeatMapRegion> LoadHeatMapRegionsToTestWorkspace(string testWorkspaceName) { List <HeatMapRegion> heatMapRegions = new List <HeatMapRegion>(); string workspaceResultsPath = GetWorkspaceRandomExplorationResultsPath(testWorkspaceName); string heatMapRegionsFilePath = workspaceResultsPath + RandomExplorationRun.heatMapRegionsFileName; if (!File.Exists(heatMapRegionsFilePath)) { return(null); } string[] heatMapRegionsFileLines = System.IO.File.ReadAllLines(heatMapRegionsFilePath); MatchCollection wordMatches = Regex.Matches(heatMapRegionsFileLines[0], @"[^,]+"); if (wordMatches.Count != (6 + 3 * 5)) { return(null); } string[] objectiveFunctionsName = new string[5]; for (int i = 0; i < 5; ++i) { objectiveFunctionsName[i] = wordMatches[6 + i * 3].Value; } HeatMap heatMap = new HeatMap(); for (int l = 1; l < heatMapRegionsFileLines.Count(); ++l) { MatchCollection valueMatches = Regex.Matches(heatMapRegionsFileLines[l], @"[^,]+"); if (valueMatches.Count != (6 + 3 * 5)) { return(null); } for (int i = 0; i < 5; ++i) { HeatMapRegion heatMapRegion = new HeatMapRegion(); heatMapRegion.indexX = Int16.Parse(valueMatches[0].Value); heatMapRegion.indexY = Int16.Parse(valueMatches[1].Value); heatMapRegion.xStart = float.Parse(valueMatches[2].Value); heatMapRegion.xEnd = float.Parse(valueMatches[3].Value); heatMapRegion.yStart = float.Parse(valueMatches[4].Value); heatMapRegion.yEnd = float.Parse(valueMatches[5].Value); heatMapRegion.requirementName = objectiveFunctionsName[i]; HeatMapPoint heatMapPoint = new HeatMapPoint(); heatMapPoint.objectiveFunctionValues[heatMapRegion.requirementName] = float.Parse(valueMatches[6 + i * 3].Value); heatMapPoint.x = float.Parse(valueMatches[7 + i * 3].Value); heatMapPoint.y = float.Parse(valueMatches[8 + i * 3].Value); heatMapRegion.worstCasePointFromRandomExploration = heatMapPoint; heatMapRegion.objectiveFunctionAverageValue = heatMapPoint.objectiveFunctionValues[heatMapRegion.requirementName]; heatMapRegions.Add(heatMapRegion); } } return(heatMapRegions); }
private void Awake() { agentRef = FindObjectOfType <BilliardAgent>(); gameSystemRef = FindObjectOfType <BilliardGameSystem>(); heatmapRef = FindObjectOfType <HeatMap>(); trainerRef = FindObjectOfType <TrainerMimic>(); agentDecisionRef = agentRef.GetComponent <DecisionMAES>(); if (agentDecisionRef && agentDecisionRef.GetComponent <ESOptimizer>()) { defaultMAESInitStep = agentDecisionRef.GetComponent <ESOptimizer>().initialStepSize; } }
private void NormalizeResult() { if (HeatMap != null) { for (int l = 0; l < HeatMap.GetLength(0); l++) { for (int r = 0; r < HeatMap.GetLength(1); r++) { HeatMap[l, r] = HeatMap[l, r] / IterationCount; } } } }
// Use this for initialization void Start() { // singleton-ish instance = this; // initialization colors = new Color[resolution, resolution]; texture = new Texture2D(resolution, resolution); GetComponent <Renderer>().material.mainTexture = texture; // start update loop StartCoroutine(UpdateFloor()); }
// Use this for initialization protected virtual void Start() { this.gun = new BasicGun(this); controller = new BillController(this); leftOrRight = 0; health = 3; billHealth = GameObject.Find("BillHealth").GetComponent <GUIText>(); if (godMode) { health = 1000; } startingHeight = renderer.bounds.size.y; startingWidth = renderer.bounds.size.x; if (Application.loadedLevelName == "Level_2") { leftBoundary = 0.8f; rightBoundary = 0.8f; } Respawn(); if (Application.loadedLevelName == "Level_1") { heatmap = GetComponent <HeatMap> (); string p_string = "Contra Bill Progresssion Level 1"; string d_string = "Contra Bill Death Level 1"; progressionTag = new HeatTag("p_string", url); progressionTag.SetSorted(); progressionTag.MapPointColorDelta = ProgressionMapColorDelta; deathTag = new HeatTag("d_string", url); deathTag.Type = HeatTag.HeatType.POINT; if (TrackPlayer) { heatmap.TrackPlayer(this.gameObject, progressionTag, 0.2f); } if (ShowHeatMap) { heatmap.PlotData(progressionTag); heatmap.PlotData(deathTag); } } }
void GetHeatmapFromText(string text) { // Debug.Log(text); string[] HeatMaps = text.Split('|'); foreach (var HeatMap in HeatMaps) { string[] entries = HeatMap.Split('\n'); foreach (var entry in entries) { if (entry != "") { i = int.Parse(entry.Substring(1, 1)); if (entry.Substring(4, 1) == ")") { j = int.Parse(entry.Substring(3, 1)); value = float.Parse(entry.Substring(6)); } else { j = int.Parse(entry.Substring(3, 2)); value = float.Parse(entry.Substring(7)); } heatMapArray[i, j] += value; } } } for (int i = 0; i < heatMapArray.GetLength(0); i++) { for (int j = 0; j < heatMapArray.GetLength(1); j++) { if (highest < heatMapArray[i, j]) { highest = heatMapArray[i, j]; } } } for (int i = 0; i < heatMapArray.GetLength(0); i++) { for (int j = 0; j < heatMapArray.GetLength(1); j++) { heatMapArray[i, j] = heatMapArray[i, j] / highest; } } control.instance.overAllHeatMap = heatMapArray; }
private void DisplayHeatMap() { if (HeatMap != null) { Console.WriteLine("{0}x{1}", HeatMap.GetLength(0), HeatMap.GetLength(1)); Console.WriteLine(""); for (int l = 0; l < HeatMap.GetLength(0); l++) { for (int r = HeatMap.GetLength(1) - 1; r >= 0; r--) { Console.Write("(" + HeatMap[l, r].ToString() + ") "); } Console.WriteLine(""); } } }
public static Texture2D TextureFromHeatMap(HeatMap heatMap) { int width = heatMap.values.GetLength(0); int height = heatMap.values.GetLength(1); Color[] colourMap = new Color[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { colourMap[y * width + x] = Color.Lerp(Color.black, Color.white, Mathf.InverseLerp(heatMap.minValue, heatMap.maxValue, heatMap.values[x, y])); } } return(TextureFromColourMap(colourMap, width, height)); }
public IActionResult HeatMap() { ViewData["Title"] = "HeatMap"; ViewData["Message"] = "HeatMap en desarrollo... v.100"; Data pruebaBBDD = new Data(); DataTable myData = pruebaBBDD.selectQuery("SELECT bssid, lat, lon, signal_rssi FROM SeenAp"); HeatMap customHeatMap = new HeatMap(); foreach (DataRow row in myData.Rows) { customHeatMap.seenAPs.Add(new AccessPoint(row["bssid"].ToString(), row["lat"].ToString(), row["lon"].ToString(), row["signal_rssi"].ToString())); } return(View(customHeatMap)); }
public static IEnumerable <(int x, int y, uint value)> GetValues(this HeatMap heatMap, ulong tileId, uint resolution = 256) { var(xTile, yTile, scaledResolution) = heatMap.GetTilePosition(tileId); if (scaledResolution < resolution) { throw new NotSupportedException("Upscaling of heatmap not supported."); } if (scaledResolution > resolution) { var factor = scaledResolution / resolution; for (var x = 0; x < resolution; x++) { for (var y = 0; y < resolution; y++) { var xScaled = x * factor; var yScaled = y * factor; var count = 0U; for (var dx = 0; dx < factor; dx++) { for (var dy = 0; dy < factor; dy++) { count += heatMap[xTile + xScaled + dx, yTile + yScaled + dy]; } } if (count != 0) { yield return(x, y, count); } } } } for (var x = 0; x < resolution; x++) { for (var y = 0; y < resolution; y++) { var count = heatMap[xTile + x, yTile + y]; if (count != 0) { yield return(x, y, count); } } } }
public HeatMap LoadHeatMapDiagramToTestWorkspace(string testWorkspaceName) { string workspaceResultsPath = GetWorkspaceRandomExplorationResultsPath(testWorkspaceName); string heatMapDiagramsFilePath = workspaceResultsPath + RandomExplorationRun.heatMapDiagramsFileName; if (!File.Exists(heatMapDiagramsFilePath)) { return(null); } string[] heatMapDiagramsFileLines = System.IO.File.ReadAllLines(heatMapDiagramsFilePath); MatchCollection wordMatches = Regex.Matches(heatMapDiagramsFileLines[0], @"[^,]+"); if (wordMatches.Count != (4 + 5)) { return(null); } string[] objectiveFunctionsName = new string[5]; for (int i = 0; i < 5; ++i) { objectiveFunctionsName[i] = wordMatches[i + 4].Value; } HeatMap heatMap = new HeatMap(); for (int l = 1; l < heatMapDiagramsFileLines.Count(); ++l) { MatchCollection valueMatches = Regex.Matches(heatMapDiagramsFileLines[l], @"[^,]+"); if (valueMatches.Count != (4 + 5)) { return(null); } HeatMapPoint heatMapPoint = new HeatMapPoint(); heatMapPoint.indexX = Int16.Parse(valueMatches[0].Value); heatMapPoint.indexY = Int16.Parse(valueMatches[1].Value); heatMapPoint.x = float.Parse(valueMatches[2].Value); heatMapPoint.y = float.Parse(valueMatches[3].Value); for (int i = 4; i < valueMatches.Count; ++i) { heatMapPoint.objectiveFunctionValues.Add(objectiveFunctionsName[i - 4], float.Parse(valueMatches[i].Value)); } heatMap.AddPoint(heatMapPoint); } heatMap.FinalizeAddingPoints(); return(heatMap); }