private string outDescripAnalysis(Sitio s, DescriptiveAnalysis da) { StringBuilder sb = new StringBuilder(); sb.Append(s.name + ","); sb.Append(s.gridPoints.Count + ","); sb.Append(da.Means[0] + ","); sb.Append(da.Medians[0] + ","); sb.Append(da.Modes[0] + ","); sb.Append(da.Ranges[0].Min + ","); sb.Append(da.Ranges[0].Max + ","); return(sb.ToString()); }
private void getSitioData() { boundaries = MapTools.readPolylines(@"C:\Users\Admin\Documents\projects\LostCity\georefObjects\sitios.csv", true); StreamReader sr = new StreamReader(@"C:\Users\Admin\Documents\projects\LostCity\georefObjects\sitioData.csv"); string line = sr.ReadLine(); int rank = 1; while (line != null) { string[] parts = line.Split(','); Sitio s = new Sitio(); s.rank = rank; s.name = parts[0]; s.area = Convert.ToDouble(parts[1]); s.populationL = Convert.ToDouble(parts[2]); s.populationF = Convert.ToDouble(parts[3]); s.boundary = boundaries.Find(x => x.name == s.name); sitios.Add(s); line = sr.ReadLine(); rank++; } sr.Close(); }
private bool makeRandom(Sitio s) { Random r = new Random(); double ele = 1000000; int i = 0; int j = 0; bool pointInUse = true; bool noWater = false; bool wrongSlope = false; if (this.useDistToWater) { noWater = true; } if (this.useSlope) { wrongSlope = true; } while (ele > 1750 || pointInUse || noWater || wrongSlope) { i = r.Next(30, topo.Count - 30); j = r.Next(30, topo.Count - 30); ele = topo[i][j].Z; pointInUse = checkPointUse(i, j); if (this.useDistToWater) { noWater = testDrySite(topo[i][j].Y, topo[i][j].X); } if (this.useSlope) { wrongSlope = testSlope(i, j); } } Sitio newS = new Sitio(); sitiosRandom.Add(newS); newS.gridPoints.Add(new int[] { i, j }); //one less gridpoint as we have a start point int totalpoints = s.gridPoints.Count - 1; int pointsCreated = 0; int growthAttempts = 0; while (pointsCreated < totalpoints) { List <int[]> freeNeighbours = new List <int[]>(); while (freeNeighbours.Count == 0) { //random select one gridpoint int start = r.Next(0, newS.gridPoints.Count); i = newS.gridPoints[start][0]; j = newS.gridPoints[start][1]; freeNeighbours = getFreeNeighbours(i, j); growthAttempts++; if (growthAttempts > 500) { sitiosRandom.Remove(newS); return(false); } } int next = r.Next(0, freeNeighbours.Count); newS.gridPoints.Add(freeNeighbours[next]); pointsCreated++; } indicesForAnalysis.Add(newS.gridPoints); return(true); }