private void computeClusters(int nb) { FileReader filereader = new FileReader("Data/data.txt"); double[][] rawData = filereader.readfromtextfile(); kmeans = new KMeansClustering(nb, rawData); List<List<double[]>> clusters = kmeans.getCalculatedClusters(); System.Diagnostics.Debug.WriteLine(kmeans.displayResult()); Microsoft.Phone.Maps.Controls.MapLayer points = new Microsoft.Phone.Maps.Controls.MapLayer(); System.Windows.Media.Color[] colors = new System.Windows.Media.Color[10]; colors[0] = System.Windows.Media.Colors.Blue; colors[1] = System.Windows.Media.Colors.Red; colors[2] = System.Windows.Media.Colors.Green; colors[3] = System.Windows.Media.Colors.Yellow; colors[4] = System.Windows.Media.Colors.Purple; colors[5] = System.Windows.Media.Colors.Orange; colors[6] = System.Windows.Media.Colors.Cyan; colors[7] = System.Windows.Media.Colors.DarkGray; colors[8] = System.Windows.Media.Colors.Magenta; colors[9] = System.Windows.Media.Colors.White; for (int j = 0; j < clusters.ToArray().Length; j++) { System.Diagnostics.Debug.WriteLine(j); // lire dans chacun des clusters for (int i = 0; i < clusters.ElementAt(j).ToArray().Length; i++) { double[] data = clusters.ElementAt(j).ElementAt(i); Microsoft.Phone.Maps.Controls.MapOverlay pointsdata = new Microsoft.Phone.Maps.Controls.MapOverlay(); System.Windows.Shapes.Ellipse test = new System.Windows.Shapes.Ellipse(); test.Fill = new System.Windows.Media.SolidColorBrush(colors[j % 10]); test.Height = 6; test.Width = 6; test.Opacity = 75; pointsdata.Content = test; System.Device.Location.GeoCoordinate coord = new System.Device.Location.GeoCoordinate(data[0], data[1]); pointsdata.GeoCoordinate = coord; points.Add(pointsdata); } } carte.Layers.Clear(); carte.Layers.Add(points); }
private Microsoft.Phone.Maps.Controls.LocationRectangle getBoundingCoord() { double minX, maxX, minY, maxY; FileReader filereader = new FileReader("Data/data.txt"); double[][] data = filereader.readfromtextfile(); minX = data[0][0]; maxX = data[0][0]; minY = data[0][1]; maxY = data[0][1]; for (int i = 1; i < data.Length; i++) { if (minX > data[i][0]) { minX = data[i][0]; } if (maxX < data[i][0]) { maxX = data[i][0]; } if (minY > data[i][1]) { minY = data[i][1]; } if (maxY < data[i][1]) { maxY = data[i][1]; } } System.Diagnostics.Debug.WriteLine("[" + minX + " ; " + minY + "]" + "[" + maxX + " ; " + maxY + "]"); return new Microsoft.Phone.Maps.Controls.LocationRectangle(maxX, minY, minX, maxY); }