private void ReadCrossroad(ICrossroad crossroad, IRoadmapFactory roadmapFactory, XmlNode crossroadNode) { var pivotPoint = ReadPoint(crossroadNode.SelectSingleNode("pivotPoint")); var index = ushort.Parse(crossroadNode.GetFieldValue("index")); crossroad.PivotPoint = pivotPoint; crossroad.Index = index; var junctionNodes = crossroadNode.SelectNodes("roadJunctions/roadJunction"); foreach (XmlNode junctionNode in junctionNodes) { IRoadJunction junction = roadmapFactory.Junction(); ReadRoadJunction(junction, roadmapFactory, junctionNode); crossroad.Junctions.Add(junction); } var boundNodes = crossroadNode.SelectNodes("bounds/point"); foreach (XmlNode pointNode in boundNodes) { crossroad.Bounds.Add(ReadPoint(pointNode)); } var semaphoreNodes = crossroadNode.SelectNodes("trafficLightSemaphores/semaphore"); foreach (XmlNode semaphoreNode in semaphoreNodes) { ITrafficLightSemaphore semaphore = roadmapFactory.TrafficLightSemaphore(); ReadTrafficLightSemaphore(semaphore, semaphoreNode); crossroad.TrafficLightSemaphores.Add(semaphore); } }
private void WriteJunction(IRoadJunction junction, XmlDocument xml, XmlNode node) { node.AddFieldWithValue(xml, "fromRoadGraphEdge", junction.FromRoadGraphEdgeIndex); node.AddFieldWithValue(xml, "fromLane", junction.FromLaneIndex); node.AddFieldWithValue(xml, "toRoadGraphEdge", junction.ToRoadGraphEdgeIndex); node.AddFieldWithValue(xml, "toLane", junction.ToLaneIndex); node.AddFieldWithValue(xml, "unkn6", junction.Unkn6); node.AddFieldWithValue(xml, "unkn8", junction.Unkn8); var splineNode = xml.CreateElement("spline"); WriteSpline(junction.Spline, xml, splineNode); node.AppendChild(splineNode); }
private void ReadRoadJunction(IRoadJunction junction, IRoadmapFactory roadmapFactory, XmlNode junctionNode) { var from = ushort.Parse(junctionNode.GetFieldValue("fromRoadGraphEdge")); var fromLane = byte.Parse(junctionNode.GetFieldValue("fromLane")); var to = ushort.Parse(junctionNode.GetFieldValue("toRoadGraphEdge")); var toLane = byte.Parse(junctionNode.GetFieldValue("toLane")); var unkn6 = byte.Parse(junctionNode.GetFieldValue("unkn6")); var unkn8 = ushort.Parse(junctionNode.GetFieldValue("unkn8")); var spline = roadmapFactory.Spline(); ReadSpline(spline, junctionNode.SelectSingleNode("spline")); junction.FromRoadGraphEdgeIndex = from; junction.FromLaneIndex = fromLane; junction.ToRoadGraphEdgeIndex = to; junction.ToLaneIndex = toLane; junction.Unkn4 = 255; // always 255 junction.Unkn6 = unkn6; junction.Unkn8 = unkn8; junction.Spline = spline; }