public static List <Core.Data.Waypoint> ImportWaypoints(Core.Storage.Database db, LiveV6.AdditionalWaypoint[] wps) { List <Core.Data.Waypoint> result = new List <Core.Data.Waypoint>(); if (wps != null) { foreach (var lg in wps) { Core.Data.Waypoint g = ImportWaypoint(db, lg); if (g != null) { result.Add(g); } } } return(result); }
public static Core.Data.Waypoint ImportWaypoint(Core.Storage.Database db, LiveV6.AdditionalWaypoint wp) { Core.Data.Waypoint result = null; if (wp != null) { result = db.WaypointCollection.GetWaypoint(wp.Code); Core.Data.IWaypointData wpd; if (result == null) { wpd = new Core.Data.WaypointData(); wpd.Code = wp.Code; wpd.ID = wp.Code; } else { wpd = result; } wpd.DataFromDate = DateTime.Now; wpd.WPType = Utils.DataAccess.GetWaypointType(wp.WptTypeID); wpd.Comment = wp.Comment; wpd.Description = wp.Description; wpd.GeocacheCode = wp.GeocacheCode; wpd.Lat = wp.Latitude; wpd.Lon = wp.Longitude; wpd.Name = wp.Name; wpd.Time = wp.UTCEnteredDate; wpd.Url = wp.Url; wpd.UrlName = wp.UrlName; if (wpd is Core.Data.WaypointData) { if (Utils.DataAccess.AddWaypoint(db, wpd as Core.Data.WaypointData)) { result = db.WaypointCollection.GetWaypoint(wp.Code); } } } return(result); }
private object GetPosition(Core.Data.Waypoint wpt) { double lat, lon; if (wpt.Lat != null) { lat = (double)wpt.Lat; } else { return(""); } if (wpt.Lon != null) { lon = (double)wpt.Lon; } else { return(""); } return(Utils.Conversion.GetCoordinatesPresentation(lat, lon)); }
////////////////////////////////////////////////////////////// //defines the filename based on wpt attribute & opens the file // if new ////////////////////////////////////////////////////////////// private System.IO.StreamWriter WptCsv(Core.Data.Geocache gc, Core.Data.Waypoint wpt) { string csvName = null; string postFix = ""; switch (wpt.WPType.ID) { case 217: csvName = "Parking_Area"; break; case 218: csvName = "Question_to_Answer"; break; case 219: csvName = "Stages_of_a_Multicache"; break; case 220: csvName = "Final_Location"; break; case 221: csvName = "Trailhead"; break; case 452: csvName = "Reference_Point"; break; default: csvName = wpt.WPType.Name.Replace(" ", "_"); break; } if (gc.Found) { postFix = "_Found"; } if (!gc.Available || gc.Archived) { postFix = "_Disabled"; } csvName = csvName + postFix; if (!sd.ContainsKey(csvName)) { //new -> open File System.IO.StreamWriter cs = null; string csvPath = Core.Settings.Default.GarminPOIExportPath + Path.DirectorySeparatorChar + csvName + ".csv"; cs = new System.IO.StreamWriter(csvPath, false, Encoding.GetEncoding(1250), 32768); sd.Add(csvName, cs); //create wpt icon try { //using (Stream input = Assembly.GetExecutingAssembly().GetManifestResourceStream("GlobalcachingApplication.Plugins.ExportGarminPOI.Resources." + csvName + ".bmp")) //using (Stream output = File.Create(Properties.Settings.Default.POIExportPath + Path.DirectorySeparatorChar + csvName + ".bmp")) //{ // input.CopyTo(output); //} Utils.ResourceHelper.SaveToFile("/GarminPOI/Resources/" + csvName + ".bmp", Core.Settings.Default.GarminPOIExportPath + Path.DirectorySeparatorChar + csvName + ".bmp", true); } catch { } //ignore invalid resource or write errors here } return(sd[csvName]); }
public static Core.Data.Waypoint AddWaypoint(Core.Storage.Database db, OKAPIService.Waypoint wp) { Core.Data.Waypoint result = null; if (wp != null) { result = db.WaypointCollection.GetWaypoint(wp.name); Core.Data.IWaypointData wpd; if (result == null) { wpd = new Core.Data.WaypointData(); wpd.Code = wp.name; wpd.ID = wp.name; } else { wpd = result; } wpd.DataFromDate = DateTime.Now; //for now map: parking, path, stage, physical-stage, virtual-stage, final, poi, other if (wp.sym == "parking") { wpd.WPType = DataAccess.GetWaypointType(217); } else if (wp.sym == "path") { wpd.WPType = DataAccess.GetWaypointType(452); } else if (wp.sym == "stage" || wp.sym == "physical-stage" || wp.sym == "virtual-stage") { wpd.WPType = DataAccess.GetWaypointType(219); } else if (wp.sym == "final") { wpd.WPType = DataAccess.GetWaypointType(220); } else if (wp.sym == "poi") { wpd.WPType = DataAccess.GetWaypointType(452); } else { wpd.WPType = DataAccess.GetWaypointType(452); } wpd.Comment = wp.description; wpd.Description = wp.description; wpd.GeocacheCode = wp.cache_code; wpd.Lat = Utils.Conversion.StringToDouble(wp.location.Substring(0, wp.location.IndexOf('|'))); wpd.Lon = Utils.Conversion.StringToDouble(wp.location.Substring(wp.location.IndexOf('|') + 1)); wpd.Name = wp.type_name; wpd.Time = DateTime.Now; wpd.Url = ""; wpd.UrlName = wp.type_name; if (wpd is Core.Data.WaypointData) { if (Utils.DataAccess.AddWaypoint(db, wpd as Core.Data.WaypointData)) { result = db.WaypointCollection.GetWaypoint(wpd.Code); } } } return(result); }