Ejemplo n.º 1
0
        public FmsFlightplan CreateFmsFlightplanFromGarminFpl(GarminFpl garminFlightplan)
        {
            List <PlanItem> planItems = new List <PlanItem>();

            foreach (var routepoint in garminFlightplan.Route.Routepoint)
            {
                Waypoint waypointToRoutepoint = garminFlightplan.Waypointtable.Waypoint.Single(x =>
                                                                                               x.Identifier == routepoint.Waypointidentifier && x.Type == routepoint.Waypointtype &&
                                                                                               x.Countrycode == routepoint.Waypointcountrycode);
                double       lat          = waypointToRoutepoint.Lat;
                double       lon          = waypointToRoutepoint.Lon;
                WaypointType waypointType = _fplToFmsWaypointTypeConverter.FplWaypointTypeToFms(waypointToRoutepoint.Type);
                string       id;
                if (waypointType == WaypointType.LatLon)
                {
                    id = CreateIdentifierFromCoordinates(lat, lon);
                }
                else
                {
                    id = waypointToRoutepoint.Identifier;
                }
                planItems.Add(new PlanItem(
                                  waypointType,
                                  id,
                                  0,
                                  lat,
                                  lon)
                              );
            }

            Header header = new Header(planItems.Count - 1);

            return(new FmsFlightplan(header, planItems));
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            IUnityContainer container = CreateContainer();

            IGarminFplService garminFplService = container.Resolve <IGarminFplService>();
            GarminFpl         garminFlightplan = garminFplService.GetFromXmlFile(new FileInfo(args[0]));

            IGarminFplToFmsService garminToFmsService = container.Resolve <IGarminFplToFmsService>();
            FmsFlightplan          fmsFlightplan      = garminToFmsService.CreateFmsFlightplanFromGarminFpl(garminFlightplan);

            IFmsService fmsService = container.Resolve <IFmsService>();

            fmsService.WriteFmsFlightplanToFile(fmsFlightplan, new FileInfo(args[1]));
        }
Ejemplo n.º 3
0
        public void Converting_FPL_should_give_correct_FMS()
        {
            var garminFplBuilder = Create.GarminFpl();

            garminFplBuilder.AddWaypoint("AIRPORT", "EDDC", 51.134344, 51.134344);
            garminFplBuilder.AddWaypoint("VOR", "DRN", 51.015547, 13.598889);
            garminFplBuilder.AddWaypoint("INT", "DC422", 51.065489, 13.457303);
            garminFplBuilder.AddWaypoint("NDB", "FS", 51.193011, 13.850031);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST1", 51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST2", -51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST3", -51.378353, -13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST4", 51.378353, -13.115295);
            GarminFpl garminFpl = garminFplBuilder.Build();

            IGarminFplToFmsService service = new GarminFplToFmsService(new FplToFmsWaypointTypeConverter());
            FmsFlightplan          fms     = service.CreateFmsFlightplanFromGarminFpl(garminFpl);

            fms.Header.Source.Should().Be('I');
            fms.Header.VersionNumber.Should().Be(3);
            fms.Header.WaypointCount.Should().Be(7);

            PlanItem waypoint1 = fms.PlanItems[0];

            waypoint1.Typ.Should().Be(WaypointType.Airport);
            waypoint1.Id.Should().Be("EDDC");
            waypoint1.Altitude.Should().Be(0);
            waypoint1.Latitude.Should().Be(51.134344);
            waypoint1.Longitude.Should().Be(51.134344);

            PlanItem waypoint5 = fms.PlanItems[4];

            waypoint5.Typ.Should().Be(WaypointType.LatLon);
            waypoint5.Id.Should().Be("+51.378_+013.115");

            PlanItem waypoint6 = fms.PlanItems[5];

            waypoint6.Typ.Should().Be(WaypointType.LatLon);
            waypoint6.Id.Should().Be("-51.378_+013.115");

            PlanItem waypoint7 = fms.PlanItems[6];

            waypoint7.Typ.Should().Be(WaypointType.LatLon);
            waypoint7.Id.Should().Be("-51.378_-013.115");

            PlanItem waypoint8 = fms.PlanItems[7];

            waypoint8.Typ.Should().Be(WaypointType.LatLon);
            waypoint8.Id.Should().Be("+51.378_-013.115");
        }