public void findNearPOIFromGpx(string trkFile, string poiFile) { try { GpxResult res = GpsData.findPoiNearGpxTracks(trkFile, poiFile); if (res.GPX == null) { string msg = "Find Near POI to GPX tracks/routes failed" + NL + " " + res.Message; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, NL + msg)); return; } gpx poiNear = res.GPX; string saveFileName = getSaveName(poiFile, ".foundnear"); if (saveFileName != null) { poiNear.Save(saveFileName); string msg = "Find Near POI to GPX tracks/routes:" + NL + " Tracks/routes file=" + trkFile + NL + " POI file=" + poiFile + NL + " Output=" + saveFileName + NL + " " + res.Message; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, NL + msg)); } else { return; } } catch (Exception ex) { string msg = "Error finding Near POI from GPX"; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.EXC, msg, ex)); return; } }
public static void fixPolarGpx(string gpxFile, MainForm mainForm) { try { GpxResult res = GpsData.fixPolarGpx(gpxFile); if (res.GPX == null) { Utils.errMsg("Fixing GPX failed:" + NL + "for " + Path.GetFileName(gpxFile) + NL + res.Message); return; } if (res.Message.StartsWith("Unmodified")) { mainForm.gpxTxcCallback(NL + "Did not change " + gpxFile + NL); return; } // Overwrite the existing file and restore the modified time DateTime lastModifiedTime = File.GetLastWriteTime(gpxFile); res.GPX.Save(gpxFile); File.SetLastWriteTime(gpxFile, lastModifiedTime); mainForm.gpxTxcCallback(NL + "Overwrote " + gpxFile + NL + res.Message); } catch (Exception ex) { Utils.excMsg("Error fixing Gpx for " + gpxFile, ex); return; } }
public void fixPolarGpx(string gpxFile, bool silent) { try { GpxResult res = GpsData.fixPolarGpx(gpxFile); if (res.GPX == null) { string msg = "Fix Polar Access GPX: Fixing GPX failed:" + NL + "for " + Path.GetFileName(gpxFile) + NL + res.Message; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.ERR, msg)); return; } if (res.Message.StartsWith("Unmodified")) { string msg = "Fix Polar Access GPX: No changes to" + " be made in " + gpxFile; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, NL + msg)); return; } if (silent) { // Overwrite the existing file and restore the modified time DateTime lastModifiedTime = File.GetLastWriteTime(gpxFile); res.GPX.Save(gpxFile); File.SetLastWriteTime(gpxFile, lastModifiedTime); string msg = "Fix Polar Access GPX: Overwrote " + gpxFile + NL + res.Message; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, NL + msg)); } else { string saveFileName = getSaveName(gpxFile, ".fixed"); if (saveFileName != null) { res.GPX.Save(saveFileName); string msg = "Fix Polar Access GPX: Changed times in " + gpxFile + NL + " Output is " + saveFileName + NL + " " + res.Message; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, NL + msg)); } else { string msg = "Fix Polar Access GPX: Failed to change " + "times in " + gpxFile + NL; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.MSG, msg)); } } } catch (Exception ex) { string msg = "Fix Polar Access GPX: Error fixing Gpx for " + gpxFile; raiseGpxTcxEvent(new GpxTcxEventArgs(EventType.EXC, msg, ex)); return; } }