public Parcours(Map parentMap) : base() { this.forbiddenZones = new ForbiddenZoneCollection(); this.routes = new RouteCollection(); this.nbLine = new Gate(); this.parentMap = parentMap; }
public Parcours(string filepath, Map parentMap) : base() { this.forbiddenZones = new ForbiddenZoneCollection(); this.routes = new RouteCollection(); this.nbLine = new Gate(); this.parentMap = parentMap; this.importFromDxf(filepath); }
public bool MissedGate( GpsPoint p1, GpsPoint p2) { Gate extendedGate = new Gate(); double m = (p1.Latitude - p2.Latitude) / (p1.Longitude - p2.Longitude); extendedGate.LeftPoint.Longitude += 10000; extendedGate.LeftPoint.Latitude += 10000* m; extendedGate.RightPoint.Longitude += 10000; extendedGate.rightPoint.Latitude += 10000 * m; return gatePassed(p1, p2); }
/// <summary> /// Imports a DxfFile that is in the specified Format. Any changes on the import schema may cause Errors! /// </summary> /// <param name="filepath"></param> public void importFromDxf(string filepath) { StreamReader sr = new StreamReader(filepath); List<string> lineList = new List<string>(); while (!sr.EndOfStream) { lineList.Add(sr.ReadLine()); } string[] lines = lineList.ToArray(); for (int i = 1; i < lines.Length; i++) //Looping through Array, starting with 1 (lines[0] is "0") { //Find Lines Containing a new Element Definition if (lines[i] == "LWPOLYLINE" && lines[i - 1] == " 0") // { //Reading out Layer ( "8" [\n] layerName) = Type of Element if (lines[i + 5] == " 8" && lines[i + 6].Contains("PROH")) // "Prohibited Zone" = ForbiddenZone { if (lines[i + 9] == " 90") { int numberOfVertexes = int.Parse(lines[i + 10]); ForbiddenZone forbiddenZone = new ForbiddenZone(); for (int j = 0; j < numberOfVertexes; j++) { forbiddenZone.AddGpsPoint(new GpsPoint(double.Parse(lines[i + (j * 4) + 18]) * 1000, double.Parse(lines[i + (j * 4) + 16]) * 1000, GpsPointFormatImport.Swiss)); } this.ForbiddenZones.Add(forbiddenZone); } } else if (lines[i + 5] == " 8" && lines[i + 6].Contains("STARTPOINT-")) { Gate g = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss), new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss)); string gatename = lines[i + 6].Substring(11, 1); if (!this.Routes.Contains(gatename)) { Route newRoute = new Route(this); newRoute.RouteName = gatename; this.Routes.Add(newRoute); } this.Routes[gatename].StartGate = g; } else if (lines[i + 5] == " 8" && lines[i + 6].Contains("ENDPOINT-")) { Gate g = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss), new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss)); string gatename = lines[i + 6].Substring(9, 1); if (!this.Routes.Contains(gatename)) { Route newRoute = new Route(this); newRoute.RouteName = gatename; this.Routes.Add(newRoute); } this.Routes[gatename].EndGate = g; } else if (lines[i + 5] == " 8" && lines[i + 6].Contains("NBLINE")) { if (lines[i + 9] == " 90" && double.Parse(lines[10]) == 2) { this.NbLine = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss), new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss)); } } } } }
public Gate getExtendedGate(Gate gate) { double k = 200; //distance to middle point GpsPoint m = new GpsPoint((gate.LeftPoint.Latitude + gate.RightPoint.Latitude) / 2, (gate.LeftPoint.Longitude + gate.RightPoint.Longitude) / 2, GpsPointFormatImport.WGS84); double alpha = Math.Atan((gate.LeftPoint.Latitude - gate.RightPoint.Latitude) / (gate.LeftPoint.Longitude + gate.RightPoint.Longitude)); GpsPoint p1 = new GpsPoint(m.Latitude - (k * Math.Cos(alpha - (Math.PI / 2))), m.Longitude - (k * Math.Sin(alpha - (Math.PI / 2))), GpsPointFormatImport.WGS84); GpsPoint p2 = new GpsPoint(m.Latitude + (k * Math.Cos((Math.PI / 2) - alpha)), m.Longitude + (k * Math.Sin((Math.PI / 2) - alpha)), GpsPointFormatImport.WGS84); return new Gate(p1, p2); }