public void FileController_FileRemoveJSON_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                controllerAction = "FileRemoveJSON";
                contactModel     = contactModelListGood[0];

                SetupTest(contactModel, culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    TVItemModel tvItemModelMunicipality = randomService.RandomTVItem(TVTypeEnum.Municipality);
                    Assert.AreEqual("", tvItemModelMunicipality.Error);

                    TVItemModel tvItemModelTVFile = tvItemService.PostAddChildTVItemDB(tvItemModelMunicipality.TVItemID, randomService.RandomString("FileName ", 20), TVTypeEnum.File);
                    Assert.AreEqual("", tvItemModelTVFile.Error);

                    TVFileModel tvFileModel = randomService.RandomTVFileModel(tvItemModelTVFile, true);
                    Assert.AreEqual("", tvFileModel.Error);

                    CoordModel coordModel = mapInfoService.GetParentLatLngDB(tvFileModel.TVFileTVItemID);
                    Assert.AreEqual("", coordModel.Error);

                    JsonResult jsonResult = controller.FileRemoveJSON(tvFileModel.TVFileTVItemID) as JsonResult;
                    Assert.IsNotNull(jsonResult);
                    string retStr = (string)jsonResult.Data;
                    Assert.AreEqual("", retStr);
                }
            }
        }
        public JsonResult GetMunicipalityLatLngJSON(int MunicipalityTVItemID)
        {
            List <MapInfoPointModel> mapInfoPointModelList = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(MunicipalityTVItemID, TVTypeEnum.Municipality, MapInfoDrawTypeEnum.Point);

            CoordModel coordModel = new CoordModel()
            {
                Lat = 0.0f, Lng = 0.0f
            };

            if (mapInfoPointModelList.Count > 0)
            {
                coordModel.Lat = (float)mapInfoPointModelList[0].Lat;
                coordModel.Lng = (float)mapInfoPointModelList[0].Lng;
            }

            return(Json(coordModel, JsonRequestBehavior.AllowGet));
        }
        public void MapController_GetParentLatLng_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                // Arrange
                controllerAction = "GetParentLatLng";
                contactModel     = contactModelListGood[0];

                // Act
                SetupTest(contactModel, culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    // Act
                    TVItemModel tvItemModelMunicipality = randomService.RandomTVItem(TVTypeEnum.Municipality);

                    // Assert
                    Assert.AreEqual("", tvItemModelMunicipality.Error);

                    // Act
                    List <MapInfoPointModel> mapInfoPointModelList = mapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(tvItemModelMunicipality.TVItemID, TVTypeEnum.Municipality, MapInfoDrawTypeEnum.Point);

                    // Assert
                    Assert.AreEqual(1, mapInfoPointModelList.Count);

                    // Act
                    JsonResult jsonResult = controller.GetParentLatLng(tvItemModelMunicipality.TVItemID) as JsonResult;

                    // Assert
                    Assert.IsNotNull(jsonResult);
                    CoordModel coordModel = (CoordModel)jsonResult.Data;
                    Assert.AreEqual(mapInfoPointModelList[0].Lat, coordModel.Lat);
                    Assert.AreEqual(mapInfoPointModelList[0].Lng, coordModel.Lng);
                }
            }
        }
