OSDN Git Service

Pre-RC1: Added Tab delimited POI/EOI report file
authormelchior <melchior@users.osdn.me>
Fri, 20 Mar 2020 01:27:14 +0000 (21:27 -0400)
committermelchior <melchior@users.osdn.me>
Fri, 20 Mar 2020 01:27:14 +0000 (21:27 -0400)
Automap/Subsystems/AutomapSystem.cs

index 7af9a94..8295017 100644 (file)
@@ -36,6 +36,7 @@ namespace Automap
                private const string chunkFile_filter = @"*_*.png";
                private const string poiFileName = @"poi_binary";
                private const string eoiFileName = @"eoi_binary";
+               private const string pointsTsvFileName = @"points_of_interest.tsv";
                private static Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+).png", RegexOptions.Singleline);
 
                private ConcurrentDictionary<Vec2i, uint> columnCounter = new ConcurrentDictionary<Vec2i, uint>(3, 150);
@@ -225,7 +226,6 @@ namespace Automap
                                        //What about chunk updates themselves; a update bitmap isn't kept...
                                        updatedChunksTotal += updatedChunks;
                                        GenerateJSONMetadata();
-                                       PersistPointsData( );
                                        updatedChunks = 0;
                                }
 
@@ -251,6 +251,7 @@ namespace Automap
                        finally
                        {
                                Logger.VerboseDebug("Thread '{0}' executing finally block.", Thread.CurrentThread.Name);
+                               PersistPointsData( );
                        }
                }
 
@@ -532,7 +533,7 @@ namespace Automap
                /// </summary>
                private void PersistPointsData( )
                {
-               //POI and EOI raw dump files ~ reload em!
+               //POI and EOI raw dump files ~ WRITE em!
                //var poiRawFile = File.
                string poiPath = Path.Combine(path, poiFileName);
                string eoiPath = Path.Combine(path, eoiFileName);
@@ -548,6 +549,31 @@ namespace Automap
                        Serializer.Serialize<EntitiesOfInterest>(eoiFile, this.EOIs);
                }
                }
+
+               //Create Easy to Parse CSV file for tool/human use....
+               string pointsTsvPath = Path.Combine(path, pointsTsvFileName);
+
+               using (var tsvWriter = new StreamWriter(pointsTsvPath, false, Encoding.UTF8))
+               {
+               tsvWriter.WriteLine("Name\tDescription\tLocation\tTime\t");
+                       foreach (var point in this.POIs) {
+                                       tsvWriter.Write(point.Name + "\t");
+                                       tsvWriter.Write(point.Notes + "\t");
+                                       tsvWriter.Write(point.Location.PrettyCoords(ClientAPI) + "\t");
+                                       tsvWriter.Write(point.Timestamp.ToString("u")+"\t");
+                                       tsvWriter.WriteLine();
+                       }
+                       foreach (var entity in this.EOIs) {
+                                       tsvWriter.Write(entity.Name + "\t");
+                                       tsvWriter.Write(entity.Notes + "\t");
+                                       tsvWriter.Write(entity.Location.PrettyCoords(ClientAPI) + "\t");
+                                       tsvWriter.Write(entity.Timestamp.ToString("u") + "\t");
+                                       tsvWriter.WriteLine( );
+                       }
+               tsvWriter.WriteLine();
+               tsvWriter.Flush( );
+               }
+
                }
 
                private ColumnMeta CreateColumnMetadata(KeyValuePair<Vec2i, uint> mostActiveCol, IMapChunk mapChunk)