/// <summary> /// Changes vector shapefiles into GeoJSON-formatted JSON objects, and csv files of the data in their attribute tables /// </summary> /// <param name="args"></param> /// <param name="colorRepo"></param> /// <param name="extension"></param> /// <param name="di"></param> /// <param name="resultDir"></param> /// <remarks>See http://nettopologysuite.googlecode.com/svn/branches/v2.0/NetTopologySuite.Samples.Console/SimpleTests/Attributes/AttributesTest.cs </remarks> private static Tuple<List<string>, List<string>> ProcessVectorFiles(string[] args, IColorRepository colorRepo, LegendRepository legend, string extension, DirectoryInfo di, DirectoryInfo resultDir, List<string> processedDatasets) { List<string> skipped = new List<string>(); foreach (FileInfo fi in FilesInDirectoryWithExtension(extension, di)) { if (colorRepo.HasColorMappingOfFile(fi.Name)) { foreach (string resultName in colorRepo.ResultFileName(fi.Name)) { if (!processedDatasets.Contains(resultName)) { ProcessVectorFile(colorRepo, resultDir, fi, resultName); legend.Add(resultName, colorRepo.FileLegend(fi.Name, resultName)); processedDatasets.Add(resultName); } } } else { skipped.Add(fi.Name); } } return new Tuple<List<string>, List<string>>(processedDatasets, skipped); }
/// <summary> /// Applies color map to input 1-band 32-bit float raster files and persists results as new .tif files with equivalent spatial /// metadata as respective source files as 3-band 8-bit int raster files suitable for web tiling. /// </summary> /// <param name="args"></param> /// <param name="colorRepo"></param> /// <param name="extension"></param> /// <param name="di"></param> /// <param name="resultDir"></param> private static Tuple<List<string>, List<string>> ProcessRasterFiles(string[] args, IColorRepository colorRepo, LegendRepository legend, string extension, DirectoryInfo di, DirectoryInfo resultDir, List<string> processedDatasets) { OSGeo.GDAL.Driver srcDrv = Gdal.GetDriverByName("GTiff"); List<string> skipped = new List<string>(); foreach (FileInfo fi in FilesInDirectoryWithExtension(extension, di)) { if (colorRepo.HasColorMappingOfFile(fi.Name)) { foreach (string resultName in colorRepo.ResultFileName(fi.Name)) { if (!processedDatasets.Contains(resultName)) { if (colorRepo.FileLegend(fi.Name, resultName).Any(a => string.IsNullOrEmpty(a.LegendFile))) { ProcessRasterFile(args, colorRepo, resultDir, srcDrv, fi, resultName); } string plainName = resultName.Replace(".tif", "").Replace(".json", ""); DirectoryInfo dirOut = new DirectoryInfo(resultDir + plainName); if (!dirOut.Exists) { dirOut.Create(); } legend.Add(plainName, colorRepo.FileLegend(fi.Name, resultName)); processedDatasets.Add(resultName); } } } else { skipped.Add(fi.Name); } } return new Tuple<List<string>, List<string>>(processedDatasets, skipped); }