private void AddWayPointXmlNode(XmlDocument doc, XmlNode parent, SoundscapeWayPoint waypoint) { XmlNode waypointNode = doc.CreateElement(waypointNodeName); XmlAttribute latattribute = doc.CreateAttribute("lat"); latattribute.Value = waypoint.Latitude.ToString(); XmlAttribute lonattribute = doc.CreateAttribute("lon"); lonattribute.Value = waypoint.Longitude.ToString(); waypointNode.Attributes.Append(latattribute); waypointNode.Attributes.Append(lonattribute); XmlNode nameNode = doc.CreateElement("name"); nameNode.InnerText = waypoint.Name; waypointNode.AppendChild(nameNode); XmlNode descNode = doc.CreateElement("desc"); descNode.InnerText = waypoint.Description; waypointNode.AppendChild(descNode); XmlNode typeNode = doc.CreateElement("type"); typeNode.InnerText = waypoint.Type; waypointNode.AppendChild(typeNode); XmlNode elevationNode = doc.CreateElement("ele"); elevationNode.InnerText = waypoint.Elevation.ToString(); waypointNode.AppendChild(elevationNode); XmlNode extensionsNode = doc.CreateElement("extensions"); XmlNode annotationsNode = doc.CreateElement("annotations"); XmlNode annotationNode = doc.CreateElement("annotations"); annotationNode.InnerText = waypoint.Description; XmlAttribute annotationTitle = doc.CreateAttribute("Title"); annotationTitle.Value = waypoint.Name; annotationNode.Attributes.Append(annotationTitle); XmlNode poiNode = doc.CreateElement("poi"); XmlNode streetNode = doc.CreateElement("street"); streetNode.InnerText = waypoint.Street; waypointNode.AppendChild(extensionsNode); annotationsNode.AppendChild(annotationNode); extensionsNode.AppendChild(annotationsNode); extensionsNode.AppendChild(poiNode); poiNode.AppendChild(streetNode); parent.AppendChild(waypointNode); }
private static void WriteSoundscapeXmlTest() { var point1 = new SoundscapeWayPoint { Name = "Cemetry Junction", Description = "A junction between two large roads in Reading, the name references the large cemetery whose entrance is at this junction", Type = "WayPoint", Latitude = 51.452833, // lat Longitude = -0.948861, // long Elevation = 9, Street = "Cemetery Junction, Reading" }; var point2 = new SoundscapeWayPoint { Name = "North end of Donnington Road", Description = "North end of Donnington Road", Type = "WayPoint", Latitude = 51.452405, // lat Longitude = -0.952123, // long Elevation = 9, Street = "North end of Donnington Road" }; SoundscapeWayPoint point3 = new SoundscapeWayPoint { Name = "Donnington Cars", Description = "Donnington Cars", Type = "WayPoint", Latitude = 51.449737, // lat Longitude = -0.950664, // long Elevation = 9, Street = "Donnington Cars" }; var waypoints = new List <SoundscapeWayPoint> { point1, point2, point3 }; var metadata = new ExperienceMetadata { Name = "Frazier's test route in Reading", Description = "Route for testing the scavenger hunt in Reading", Author = "QA Team", StartTime = new DateTime(2019, 11, 01, 11, 52, 51), EndTime = new DateTime(2021, 01, 01, 11, 53, 52), RegionLatitude = 51.4502463333333333, RegionLongitude = -0.94847866666666666667, RegionRadius = 2000.00, Waypoints = waypoints, Locale = "en_us", Behaviour = "ScavengerHunt", CreationTime = DateTime.UtcNow, Identifier = "c713e0b491e74468b5600312291018f8" }; var builder = new SoundscapeGpxBuilder(metadata); var doc = builder.ExportToGpx(); Console.WriteLine(doc.ToString()); }