private static void _SaveFakeItems(XmlWriter writer, int partID, IList <Stop> sortedStops, Stop currentStop, bool previouslyStopBreak, int currentIndex) { Debug.Assert(currentStop.StopType == StopType.Lunch); // WORKAROUND: add fake direction for break var stopWithLocation = SolveHelper.GetActualLunchStop(sortedStops, currentIndex); Debug.Assert(0 < stopWithLocation.Directions.Length); int lastDirIndex = stopWithLocation.Directions.Length - 1; Direction lastDirection = stopWithLocation.Directions[lastDirIndex]; string geometry = lastDirection.Geometry; // hardcoded text string text = Properties.Resources.DomainPropertyNameLunch; // add depart direction string departText = text; string departGeometry = geometry; StopManeuverType maneuver = StopManeuverType.Depart; // if previously stop not Break if (!previouslyStopBreak) { // if next stop have directions Direction?nextDirection = _GetNextStopStartDirection(sortedStops, currentIndex); if (nextDirection.HasValue) { // update values from start direction Direction direction = nextDirection.Value; maneuver = direction.ManeuverType; departText = direction.Text; departGeometry = direction.Geometry; } } _SaveStopDirection(writer, partID, 0.0, 0.0, maneuver, departText, departGeometry); // add arrive direction _SaveStopDirection(writer, partID, 0.0, 0.0, StopManeuverType.Stop, text, geometry); }
private static void _SaveStops( XmlWriter writer, Route route, ICollection <Stop> stops, ICollection <string> orderPropertiesToExport, Project project, AddressField[] addressFields) { Debug.Assert(route != null); var sortedStops = new List <Stop>(stops); CommonHelpers.SortBySequence(sortedStops); var orderPropertiesTitlesToExport = new List <string>(); var names = new List <string>(Order.GetPropertyNames(project.CapacitiesInfo, project.OrderCustomPropertiesInfo, addressFields)); var titles = new List <string>(Order.GetPropertyTitles(project.CapacitiesInfo, project.OrderCustomPropertiesInfo, addressFields)); foreach (string name in orderPropertiesToExport) { int index = names.IndexOf(name); string title = titles[index]; orderPropertiesTitlesToExport.Add(title); } var routeStops = CommonHelpers.GetSortedStops(route); writer.WriteStartElement(STOPS_NODE_NAME); foreach (Stop stop in sortedStops) { string name = _GetStopName(stop, routeStops); var mapLocation = stop.MapLocation; if (!mapLocation.HasValue) { if (stop.StopType != StopType.Lunch) { throw new InvalidOperationException( Properties.Messages.Error_GrfExporterNoLocationForStop); // exception } var currentIndex = stop.SequenceNumber - 1; var stopWithLocation = SolveHelper.GetActualLunchStop(routeStops, currentIndex); if (!stopWithLocation.MapLocation.HasValue) { throw new InvalidOperationException( Properties.Messages.Error_GrfExporterNoLocationForStop); // exception } mapLocation = stopWithLocation.MapLocation.Value; } writer.WriteStartElement(STOP_NODE_NAME); writer.WriteAttributeString(ENABLED_ATTR_NAME, TRUE_VALUE); string comments = _GetComments(stop, orderPropertiesToExport, orderPropertiesTitlesToExport); _SaveLocationNode(writer, mapLocation.Value, name, comments); writer.WriteStartElement(DURATION_NODE_NAME); double duration = stop.TimeAtStop * 60; writer.WriteValue(duration.ToString(DOUBLE_FORMAT, NumberFormatInfo.InvariantInfo)); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); }