public GeoMapData Dump() { #if DEBUG var uncoveredSuburbs = new Dictionary <Suburb, GeoPoint>(); #endif var dumpSuburbs = new Dictionary <Suburb, List <GeoIndex> >(); for (var i = 0; i < indexes.LatitudeIntervalCount; i++) { for (var j = 0; j < indexes.LongitudeIntervalCount; j++) { if (suburbs[i][j] == null) { continue; } foreach (var suburb in suburbs[i][j]) { if (string.IsNullOrEmpty(suburb.Postcode)) { #if DEBUG uncoveredSuburbs[suburb] = indexes.GetGeoPoint(new GeoIndex(i, j)); #endif continue; } if (!dumpSuburbs.ContainsKey(suburb)) { dumpSuburbs[suburb] = new List <GeoIndex>(); } dumpSuburbs[suburb].Add(new GeoIndex(i, j)); } } } #if DEBUG using var sw = new StreamWriter("uncovered-suburbs.txt"); foreach (var(key, value) in uncoveredSuburbs) { sw.WriteLine($"{key}\t{value}"); } #endif return(new GeoMapData { GeoIndexes = indexes.Dump(), ResolutionInMetres = resolution.AsMetres, Suburbs = dumpSuburbs.Select(kv => new SuburbGeoIndexes { Suburb = kv.Key, IndexRanges = ToRanges(kv.Value).Select(x => x.ToArray()).ToList() }).ToList() }); }
public void TestCreateFromGeoIndexesData() { var data = new GeoIndexesData { LatitudeInterval = 1.0, LongitudeInterval = 2.0, LatitudeIntervalCount = 1, LongitudeIntervalCount = 2, SouthWest = new GeoPoint(3, 4) }; var indexes = new GeoIndexes(data); Assert.AreEqual(JsonConvert.SerializeObject(data), JsonConvert.SerializeObject(indexes.Dump())); }