public void CreatePoints(CoordinatePair[] polygon, int[] featureValues) { if (featureValues.Length != features.Length) throw new ArgumentException("featureValues"); var bounds = getBounds(polygon); int total = featureValues.Sum(); Console.WriteLine("Total dots: {0}", total); for (int k=0;k<features.Length;k++) { for (int i = 0; i < featureValues[k]; i++) { if (i % 10000 == 0) Console.Write("."); CoordinatePair point = null; while (true) { point = new CoordinatePair() { X = createRandomValue(bounds[0], bounds[2]), Y = createRandomValue(bounds[1], bounds[3]) }; if (Utils.IsPointInPolygon(polygon, point)) break; } var mPoint = merc.LatLonToMeters(point.Y, point.X); var tileAddress = merc.MetersToTile(mPoint.X, mPoint.Y, 21); var quadkey = merc.QuadTree(tileAddress.X, tileAddress.Y, 21); var person = new Person() { Pos = mPoint, FeatureIndex = k }; people.Add(Tuple.Create(quadkey, person)); } } Console.WriteLine(""); }
public void ReadPoints(string filename) { using (StreamReader file = File.OpenText(filename)) { while (!file.EndOfStream) { string line = file.ReadLine(); var tokens = line.Split(','); var person=new Person() { Pos=new CoordinatePair() { X = Convert.ToDouble(tokens[1]), Y = Convert.ToDouble(tokens[2]) }, FeatureIndex=tokens.Length == 3 ? 0 : Convert.ToInt32(tokens[3]) }; people.Add(Tuple.Create(tokens[0],person)); } } }