/// <summary> /// Clone constructor is needed for Magellan GetRoutes, when CreateInfo instances are buffered /// </summary> /// <param name="ci"></param> public CreateInfo(CreateInfo ci) { id = ci.id; type = ci.type; typeExtra = ci.typeExtra; lat = ci.lat; lng = ci.lng; elev = ci.elev; magn = ci.magn; dateTime = ci.dateTime; name = ci.name; urlName = ci.urlName; url = ci.url; desc = ci.desc; comment = ci.comment; sym = ci.sym; source = ci.source; par1 = ci.par1; node1 = ci.node1; // ref node2 = ci.node2; // ref }
public bool Equals(CreateInfo other) { return(other != null && //other.id == id && other.type == type && other.typeExtra == typeExtra && other.lat == lat && other.lng == lng && other.elev == elev && other.magn == magn && other.dateTime == dateTime && other.name == name && other.urlName == urlName && other.url == url && other.desc == desc && other.comment == comment && other.sym == sym && other.source == source && other.par1 == par1 && other.node1 == node1 && other.node2 == node2); }
// xmlDoc must be Load'ed; can throw exceptions protected bool processGpx(string url, XmlDocument xmlDoc, string source) { bool ret = true; XmlNodeList waypointNodes = xmlDoc.DocumentElement.ChildNodes; //.SelectNodes("/gpx/wpt"); - this don't work #if DEBUG LibSys.StatusBar.Trace("IP: FileGpx:process() first level nodeCount=" + waypointNodes.Count); #endif /* <gpx version="1.0" creator="EasyGPS 1.1.9 - http://www.topografix.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xmlns:topografix="http://www.topografix.com/GPX/Private/TopoGrafix/0/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/Private/TopoGrafix/0/1 http://www.topografix.com/GPX/Private/TopoGrafix/0/1/topografix.xsd"> <time>2002-10-04T18:49:55Z</time> <bounds minlat="25.061783" minlon="-123.003111" maxlat="50.982883" maxlon="121.640267"/> <wpt lat="33.575106480" lon="-117.735883651"> <ele>159.703613</ele> <time>2002-10-04T18:47:47Z</time> <name><![CDATA[001]]></name> <cmt><![CDATA[29-AUG-02 11:21:24PM]]></cmt> <desc><![CDATA[001]]></desc> <sym>Dot</sym> <type><![CDATA[Dot]]></type> </wpt> <rte> <name><![CDATA[HOME TO CNTRYC]]></name> <number>1</number> <topografix:color>ff0000</topografix:color> <rtept lat="33.574991229" lon="-117.736144077"> <time>2002-10-11T05:34:36Z</time> <name><![CDATA[HOME]]></name> <cmt><![CDATA[AURORA]]></cmt> <desc><![CDATA[HOME]]></desc> <sym>House</sym> <type><![CDATA[Residence]]></type> </rtept> </rte> <trk> <name><![CDATA[ACTIVE LOG]]></name> <number>1</number> <topografix:color>ff0000</topografix:color> <trkseg> <trkpt lat="33.570749483" lon="-117.723665938"> <ele>106.363037</ele> <time>2002-10-11T04:32:08Z</time> <sym>Waypoint</sym> </trkpt> <trkpt lat="33.571032289" lon="-117.722491633"> <ele>99.153076</ele> <time>2002-10-11T04:32:18Z</time> <sym>Waypoint</sym> </trkpt> </trkseg> </trk> </gpx> */ CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. // we want to traverse XmlDocument fast, as tile load operations can be numerous // and come in pack. So we avoid using XPath and rely mostly on "foreach child": foreach(XmlNode nnode in waypointNodes) { try { switch(nnode.Name) { case "author": //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); break; case "desc": //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); break; case "bounds": //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); break; case "wpt": //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); createInfo.init("wpt"); createInfo.setLat(nnode.Attributes["lat"].InnerText); createInfo.setLng(nnode.Attributes["lon"].InnerText); createInfo.typeExtra = "unknown"; // type: ppl, school, park, locale, airport, reservoir, dam, // civil, cemetery, valley, building createInfo.source = source; foreach(XmlNode node in nnode.ChildNodes) { //LibSys.StatusBar.Trace(" child node=" + node.Name); switch(node.Name) { case "time": createInfo.setDateTime(node.InnerText); break; case "ele": createInfo.setElev(node.InnerText); break; case "name": createInfo.name = node.InnerText.Trim(); // number like 001 for route-related wpts or GCSDFX for geocaches break; case "desc": createInfo.desc = node.InnerText.Trim(); break; case "groundspeak:cache": createInfo.node1 = node; // will be parsed in Waypoint() constructor break; case "urlname": // may overwrite name in Pocket Queries createInfo.urlName = node.InnerText.Trim(); break; case "url": createInfo.url = node.InnerText.Trim(); break; case "cmt": createInfo.comment = node.InnerText.Trim(); // may contain time, so try to extract it if possible: try { createInfo.setDateTime(node.InnerText); } catch {} break; case "sym": createInfo.sym = node.InnerText.Trim(); break; case "type": // like "user waypoint" or "geocache" createInfo.typeExtra = node.InnerText.Trim(); break; } } m_insertWaypoint(createInfo); break; case "rte": { string routeName = ""; string routeColor = ""; bool routeCreated = false; foreach(XmlNode nnnode in nnode.ChildNodes) { switch(nnnode.Name) { case "name": // route name routeName = nnnode.InnerText.Trim(); break; case "number": // route number break; case "topografix:color": // like 00ffee routeColor = nnnode.InnerText.Trim(); break; case "rtept": /* <rtept lat="38.518697986" lon="-122.978969274"> <ele>4.211426</ele> <time>2002-10-04T18:48:23Z</time> <name><![CDATA[006]]></name> <cmt><![CDATA[28-SEP-02 1:56:26PM]]></cmt> <desc><![CDATA[006]]></desc> <sym>Dot</sym> <type><![CDATA[Dot]]></type> </rtept> */ //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); if(!routeCreated) { Project.trackId++; createInfo.init("rte"); createInfo.name = routeName; createInfo.id = Project.trackId; createInfo.par1 = nnnode.InnerText.Trim(); // number for route createInfo.source = source; createInfo.par1 = routeColor; m_insertWaypoint(createInfo); // actually inserts a route routeCreated = true; } createInfo.init("rtept"); createInfo.setLat(nnnode.Attributes["lat"].InnerText); createInfo.setLng(nnnode.Attributes["lon"].InnerText); createInfo.id = Project.trackId; // relate waypoint to track createInfo.source = source; foreach(XmlNode node in nnnode.ChildNodes) { //LibSys.StatusBar.Trace(" child node=" + node.Name); switch(node.Name) { case "time": createInfo.setDateTime(node.InnerText); break; case "ele": createInfo.setElev(node.InnerText); break; case "name": createInfo.name = node.InnerText.Trim(); // number like 001 for route-related wpts or GCSDFX for geocaches break; case "desc": createInfo.desc = node.InnerText.Trim(); break; case "urlname": createInfo.urlName = node.InnerText.Trim(); break; case "url": createInfo.url = node.InnerText.Trim(); break; case "cmt": createInfo.comment = node.InnerText.Trim(); break; case "sym": createInfo.sym = node.InnerText.Trim(); if("Waypoint".Equals(createInfo.sym)) { createInfo.sym = null; } break; case "type": // like "user waypoint" or "geocache" createInfo.typeExtra = node.InnerText.Trim(); break; } } m_insertWaypoint(createInfo); break; } } } break; case "trk": { string trackName = ""; string trackNumber = ""; string trackColor = ""; foreach(XmlNode nnnode in nnode.ChildNodes) { switch(nnnode.Name) { case "name": // track name trackName = nnnode.InnerText.Trim(); break; case "number": // track number trackNumber = nnnode.InnerText.Trim(); break; case "topografix:color": // like 00ffee trackColor = nnnode.InnerText.Trim(); break; case "trkseg": Project.trackId++; createInfo.init("trk"); createInfo.name = trackName; createInfo.id = Project.trackId; createInfo.source = source; createInfo.par1 = trackColor; m_insertWaypoint(createInfo); // actually inserts a track foreach(XmlNode nnnnode in nnnode.ChildNodes) { switch(nnnnode.Name) { case "trkpt": // track point /* <trkpt lat="33.570749483" lon="-117.723665938"> <ele>106.363037</ele> <time>2002-10-11T04:32:08Z</time> <sym>Waypoint</sym> </trkpt> */ //LibSys.StatusBar.Trace("FileGpx:process() node=" + nnode.Name); createInfo.init("trkpt"); createInfo.setLat(nnnnode.Attributes["lat"].InnerText); createInfo.setLng(nnnnode.Attributes["lon"].InnerText); createInfo.id = Project.trackId; // relate waypoint to track createInfo.source = source; foreach(XmlNode node in nnnnode.ChildNodes) { //LibSys.StatusBar.Trace(" child node=" + node.Name); switch(node.Name) { case "time": createInfo.setDateTime(node.InnerText); break; case "ele": createInfo.setElev(node.InnerText); break; case "name": createInfo.name = node.InnerText.Trim(); break; case "desc": createInfo.desc = node.InnerText.Trim(); break; case "urlname": createInfo.urlName = node.InnerText.Trim(); break; case "url": createInfo.url = node.InnerText.Trim(); break; case "cmt": createInfo.comment = node.InnerText.Trim(); break; case "sym": createInfo.sym = node.InnerText.Trim(); if("Waypoint".Equals(createInfo.sym)) { createInfo.sym = null; } break; case "type": // like "user waypoint" or "geocache" createInfo.typeExtra = node.InnerText.Trim(); break; } } m_insertWaypoint(createInfo); break; } } break; } } } break; } } catch (Exception ee) { // bad node - not a big deal... LibSys.StatusBar.Error("FileGpx process node=" + nnode.Name + " " + ee); //.Message); //LibSys.StatusBar.WriteLine("Culture: " + Thread.CurrentThread.CurrentCulture + " (" + Thread.CurrentThread.CurrentCulture.DisplayName + ") UseUserOverride=" + Thread.CurrentThread.CurrentCulture.UseUserOverride); } } return ret; }
public override bool process(string url, string filename, string source) { bool ret = true; LibSys.StatusBar.Trace("IP: FileDelormeTxt:process() filename=" + filename); int wpCount = 0; int lineno = 0; try { string line; int state = 0; double zoneShift = 0.0d; CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. StreamReader stream = new StreamReader(filename); while((line = stream.ReadLine()) != null) { lineno++; try { switch(state) { case 0: // look for "Date, Time" // Date, Time ((GMT-05:00) Eastern Time (DST)), Latitude, Longitude, Elevation (ft), Heading, Speed (mi/hr), GPS Status, Log Type if(line.StartsWith("Date, Time")) { state = 1; //LibSys.StatusBar.Trace("IP: FileDelormeTxt:process() state 1 filename=" + filename); Project.trackId++; createInfo.init("trk"); createInfo.id = Project.trackId; createInfo.source = source; createInfo.name = "DeLorme Blue Logger log"; m_insertWaypoint(createInfo); int pos = line.IndexOf("((GMT"); if(pos >= 0) { string sZoneShift = line.Substring(pos+5, 3); zoneShift = Convert.ToDouble(sZoneShift); } } break; case 1: // read WPT numpoints lines like: // 08/01/2004, 11:04:04, 42:50:54.539, -70:52:16.195, -64.269, 44.08, 32.81, 3, 3 char[] sep = new Char[1] { ',' }; string[] split = line.Split(sep); DateTime dateTime = Convert.ToDateTime(split[0] + " " + split[1]); dateTime = dateTime.AddHours(-zoneShift); double lat = ParseCoord(split[2]); double lng = ParseCoord(split[3]); double elev = Convert.ToDouble(split[4]) * METERS_PER_FOOT; createInfo.init("trkpt"); createInfo.id = Project.trackId; // relate waypoint to track createInfo.dateTime = dateTime; createInfo.lat = lat; createInfo.lng = lng; createInfo.elev = elev; createInfo.source = source; m_insertWaypoint(createInfo); wpCount++; break; } } catch (Exception ee) { LibSys.StatusBar.Error("FileDelormeTxt:process(): file=" + filename + " line=" + lineno + " " + ee.Message); } } } catch (Exception eee) { LibSys.StatusBar.Error("FileDelormeTxt:process(): " + eee.Message); ret = false; } //LibSys.StatusBar.Trace("OK: FileDelormeTxt:process() filename=" + filename + " lines=" + lineno + " waypoints=" + wpCount); return ret; }
// return array of (two) track IDs or null (if track can't be ungrouped for some reason) public static ArrayList ungroupTrackAtTrackpoint(Track trk, Waypoint trkptBreak) { int trip = 0; int i; // more than one trip, go ahead break it: string newTrackSource = trk.Source; trip = 0; ArrayList ret = new ArrayList(); for(i=0; i < trk.Trackpoints.Count ;i++) { Waypoint wpt = (Waypoint)trk.Trackpoints.GetByIndex(i); if(i == 0 || wpt == trkptBreak) { Project.trackId++; trip++; string newTrackName = trk.Name + "-trip-" + trip; CreateInfo createInfo = new CreateInfo(); createInfo.init(trk.Type); createInfo.id = Project.trackId; createInfo.name = newTrackName; createInfo.source = newTrackSource; createInfo.url = trk.Url; currentTrack = new Track(createInfo); m_tracksAll.Add(currentTrack); ret.Add(Project.trackId); } if(trip > 0) { Waypoint cloneWpt = new Waypoint(wpt); cloneWpt.TrackId = Project.trackId; currentTrack.insertWaypoint(cloneWpt); } } foreach(long id in ret) { Track ttrk = getTrackById(id); if(ttrk != null) { ttrk.rebuildTrackBoundaries(); } } isDirty = true; return ret; }
// these ones we need for Drag&Drop: public static void insertWaypoint(CreateInfo createInfo) { elementCount++; WaypointsCache.insertWaypoint(createInfo); }
// called from fileProcessor: private static void insertFavorite(CreateInfo createInfo) { switch(createInfo.type) { case "trk": case "rte": return; } string name = ("" + createInfo.name).Trim(); if(createInfo.urlName != null && createInfo.urlName.Length > 0) { name += " - " + createInfo.urlName.Trim(); } else if(createInfo.desc != null && createInfo.desc.Length > 0) { name += " - " + createInfo.desc.Trim(); } if(name.StartsWith(" - ")) { name = name.Substring(3); } name = name.Replace("\r", " ").Replace("\n", " ").Trim().Replace(" ", " "); if(name != null && name.Length > 0) { CamPos favPos = new CamPos(createInfo.lng, createInfo.lat, createInfo.elev, name.Trim(), Project.drawTerraserverMode); Project.favorites.Add(favPos); fvCount++; } }
public static void insertWaypoint(CreateInfo createInfo) { lock(m_waypointsAll) { switch(createInfo.type) { case "trk": case "rte": currentTrack = new Track(createInfo); m_tracksAll.Add(currentTrack); break; default: Waypoint wpt = new Waypoint(createInfo); addWaypoint(wpt); break; } } }
public void GetWaypoints(GpsInsertWaypoint insertWaypoint, GpsProgressHandler progressCallback) { string source = "MGN-GPS-" + DateTime.Now; int total = 0; int toReceive = -1; // we don't know how many waypoints are there in GPS int maxErrors = 5; int errors = maxErrors; bool finished = false; if(!gettingRoute) { m_linkLayer.SetHandshake(Project.gpsMagellanHandshake); if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(true); } } m_linkLayer.SendPacket(new MPacketCmd("WAYPOINT")); while(!finished) { MPacketReceived received; try { received = m_linkLayer.ReceivePacket(); } catch(CommPortException e) { m_linkLayer.logError("exception waiting for GPS response: " + e.Message); break; } //m_linkLayer.log("" + total + " === " + received); if(!received.isGood) { m_linkLayer.logError("GetWaypoints: bad packet received, count=" + total + " content=" + received.m_string); continue; } //m_linkLayer.log("GetWaypoints: good packet received, count=" + total + " " + received); if(received.header.Equals("PMGNWPL") || received.header.Equals("WPL")) // NMEA WPL may come from some devices { try { MPacket wpt = received.fromString(); string type = gettingRoute ? "rtept" : "wpt"; // $PMGNWPL,3328.069,N,11738.812,W,0000000,M,Road to,GCF320 = Road to Wat,a*68 double Lat = wpt.parseLat(0); double Lng = wpt.parseLng(0); double Elev = wpt.parseElev(4); string sym = null; string name = (string)wpt.fields[6]; // short name if(name != null && name.StartsWith("GC")) { type = "geocache"; sym = "Geocache"; } string descr = null; // description if(wpt.fields.Count > 7) { descr = (string)wpt.fields[7]; if(descr != null && descr.StartsWith("GC")) { type = "geocache"; sym = "Geocache"; string _name; string _descr; if(Project.splitGcDescr(descr, out _name, out _descr)) { name = _name; descr = _descr; } } } if(wpt.fields.Count > 8) { string icon = "" + (string)wpt.fields[8]; // icon - a (not found), b (found) if(icon.Equals("b") && "geocache".Equals(type)) { type += " found"; sym = "Geocache Found"; } } // we need to allocate every createInfo here, as they will be buffered in the reader thread: CreateInfo createInfo = new CreateInfo(); createInfo.init("wpt"); createInfo.lat = Lat; createInfo.lng = Lng; createInfo.elev = Elev; createInfo.typeExtra = type; createInfo.source = source; createInfo.name = name.Trim(); if(!createInfo.name.Equals(descr)) { createInfo.desc = descr; // can be null createInfo.urlName = descr; // can be null } //if(!"a".Equals(icon) && !"b".Equals(icon)) { createInfo.sym = sym; } insertWaypoint(createInfo); total++; if((total % 3) == 0) { progressCallback("IP: uploading waypoints to PC:", total, toReceive); } errors = maxErrors; } catch(Exception ee) { m_linkLayer.logError("GetWaypoints: " + ee.Message); } } else if(received.header.Equals("PMGNCMD")) { m_linkLayer.log("GetWaypoints: end of waypoints received, count=" + total + " " + received); finished = true; break; } else { m_linkLayer.log("GetWaypoints: good other packet received, count=" + total + " content=" + received); } } // end while() if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(false); } progressCallback("loaded OK", total, total); m_linkLayer.log("GetWaypoints: loaded OK count=" + total + " waypoints"); }
private void addToRoute(GeoCoord location, Waypoint wpt, Earthquake eq) { rteptNumber++; string wptName = "" + rteptNumber; if(m_routeTrack == null) { // first route-making click on the map, create track to hold the new route string newTrackSource = "route - user created " + DateTime.Now; Project.trackId++; rteptNumber = 1; m_lastWpt = null; string newTrackName = "Route-" + Project.trackId; CreateInfo createInfo = new CreateInfo(); createInfo.init("rte"); createInfo.id = Project.trackId; createInfo.name = newTrackName; createInfo.source = newTrackSource; createInfo.par1 = "" + rteNumber; rteNumber++; if(rteNumber > 20) { rteNumber = 1; } m_routeTrack = new Track(createInfo); m_routeTrack.isRoute = true; WaypointsCache.TracksAll.Add(m_routeTrack); wptName = "Start route"; } m_speed = null; if(m_lastWpt != null && m_lastWpt.HasSpeed) { m_speed = new Speed(m_lastWpt.Speed); } else { m_speed = new Speed(Project.routeSpeed); } TimeSpan dur = new TimeSpan(100000); Waypoint routeWpt = null; bool wasNew = false; if(wpt != null) { routeWpt = new Waypoint(wpt); routeWpt.LiveObjectType = LiveObjectTypes.LiveObjectTypeRoutepoint; routeWpt.DateTime = m_dateTimeRte; } else if(eq != null) { //wptName = eq.ToString(); wptName = string.Format("{0:F1} - ", eq.Magn) + eq.sDateTime + " - " + eq.Comment; routeWpt = new Waypoint(eq.Location, m_dateTimeRte, LiveObjectTypes.LiveObjectTypeRoutepoint, Project.trackId, wptName, eq.Source, eq.Url); } else { // location must not be null then: routeWpt = new Waypoint(location, m_dateTimeRte, LiveObjectTypes.LiveObjectTypeRoutepoint, Project.trackId, "", "user created", ""); // no URL routeWpt.NameDisplayed = wptName; wasNew = true; } if(m_speed != null) { routeWpt.Speed = (float)m_speed.Meters; } if(m_lastWpt != null && m_lastWpt.TrackId == Project.trackId) { Distance dist = routeWpt.distanceFrom(m_lastWpt.Location); double durSeconds = m_speed.Meters <= 0.0d ? 0.000001d : (dist.Meters / m_speed.Meters * 3600.0d); dur = new TimeSpan((long)(durSeconds * 10000000.0d)); m_dateTimeRte += dur; } routeWpt.DateTime = m_dateTimeRte; m_lastWpt = routeWpt; // we need to make sure that the point added is different from the last point in track. // Magellan will not accept routes with zero-length legs. Waypoint lastWpt = null; if(m_routeTrack.Trackpoints.Count > 0) { lastWpt = (Waypoint)m_routeTrack.Trackpoints.GetByIndex(m_routeTrack.Trackpoints.Count - 1); } if(lastWpt == null || lastWpt.Location.distanceFrom(routeWpt.Location).Meters > 2.0d) { if(wasNew && lastWpt != null) { routeWpt.Location.Elev = lastWpt.Location.Elev; } m_routeTrack.Trackpoints.Add(routeWpt.DateTime, routeWpt); m_routeTrack.PutOnMap(this, null, this); if(wptName.Length > 2) { //m_cameraManager.MarkLocation(mouseGeoLocation, 0); m_cameraManager.ProcessCameraMove(); // make sure label is positionsed on the map } else { // invalidate picture region around just created leg: Waypoint prevWpt = (Waypoint)m_routeTrack.Trackpoints.GetByIndex(m_routeTrack.Trackpoints.Count - 2); Point p1 = m_cameraManager.toPixelLocation(routeWpt.Location, null); Point p2 = m_cameraManager.toPixelLocation(prevWpt.Location, null); int x = Math.Min(p1.X, p2.X); int y = Math.Min(p1.Y, p2.Y); int w = Math.Abs(p1.X - p2.X); int h = Math.Abs(p1.Y - p2.Y); Rectangle toInv = new Rectangle(x, y, w, h); toInv.Offset(-5, -5); toInv.Inflate(10, 10); m_pictureManager.Invalidate(toInv); } } }
private void bufferWaypoint(CreateInfo createInfo) { wptBuffer.Add(createInfo); }
public void GetTracks(GpsInsertWaypoint insertWaypoint, GpsProgressHandler progressCallback) { string source = "MGN-GPS-" + DateTime.Now; string trackName = ""; bool trackCreated = false; int total = 0; int toReceive = -1; // we don't know how many trackpoints are there in GPS int maxErrors = 5; int errors = maxErrors; bool finished = false; DateTime dtPrev = DateTime.MinValue; m_linkLayer.SetHandshake(Project.gpsMagellanHandshake); if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(true); } MPacketCmd trackCmd = new MPacketCmd("TRACK"); trackCmd.fields.Add("2"); // undocumented, causes date to be included in PMGNTRK responses m_linkLayer.SendPacket(trackCmd); while(!finished) { MPacketReceived received; try { received = m_linkLayer.ReceivePacket(); } catch(CommPortException e) { m_linkLayer.logError("exception waiting for GPS response: " + e.Message); break; } //m_linkLayer.log("" + total + " === " + received); if(!received.isGood) { m_linkLayer.logError("GetTracks: bad packet received, count=" + total + " content=" + received.m_string); continue; } //m_linkLayer.log("GetTracks: good packet received, count=" + total + " " + received); if(received.header.Equals("PMGNTRK")) { // $PMGNTRK,3334.100,N,11742.518,W,00147,M,033531.02,A,,280403*63 // 03:35:31.02 28 Apr 2003 UTM try { MPacket trkpt = received.fromString(); if(!trackCreated) { Project.trackId++; trackName = "MGN-TRACK-LOG" + Project.trackId; // we need to allocate every infos here, as they will be buffered in the reader thread: CreateInfo createInfo = new CreateInfo(); createInfo.init("trk"); createInfo.id = Project.trackId; // track id createInfo.source = source; createInfo.name = trackName; insertWaypoint(createInfo); // actually inserts a track trackCreated = true; } // $PMGNTRK,3334.100,N,11742.518,W,00147,M,033531.02,A,,280403*63 // 03:35:31.02 28 Apr 2003 UTM double Lat = trkpt.parseLat(0); double Lng = trkpt.parseLng(0); double Elev = trkpt.parseElev(4); int h, m, s, ms; trkpt.parseTime(6, out h, out m, out s, out ms); int y, mm, d; trkpt.parseDate(9, out y, out mm, out d); DateTime dt = new DateTime(y, mm, d, h, m, s, ms); // UTM /* this is from the days when I didn't know how to get date from Magellan: // make sure that as points come, DateTime only grows: DateTime dt = new DateTime(m_year, m_month, m_day, h, m, s, ms); while(dt.CompareTo(dtPrev) < 0) { m_day++; if(m_day > 28) { m_month++; m_day = 1; } dt = new DateTime(m_year, m_month, m_day, h, m, s, ms); } dtPrev = dt; */ //m_linkLayer.log("time=" + dt); { // we need to allocate every createInfo here, as they will be buffered in the reader thread: CreateInfo createInfo = new CreateInfo(); createInfo.init("trkpt"); createInfo.id = Project.trackId; // relate waypoint to track createInfo.dateTime = dt; createInfo.lat = Lat; createInfo.lng = Lng; createInfo.elev = Elev; createInfo.source = source; insertWaypoint(createInfo); } total++; if((total % 3) == 0) { progressCallback("IP: uploading track: " + trackName + " to PC\n\nleg ", total, toReceive); } errors = maxErrors; } catch(Exception ee) { m_linkLayer.logError("GetTracks: " + ee.Message); } } else if(received.header.Equals("PMGNCMD")) { m_linkLayer.log("GetTracks: end of tracks received, count=" + total + " " + received); finished = true; break; } else { m_linkLayer.log("GetTracks: good other packet received, count=" + total + " content=" + received); } } // end while() if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(false); } progressCallback("loaded OK", total, total); m_linkLayer.log("GetTracks: loaded OK count=" + total + " trackpoints"); }
public void GetRoutes(GpsInsertWaypoint insertWaypoint, GpsProgressHandler progressCallback) { ArrayList namesBuffer = new ArrayList(); ArrayList nameRoutesBuffer = new ArrayList(); // now get the route information, which is actually list of names: string source = "MGN-GPS-" + DateTime.Now; int total = 0; int toReceive = -1; // we don't know how many routepoints are there in GPS int maxErrors = 5; int errors = maxErrors; bool finished = false; DateTime dtPrev = DateTime.MinValue; char[] digits = "0123456789".ToCharArray(); m_linkLayer.SetHandshake(Project.gpsMagellanHandshake); if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(true); } MPacketCmd trackCmd = new MPacketCmd("ROUTE"); m_linkLayer.SendPacket(trackCmd); while(!finished) { MPacketReceived received; try { received = m_linkLayer.ReceivePacket(); } catch(CommPortException e) { m_linkLayer.logError("exception waiting for GPS response: " + e.Message); break; } //m_linkLayer.log("" + total + " === " + received); if(!received.isGood) { m_linkLayer.logError("GetRoutes: bad packet received, count=" + total + " content=" + received.m_string); continue; } m_linkLayer.log("GetRoutes: good packet received, count=" + total + " " + received); if(received.header.Equals("PMGNRTE")) { try { MPacket trkpt = received.fromString(); // $PMGNRTE,14,2,c,1,T01P03,a,T01P04,a*35 - message 2 of 14, "c" means this is route, route name "1", "m" means it is route message // a a - means default icon string routeName = ""; try { string sCount = (string)trkpt.fields[0]; string sPtr = (string)trkpt.fields[1]; string type = (string)trkpt.fields[2]; routeName = (string)trkpt.fields[3]; if("c".Equals(type)) { for(int j=4; j < trkpt.fields.Count ;j++) { string name = (string)trkpt.fields[j]; if(name != null && name.Length > 0) { //m_linkLayer.log("GetRoutes: name=" + name); namesBuffer.Add(name); nameRoutesBuffer.Add(routeName); total++; } } } } catch(Exception e) { m_linkLayer.logError("exception parsing PMGNRTE: " + e.Message); } if((total % 3) == 0) { progressCallback("IP: uploading route: " + routeName + " to PC\n\nleg ", total, toReceive); } errors = maxErrors; } catch(Exception ee) { m_linkLayer.logError("GetRoutes: " + ee.Message); } } else if(received.header.Equals("PMGNCMD")) { m_linkLayer.log("GetRoutes: end of routes received, count=" + total + " " + received + " names: " + namesBuffer.Count); finished = true; break; } else { m_linkLayer.log("GetRoutes: good other packet received, count=" + total + " content=" + received); } } // end while() if(namesBuffer.Count == 0) { if(Project.gpsMagellanHandshake) { m_linkLayer.SetTransferMode(false); } progressCallback("Error: no routes in GPS", -1, -1); return; } //Thread.Sleep(3000); // let magellan messages die down // now get all waypoints into a separate array, so that we can relate incoming route points to waypoints: wptBuffer.Clear(); gettingRoute = true; GetWaypoints(new GpsInsertWaypoint(bufferWaypoint), progressCallback); gettingRoute = false; m_linkLayer.log("GetRoutes: waypoints received, count=" + wptBuffer.Count); if(wptBuffer.Count == 0) { progressCallback("Error: no waypoints in GPS to define a valid route", -1, -1); return; } // now relate list of names that came with routes to list of waypoints. // we need to insert waypoints within the route in the same order as the names came from GPS, with time growing: string nameRoutePrev = ""; for(int i=0; i < namesBuffer.Count; i++) { string name = (string)namesBuffer[i]; string nameRoute = (string)nameRoutesBuffer[i]; if(!nameRoute.Equals(nameRoutePrev)) { Project.trackId++; string routeName = "MGN-ROUTE-" + nameRoute; // + "-" + Project.trackId; CreateInfo createInfo = new CreateInfo(); createInfo.init("rte"); createInfo.id = Project.trackId; // track id createInfo.source = source; createInfo.name = routeName; insertWaypoint(createInfo); // actually inserts a Track (route) nameRoutePrev = nameRoute; } // find corresponding waypoint in the big buffer: bool wptFound = false; string nameL = name.ToLower(); for(int j=0; j < wptBuffer.Count; j++) { CreateInfo createInfo = (CreateInfo)wptBuffer[j]; string infosName = ("" + createInfo.name).Trim(); string infosDetail = createInfo.desc; string infosNameL = infosName.ToLower(); if(infosNameL.Equals(nameL) || infosNameL.StartsWith(nameL + " ")) { wptFound = true; m_dt = m_dt.AddSeconds(1); // grow time createInfo.dateTime = m_dt; if(infosDetail != null && infosDetail.Length > 0 && infosDetail.Equals(infosName)) { createInfo.name = infosName; } if(createInfo.name.StartsWith("T") && createInfo.name.Substring(1,1).IndexOfAny(digits) == 0) { int ppos = createInfo.name.IndexOf("P"); if(ppos == 2 || ppos == 3 && createInfo.name.Substring(2,1).IndexOfAny(digits) == 0) { string toReplace = createInfo.name.Substring(0, ppos + 1); createInfo.name = createInfo.name.Replace(toReplace,""); } } createInfo.id = Project.trackId; insertWaypoint(new CreateInfo(createInfo)); //wptBuffer.RemoveAt(j); break; } } if(!wptFound) { m_linkLayer.logError("name='" + name + "' route='" + nameRoute + "' could not be related"); } #if DEBUG else { m_linkLayer.log("name='" + name + "' route='" + nameRoute + "' related ok"); } #endif } wptBuffer.Clear(); namesBuffer.Clear(); nameRoutesBuffer.Clear(); progressCallback("loaded OK", total, total); m_linkLayer.log("GetRoutes: loaded OK count=" + total + " trackpoints"); }
public Track(CreateInfo createInfo) { m_name = createInfo.name; m_id = createInfo.id; m_type = createInfo.type; // "trk" or "rte" m_isRoute = "rte".Equals(m_type); m_comment = m_name; if(m_isRoute) { try { m_routeNumber = Convert.ToInt32(createInfo.par1); } catch {} if(m_routeNumber < 1) { m_routeNumber = 1; } if(m_routeNumber > 20) { m_routeNumber = 20; } } else { m_url = createInfo.url; } m_source = createInfo.source; if(createInfo.par1 != null && createInfo.par1.Length == 6) // have <topografix:color>98fb98<topografix:color> tag or something? { try { int argb = Convert.ToInt32(("0xff" + createInfo.par1).ToLower(), 16); setColor(Color.FromArgb(argb)); } catch {} } brushFont = Project.trackFontBrush; brushBackground = Project.trackBackgroundBrush; penUnderline = Project.trackPen; }
/// <summary> /// for tracks only /// </summary> /// <returns></returns> public Track toRoute() { if(!this.isRoute) { CreateInfo createInfo = new CreateInfo(); createInfo.init("rte"); Project.trackId++; createInfo.id = Project.trackId; createInfo.name = "From " + this.Name; createInfo.source = "From " + m_source; Track route = new Track(createInfo); int step = (int)Math.Ceiling((double)m_trackpoints.Count / (double)Project.gpsMaxPointsPerRoute); if(step <= 0) { step = 1; } int iLast = 0; for(int i=0; i < m_trackpoints.Count && route.Trackpoints.Count < Project.gpsMaxPointsPerRoute - 1 ;i+=step) { Waypoint wpt = (Waypoint)m_trackpoints.GetByIndex(i); if(wpt.ThumbImage != null) { i -= step - 1; // move to a trackpoint immediately after the photo point continue; } iLast = i; Waypoint wptClone = new Waypoint(wpt); wptClone.LiveObjectType = LiveObjectTypes.LiveObjectTypeRoutepoint; wptClone.TrackId = route.Id; wptClone.Source = route.Source; route.Trackpoints.Add(wptClone.DateTime, wptClone); } // we want the end of the route to be the end track point: if(iLast < m_trackpoints.Count - 1) { Waypoint wpt = (Waypoint)m_trackpoints.GetByIndex(m_trackpoints.Count - 1); Waypoint wptClone = new Waypoint(wpt); wptClone.TrackId = route.Id; wptClone.Source = route.Source; route.Trackpoints.Add(wptClone.DateTime, wptClone); } route.rebuildTrackBoundaries(); return route; } return null; }
private static bool processGcPage(string url, byte[] dataDownloaded) { bool ret = false; int lineno = 0; string line; int state = 0; string lineToSearch = "<span id=\"CacheName\">"; int pos; string cacheName = ""; ASCIIEncoding enc = new ASCIIEncoding(); string pageText = new String(enc.GetChars(dataDownloaded)); CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. StringReader stream = new StringReader(pageText); try { while((line = stream.ReadLine()) != null && state < 99) { lineno++; switch(state) { case 0: if((pos = line.IndexOf(lineToSearch)) != -1) { pos += lineToSearch.Length; int pos1 = line.IndexOf("</span>", pos); if(pos1 > pos) { cacheName = line.Substring(pos, pos1-pos).Trim(); LibSys.StatusBar.Trace("OK: cacheName='" + cacheName + "'"); state = 1; lineToSearch = "<span id=\"LatLon\""; } } break; case 1: if((pos = line.IndexOf(lineToSearch)) != -1) { pos += lineToSearch.Length; int pos1 = line.IndexOf("</span>", pos); if(pos1 > pos) { string sCacheCoords = line.Substring(pos, pos1-pos).Trim(); LibSys.StatusBar.Trace("OK: cacheCoords='" + sCacheCoords + "'"); GeoCoord loc = getCleanLocation(sCacheCoords); //LibSys.StatusBar.Trace("OK: loc='" + loc + "'"); createInfo.init("wpt"); createInfo.lat = loc.Lat; createInfo.lng = loc.Lng; createInfo.typeExtra = "geocache"; createInfo.source = url; createInfo.name = cacheName; createInfo.url = url; WaypointsCache.insertWaypoint(createInfo); WaypointsCache.isDirty = true; ret = true; // report successfully parsed page state = 99; lineToSearch = ""; } } break; } } } catch {} return ret; }
public object Clone() { CreateInfo clone = new CreateInfo(); clone.id = id; clone.type = type; clone.typeExtra = typeExtra; clone.lat = lat; clone.lng = lng; clone.elev = elev; clone.magn = magn; clone.dateTime = dateTime; clone.name = name; clone.urlName = urlName; clone.url = url; clone.desc = desc; clone.comment = comment; clone.sym = sym; clone.source = source; clone.par1 = par1; clone.node1 = node1; clone.node2 = node2; return clone; }
private static void countWaypoint(CreateInfo createInfo) { elementCount++; if(m_tab == TAB_RESULTS) { WaypointsCache.insertWaypoint(createInfo); } }
public bool SameSpot(CreateInfo other) { return other != null && other.lat == lat && other.lng == lng && other.elev == elev; }
// real-time track logging: private bool logTrack(GpsRealTimeData rtData) { bool ret = false; // only good fixes with non-null location reach here string source = "GPS-" + DateTime.Now; string trackName = "GPSLOG-" + Project.trackId; if(!trackCreated) { Project.trackId++; CreateInfo createInfo = new CreateInfo(); createInfo.init("trk"); createInfo.name = trackName; createInfo.id = Project.trackId; createInfo.source = source; totalTrkpt = 0; WaypointsCache.insertWaypoint(createInfo); // actually inserts a track trackCreated = true; WaypointsCache.isDirty = true; } // garmin sends data every second, even if it is same point. Ignore repetetions to save memory. double[] howfars = new Double[] { 0.0d, 1.0d, 10.0d, 20.0d, 50.0d, 100.0d }; double howFarMeters = howfars[trackToleranceComboBox.SelectedIndex]; GeoCoord loc = new GeoCoord(rtData.location.Lng, rtData.location.Lat, rtData.location.Elev); // tolerance 0.0001 degree = 10 meters if(trackToleranceComboBox.SelectedIndex == 0 || !loc.almostAs(lastTrackLoc, howFarMeters * 0.00001d)) // 0 means every incoming reading //if(rtData.location.Lat != lastLat || rtData.location.Lng != lastLng || rtData.location.Elev != lastElev) { CreateInfo createInfo = new CreateInfo(); createInfo.init("trkpt"); createInfo.id = Project.trackId; // relate waypoint to track createInfo.dateTime = rtData.time; // always zulu createInfo.lat = rtData.location.Lat; createInfo.lng = rtData.location.Lng; createInfo.elev = rtData.location.Elev; createInfo.source = source; //createInfo.name = "" + totalTrkpt; // track point name lastLat = rtData.location.Lat; lastLng = rtData.location.Lng; lastElev = rtData.location.Elev; totalTrkpt++; ret = true; WaypointsCache.insertWaypoint(createInfo); lastTrackLoc = loc; } return ret; }
public override bool process(string url, string filename, string source) { bool ret = true; LibSys.StatusBar.Trace("IP: FilePlainWpt:process() filename=" + filename); int wpCount = 0; int lineno = 0; try { string line; int state = 0; int numpoints = 0; CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. StreamReader stream = new StreamReader(filename); while((line = stream.ReadLine()) != null) { lineno++; try { switch(state) { case 0: // look for [WAYPOINTS] if(line.StartsWith("[WAYPOINTS]")) { state = 2; //LibSys.StatusBar.Trace("IP: FilePlainWpt:process() state 2 filename=" + filename); } if(line.StartsWith("[ROUTES]")) { state = 3; //LibSys.StatusBar.Trace("IP: FilePlainWpt:process() state 3 filename=" + filename); break; } break; case 2: // look for "NUMPOINTS=" for wpts case 3: // look for "NUMPOINTS=" for routes if(line.StartsWith("NUMPOINTS=")) { state *= 2; string sNumpoints = line.Substring("NUMPOINTS=".Length); numpoints = Convert.ToInt32(sNumpoints); if(numpoints <= 0) { state = 0; } //LibSys.StatusBar.Trace("IP: FilePlainWpt:process() state " + state + " numpoints=" + numpoints + " filename=" + filename); } break; case 4: // read WPT numpoints lines like: // WPT1=1,5052.677,N,00002.217,E,0000164,M,ME164-,Cliffe Hill ,a if(line.StartsWith("WPT")) { char[] sep = new Char[1] { ',' }; string[] split = line.Split(sep); double lat = Convert.ToDouble(split[1]) / 100.0d; double lng = Convert.ToDouble(split[3]) / 100.0d; createInfo.init("wpt"); createInfo.setLat("" + lat + split[2].ToLower()); createInfo.setLng("" + lng + split[4].ToLower()); createInfo.setElev(split[5]); createInfo.typeExtra = "waypoint"; createInfo.source = source; createInfo.name = split[8]; m_insertWaypoint(createInfo); wpCount++; numpoints--; if(numpoints == 0) { state = 0; // look for command again } } break; case 6: // read ROUTE numpoints lines like: numpoints--; if(numpoints == 0) { state = 0; // look for command again } break; } } catch (Exception ee) { LibSys.StatusBar.Error("FilePlainWpt:process(): file=" + filename + " line=" + lineno + " " + ee.Message); } } } catch (Exception eee) { LibSys.StatusBar.Error("FilePlainWpt:process(): " + eee.Message); ret = false; } //LibSys.StatusBar.Trace("OK: FilePlainWpt:process() filename=" + filename + " lines=" + lineno + " waypoints=" + wpCount); return ret; }
public bool Equals(CreateInfo other) { return other != null && //other.id == id && other.type == type && other.typeExtra == typeExtra && other.lat == lat && other.lng == lng && other.elev == elev && other.magn == magn && other.dateTime == dateTime && other.name == name && other.urlName == urlName && other.url == url && other.desc == desc && other.comment == comment && other.sym == sym && other.source == source && other.par1 == par1 && other.node1 == node1 && other.node2 == node2; }
private void duatsConvertButton_Click(object sender, System.EventArgs e) { string duatsPlanTxt = duatsTextBox.Text; TextReader reader = new StringReader(duatsPlanTxt); Track route = null; int state = 0; string str; string fromName = null; string toName = null; string wptName = null; string wptDescr = null; string wptLon = null; string wptLat = null; string wptAlt = null; string wptUrl = ""; string wptFuel = null; string wptTime = null; string wptDist = null; string legFuel = null; string legTime = null; string legDist = null; int wptcnt = 0; DateTime startDate = Project.localToZulu(new DateTime(7000, 1, 1)); try { while ((str=reader.ReadLine()) != null) { switch(state) { case 0: if(str.StartsWith("From:")) { fromName = str.Substring(5); } if(str.StartsWith("To:")) { toName = str.Substring(3); state = 100; CreateInfo createInfo = new CreateInfo(); createInfo.init("rte"); Project.trackId++; createInfo.id = Project.trackId; createInfo.name = fromName + " ->> " + toName; createInfo.source = "From DUATS.COM flight plan"; route = new Track(createInfo); } break; case 100: if(str.StartsWith("---+--------+---------+-----")) { state = 110; } break; case 110: if(str.Length > 51 && str.Substring(2,1) == ".") { wptFuel = str.Substring(54).Trim(); wptName = str.Substring(4, 24).Replace("Apt.", "").Trim(); state = 120; } else { state = 900; } break; case 120: wptTime = str.Substring(54).Trim(); wptDescr = str.Substring(4, 24).Trim(); state = 130; break; case 130: { wptDist = str.Substring(54).Trim(); wptLat = str.Substring(4, 8); wptLon = str.Substring(13, 9); wptAlt = str.Substring(22, 5).Trim() + "00"; // feet //LibSys.StatusBar.Trace("lat='" + wptLat + "' lon='" + wptLon + "' alt='" + wptAlt + "'"); double altMeters = Convert.ToDouble(wptAlt) * Distance.METERS_PER_FOOT; // sPos in form: W117.23'45" N36.44'48" [or N33,27.661 W117,42.945] string sPos = "W" + wptLon.Substring(0,3).Trim() + "." + wptLon.Substring(4,2) + "'" + wptLon.Substring(7) + "\" " + "N" + wptLat.Substring(0,2).Trim() + "." + wptLat.Substring(3,2) + "'" + wptLat.Substring(6) + "\""; //LibSys.StatusBar.Trace("sPos='" + sPos + "'"); GeoCoord loc = new GeoCoord(sPos); loc.Elev = altMeters; //LibSys.StatusBar.Trace("wpt='" + loc + "'"); //DateTime wptDateTime = DateTime.Now.AddMilliseconds(wptcnt); string[] split = wptTime.Split(new Char[] { ':' }); double hours = Convert.ToDouble(split[0]); double minutes = Convert.ToDouble(split[1]); DateTime wptDateTime = startDate.AddHours(hours).AddMinutes(minutes); Waypoint wpt = new Waypoint(loc, wptDateTime, LiveObjectTypes.LiveObjectTypeRoutepoint, route.Id, wptName, route.Source, wptUrl); wpt.Desc = wptDescr + "\nFuelSpent: " + wptFuel + " TimeInFlight: " + wptTime + " DistLeft: " + wptDist; wptcnt++; route.Trackpoints.Add(wpt.DateTime, wpt); } state = 100; break; } } } catch (Exception exc) { LibSys.StatusBar.Error("Exception: " + exc); } if(route == null) { System.Windows.Forms.MessageBox.Show(this, "Error: No data to parse.\n\nPlease copy DUATS.COM generated flight plan into the text field.\n\nIt should look like this:\n\n" + m_duatsSample); } else { WaypointsCache.TracksAll.Add(route); route.rebuildTrackBoundaries(); route.PutOnMap(LayerWaypoints.This, null, LayerWaypoints.This); m_routeIdToSelect = route.Id; // refresh map and rebind the datagrid: PutOnMap(); WaypointsCache.isDirty = true; //rebuildTracksTab(); rebuildRoutesTab(); tabControl1.SelectedTab = this.routesTabPage; prevSelectedTab = this.routesTabPage; } }
// takes array of Track public static Track groupTracks(ArrayList tracks) { Project.trackId++; string tType = ((Track)tracks[0]).Type; string newTrackSource = "joined" + ("trk".Equals(tType) ? (" " + DateTime.Now) : ("-" + Project.trackId)); string newTrackName = newTrackSource; CreateInfo createInfo = new CreateInfo(); createInfo.init(tType); createInfo.id = Project.trackId; createInfo.name = newTrackName; createInfo.source = newTrackSource; Track joinedTrack = new Track(createInfo); m_tracksAll.Add(joinedTrack); DateTime dateTime = new DateTime(8888, 1, 1, 1, 1, 1, 1); // for routes, we make new time sequence foreach(Track trk in tracks) { for(int i=0; i < trk.Trackpoints.Count ;i++) { Waypoint wpt = (Waypoint)trk.Trackpoints.GetByIndex(i); Waypoint cloneWpt = new Waypoint(wpt); cloneWpt.TrackId = joinedTrack.Id; if(joinedTrack.isRoute) { cloneWpt.DateTime = dateTime; dateTime = dateTime.AddSeconds(1); cloneWpt.NameDisplayed = ""; // let it be the number or Detail } joinedTrack.insertWaypoint(cloneWpt); } } joinedTrack.rebuildTrackBoundaries(); return joinedTrack; }
public void createWaypoint(CreateInfo ci, bool keepInView) { string cmd = "api|newwpt"; cmd += "|" + ci.lat; cmd += "|" + ci.lng; cmd += "|" + ci.elev; cmd += "|" + ci.dateTime; cmd += "|" + ci.name; cmd += "|" + ci.urlName; cmd += "|" + ci.type; cmd += "|" + ci.typeExtra; cmd += "|" + ci.sym; cmd += "|" + ci.id; cmd += "|" + ci.url; cmd += "|" + ci.desc; cmd += "|" + ci.source; cmd += "|" + keepInView; CommandMappingEngine(cmd); }
// return array of track IDs or null (if track can't be ungrouped) public static ArrayList ungroupTrack(Track trk, double breakTimeMinutes) { double maxJumpMeters = 5000.0d; // for sanity filter. make sure it is big enough, as GPSV makes big gaps. DateTime lastTime = DateTime.MinValue; GeoCoord lastLoc = null; int trip = 0; int i; // first count how many trips we can break the track into: for(i=0; i < trk.Trackpoints.Count ;i++) { Waypoint wpt = (Waypoint)trk.Trackpoints.GetByIndex(i); DateTime wptTime = wpt.DateTime; if(wptTime.CompareTo(lastTime.AddMinutes(breakTimeMinutes)) > 0 || (lastLoc != null && wpt.Location.distanceFrom(lastLoc).Meters > maxJumpMeters)) { trip++; } if(trip > 0) { lastTime = wptTime; } lastLoc = wpt.Location; } if(trip < 2) { return null; } // more than one trip, go ahead break it: string[] infos = new string[8]; string newTrackSource = trk.Source; lastTime = DateTime.MinValue; lastLoc = null; trip = 0; ArrayList ret = new ArrayList(); for(i=0; i < trk.Trackpoints.Count ;i++) { Waypoint wpt = (Waypoint)trk.Trackpoints.GetByIndex(i); DateTime wptTime = wpt.DateTime; if(wptTime.CompareTo(lastTime.AddMinutes(breakTimeMinutes)) > 0 || (lastLoc != null && wpt.Location.distanceFrom(lastLoc).Meters > maxJumpMeters)) { Project.trackId++; trip++; string newTrackName = trk.Name + "-trip-" + trip; CreateInfo createInfo = new CreateInfo(); createInfo.init(trk.Type); createInfo.id = Project.trackId; createInfo.name = newTrackName; createInfo.source = newTrackSource; createInfo.url = trk.Url; currentTrack = new Track(createInfo); m_tracksAll.Add(currentTrack); ret.Add(Project.trackId); } if(trip > 0) { Waypoint cloneWpt = new Waypoint(wpt); cloneWpt.TrackId = Project.trackId; currentTrack.insertWaypoint(cloneWpt); lastTime = wptTime; } lastLoc = wpt.Location; } // make sure the speed and odometer values are computed: foreach(long trackId in ret) { Track ttrk = getTrackById(trackId); ttrk.rebuildTrackBoundaries(); } // now apply Sanity Filter: if(Project.sanityFilter) { ArrayList ret1 = new ArrayList(); foreach(long trackId in ret) { Track ttrk = getTrackById(trackId); if(ttrk.Trackpoints.Count >= 5 && ttrk.Odometer > 10.0f) // odometer in meters, eliminates standing points { ret1.Add(trackId); } else { RemoveTrackById(trackId); } } if(ret1.Count < 2) { //return null; } ret = ret1; } if(ret != null) { isDirty = true; } return ret; }
/// <summary> /// delete waypoint by one of: name, urlName, source /// </summary> /// <param name="ci"></param> /// <returns></returns> public void deleteWaypoint(CreateInfo ci) { string cmd = "api|delwpt"; cmd += "|" + ci.name; cmd += "|" + ci.urlName; cmd += "|" + ci.source; CommandMappingEngine(cmd); }
public override bool process(string url, string filename, string source) { bool ret = true; OleDbConnection con = null; LibSys.StatusBar.Trace("IP: processing MDB file: " + filename); try { con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;data source=" + filename + ""); con.Open(); //connection must be opened DataTable dt = con.GetSchema("Tables"); DataRow row = dt.Select("TABLE_TYPE='TABLE'")[0]; string tableName = row["TABLE_NAME"].ToString(); OleDbCommand cmd = new OleDbCommand("SELECT * from [" + tableName + "]", con); // creating query command OleDbDataReader reader = cmd.ExecuteReader(); // executes query int i = 0; int errCnt = 0; while (reader.Read()) // if can read row from database { try { SectionRow sr = new SectionRow() { RECRD = (int)reader.GetValue(0), VESSLTERMS = reader.GetValue(1).ToString(), CHART = reader.GetValue(2).ToString(), AREA = reader.GetValue(3).ToString(), CARTOCODE = reader.GetValue(4).ToString(), SNDINGCODE = reader.GetValue(5).ToString(), DEPTH = reader.GetValue(6).ToString(), NATIVLAT = reader.GetValue(7).ToString(), NATIVLON = reader.GetValue(8).ToString(), LAT83 = reader.GetValue(9).ToString(), LONG83 = reader.GetValue(10).ToString(), LATDEC = (double)reader.GetValue(11), LONDEC = -(double)reader.GetValue(12), NATIVDATUM = reader.GetValue(13).ToString(), CONVERT83 = reader.GetValue(14).ToString(), GPACCURACY = reader.GetValue(15).ToString(), GPQUALITY = reader.GetValue(16).ToString(), GPSOURCE = reader.GetValue(17).ToString(), QUADRANT = reader.GetValue(18).ToString(), History = reader.GetValue(19).ToString(), REFERENCE = reader.GetValue(20).ToString(), YEARSUNK = reader.GetValue(21).ToString() }; CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. createInfo.init("wpt"); createInfo.name = (sr.VESSLTERMS + " " + sr.DEPTH).Trim(); createInfo.desc = sr.YEARSUNK; createInfo.lat = sr.LATDEC; createInfo.lng = sr.LONDEC; createInfo.typeExtra = "unknown"; // type: ppl, school, park, locale, airport, reservoir, dam, civil, cemetery, valley, building createInfo.source = source; createInfo.comment = sr.History.Replace(". ", ".\r\n") + ";\r\n" + sr.REFERENCE; m_insertWaypoint(createInfo); } catch (Exception excr) { errCnt++; } i++; } LibSys.StatusBar.Trace("OK: MDB file: '" + filename + "' processed; found table[" + tableName + "] records/waypoints count=" + i + " errors count=" + errCnt); } catch (Exception e) { LibSys.StatusBar.Error("FileAwoisMdb process() " + e.Message); ret = false; } finally { if (con != null) { con.Close(); } } return ret; }
/// <summary> /// full constructor for InsertWaypoint type of action /// </summary> /// <param name="createInfo"></param> public Waypoint(CreateInfo createInfo) { m_id = nextWaypointId++; m_dateTime = createInfo.dateTime; m_location = new GeoCoord(createInfo.lng, createInfo.lat, createInfo.elev); if(createInfo.typeExtra == null) { switch(createInfo.type) // null, "wpt", "rtept", "trkpt", "geocache", "earthquake" { default: case "earthquake": case "wpt": LiveObjectType = LiveObjectTypes.LiveObjectTypeWaypoint; break; case "geocache": LiveObjectType = LiveObjectTypes.LiveObjectTypeGeocache; break; case "rtept": LiveObjectType = LiveObjectTypes.LiveObjectTypeRoutepoint; break; case "trkpt": LiveObjectType = LiveObjectTypes.LiveObjectTypeTrackpoint; break; } } else { string typeExtra = createInfo.typeExtra.ToLower().Trim(); // can be "geocache found" or "geocache|traditional cache|found" if(typeExtra.IndexOf("geocache") != -1) { LiveObjectType = LiveObjectTypes.LiveObjectTypeGeocache; } else { switch(createInfo.type) // null, "wpt", "rtept", "trkpt" { default: case "wpt": LiveObjectType = LiveObjectTypes.LiveObjectTypeWaypoint; break; case "rtept": LiveObjectType = LiveObjectTypes.LiveObjectTypeRoutepoint; break; case "trkpt": LiveObjectType = LiveObjectTypes.LiveObjectTypeTrackpoint; break; } } if(typeExtra.IndexOf("found") != -1) { m_found = true; } m_wptType = createInfo.typeExtra.Trim(); } m_sym = createInfo.sym == null ? "" : createInfo.sym; m_desc = createInfo.desc == null ? "" : createInfo.desc; m_wptName = createInfo.name == null ? "" : createInfo.name; m_comment = createInfo.comment == null ? "" : createInfo.comment; m_trackId = createInfo.id; m_url = createInfo.url == null ? "" : createInfo.url; m_wptGuid = extractGuid(createInfo.url); // pocket queries have GUID-based URLs, get guid for Tools sring m_urlName = createInfo.urlName == null ? "" : createInfo.urlName; m_source = createInfo.source == null ? "" : createInfo.source; if(createInfo.node1 != null) { groundspeakCache = new GroundspeakCache(createInfo.node1); } Name = getLabel(false); setBrushes(); }
public override bool process(string url, string filename, string source) { bool ret = true; LibSys.StatusBar.Trace("IP: FileStreetsTripsCsv:process() filename=" + filename); int wpCount = 0; int lineno = 0; try { string line; int state = 0; double zoneShift = 0.0d; CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. StreamReader stream = new StreamReader(filename); while((line = stream.ReadLine()) != null) { lineno++; try { switch(state) { case 0: // look for "Name,Latitude,Longitude,Name 2,URL,Type" // Name,Latitude,Longitude,Name 2,URL,Type if(line.StartsWith("Name,Latitude,Longitude")) { state = 1; //LibSys.StatusBar.Trace("IP: FileStreetsTripsCsv:process() state 1 filename=" + filename); } break; case 1: // read WPT numpoints lines like: // Active Pass Lighthouse,48.873472,-123.290139,"","","" char[] sep = new Char[1] { ',' }; string[] split = line.Split(sep); if(split.Length < 3) { // possible empty line or something. Reset to searcing for header again. state = 0; break; } string name = stripQuotes(split[0]); double lat = ParseCoord(split[1]); double lng = ParseCoord(split[2]); string name2 = split.Length > 3 ? stripQuotes(split[3]) : null; string wurl = split.Length > 4 ? stripQuotes(split[4]) : null; string type = split.Length > 5 ? stripQuotes(split[5]) : null; double elev = split.Length > 6 ? ParseCoord(split[6]) : 0.0d; string desc = split.Length > 7 ? stripQuotes(split[7]) : null; string stime = split.Length > 8 ? stripQuotes(split[8]) : null; string track = split.Length > 9 ? stripQuotes(split[9]) : null; string speed = split.Length > 10 ? stripQuotes(split[10]) : null; string odometer = split.Length > 11 ? stripQuotes(split[11]) : null; bool found = split.Length > 12 ? ("true".Equals(stripQuotes(split[12]).ToLower()) || "yes".Equals(stripQuotes(split[12]).ToLower())) : false; string strLiveObjectType = "wpt"; switch(type) { case "geocache": strLiveObjectType = type; break; case "trkpt": case "rtept": if(desc == null && track != null) { desc = track; } if(name == null && name2 == null && stime != null) { name2 = stime; } strLiveObjectType = type; break; } createInfo.init(strLiveObjectType); createInfo.lat = lat; createInfo.lng = lng; createInfo.elev = elev; if(name2 != null) { createInfo.urlName = name2; } if(desc != null) { createInfo.desc = desc; } if(wurl != null) { createInfo.url = wurl; } if(name != null) { createInfo.name = name; } if(type != null) { createInfo.typeExtra = type; } if(stime != null && stime.Length >= 4) { try { createInfo.dateTime = Convert.ToDateTime(stime); } catch {} } createInfo.source = source; m_insertWaypoint(createInfo); wpCount++; break; } } catch (Exception ee) { LibSys.StatusBar.Error("FileStreetsTripsCsv:process(): file=" + filename + " line=" + lineno + " " + ee.Message); } } } catch (Exception eee) { LibSys.StatusBar.Error("FileStreetsTripsCsv:process(): " + eee.Message); ret = false; } //LibSys.StatusBar.Trace("OK: FileStreetsTripsCsv:process() filename=" + filename + " lines=" + lineno + " waypoints=" + wpCount); return ret; }
public override bool process(string url, string filename, string source) { bool ret = true; LibSys.StatusBar.Trace("IP: FileNmeaLog:process() filename=" + filename); int wpCount = 0; int lineno = 0; int packetsCount = 0; Cursor.Current = Cursors.WaitCursor; try { string line; double zoneShift = 0.0d; NmeaPacketReceived packetIn = null; CreateInfo createInfo = new CreateInfo(); // we will recycle it in place, filling every time. double lat = 0.0d; double lng = 0.0d; // we allow elev and dateTime to stay in the cycle and be promoted/inherited to points that do not have this data in NMEA sentence. double elev = 0.0d; // alt above mean sea level DateTime dateTime = DateTime.Now; StreamReader stream = new StreamReader(filename); while ((line = stream.ReadLine()) != null) { lineno++; // we are in a VERY long cycle here, need to make sure Windows events and memory are managed Application.DoEvents(); if (lineno % 1000 == 0) { GC.Collect(); } line = line.Trim(); if (string.IsNullOrEmpty(line)) { continue; } try { // first see if that was a proprietary, non-NMEA packet: if (line.IndexOf("*") < 0) { LibSys.StatusBar.Trace("proprietary packet: " + line); if (packetIn != null && packetIn.isGood) { LibSys.StatusBar.Trace("last good NMEA packet: " + packetIn); } if (line.StartsWith("$ADVER,")) { Project.trackId++; createInfo.init("trk"); createInfo.id = Project.trackId; createInfo.source = source; createInfo.name = "GPS NMEA Log"; insertWaypoint(createInfo); } } else { packetIn = new NmeaPacketReceived(); packetIn.isGood = false; packetIn.m_string = line; if (!NmeaPacket.checksumVerify(packetIn.m_string)) { packetIn.isGood = false; LibSys.StatusBar.Error("bad checksum, line " + lineno + " bad packet: " + line); } else { packetIn.isGood = packetIn.basicParse(packetIn.m_string); // packet is good and parsed, so the fields array is filled //LibSys.StatusBar.Trace("NMEA packet: " + packetIn); if (packetIn.header.EndsWith("GGA")) // NMEA GGA expected for location { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); try { NmeaPacket pvt = packetIn.fromString(); /* $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 Where: GGA Global Positioning System Fix Data 0 123519 Fix taken at 12:35:19 UTC 1 4807.038,N Latitude 48 deg 07.038' N 3 01131.000,E Longitude 11 deg 31.000' E 5 1 Fix quality: 0 = invalid 1 = GPS fix 2 = DGPS fix 6 = estimated (2.3 feature) 6 08 Number of satellites being tracked 7 0.9 Horizontal dilution of position 8 545.4,M Altitude, Meters, above mean sea level 10 46.9,M Height of geoid (mean sea level) above WGS84 ellipsoid 12 (empty field) time in seconds since last DGPS update 13 (empty field) DGPS station ID number *47 the checksum data, always begins with * */ lat = pvt.parseLat(1); lng = pvt.parseLng(1); elev = pvt.parseElev(8); // alt above mean sea level // time component (don't know the date): dateTime = pvt.parseNmeaTime(0, dateTime); // UTC dateTime = dateTime.AddHours(-zoneShift); // errors and velocity: double posError = 0; double posErrorH = 0; double posErrorV = 0; double fix = 0; // failed integrity check switch ((string)pvt.fields[5]) { case "0": // invalid fix = 1; // invalid break; case "1": // GPS fix fix = 2; // two dimensional break; case "2": // DGPS fix fix = 4; // two dimensional differential break; case "6": // estimated fix = 6; // estimated break; } string comment = "received " + packetIn.header; //realtimeCallback(pvtData); createInfo.init("trkpt"); createInfo.id = Project.trackId; // relate waypoint to track createInfo.dateTime = dateTime; createInfo.lat = lat; createInfo.lng = lng; createInfo.elev = elev; createInfo.source = source; insertWaypoint(createInfo); wpCount++; packetsCount++; } catch (Exception ee) { LibSys.StatusBar.Error("StartRealTime: " + ee.Message); } } else if (packetIn.header.EndsWith("RMC")) // NMEA RMC may come { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); try { NmeaPacket pvt = packetIn.fromString(); // $GPRMC,052458.73,V,3334.6441,N,11739.6622,W,00.0,000.0,290103,13,E*4F /* * see http://www.gpsinformation.org/dale/nmea.htm for NMEA reference * RMC - NMEA has its own version of essential gps pvt (position, velocity, time) data. It is called RMC, The Recommended Minimum, which might look like: $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A $GPRMC,050821.000,A,3334.5551,N,11739.7705,W,0.00,,251006,,,A*67 Where: RMC Recommended Minimum sentence C 0 123519 Fix taken at 12:35:19 UTC 1 A Status A=active or V=Void. 2 4807.038,N Latitude 48 deg 07.038' N 4 01131.000,E Longitude 11 deg 31.000' E 6 022.4 Speed over the ground in knots 7 084.4 Track angle in degrees True 8 230394 Date - 23rd of March 1994 9 003.1,W Magnetic Variation *6A The checksum data, always begins with * Note that, as of the 2.3 release of NMEA, there is a new field in the RMC sentence at the end just prior to the checksum. The value of the entry is A=autonomous, D=differential, E=estimated, N=Data not valid. */ bool status = "A".Equals(pvt.fields[1]); if (status) { lat = pvt.parseLat(2); lng = pvt.parseLng(2); //double elev = 0.0d; // inherit elevation from a GGA //LibSys.StatusBar.Trace("coord=" + pvtData.location); // time component (only time part): dateTime = pvt.parseNmeaDateTime(0, 8); // UTC dateTime = dateTime.AddHours(-zoneShift); //if (!"".Equals(pvt.fields[6])) //{ // double knots = Convert.ToDouble(pvt.fields[6]); // pvtData.velocity = knots * Distance.METERS_PER_NAUTICAL_MILE / 3600.0d; // // calculate velocity vector based on track angle: // if (!"".Equals(pvt.fields[7])) // { // double trackAngleRad = Convert.ToDouble(pvt.fields[7]) * Math.PI / 180.0d; // pvtData.velocityNorth = pvtData.velocity * Math.Cos(trackAngleRad); // pvtData.velocityEast = pvtData.velocity * Math.Sin(trackAngleRad); // } //} //pvtData.fix = 2; // assume two-dimensional //pvtData.comment = "received " + received.header; createInfo.init("trkpt"); createInfo.id = Project.trackId; // relate waypoint to track createInfo.dateTime = dateTime; createInfo.lat = lat; createInfo.lng = lng; createInfo.elev = elev; createInfo.source = source; insertWaypoint(createInfo); wpCount++; } packetsCount++; } catch (Exception ee) { LibSys.StatusBar.Error("StartRealTime: " + ee.Message); } } else if (packetIn.header.EndsWith("WPL")) // NMEA WPL may come as a result of manually marking a location { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); try { NmeaPacket pvt = packetIn.fromString(); // $GPWPL,3334.7038,N,11739.7796,W,00001*61 /* see http://www.gpsinformation.org/dale/nmea.htm for NMEA reference WPL - Waypoint Location data provides essential waypoint data. It is output when navigating to indicate data about the destination and is sometimes supported on input to redefine a waypoint location. Note that waypoint data as defined in the standard does not define altitude, comments, or icon data. When a route is active, this sentence is sent once for each waypoint in the route, in sequence. When all waypoints have been reported, the RTE sentence is sent in the next data set. In any group of sentences, only one WPL sentence, or an RTE sentence, will be sent. $GPWPL,4807.038,N,01131.000,E,WPTNME*5C With an interpretation of: WPL Waypoint Location 0 4807.038,N Latitude 1 01131.000,E Longitude 2 WPTNME Waypoint Name *5C The checksum data, always begins with * */ lat = pvt.parseLat(0); lng = pvt.parseLng(0); //elev = 0.0d; // inherit elevation //LibSys.StatusBar.Trace("coord=" + pvtData.location); createInfo.init("wpt"); createInfo.lat = lat; createInfo.lng = lng; createInfo.elev = elev; createInfo.dateTime = dateTime; createInfo.name = "" + pvt.fields[4]; createInfo.source = source; insertWaypoint(createInfo); wpCount++; packetsCount++; } catch (Exception ee) { LibSys.StatusBar.Error("StartRealTime: " + ee.Message); } } //else if (packetIn.header.EndsWith("GLL")) // NMEA GLL may come //{ // LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); // try // { // NmeaPacket pvt = packetIn.fromString(); // // $GPGLL,3334.6464,N,11739.6583,W,052707.129,A*29 // /* // * see http://www.gpsinformation.org/dale/nmea.htm for NMEA reference // * // GLL - Geographic Latitude and Longitude is a holdover from Loran data and some old units // may not send the time and data valid information if they are emulating Loran data. // If a gps is emulating Loran data they may use the LC Loran prefix instead of GP. // $GPGLL,4916.45,N,12311.12,W,225444,A,*31 // Where: // GLL Geographic position, Latitude and Longitude // 0 4916.46,N Latitude 49 deg. 16.45 min. North // 2 12311.12,W Longitude 123 deg. 11.12 min. West // 4 225444 Fix taken at 22:54:44 UTC // 5 A Data valid or V (void) // *31 checksum data // */ // bool status = "A".Equals(pvt.fields[5]); // if (status) // { // double lat = pvt.parseLat(0); // double lng = pvt.parseLng(0); // double elev = 0.0d; // // time component (only time part): // //pvtData.time = pvt.parseNmeaTime(4); // UTC // //pvtData.fix = 2; // assume two-dimensional // //pvtData.comment = "received " + received.header; // createInfo.init("trkpt"); // createInfo.id = Project.trackId; // relate waypoint to track // //createInfo.dateTime = dateTime; // createInfo.lat = lat; // createInfo.lng = lng; // createInfo.elev = elev; // createInfo.source = source; // insertWaypoint(createInfo); // wpCount++; // } // packetsCount++; // } // catch (Exception ee) // { // LibSys.StatusBar.Error("StartRealTime: " + ee.Message); // } //} else if (packetIn.header.EndsWith("GSV")) // NMEA GSV may come for satellite reception status { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); // /* // * see http://www.gpsinformation.org/dale/nmea.htm for NMEA reference // * // $GPGSV,3,1,08,14,69,204,,15,57,105,36,18,45,047,36,03,42,263,36*71 // $GPGSV,2,1,08,01,40,083,46,02,17,308,41,12,07,344,39,14,22,228,45*75 // Where: // GSV Satellites in view // 0 2 Number of sentences for full data // 1 1 sentence 1 of 2 // 2 08 Number of satellites in view // for up to 4 satellites per sentence { // 3 01 Satellite PRN number // 4 40 Elevation, degrees // 5 083 Azimuth, degrees // 6 46 Signal strength - higher is better // } // *75 the checksum data, always begins with * // */ // //MPacket pvt = received.fromString(); // //pvtData.comment = "received"; // //realtimeCallback(pvtData); packetsCount++; } else if (packetIn.header.EndsWith("VTG")) // NMEA GSA may come { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); // $GPVTG,309.62,T,,M,0.13,N,0.2,K*6E /* VTG - Course Over Ground and Ground Speed Name Example Units Description Message ID $GPVTG VTG protocol header Course 309.62 degrees Measured heading Reference T True Course degrees Measured heading Reference M Magnetic Speed 0.13 knots Measured horizontal speed Units N Knots Speed 0.2 Km/hr Measured horizontal speed Units K Kilometers per hour */ packetsCount++; } else if (packetIn.header.EndsWith("GSA")) // NMEA GSA may come { //LibSys.StatusBar.Trace("process: " + packetIn.header + " packet, count=" + packetsCount + " content=" + packetIn); // $GPGSA,A,2,15,18,14,31,,,,,,,,,05.6,05.6,*17 /* * see http://www.gpsinformation.org/dale/nmea.htm for NMEA reference * GSA - GPS DOP and active satellites. This sentence provides details on the nature of the fix. It includes the numbers of the satellites being used in the current solution and the DOP. DOP (dilution of precision) is an indication of the effect of satellite geometry on the accuracy of the fix. It is a unitless number where smaller is better. For 3D fixes using 4 satellites a 1.0 would be considered to be a perfect number. For overdetermined solutions it is possible to see numbers below 1.0. There are differences in the way the PRN's are presented which can effect the ability of some programs to display this data. For example, in the example shown below there are 5 satellites in the solution and the null fields are scattered indicating that the almanac would show satellites in the null positions that are not being used as part of this solution. Other receivers might output all of the satellites used at the beginning of the sentence with the null field all stacked up at the end. This difference accounts for some satellite display programs not always being able to display the satellites being tracked. $GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39 Where: GSA Satellite status A Auto selection of 2D or 3D fix (M = manual) 3 3D fix - other values include: 1 = no fix 2 = 2D fix 04,05... PRNs of satellites used for fix (space for 12) 2.5 PDOP (dilution of precision) 1.3 Horizontal dilution of precision (HDOP) 2.1 Vertical dilution of precision (VDOP) *39 the checksum data, always begins with * */ packetsCount++; } else { LibSys.StatusBar.Trace("StartRealTime: good other (unrecognized) packet received, count=" + packetsCount + " content=" + packetIn); } } } } catch (Exception ee) { LibSys.StatusBar.Error("FileNmeaLog:process(): file=" + filename + " line=" + lineno + " " + ee.Message); } } } catch (Exception eee) { LibSys.StatusBar.Error("FileNmeaLog:process(): " + eee.Message); ret = false; } finally { Cursor.Current = Cursors.Default; Application.DoEvents(); } LibSys.StatusBar.Trace("OK: FileNmeaLog:process() filename=" + filename + " lines=" + lineno + ", packets=" + packetsCount + " waypoints=" + wpCount); return ret; }