public static List <Geocache> Parse(Gpx gpx) { List <Geocache> caches = new List <Geocache>(); foreach (var item in gpx.Waypoints) { foreach (var singleCache in item.Caches) { Geocache cache = new Geocache(); cache.Id = item.Name; cache.Description = item.Description; cache.Difficulty = singleCache.Difficulty; cache.Terrain = singleCache.Terrain; cache.AlreadyFound = false; cache.Archived = singleCache.Archived; cache.Disabled = singleCache.Available; cache.EncodedHint = singleCache.EncodedHints; cache.Location = GeoPoint.Parse((double)item.Latitude, (double)item.Longitude); cache.Logs = Log.Parse(singleCache.Logs); cache.Name = singleCache.Name; cache.Owner = new User() { Name = singleCache.Owners.First().Name, //Id = int.Parse(singleCache.Owners.First().Id) }; cache.Size = (CacheSize)Enum.Parse(typeof(CacheSize), singleCache.Container, true); cache.Travelbugs = Travelbug.Parse(singleCache.Travelbugs); cache.Url = item.Url; foreach (var attribute in singleCache.AttributesField) { cache.Tags.Add(new Tag() { Type = TagType.Attribute, Text = (attribute.Inc == 1) ? attribute.Value : "not " + attribute.Value }); } cache.Tags.Add(new Tag() { Type = TagType.System, Text = singleCache.Type }); caches.Add(cache); } } return(caches); }
public static List<Geocache> Parse(Gpx gpx) { List<Geocache> caches = new List<Geocache>(); foreach (var item in gpx.Waypoints) { foreach (var singleCache in item.Caches) { Geocache cache = new Geocache(); cache.Id = item.Name; cache.Description = item.Description; cache.Difficulty = singleCache.Difficulty; cache.Terrain = singleCache.Terrain; cache.AlreadyFound = false; cache.Archived = singleCache.Archived; cache.Disabled = singleCache.Available; cache.EncodedHint = singleCache.EncodedHints; cache.Location = GeoPoint.Parse((double)item.Latitude, (double)item.Longitude); cache.Logs = Log.Parse(singleCache.Logs); cache.Name = singleCache.Name; cache.Owner = new User() { Name = singleCache.Owners.First().Name, //Id = int.Parse(singleCache.Owners.First().Id) }; cache.Size = (CacheSize)Enum.Parse(typeof(CacheSize), singleCache.Container, true); cache.Travelbugs = Travelbug.Parse(singleCache.Travelbugs); cache.Url = item.Url; foreach (var attribute in singleCache.AttributesField) { cache.Tags.Add(new Tag() { Type = TagType.Attribute, Text = (attribute.Inc == 1) ? attribute.Value : "not " + attribute.Value }); } cache.Tags.Add(new Tag() { Type = TagType.System, Text = singleCache.Type }); caches.Add(cache); } } return caches; }