/// <summary> /// rebuild gpxFile from Map Layers /// </summary> /// <param name="oLayerGPXPolylines"></param> /// <param name="oLayerGPXSymbols"></param> /// <returns></returns> public static GPXFile makeGPXfromMapLayers(LayerVectors oLayerGPXPolylines, LayerVectors oLayerGPXSymbols) { GPXFile gpxFile = new GPXFile(); GPXTrk trk = new GPXTrk(); gpxFile.trks.Add(trk); for (int i = 0; i < oLayerGPXPolylines.FeaturesCount; i++) { GPXTrkSeg seg = new GPXTrkSeg(); Feature f = oLayerGPXPolylines.FeatureGet(i); if (f is PolylineFeature) { PolylineFeature oPolyline = (PolylineFeature)f; for (int ipart = 0; ipart < oPolyline.m_oParts.Count; ipart++) { Part part = oPolyline.m_oParts[ipart]; for (int ipoint = 0; ipoint < part.Points.Count; ipoint++) { DPoint layerPoint = part.Points[ipoint]; SymbolFeature symbol = (SymbolFeature)layerPoint.Tag; double lon = layerPoint.X; double lat = layerPoint.Y; double ele = (double)symbol.getField("ele"); DateTime time = (DateTime)symbol.getField("time"); GpxWpt wpt = new GpxWpt(lon, lat, ele, time, -99); wpt.selected = layerPoint.Selected; seg.wpts.Add(wpt); } } } if (seg.wpts.Count > 0) { trk.trkSeg.Add(seg); } } return gpxFile; }
private static void DecodeGPX11(GPXFile gpxFile, XmlDocument oDoc) { XmlNamespaceManager manager = new XmlNamespaceManager(oDoc.NameTable); manager.AddNamespace("oo", "http://www.topografix.com/GPX/1/1"); XmlNodeList oTracks = oDoc.SelectNodes("oo:gpx/oo:trk", manager); foreach (XmlNode xmltrk in oTracks) { GPXTrk gpxtrk = new GPXTrk(); gpxtrk.parent = gpxFile; gpxFile.trks.Add(gpxtrk); XmlNode nameNode = xmltrk.SelectSingleNode("oo:name", manager); if (nameNode != null) gpxtrk.name = nameNode.InnerText; XmlNode cmtNode = xmltrk.SelectSingleNode("oo:cmt", manager); if (cmtNode != null) gpxtrk.cmt = cmtNode.InnerText; XmlNode descNode = xmltrk.SelectSingleNode("oo:desc", manager); if (descNode != null) gpxtrk.desc = descNode.InnerText; XmlNodeList oTrkSeg = xmltrk.SelectNodes("oo:trkseg", manager); foreach (XmlNode xmlseg in oTrkSeg) { GPXTrkSeg gpxseg = new GPXTrkSeg(); gpxseg.parent = gpxtrk; gpxtrk.trkSeg.Add(gpxseg); XmlNodeList oTrackPoints = xmlseg.SelectNodes("oo:trkpt", manager); foreach (XmlNode oTrkPt in oTrackPoints) { string sLat = oTrkPt.Attributes.GetNamedItem("lat").Value; string sLon = oTrkPt.Attributes.GetNamedItem("lon").Value; string sTime = ""; XmlNode nodeTime = oTrkPt.SelectSingleNode("oo:time", manager); if (nodeTime != null) { sTime = nodeTime.InnerText; } XmlNode oN = oTrkPt.SelectSingleNode("oo:ele", manager); string sEle = "-9999"; if (oN != null) { sEle = oN.InnerText; } string sSpeed = "0"; oN = oTrkPt.SelectSingleNode("oo:speed", manager); if (oN != null) { sSpeed = oN.InnerText; } double dLat = Convert.ToDouble(sLat, CultureInfo.InvariantCulture); double dLon = Convert.ToDouble(sLon, CultureInfo.InvariantCulture); DateTime dDTime; DateTime dDTime_utc; if (sTime != "") { //DateTime t1 = DateTime.Parse("2009-07-05T09:06:07Z", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); //DateTime t2 = DateTime.Parse("2009-07-05T09:06:07", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); dDTime = DateTime.Parse(sTime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); dDTime_utc = dDTime.ToUniversalTime(); } else { dDTime = DateTime.MinValue; dDTime_utc = DateTime.MinValue; } double dEle = Convert.ToDouble(sEle, CultureInfo.InvariantCulture); double dSpeed = Convert.ToDouble(sSpeed, CultureInfo.InvariantCulture); GpxWpt wpt = new GpxWpt(dLon, dLat, dEle, dDTime_utc, dSpeed); wpt.parent = gpxseg; gpxseg.wpts.Add(wpt); } } } return; }
void selectSeg(GPXTrkSeg seg) { seg.selected = true; foreach (GpxWpt wpt in seg.wpts) { wpt.selected = true; } }