static FeatureCollection WriteState(State state, string shpFile) { var stateJsonPath = Path.Combine(DataLocations.TempPath, $"{state}.geojson"); MapToGeoJson.ConvertShape(stateJsonPath, shpFile); var stateCollection = JsonSerializer.Deserialize <FeatureCollection>(stateJsonPath); MetadataCleaner.CleanMetadata(stateCollection, state); return(stateCollection); }
static void WriteOptimised(string directory) { var jsonPath = Path.Combine(directory, "australia.geojson"); var raw = JsonSerializer.DeserializeGeo(jsonPath); raw.FixBoundingBox(); foreach (var percent in percents) { var percentJsonPath = Path.Combine(directory, $"australia_{percent:D2}.geojson"); MapToGeoJson.ConvertShape(percentJsonPath, jsonPath, percent); var featureCollection = JsonSerializer.DeserializeGeo(percentJsonPath); featureCollection.FixBoundingBox(); JsonSerializer.SerializeGeo(featureCollection, percentJsonPath); } }
static async Task GetCountry(int year, string url, string mapsPath) { var zip = Path.Combine(DataLocations.TempPath, year + ".zip"); await Downloader.DownloadFile(zip, url); var targetPath = Path.Combine(mapsPath, "australia.geojson"); var extractDirectory = Path.Combine(DataLocations.TempPath, $"australia{year}_extract"); ZipFile.ExtractToDirectory(zip, extractDirectory); MapToGeoJson.ConvertTab(targetPath, Path.Combine(extractDirectory, "COM_ELB.tab")); var featureCollection = JsonSerializer.Deserialize <FeatureCollection>(targetPath); featureCollection.FixBoundingBox(); MetadataCleaner.CleanMetadata(featureCollection); JsonSerializer.SerializeGeo(featureCollection, targetPath); }