Example #4
0
 public string GenerateQuery(CoordModel coord)
 {
     return(GenerateQuery(coord.Lat, coord.Lon));
 }
        private bool LoadFromFLT(string filename)
        {
            //      C: \Users\junge\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalState\MISSIONS\Custom\CustomFlight\CustomFlight.FLT

            this.LoadDt = DateTime.Now;
            if (File.Exists(filename))
            {
                try
                {
                    this.WaypointList.Clear();
                    IniFile ini = new IniFile();
                    if (ini.LoadFromFile(filename))
                    {
                        string section = "";
                        if (ini.GetValue("ATC_Aircraft.0", "RequestedFlightPlan", false) == true)
                        {
                            section = "atc_requestedflightplan.0";
                        }
                        else if (ini.GetValue("ATC_Aircraft.0", "ActiveFlightPlan", false) == true)
                        {
                            section = "atc_activeflightplan.0";
                        }

                        if (section != "")
                        {
                            for (int i = 0; i < 100; i++)
                            {
                                string kw = "waypoint." + i.ToString();
                                string l  = ini.GetValue(section, kw);
                                if (l != "")
                                {
                                    string[] items = l.Split(',');
                                    if (items.Length == 20)
                                    {
                                        // waypoint.0 =, BIRK, , BIRK,      A, N64° 7.80',  W21° 56.43', +000027.75, , , , , , NONE, 0, 0, -1, 0, 0,
                                        // waypoint.1 =,     , , TIMECRUIS, U, N59° 4.62',  W1° 3.30',   +007500.00, , , , , , NONE, 0, 0, -1, 0, 0,
                                        // waypoint.2 =,     , , TIMEDSCNT, U, N55° 33.92', E6° 53.28',  +007500.00, , , , , , NONE, 0, 0, -1, 0, 0,
                                        // waypoint.3 =, LHTL, , LHTL,      A, N47° 20.73', E18° 58.85', +000350.00, , , , , , NONE, 0, 0, -1, 0, 0,


                                        Waypoint wp = new Waypoint();
                                        wp.ID           = i;
                                        wp.ICAO         = items[1];
                                        wp.WaypointDesc = items[3];
                                        wp.WaypointType = items[4];
                                        wp.Coord        = CoordModel.Parse(items[5] + "," + items[6]);
                                        wp.Altitude     = double.Parse(items[7]);

                                        this.WaypointList.Add(wp);
                                    }
                                }
                                else
                                {
                                    return(true);
                                }
                            }
                        }
                    }


                    //string[] lines = File.ReadAllLines(filename);
                    //string section = "";
                    //foreach (string line in lines)
                    //{
                    //    string l = line.Trim();
                    //    if (l == "")
                    //    {
                    //        section = "";
                    //    }
                    //    else if (l.StartsWith("[") && line.EndsWith("]"))
                    //    {
                    //        section = l.ToLower();
                    //    }

                    //    switch (section)
                    //    {
                    //        case "[departure]":
                    //            break;

                    //        case "[arrival]":
                    //            break;

                    //        case "[atc_aircraft.0]":
                    //            //ActiveFlightPlan=True
                    //            //RequestedFlightPlan=False"

                    //            break;

                    //        case "[atc_requestedflightplan.0]":

                    //            if (l.StartsWith("waypoint."))
                    //            {
                    //                string[] items = l.Split(',');
                    //                if (items.Length == 20)
                    //                {

                    //                    // waypoint.0 =, BIRK, , BIRK,      A, N64° 7.80',  W21° 56.43', +000027.75, , , , , , NONE, 0, 0, -1, 0, 0,
                    //                    // waypoint.1 =,     , , TIMECRUIS, U, N59° 4.62',  W1° 3.30',   +007500.00, , , , , , NONE, 0, 0, -1, 0, 0,
                    //                    // waypoint.2 =,     , , TIMEDSCNT, U, N55° 33.92', E6° 53.28',  +007500.00, , , , , , NONE, 0, 0, -1, 0, 0,
                    //                    // waypoint.3 =, LHTL, , LHTL,      A, N47° 20.73', E18° 58.85', +000350.00, , , , , , NONE, 0, 0, -1, 0, 0,


                    //                    Waypoint wp = new Waypoint();
                    //                    wp.ID = int.Parse(line.Split('.')[1].Split('=')[0]);
                    //                    wp.ICAO = items[1];
                    //                    wp.WaypointDesc = items[3];
                    //                    wp.WaypointType = items[4];
                    //                    wp.Coord = CoordModel.Parse(items[5] + "," + items[6]);
                    //                    wp.Altitude = double.Parse(items[7]);

                    //                    this.WaypointList.Add(wp);
                    //                }
                    //            }

                    //            break;
                    //    }
                    //}
                    this.FileName = filename;
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            return(false);
        }
        private bool LoadFromPLN(string filename)
        {
            this.ErrMsg = "";
            this.ErrSep = "";
            this.WaypointList.Clear();
            this.LoadDt = DateTime.Now;
            int id = 0;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(filename);

                XmlNode root = doc.FirstChild;

                XmlNode fp = doc.SelectSingleNode("SimBase.Document/FlightPlan.FlightPlan");
                if (fp != null)
                {
                    this.Title           = GetNodeText(fp, "Title");
                    this.FPType          = GetNodeText(fp, "FPType");
                    this.RouteType       = GetNodeText(fp, "RouteType");
                    this.CruisingAlt     = GetNodeText(fp, "CruisingAlt");
                    this.DepartureID     = GetNodeText(fp, "DepartureID");
                    this.DepartureLLA    = GetNodeText(fp, "DepartureLLA");
                    this.DestinationID   = GetNodeText(fp, "DestinationID");
                    this.DestinationLLA  = GetNodeText(fp, "DestinationLLA");
                    this.Description     = GetNodeText(fp, "Descr");
                    this.DepartureName   = GetNodeText(fp, "DepartureName");
                    this.DestinationName = GetNodeText(fp, "DestinationName");


                    foreach (XmlNode node in fp.ChildNodes)
                    {
                        if (node.Name == "ATCWaypoint")
                        {
                            Waypoint wp = new Waypoint();
                            wp.ID            = id++;
                            wp.ICAO          = GetAttr(node, "id");
                            wp.WaypointType  = GetNodeText(node, "ATCWaypointType");
                            wp.WorldPosition = GetNodeText(node, "WorldPosition");
                            wp.Coord         = CoordModel.Parse(GetNodeText(node, "WorldPosition"));

                            XmlNode icao = node.SelectSingleNode("ICAO");
                            //if (icao != null)
                            //{
                            //    wp.ICAOIdent = GetNodeText(icao, "ICAOIdent");
                            //}

                            this.WaypointList.Add(wp);
                        }
                    }
                }

                this.FileName = filename;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(false);
        }
Example #7
0
        public JsonResult GetParentLatLng(int TVItemID)
        {
            CoordModel coordModel = _MapInfoService.GetParentLatLngDB(TVItemID);

            return(Json(coordModel, JsonRequestBehavior.AllowGet));
        }