Esempio n. 1
0
        private GeocacheLog ReadLogAndGeocacheDetails(XmlReader reader)
        {
            var log = new GeocacheLog();

            if (reader.HasAttributes)
            {
                log.GeoLocation.Lat = GetAttributeAsDouble(reader, "lat");
                log.GeoLocation.Lon = GetAttributeAsDouble(reader, "lon");
            }

            while (reader.Read())
            {
                if (reader.Name == "wpt")
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                case "groundspeak:logs": ReadLogEntrySection(reader, log); break;

                case "time": log.Placed = GetElementAsDateTime(reader); break;

                case "name": log.Code = GetElementAsString(reader); break;

                case "url": log.Url = GetElementAsString(reader); break;

                case "groundspeak:name": log.Name = GetElementAsString(reader); break;

                case "groundspeak:long_description": log.Description = GetElementAsString(reader); break;

                case "groundspeak:type": log.Type = GetElementAsString(reader); break;

                case "groundspeak:container": log.Size = GetElementAsString(reader); break;

                case "groundspeak:country": log.Country = GetElementAsString(reader); break;

                case "groundspeak:state": log.State = GetElementAsString(reader); break;

                case "groundspeak:owner":
                    if (reader.HasAttributes)
                    {
                        log.OwnerId = GetAttributeAsString(reader, "id");
                    }
                    log.PlacedBy = GetElementAsString(reader);
                    break;

                case "groundspeak:difficulty": log.Difficulty = GetElementAsDouble(reader); break;

                case "groundspeak:terrain": log.Terrain = GetElementAsDouble(reader); break;
                }
            }

            return(log);
        }
Esempio n. 2
0
        private void ReadLogEntrySection(XmlReader reader, GeocacheLog log)
        {
            while (reader.Read())
            {
                if (reader.Name == "groundspeak:logs")
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element || reader.Name != "groundspeak:log")
                {
                    continue;
                }

                if (reader.HasAttributes)
                {
                    log.LogId = GetAttributeAsString(reader, "id");
                }

                var foundDate   = DateTime.MinValue;
                var foundLogMsg = "";
                var logType     = "";
                while (reader.Read())
                {
                    if (reader.Name == "groundspeak:log")
                    {
                        break;
                    }
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    switch (reader.Name)
                    {
                    case "groundspeak:date": foundDate = GetElementAsDateTime(reader); break;

                    case "groundspeak:text": foundLogMsg = GetElementAsString(reader); break;

                    case "groundspeak:type": logType = GetElementAsString(reader); break;
                    }
                }

                if (logType.IsValidLogType())
                {
                    log.FoundDate = foundDate;
                    log.FoundLog  = foundLogMsg;
                    log.LogType   = logType;
                }
            }
        }
Esempio n. 3
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);
        }