Пример #1
0
        private static void AnniversaryFounds(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
        {
            var anniversaryList = foundLogs
                                  .OrderBy(f => f.FoundDate)
                                  .Where((l, i) => i == 0 || (i + 1) % 100 == 0);

            htmlGenerator.AddTableSection(anniversaryList, "Every 100th Found", "Every100thFound", ShortInfoTableSpec);
        }
Пример #2
0
 private static void FoundsByFoundDate(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
 {
     htmlGenerator.AddTableSection(
         foundLogs.OrderBy(f => f.FoundDate),
         "Logs by Found Date",
         "ByFoundDate",
         ShortInfoTableSpec);
 }
Пример #3
0
 private static void FoundsByPlacedDate(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
 {
     htmlGenerator.AddTableSection(
         foundLogs.OrderBy(f => f.Placed),
         "Logs by Placed Date",
         "ByPlacedDate",
         FullInfoTableSpec);
 }
Пример #4
0
        private static void FoundsByCountry(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
        {
            var countryStats = foundLogs
                               .GroupBy(l => l.Country)
                               .Select(x => new SimpleStat(x.Key, x.Count()))
                               .OrderByDescending(s => s.Founds);

            htmlGenerator.AddTableSection(countryStats, "Founds by Country", "FoundsByCountry", GetSimpleStatSpec("Country"));
        }
Пример #5
0
        private static void FoundsByState(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
        {
            var stateStats = foundLogs
                             .Where(l => l.Country == "Germany")
                             .GroupBy(l => l.State)
                             .Select(x => new SimpleStat(x.Key, x.Count()))
                             .OrderByDescending(s => s.Founds);

            htmlGenerator.AddTableSection(
                stateStats,
                "Founds by 'Bundesland'",
                "FoundsByBundesland",
                GetSimpleStatSpec("Bundesland"));
        }
Пример #6
0
        private static void FoundsByOwner(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
        {
            var ownerStats = foundLogs
                             .GroupBy(l => l.PlacedBy)
                             .Select(x => new SimpleStat(x.Key, x.Count()))
                             .Where(x => x.Founds >= 5)
                             .OrderByDescending(s => s.Founds);

            htmlGenerator.AddTableSection(
                ownerStats,
                "Founds by Owner (five and more founds)",
                "FoundsByOwner",
                GetSimpleStatSpec("Owner"));
        }
Пример #7
0
        public static void Analyze(List <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator, Action <string> logMethod)
        {
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException(nameof(htmlGenerator));
            }
            if (foundLogs == null)
            {
                throw new ArgumentNullException(nameof(foundLogs));
            }

            foreach (var analyzingMethod in AnalyzingMethods)
            {
                logMethod?.Invoke($"Adding {analyzingMethod.Method.Name}");
                analyzingMethod(foundLogs, htmlGenerator);
            }
        }
Пример #8
0
        public static void Main(string[] args)
        {
            Console.WriteLine("=== GC Logs Analyzer ===");
            if (args.Length < 2)
            {
                Console.WriteLine("Expected Parameters: <GPX-Filename> <HTML-Output-Filename>");
                return;
            }

            var filename      = args[0];
            var htmlFile      = args[1];
            var htmlGenerator = new HtmlGenerator();

            var converter = new GpxConverter(filename).Parse();

            Console.WriteLine($"{converter.FoundLogs.Count} logs read from file");

            DataAnalyzer.Analyze(converter.FoundLogs, htmlGenerator, Console.WriteLine);
            htmlGenerator.GenerateHtmlFile(htmlFile);
            Console.WriteLine($"HTML-Output written to '{htmlFile}'");
        }
Пример #9
0
        private static void FarthestAwayFoundsByCardinalDirection(IEnumerable <GeocacheLog> foundLogs, HtmlGenerator htmlGenerator)
        {
            // Farthest away founds by cardinal direction
            GeocacheLog maxNorth = null;
            GeocacheLog maxSouth = null;
            GeocacheLog maxEast  = null;
            GeocacheLog maxWest  = null;

            foreach (var geocacheLog in foundLogs)
            {
                if (maxNorth == null || maxNorth.GeoLocation.Lat < geocacheLog.GeoLocation.Lat)
                {
                    maxNorth = geocacheLog;
                }
                if (maxSouth == null || maxSouth.GeoLocation.Lat > geocacheLog.GeoLocation.Lat)
                {
                    maxSouth = geocacheLog;
                }
                if (maxEast == null || maxEast.GeoLocation.Lon < geocacheLog.GeoLocation.Lon)
                {
                    maxEast = geocacheLog;
                }
                if (maxWest == null || maxWest.GeoLocation.Lon > geocacheLog.GeoLocation.Lon)
                {
                    maxWest = geocacheLog;
                }
            }

            var stats = new List <SimpleLogStat>
            {
                new SimpleLogStat("Farthest North", maxNorth),
                new SimpleLogStat("Farthest South", maxSouth),
                new SimpleLogStat("Farthest East", maxEast),
                new SimpleLogStat("Farthest West", maxWest)
            };

            htmlGenerator.AddTableSection(stats, "Cardinal Direction Maximums", "CardinalDirectionMaximums", SimpleLogStatTableSpec);
        }