Esempio n. 1
0
        void ExportFile(HeightData data, string outPath)
        {
            try {
                string dir   = Path.GetDirectoryName(outPath);
                string fname = Path.GetFileNameWithoutExtension(outPath);
                if (Directory.Exists(dir))
                {
                    HeightDataSplitter splitter = new HeightDataSplitter(data, exportSettings.fileSplitDims);
                    for (int z = 0; z < splitter.NumDataY; z++)
                    {
                        for (int x = 0; x < splitter.NumDataX; x++)
                        {
                            exportNumX = x;
                            exportNumZ = z;
                            foreach (FileFormat format in exportSettings.outputFormats)
                            {
                                ExportJob exportJob = new ExportJob(splitter.GetDataChunk(x, z), format, exportSettings, dir, fname);
                                if (splitter.NumChunks > 1)
                                {
                                    exportJob.nameBuilder.gridNum = (x, z);
                                }
                                format.exportHandler.EditFileName(exportJob, exportJob.nameBuilder);
                                string fullpath = exportJob.nameBuilder.GetFullPath();

                                WriteLine($"Creating file {fullpath} ...");
                                try {
                                    var startTime = DateTime.Now;
                                    exportJob.Export();
                                    var span = DateTime.Now - startTime;
                                    if (span.TotalSeconds > 5)
                                    {
                                        WriteLine($"Time: {span.TotalSeconds:F2}");
                                    }
                                    WriteSuccess($"{format.Identifier} file created successfully!");
                                } catch (Exception e) {
                                    throw new IOException($"Failed to write {format.Identifier} file!", e);
                                }
                            }
                        }
                    }
                }
                else
                {
                    throw new IOException($"Directory '{dir}' does not exist!");
                }
                if (FileExported != null)
                {
                    FileExported(CurrentFileIndex, outputPath);
                }
            } catch (Exception e) {
                if (FileExportFailed != null)
                {
                    FileExportFailed(CurrentFileIndex, outputPath, e);
                }
            }
        }
Esempio n. 2
0
 public override bool Export(ExportJob job)
 {
     if (job.format.IsPointFormat())
     {
         return(WriteFilePointData(job));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
 public static bool WriteFilePointData(ExportJob job)
 {
     try {
         if (job.format.IsFormat("ASC") || job.format.IsFormat("PTS_XYZ"))
         {
             IExporter exporter;
             exporter = new PointDataExporter(job.data);
             ExportUtility.WriteFile(exporter, job.FilePath, job.format);
             return(true);
         }
         else
         {
             WriteError("Don't know how to export " + job.format.ToString());
             return(false);
         }
     } catch (Exception e) {
         WriteError("Failed to create Point data file!");
         WriteLine(e.ToString());
         return(false);
     }
 }
Esempio n. 4
0
 public virtual void EditFileName(ExportJob exportJob, FileNameBuilder nameBuilder)
 {
 }
Esempio n. 5
0
 public abstract bool Export(ExportJob job);