/// <summary> /// Calculates the relative direction. /// </summary> /// <param name="from"></param> /// <param name="along"></param> /// <param name="to"></param> /// <returns></returns> public static RelativeDirection Calculate(GeoCoordinate from, GeoCoordinate along, GeoCoordinate to) { RelativeDirection direction = new RelativeDirection(); double margin = 65; double straight_on = 10; double turn_back = 5; GeoCoordinateLine line_from = new GeoCoordinateLine(from, along); GeoCoordinateLine line_to = new GeoCoordinateLine(along, to); Degree angle = line_from.Direction.Angle(line_to.Direction); if (angle >= new Degree(360 - straight_on) || angle < new Degree(straight_on)) { direction.Direction = RelativeDirectionEnum.StraightOn; } else if (angle >= new Degree(straight_on) && angle < new Degree(90 - margin)) { direction.Direction = RelativeDirectionEnum.SlightlyLeft; } else if (angle >= new Degree(90 - margin) && angle < new Degree(90 + margin)) { direction.Direction = RelativeDirectionEnum.Left; } else if (angle >= new Degree(90 + margin) && angle < new Degree(180 - turn_back)) { direction.Direction = RelativeDirectionEnum.SharpLeft; } else if (angle >= new Degree(180 - turn_back) && angle < new Degree(180 + turn_back)) { direction.Direction = RelativeDirectionEnum.TurnBack; } else if (angle >= new Degree(180 + turn_back) && angle < new Degree(270-margin)) { direction.Direction = RelativeDirectionEnum.SharpRight; } else if (angle >= new Degree(270 - margin) && angle < new Degree(270 + margin)) { direction.Direction = RelativeDirectionEnum.Right; } else if (angle >= new Degree(270 + margin) && angle < new Degree(360- straight_on)) { direction.Direction = RelativeDirectionEnum.SlightlyRight; } //direction.Direction = RelativeDirectionEnum.StraightOn; direction.Angle = angle; return direction; }
/// <summary> /// Calculates the relative direction. /// </summary> /// <param name="from"></param> /// <param name="along"></param> /// <param name="to"></param> /// <returns></returns> public static RelativeDirection Calculate(GeoCoordinate from, GeoCoordinate along, GeoCoordinate to) { RelativeDirection direction = new RelativeDirection(); double margin = 65; double straight_on = 10; double turn_back = 5; GeoCoordinateLine line_from = new GeoCoordinateLine(from, along); GeoCoordinateLine line_to = new GeoCoordinateLine(along, to); Degree angle = line_from.Direction.Angle(line_to.Direction); if (angle >= new Degree(360 - straight_on) || angle < new Degree(straight_on)) { direction.Direction = RelativeDirectionEnum.StraightOn; } else if (angle >= new Degree(straight_on) && angle < new Degree(90 - margin)) { direction.Direction = RelativeDirectionEnum.SlightlyLeft; } else if (angle >= new Degree(90 - margin) && angle < new Degree(90 + margin)) { direction.Direction = RelativeDirectionEnum.Left; } else if (angle >= new Degree(90 + margin) && angle < new Degree(180 - turn_back)) { direction.Direction = RelativeDirectionEnum.SharpLeft; } else if (angle >= new Degree(180 - turn_back) && angle < new Degree(180 + turn_back)) { direction.Direction = RelativeDirectionEnum.TurnBack; } else if (angle >= new Degree(180 + turn_back) && angle < new Degree(270 - margin)) { direction.Direction = RelativeDirectionEnum.SharpRight; } else if (angle >= new Degree(270 - margin) && angle < new Degree(270 + margin)) { direction.Direction = RelativeDirectionEnum.Right; } else if (angle >= new Degree(270 + margin) && angle < new Degree(360 - straight_on)) { direction.Direction = RelativeDirectionEnum.SlightlyRight; } //direction.Direction = RelativeDirectionEnum.StraightOn; direction.Angle = angle; return(direction); }
/// <summary> /// Calculates the relative direction. /// </summary> /// <param name="from"></param> /// <param name="along"></param> /// <param name="to"></param> /// <returns></returns> public static RelativeDirection Calculate(GeoCoordinate from, GeoCoordinate along, GeoCoordinate to) { var direction = new RelativeDirection(); var margin = 65.0; var straight_on = 10.0; var turn_back = 5.0; var lineFrom = new GeoCoordinateLine(from, along); var lineTo = new GeoCoordinateLine(along, to); var angle = lineFrom.Direction.Angle(lineTo.Direction); if (angle >= new Degree(360 - straight_on) || angle < new Degree(straight_on)) { direction.Direction = RelativeDirectionEnum.StraightOn; } else if (angle >= new Degree(straight_on) && angle < new Degree(90 - margin)) { direction.Direction = RelativeDirectionEnum.SlightlyLeft; } else if (angle >= new Degree(90 - margin) && angle < new Degree(90 + margin)) { direction.Direction = RelativeDirectionEnum.Left; } else if (angle >= new Degree(90 + margin) && angle < new Degree(180 - turn_back)) { direction.Direction = RelativeDirectionEnum.SharpLeft; } else if (angle >= new Degree(180 - turn_back) && angle < new Degree(180 + turn_back)) { direction.Direction = RelativeDirectionEnum.TurnBack; } else if (angle >= new Degree(180 + turn_back) && angle < new Degree(270 - margin)) { direction.Direction = RelativeDirectionEnum.SharpRight; } else if (angle >= new Degree(270 - margin) && angle < new Degree(270 + margin)) { direction.Direction = RelativeDirectionEnum.Right; } else if (angle >= new Degree(270 + margin) && angle < new Degree(360 - straight_on)) { direction.Direction = RelativeDirectionEnum.SlightlyRight; } direction.Angle = angle; return(direction); }
/// <summary> /// Calculates the relative direction. /// </summary> /// <param name="from"></param> /// <param name="along"></param> /// <param name="to"></param> /// <returns></returns> public static RelativeDirection Calculate(GeoCoordinate from, GeoCoordinate along, GeoCoordinate to) { var direction = new RelativeDirection(); var margin = 65.0; var straight_on = 10.0; var turn_back = 5.0; var lineFrom = new GeoCoordinateLine(from, along); var lineTo = new GeoCoordinateLine(along, to); var angle = lineFrom.Direction.Angle(lineTo.Direction); if (angle >= new Degree(360 - straight_on) || angle < new Degree(straight_on)) { direction.Direction = RelativeDirectionEnum.StraightOn; } else if (angle >= new Degree(straight_on) && angle < new Degree(90 - margin)) { direction.Direction = RelativeDirectionEnum.SlightlyLeft; } else if (angle >= new Degree(90 - margin) && angle < new Degree(90 + margin)) { direction.Direction = RelativeDirectionEnum.Left; } else if (angle >= new Degree(90 + margin) && angle < new Degree(180 - turn_back)) { direction.Direction = RelativeDirectionEnum.SharpLeft; } else if (angle >= new Degree(180 - turn_back) && angle < new Degree(180 + turn_back)) { direction.Direction = RelativeDirectionEnum.TurnBack; } else if (angle >= new Degree(180 + turn_back) && angle < new Degree(270-margin)) { direction.Direction = RelativeDirectionEnum.SharpRight; } else if (angle >= new Degree(270 - margin) && angle < new Degree(270 + margin)) { direction.Direction = RelativeDirectionEnum.Right; } else if (angle >= new Degree(270 + margin) && angle < new Degree(360- straight_on)) { direction.Direction = RelativeDirectionEnum.SlightlyRight; } direction.Angle = angle; return direction; }
/// <summary> /// Generates POI instruction. /// </summary> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GeneratePOI(RelativeDirection direction, List<PointPoi> pois) { if (direction != null) { return string.Format("GeneratePoi:{0}_{1}", pois.Count, direction.Direction.ToString()); } else { return string.Format("GeneratePoi:{0}", pois.Count); } }
/// <summary> /// Generates an instruction for a direct turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateDirectTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Neem de 1ste afslag {0}, de {1} op.", TurnDirection(direction), this.GetName("nl", street)); } else { return string.Format("Neem de {0}de afslag {1}, de {2} op.", countBefore, TurnDirection(direction), this.GetName("nl", street)); } }
/// <summary> /// Generates an instruction for a direct turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateDirectTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Nimm die erste Abzweigung {0}, auf die {1}", TurnDirection(direction), this.GetName("de", street)); } else { return string.Format("Nimm die {0}te Abzweigung {1}, auf die {2}.", countBefore, TurnDirection(direction), this.GetName("de", street)); } }
/// <summary> /// Generates an instruction for a direct turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateDirectTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Take the first turn {0}, on {1}.", TurnDirection(direction), this.GetName("en", street)); } else { return string.Format("Take the {0}th turn {1}, on {2}.", countBefore, TurnDirection(direction), this.GetName("en", street)); } }
public static RelativeDirection Calculate(GeoCoordinate from, GeoCoordinate along, GeoCoordinate to) { RelativeDirection relativeDirection = new RelativeDirection(); double num1 = 65.0; double num2 = 10.0; double num3 = 5.0; Radian radian = new GeoCoordinateLine(from, along).Direction.Angle(new GeoCoordinateLine(along, to).Direction); if ((Degree)radian >= new Degree(360.0 - num2) || (Degree)radian < new Degree(num2)) { relativeDirection.Direction = RelativeDirectionEnum.StraightOn; } else if ((Degree)radian >= new Degree(num2) && (Degree)radian < new Degree(90.0 - num1)) { relativeDirection.Direction = RelativeDirectionEnum.SlightlyLeft; } else if ((Degree)radian >= new Degree(90.0 - num1) && (Degree)radian < new Degree(90.0 + num1)) { relativeDirection.Direction = RelativeDirectionEnum.Left; } else if ((Degree)radian >= new Degree(90.0 + num1) && (Degree)radian < new Degree(180.0 - num3)) { relativeDirection.Direction = RelativeDirectionEnum.SharpLeft; } else if ((Degree)radian >= new Degree(180.0 - num3) && (Degree)radian < new Degree(180.0 + num3)) { relativeDirection.Direction = RelativeDirectionEnum.TurnBack; } else if ((Degree)radian >= new Degree(180.0 + num3) && (Degree)radian < new Degree(270.0 - num1)) { relativeDirection.Direction = RelativeDirectionEnum.SharpRight; } else if ((Degree)radian >= new Degree(270.0 - num1) && (Degree)radian < new Degree(270.0 + num1)) { relativeDirection.Direction = RelativeDirectionEnum.Right; } else if ((Degree)radian >= new Degree(270.0 + num1) && (Degree)radian < new Degree(360.0 - num2)) { relativeDirection.Direction = RelativeDirectionEnum.SlightlyRight; } relativeDirection.Angle = (Degree)radian; return(relativeDirection); }
/// <summary> /// Generates a word for the the given direction. /// </summary> /// <param name="direction"></param> /// <returns></returns> private string TurnDirection(RelativeDirection direction) { if (direction != null) { switch (direction.Direction) { case RelativeDirectionEnum.Right: case RelativeDirectionEnum.SharpRight: case RelativeDirectionEnum.SlightlyRight: return "right"; case RelativeDirectionEnum.Left: case RelativeDirectionEnum.SharpLeft: case RelativeDirectionEnum.SlightlyLeft: return "left"; case RelativeDirectionEnum.TurnBack: return "back"; } } return string.Empty; }
/// <summary> /// Generates an immidiate turn. /// </summary> /// <param name="instruction"></param> /// <param name="firstStreetCountTo"></param> /// <param name="firstStreetTo"></param> /// <param name="firstDirection"></param> /// <param name="secondStreetTo"></param> /// <param name="secondDirection"></param> /// <returns></returns> public Instruction GenerateImmidiateTurn(Instruction instruction, int firstStreetCountTo, TagsCollection firstStreetTo, OsmSharp.Math.Geo.Meta.RelativeDirection firstDirection, TagsCollection secondStreetTo, RelativeDirection secondDirection) { instruction.Text = string.Format("GenerateImmidiateTurn:{0}_{1}_{2}_{3}", firstStreetCountTo, firstDirection, firstDirection.ToString(), secondDirection.ToString()); instruction.Extras = new Dictionary <string, object>(); instruction.Extras.Add("firstStreetCountTo", firstStreetCountTo); instruction.Extras.Add("firstStreetTo", firstStreetTo); instruction.Extras.Add("firstDirection", firstDirection); instruction.Extras.Add("secondStreetTo", secondStreetTo); instruction.Extras.Add("secondDirection", secondDirection); return(instruction); }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="countBefore"></param> /// <param name="firstStreet"></param> /// <param name="firstDirection"></param> /// <param name="secondStreet"></param> /// <param name="secondDirection"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateImmidiateTurn(int countBefore, TagsCollectionBase firstStreet, RelativeDirection firstDirection, TagsCollectionBase secondStreet, RelativeDirection secondDirection, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Neem de eerste afslag {0}, op de {1}, en draai onmiddellijk {2} op de {3}.", TurnDirection(firstDirection), this.GetName("nl", firstStreet), TurnDirection(secondDirection), this.GetName("nl", secondStreet)); } else { return string.Format("Neem de {4}de afslag {0}, op de {1}, en draai onmiddellijk {2} op de {3}.", TurnDirection(firstDirection), this.GetName("nl", firstStreet), TurnDirection(secondDirection), this.GetName("nl", secondStreet), countBefore); } }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="countBefore"></param> /// <param name="firstStreet"></param> /// <param name="firstDirection"></param> /// <param name="secondStreet"></param> /// <param name="secondDirection"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateImmidiateTurn(int countBefore, TagsCollectionBase firstStreet, RelativeDirection firstDirection, TagsCollectionBase secondStreet, RelativeDirection secondDirection, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Nimm die erste Abzweigung {0}, auf die {1}, und fahre sofort {2} auf die {3}.", TurnDirection(firstDirection), this.GetName("de", firstStreet), TurnDirection(secondDirection), this.GetName("de", secondStreet)); } else { return string.Format("Nimm die {4}te Abzweigung {0}, auf die {1}, und fahre sofort {2} auf die {3}.", TurnDirection(firstDirection), this.GetName("de", firstStreet), TurnDirection(secondDirection), this.GetName("de", secondStreet), countBefore); } }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="countBefore"></param> /// <param name="firstStreet"></param> /// <param name="firstDirection"></param> /// <param name="secondStreet"></param> /// <param name="secondDirection"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateImmidiateTurn(int countBefore, TagsCollectionBase firstStreet, RelativeDirection firstDirection, TagsCollectionBase secondStreet, RelativeDirection secondDirection, List<PointPoi> pois) { countBefore++; if (countBefore == 1) { return string.Format("Take the first turn {0}, on the {1}, and turn immidiately {2} on the {3}.", TurnDirection(firstDirection), this.GetName("en", firstStreet), TurnDirection(secondDirection), this.GetName("en", secondStreet)); } else { return string.Format("Take the {4}d turn {0}, on the {1}, and turn immidiately {2} on the {3}.", TurnDirection(firstDirection), this.GetName("en", firstStreet), TurnDirection(secondDirection), this.GetName("en", secondStreet), countBefore); } }
/// <summary> /// Generates an instruction for a simple turn. /// </summary> /// <param name="count"></param> /// <param name="direction"></param> /// <returns></returns> protected override string GenerateTurn(RelativeDirection direction) { return string.Format("Fahre {0}", this.TurnDirection(direction)); }
/// <summary> /// Generates an instruction for a POI. /// </summary> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GeneratePOI(RelativeDirection direction, List<PointPoi> pois) { if (direction == null) { return string.Format("Poi"); } else { return string.Format("Poi:{0}", direction.Direction); } }
/// <summary> /// Generates an instruction for an indirect turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="list"></param> /// <returns></returns> protected override string GenerateIndirectFollowTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> list) { countBefore++; if (countBefore == 1) { return string.Format("Fahre {1} und bleibe auf der {0}.", this.GetName("de", street), TurnDirection(direction)); } else { return string.Format("Nimm {1}te Straße {2} und bleib auf der {0}.", this.GetName("de", street), countBefore, TurnDirection(direction)); } }
/// <summary> /// Generates an immidiate turn. /// </summary> /// <param name="instruction"></param> /// <param name="firstStreetCountTo"></param> /// <param name="firstStreetTo"></param> /// <param name="firstDirection"></param> /// <param name="secondStreetTo"></param> /// <param name="secondDirection"></param> /// <returns></returns> public Instruction GenerateImmidiateTurn(Instruction instruction, int firstStreetCountTo, TagsCollection firstStreetTo, OsmSharp.Math.Geo.Meta.RelativeDirection firstDirection, TagsCollection secondStreetTo, RelativeDirection secondDirection) { instruction.Text = string.Format("GenerateImmidiateTurn:{0}_{1}_{2}_{3}", firstStreetCountTo, firstDirection, firstDirection.ToString(), secondDirection.ToString()); instruction.Extras = new Dictionary<string, object>(); instruction.Extras.Add("firstStreetCountTo", firstStreetCountTo); instruction.Extras.Add("firstStreetTo", firstStreetTo); instruction.Extras.Add("firstDirection", firstDirection); instruction.Extras.Add("secondStreetTo", secondStreetTo); instruction.Extras.Add("secondDirection", secondDirection); return instruction; }
/// <summary> /// Generates an indirect follow turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="list"></param> /// <returns></returns> protected override string GenerateIndirectFollowTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> list) { return string.Format("GenerateDirectFollowTurn:{0}_{1}_{2}", countBefore, direction.Direction.ToString(), list.Count); }
/// <summary> /// Generates a simple turn instruction. /// </summary> /// <param name="direction"></param> /// <returns></returns> protected override string GenerateTurn(RelativeDirection direction) { return string.Format("GenerateSimpleTurn:{0}", direction.ToString()); }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="countBefore"></param> /// <param name="firstStreet"></param> /// <param name="firstDirection"></param> /// <param name="secondStreet"></param> /// <param name="secondDirection"></param> /// <param name="pois"></param> /// <returns></returns> protected abstract string GenerateImmidiateTurn(int countBefore, TagsCollectionBase firstStreet, RelativeDirection firstDirection, TagsCollectionBase secondStreet, RelativeDirection secondDirection, List<PointPoi> pois);
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="instruction"></param> /// <param name="first_street_count_to"></param> /// <param name="first_street_to"></param> /// <param name="first_direction"></param> /// <param name="second_street_to"></param> /// <param name="second_direction"></param> /// <returns></returns> public Instruction GenerateImmidiateTurn(Instruction instruction, int first_street_count_to, TagsCollection first_street_to, RelativeDirection first_direction, TagsCollection second_street_to, RelativeDirection second_direction) { if (first_street_count_to == 1) { instruction.Text = string.Format("Neem de 1ste afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.", TurnDirection(first_direction.Direction), this.GetName("nl", first_street_to), TurnDirection(second_direction.Direction), this.GetName("nl", second_street_to)); } else { instruction.Text = string.Format("Neem de {4}de afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.", TurnDirection(first_direction.Direction), this.GetName("nl", first_street_to), TurnDirection(second_direction.Direction), this.GetName("nl", second_street_to), first_street_count_to); } // returns the instruction with text. return instruction; }
/// <summary> /// Generates an immidiate turn instruction. /// </summary> /// <param name="entryIdx"></param> /// <param name="box"></param> /// <param name="before_name"></param> /// <param name="first_direction"></param> /// <param name="first_street_count_to"></param> /// <param name="second_direction"></param> /// <param name="first_street_to"></param> /// <param name="second_street_to"></param> /// <param name="list"></param> internal void GenerateImmidiateTurn(int entryIdx, GeoCoordinateBox box, TagsCollection before_name, RelativeDirection first_direction, int first_street_count_to, RelativeDirection second_direction, TagsCollection first_street_to, TagsCollection second_street_to, List<PointPoi> list) { // create a new instruction first. Instruction instruction = new Instruction(entryIdx, box); // pass the instruction to the language generator. instruction = _generator.GenerateImmidiateTurn( instruction, first_street_count_to, first_street_to, first_direction, second_street_to, second_direction); // add the instruction to the instructions list. _instructions.Add(instruction); }
/// <summary> /// Generates an instruction for an indirect turn. /// </summary> /// <param name="instruction"></param> /// <param name="streetCountTurn"></param> /// <param name="streetCountBeforeTurn"></param> /// <param name="street_to"></param> /// <param name="direction"></param> /// <param name="list"></param> /// <returns></returns> protected override string GenerateIndirectFollowTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> list) { countBefore++; if (countBefore == 1) { return string.Format("Draai {1} en blijf op de {0}.", this.GetName("nl", street), TurnDirection(direction)); } else { return string.Format("Neem de {1}ste straat {2} en blijf op de {0}.", this.GetName("nl", street), countBefore, TurnDirection(direction)); } }
/// <summary> /// Generates an instruction for a turn followed by another turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateDirectFollowTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> pois) { return string.Format("Fahre {1}.", countBefore, TurnDirection(direction), this.GetName("de", street)); }
/// <summary> /// Generates an instruction for an indirect turn. /// </summary> /// <param name="countBefore"></param> /// <param name="street"></param> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected abstract string GenerateIndirectTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> pois);
/// <summary> /// Generates a poi instruction. /// </summary> /// <param name="entryIdx"></param> /// <param name="box"></param> /// <param name="list"></param> /// <param name="direction"></param> internal void GeneratePoi(int entryIdx, GeoCoordinateBox box, List<PointPoi> list, RelativeDirection direction) { // create a new instruction first. Instruction instruction = new Instruction(entryIdx, box, list); Instruction direction_instruction = null; // pass the instruction to the languate generator. if (direction == null) { instruction = _generator.GeneratePoi(instruction, list, null); } else { // create a direction instruction. if (direction.Direction == RelativeDirectionEnum.TurnBack) { direction_instruction = new Instruction(entryIdx, box, list); direction_instruction = _generator.GenerateSimpleTurn(direction_instruction, direction.Direction); } // generates the instructions. instruction = _generator.GeneratePoi(instruction, list, null); } // add the instruction to the instructions list. _instructions.Add(instruction); // add the direction instruction. if (direction_instruction != null) { _instructions.Add(direction_instruction); } }
/// <summary> /// Generates an instruction for a POI. /// </summary> /// <param name="direction"></param> /// <param name="pois"></param> /// <returns></returns> protected abstract string GeneratePOI(RelativeDirection direction, List<PointPoi> pois);
/// <summary> /// Generates an immidiate turn. /// </summary> /// <param name="countBefore"></param> /// <param name="firstStreet"></param> /// <param name="firstDirection"></param> /// <param name="secondStreet"></param> /// <param name="secondDirection"></param> /// <param name="pois"></param> /// <returns></returns> protected override string GenerateImmidiateTurn(int countBefore, TagsCollectionBase firstStreet, RelativeDirection firstDirection, TagsCollectionBase secondStreet, RelativeDirection secondDirection, List<PointPoi> pois) { return string.Format("GenerateImmidiateTurn:{0}_{1}_{2}_{3}", countBefore, firstDirection, firstDirection.Direction.ToString(), secondDirection.Direction.ToString()); }
/// <summary> /// Generates an instruction for a simple turn. /// </summary> /// <param name="count"></param> /// <param name="direction"></param> /// <returns></returns> protected abstract string GenerateTurn(RelativeDirection direction);
/// <summary> /// Generates an instruction for an indirect turn. /// </summary> /// <param name="instruction"></param> /// <param name="streetCountTurn"></param> /// <param name="streetCountBeforeTurn"></param> /// <param name="street_to"></param> /// <param name="direction"></param> /// <param name="list"></param> /// <returns></returns> protected override string GenerateIndirectFollowTurn(int countBefore, TagsCollectionBase street, RelativeDirection direction, List<PointPoi> list) { countBefore++; if (countBefore == 1) { return string.Format("Turn {1} to stay on {0}.", this.GetName("en", street), TurnDirection(direction)); } else { return string.Format("Take the {1}d street {2} to stay on {0}.", this.GetName("en", street), countBefore, TurnDirection(direction)); } }
/// <summary> /// Generates a turn instruction. /// </summary> /// <param name="entryIdx"></param> /// <param name="box"></param> /// <param name="direction"></param> /// <param name="streetCountTurn"></param> /// <param name="streetCountBeforeTurn"></param> /// <param name="streetFrom"></param> /// <param name="streetTo"></param> /// <param name="list"></param> internal void GenerateTurn(int entryIdx, GeoCoordinateBox box, RelativeDirection direction, int streetCountTurn, int streetCountBeforeTurn, TagsCollection streetFrom, TagsCollection streetTo, List<PointPoi> list) { // create a new instruction first. Instruction instruction = new Instruction(entryIdx, box, list); // pass the instruction to the languate generator. // test if the street is the same but a turn needs to be taken anyway. if (streetFrom == streetTo) { if (streetCountTurn == 0) {// there are no other streets between the one being turned into and the street coming from in the same // direction as the turn. instruction = _generator.GenerateDirectFollowTurn( instruction, streetCountBeforeTurn, streetTo, direction.Direction, list); } else { // there is another street; this is tricky to explain. instruction = _generator.GenerateIndirectFollowTurn( instruction, streetCountTurn, streetCountBeforeTurn, streetTo, direction.Direction, list); } } else { if (streetCountTurn == 0) { // there are no other streets between the one being turned into and the street coming from in the same // direction as the turn. instruction = _generator.GenerateDirectTurn( instruction, streetCountBeforeTurn, streetTo, direction.Direction, list); } else { // there is another street; this is tricky to explain. instruction = _generator.GenerateIndirectTurn( instruction, streetCountTurn, streetCountBeforeTurn, streetTo, direction.Direction, list); } } // add the instruction to the instructions list. _instructions.Add(instruction); }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="instruction"></param> /// <param name="firstStreetCountTo"></param> /// <param name="first_street_to"></param> /// <param name="first_direction"></param> /// <param name="second_street_to"></param> /// <param name="second_direction"></param> /// <returns></returns> public Instruction GenerateImmidiateTurn(Instruction instruction, int firstStreetCountTo, TagsCollectionBase first_street_to, RelativeDirection first_direction, TagsCollectionBase second_street_to, RelativeDirection second_direction) { firstStreetCountTo++; if (firstStreetCountTo == 1) { instruction.Text = string.Format("Take the first turn {0}, on the {1}, and turn immidiately {2} on the {3}.", TurnDirection(first_direction.Direction), this.GetName("en",first_street_to), TurnDirection(second_direction.Direction), this.GetName("en",second_street_to)); } else { instruction.Text = string.Format("Take the {4}d turn {0}, on the {1}, and turn immidiately {2} on the {3}.", TurnDirection(first_direction.Direction), this.GetName("en",first_street_to), TurnDirection(second_direction.Direction), this.GetName("en",second_street_to), firstStreetCountTo); } // returns the instruction with text. return instruction; }
/// <summary> /// Generates an instruction for an immidiate turn. /// </summary> /// <param name="instruction"></param> /// <param name="first_street_count_to"></param> /// <param name="first_street_to"></param> /// <param name="first_direction"></param> /// <param name="second_street_to"></param> /// <param name="second_direction"></param> /// <returns></returns> public Instruction GenerateImmidiateTurn(Instruction instruction, int first_street_count_to, TagsCollectionBase first_street_to, RelativeDirection first_direction, TagsCollectionBase second_street_to, RelativeDirection second_direction) { // if (first_street_count_to == 1) // { // instruction.Text = string.Format("Neem de 1ste afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.", // TurnDirection(first_direction.Direction), // this.GetName("nl", first_street_to), // TurnDirection(second_direction.Direction), // this.GetName("nl", second_street_to)); // } // else // { // instruction.Text = string.Format("Neem de {4}de afslag {0}, de {1} op, en ga onmiddellijk {2} op de {3}.", // TurnDirection(first_direction.Direction), // this.GetName("nl", first_street_to), // TurnDirection(second_direction.Direction), // this.GetName("nl", second_street_to), // first_street_count_to); // } instruction.Text = string.Format ("Draai {0} en daarna direct {1}", TurnDirection(first_direction.Direction), TurnDirection(second_direction.Direction)); // returns the instruction with text. return instruction; }