コード例 #1
0
        public void TestTerrainAlongPointToPointRoute()
        {
            var request = new PointToPointRouteData(2);

            request.Waypoints[0].Position = new ServiceCartographic
            {
                Altitude  = 1910,
                Latitude  = 39.0,
                Longitude = -104.77
            };
            request.Waypoints[0].Time = new DateTime(2018, 10, 30, 0, 0, 0);

            request.Waypoints[1].Position = new ServiceCartographic
            {
                Altitude  = 1910,
                Latitude  = 38.794,
                Longitude = -105.217755
            };
            request.Waypoints[1].Time   = new DateTime(2018, 10, 30, 1, 0, 0);
            request.OutputSettings.Step = 20;

            var result = TerrainServices.GetTerrainHeightsAlongARoute <PointToPointRouteData>(request).Result;

            Assert.That(result != null);
            Assert.That(result.Count == 181);
            Assert.AreEqual(2091.64136f, result[0].TerrainHeightFromMeanSeaLevel);
        }
コード例 #2
0
        public void TestTerrainAlongGreatArcRoute()
        {
            var request = new GreatArcRouteData(2);

            request.Waypoints[0].Position = new ServiceCartographic
            {
                Altitude  = 20000.0,
                Latitude  = 39.07096,
                Longitude = -104.78509
            };
            request.Waypoints[0].Time = new DateTime(2014, 02, 10, 10, 30, 0);

            request.Waypoints[1].Position = new ServiceCartographic
            {
                Altitude  = 100.0,
                Latitude  = 42.64541,
                Longitude = -61.11172
            };
            request.Waypoints[1].Time   = new DateTime(2014, 02, 10, 18, 30, 20);
            request.OutputSettings.Step = 3600;
            request.OutputSettings.CoordinateFormat.Coord = CoordinateRepresentation.XYZ;

            var result = TerrainServices.GetTerrainHeightsAlongARoute <GreatArcRouteData>(request).Result;

            Assert.That(result != null);
            Assert.That(result.Count == 10);
            Assert.AreEqual(2286.85181f, result[0].TerrainHeightFromMeanSeaLevel);
            Assert.AreEqual(-16.9748859f, result[0].MeanSeaLevelHeightFromWgs84);
            Assert.AreEqual(2269.87671f, result[0].TerrainHeightFromWgs84);
        }
コード例 #3
0
        public void TestTooManyPoints()
        {
            var request = new PointToPointRouteData(2);

            request.Waypoints[0].Position = new ServiceCartographic
            {
                Altitude  = 20000,
                Latitude  = 39.07096,
                Longitude = -104.78509
            };
            request.Waypoints[0].Time = new DateTime(2014, 02, 10, 10, 30, 0);

            request.Waypoints[1].Position = new ServiceCartographic
            {
                Altitude  = 100,
                Latitude  = 42.64541,
                Longitude = -61.11172
            };
            request.Waypoints[1].Time   = new DateTime(2014, 02, 10, 18, 30, 20);
            request.OutputSettings.Step = 60; // too many results for a terrain calculation

            void ErrorFunction()
            {
                var result = TerrainServices.GetTerrainHeightsAlongARoute <PointToPointRouteData>(request).Result;
            }

            var ex = Assert.Throws <AggregateException>(ErrorFunction);

            Assert.That(ex.Message.Contains("BadRequest"));
        }
コード例 #4
0
        public void TestTerrainAlongPointToPointRoute()
        {
            var request = new PointToPointRouteData(2);

            request.Waypoints[0].Position = new ServiceCartographic
            {
                Altitude  = 20000,
                Latitude  = 39.07096,
                Longitude = -104.78509
            };
            request.Waypoints[0].Time = new DateTime(2014, 02, 10, 10, 30, 0);

            request.Waypoints[1].Position = new ServiceCartographic
            {
                Altitude  = 100,
                Latitude  = 42.64541,
                Longitude = -61.11172
            };
            request.Waypoints[1].Time   = new DateTime(2014, 02, 10, 18, 30, 20);
            request.OutputSettings.Step = 900;

            var result = TerrainServices.GetTerrainHeightsAlongARoute <PointToPointRouteData>(request).Result;

            Assert.That(result != null);
            Assert.That(result.Count == 34);
            Assert.AreEqual(2269.87682f, result[0].TerrainHeightFromWgs84);
            Assert.AreEqual(-16.9748859f, result[0].MeanSeaLevelHeightFromWgs84);
            Assert.AreEqual(2286.85170f, result[0].TerrainHeightFromMeanSeaLevel);
        }
コード例 #5
0
        public ActionResult EditTerrain(int id)
        {
            var terrain = new Terrain();

            try
            {
                if (id < 1)
                {
                    terrain.Error     = "Invalid Selection!";
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                var myViewObj = new TerrainServices().GetTerrain(id);

                if (myViewObj == null || myViewObj.TerrainId < 1)
                {
                    terrain.Error     = "Terrain  Information could not be retrieved.";
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }
                Session["_terrain"] = myViewObj;
                myViewObj.ErrorCode = myViewObj.TerrainId;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                terrain.Error     = "An unknown error was Terrain  Information could not be retrieved.";
                terrain.ErrorCode = -1;
                return(Json(terrain, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public void TestTerrainAtASite()
        {
            var result = TerrainServices.GetTerrainHeightsAtASite(39.0, -104.77).Result;

            Assert.That(result != null);
            Assert.AreEqual(2091.6413192307896, result.TerrainHeightFromMeanSeaLevel);
            Assert.AreEqual(-17.063999999999989, result.MeanSeaLevelHeightFromWgs84);
            Assert.AreEqual(2074.5773192307897, result.TerrainHeightFromWgs84);
        }
コード例 #7
0
        public void TestTerrainAtASite()
        {
            var result = TerrainServices.GetTerrainHeightsAtASite(38.840318, -105.043498).Result;

            Assert.That(result != null);
            Assert.AreEqual(4299.2474923799728, result.TerrainHeightFromMeanSeaLevel);
            Assert.AreEqual(-16.108077610647548, result.MeanSeaLevelHeightFromWgs84);
            Assert.AreEqual(4283.1394147693254, result.TerrainHeightFromWgs84);
        }
コード例 #8
0
        private List <Terrain> GetTerrains()
        {
            var terrains = new TerrainServices().GetATerrains() ?? new List <Terrain>();

            if (!terrains.Any())
            {
                return(new List <Terrain>());
            }
            return(terrains);
        }
コード例 #9
0
        private List <Terrain> GetTerrains()
        {
            var sectorList = new TerrainServices().GetAllOrderedTerrains() ?? new List <Terrain>();

            if (!sectorList.Any())
            {
                return(new List <Terrain>());
            }

            return(sectorList);
        }
コード例 #10
0
        public ActionResult AddTerrain(Terrain terrain)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    terrain.Error     = "Please supply all required fields and try again";
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(terrain);

                if (wx.Code < 1)
                {
                    terrain.Error     = wx.Error;
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                var k = new TerrainServices().AddTerrainCheckDuplicate(terrain);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        terrain.Error     = "Terrain  already exists";
                        terrain.ErrorCode = -3;
                        return(Json(terrain, JsonRequestBehavior.AllowGet));
                    }

                    terrain.Error     = "Process Failed! Please contact the Admin or try again later";
                    terrain.ErrorCode = 0;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                terrain.Error     = "Record was added successfully";
                terrain.ErrorCode = 1;
                terrain.TerrainId = k;
                return(Json(terrain, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                terrain.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                terrain.ErrorCode = 0;
                return(Json(terrain, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #11
0
        public ActionResult Terrains()
        {
            var terrainList = new TerrainServices().GetAllOrderedTerrains() ?? new List <Terrain>();

            if (!terrainList.Any())
            {
                ViewBag.Edit  = 1;
                ViewBag.Title = "Terrain SetUp";
                return(View(new List <Terrain>()));
            }

            terrainList.Remove(terrainList.Find(m => m.TerrainId == (int)OtherNotAvailable.Not_Available));
            ViewBag.Title = "Manage Terrains";
            return(View(terrainList));
        }
コード例 #12
0
        public void TestBadLatitude()
        {
            void ErrorFunction()
            {
                var s = TerrainServices.GetTerrainHeightsAtASite(91, -105.043498).Result;
            }

            var ex = Assert.Throws <AggregateException>(ErrorFunction);

            Assert.That(ex.Message.Contains("BadRequest"));
            void ErrorFunction2()
            {
                var s = TerrainServices.GetTerrainHeightsAtASite(-91, -105.043498).Result;
            }

            ex = Assert.Throws <AggregateException>(ErrorFunction2);
            Assert.That(ex.Message.Contains("BadRequest"));
        }
コード例 #13
0
        private Field ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new Field
                {
                    Name = dv.Row["Field_Name"].ToString().Trim()
                };

                //[Field_Name], [Block_Name]

                var companyName = dv.Row["Company_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(companyName))
                {
                    mInfo.CompanyId = 1;
                }
                else
                {
                    var cannonicalName = "";
                    if (string.IsNullOrEmpty(dv.Row["Canonial_Name"].ToString().Trim()))
                    {
                        cannonicalName = dv.Row["Canonial_Name"].ToString().Trim();
                    }

                    var companyId = new CompanyServices().GetCompanyId(companyName, cannonicalName);
                    if (companyId < 1)
                    {
                        mInfo.CompanyId = 1;
                    }
                    mInfo.CompanyId = companyId;
                }

                var terrainName = dv.Row["Terrain_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(terrainName))
                {
                    mInfo.TerrainId = 1;
                }
                else
                {
                    var terrainId = new TerrainServices().GetTerrainIdByName(terrainName.Trim());
                    if (terrainId < 1)
                    {
                        mInfo.TerrainId = 1;
                    }
                    mInfo.TerrainId = terrainId;
                }

                mInfo.ZoneId = 1;

                var techAllowed = dv.Row["Technical_Allowable"].ToString().Trim();
                if (!string.IsNullOrEmpty(techAllowed))
                {
                    float outTech    = 0;
                    var   techResult = float.TryParse(techAllowed, out outTech);
                    if (techResult && outTech > 0)
                    {
                        mInfo.TechnicalAllowable = outTech;
                    }
                }

                var blockName = dv.Row["Block_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(blockName))
                {
                    msg = "Block Name is empty";
                    return(mInfo);;
                }

                var ttsd = new FieldServices().AddFieldCheckDuplicate(mInfo);
                if (ttsd < 1)
                {
                    msg = "Field could not be processed.";
                    return(null);
                }



                if (blockName.Contains("/"))
                {
                    var dxx = blockName.Split('/');
                    dxx.ForEach(v =>
                    {
                        if (!string.IsNullOrEmpty(v))
                        {
                            var tId = 0;
                            if (v.Trim().ToLower().Contains("oml"))
                            {
                                tId = 1;
                            }
                            if (v.Trim().ToLower().Contains("opl"))
                            {
                                tId = 2;
                            }

                            var block = new Block
                            {
                                CompanyId   = mInfo.CompanyId,
                                BlockTypeId = tId,
                                Name        = blockName,
                                LeaseTypeId = 1,
                                YearOfAward = DateTime.Now.Year
                            };

                            var ssd = new BlockServices().AddBlockCheckDuplicate(block);
                            if (ssd < 1)
                            {
                                return;
                            }
                        }
                    });
                }

                else
                {
                    var tId = 0;
                    if (blockName.Trim().ToLower().Contains("oml"))
                    {
                        tId = 1;
                    }
                    if (blockName.Trim().ToLower().Contains("opl"))
                    {
                        tId = 2;
                    }
                    var block = new Block
                    {
                        CompanyId   = mInfo.CompanyId,
                        BlockTypeId = tId,
                        Name        = blockName,
                        LeaseTypeId = 1,
                        YearOfAward = DateTime.Now.Year
                    };

                    var ssd = new BlockServices().AddBlockCheckDuplicate(block);
                    if (ssd < 1)
                    {
                        mInfo.FieldId = ttsd;
                        return(mInfo);
                    }
                }
                mInfo.FieldId = ttsd;
                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
コード例 #14
0
        public ActionResult EditTerrain(Terrain terrain)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_terrain"] == null)
                {
                    terrain.Error     = "Session has expired";
                    terrain.ErrorCode = 0;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                var oldTerrain = Session["_terrain"] as Terrain;

                if (oldTerrain == null || oldTerrain.TerrainId < 1)
                {
                    terrain.Error     = "Session has expired";
                    terrain.ErrorCode = 0;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                if (!ModelState.IsValid)
                {
                    terrain.Error     = "Please supply all required fields and try again";
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(terrain);

                if (wx.Code < 1)
                {
                    terrain.Error     = wx.Error;
                    terrain.ErrorCode = -1;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                oldTerrain.Name     = terrain.Name;
                oldTerrain.ZoneName = terrain.ZoneName;

                var k = new TerrainServices().UpdateTerrainCheckDuplicate(oldTerrain);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        terrain.Error     = "Terrain  already exists";
                        terrain.ErrorCode = 0;
                        return(Json(terrain, JsonRequestBehavior.AllowGet));
                    }

                    terrain.Error     = "Process Failed! Please contact the Admin or try again later";
                    terrain.ErrorCode = 0;
                    return(Json(terrain, JsonRequestBehavior.AllowGet));
                }

                terrain.Error     = "Terrain  Information was successfully updated";
                terrain.ErrorCode = 1;
                return(Json(terrain, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                terrain.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                terrain.ErrorCode = 0;
                return(Json(terrain, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #15
0
        private Field ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new Field
                {
                    Name = dv.Row["Field_Name"].ToString().Trim()
                };

                var zoneName = dv.Row["Zone_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(zoneName))
                {
                    msg = "Zone Name is empty";
                    return(null);
                }

                var zoneId = new ZoneServices().GetZoneIdByName(zoneName.Trim());
                if (zoneId < 1)
                {
                    msg = "Zone Information could not be processed.";
                    return(null);
                }
                mInfo.ZoneId = zoneId;

                var terrainName = dv.Row["Terrain_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(zoneName))
                {
                    msg = "Terrain Name is empty";
                    return(null);
                }

                var terrainId = new TerrainServices().GetTerrainIdByName(terrainName.Trim());
                if (terrainId < 1)
                {
                    msg = "Terrain Information could not be processed.";
                    return(null);
                }
                mInfo.TerrainId = terrainId;

                var blockName = dv.Row["Block_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(blockName))
                {
                    msg = "Block Name is empty";
                    return(null);
                }

                var blockId = new BlockServices().GetBlockId(blockName.Trim());
                if (blockId < 1)
                {
                    msg = "Block Information could not be processed.";
                    return(null);
                }
                mInfo.BlockId = blockId;


                var companyName = dv.Row["Company_Name"].ToString().Trim();
                if (string.IsNullOrEmpty(companyName))
                {
                    msg = "Company Name is empty";
                    return(null);
                }

                var companyId = new CompanyServices().GetCompanyId(companyName.Trim());
                if (companyId < 1)
                {
                    msg = "Company Information could not be processed.";
                    return(null);
                }
                mInfo.CompanyId = companyId;

                var techAllowed = dv.Row["Technical_Allowable"].ToString().Trim();
                if (!string.IsNullOrEmpty(techAllowed))
                {
                    float outTech    = 0;
                    var   techResult = float.TryParse(techAllowed, out outTech);
                    if (techResult && outTech > 0)
                    {
                        mInfo.TechnicalAllowable = outTech;
                    }
                }

                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
コード例 #16
0
        private Project ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new Project
                {
                    Name = dv.Row["ProjectName"].ToString().Trim()
                };

                var companyName = dv.Row["CompanyName"].ToString().Trim();
                if (string.IsNullOrEmpty(companyName))
                {
                    msg = "Company Name is empty";
                    return(null);
                }
                var compId = new CompanyServices().GetCompanyId(companyName);

                if (compId < 1)
                {
                    msg = "Company information could not be processed.";
                    return(null);
                }

                mInfo.CompanyId = compId;



                var projectType = dv.Row["ProjectType"].ToString().Trim();
                if (string.IsNullOrEmpty(projectType))
                {
                    msg = "project Type is empty";
                    return(null);
                }
                var projectTypeId = new ProjectTypeServices().GetProjectTypeId(projectType);

                if (projectTypeId < 1)
                {
                    msg = "Project Type information could not be processed.";
                    return(null);
                }

                mInfo.ProjectTypeId = projectTypeId;

                var terrain = dv.Row["Terrain"].ToString().Trim();
                if (string.IsNullOrEmpty(terrain))
                {
                    msg = "Terrain is empty";
                    return(null);
                }
                var terrainId = new TerrainServices().GetTerrainId(terrain);

                if (terrainId < 1)
                {
                    msg = "Terrain information could not be processed.";
                    return(null);
                }

                mInfo.TerrainId = terrainId;

                var sector = dv.Row["Sector"].ToString().Trim();
                if (string.IsNullOrEmpty(sector))
                {
                    msg = "Sector is empty";
                    return(null);
                }
                var sectorId = new SectorServices().GetSectorId(sector);

                if (sectorId < 1)
                {
                    msg = "Sector information could not be processed.";
                    return(null);
                }

                mInfo.SectorId = sectorId;

                var duration = dv.Row["Duration(Months)"].ToString().Trim();
                if (string.IsNullOrEmpty(duration))
                {
                    msg = "Project Duration is empty";
                    return(null);
                }

                int outDur;
                var durResult = int.TryParse(duration, out outDur);
                if (!durResult || outDur < 1)
                {
                    msg = "Project Duration is not Valid";
                    return(null);
                }

                mInfo.Duration = outDur;

                double cost;
                var    costStr = double.TryParse(dv.Row["Cost(Million)"].ToString().Trim(), out cost);
                if (!costStr || cost <= 0)
                {
                    msg = "Invalid Project Cost";
                    return(null);
                }

                mInfo.Cost = cost;

                if (!string.IsNullOrEmpty(dv.Row["Description"].ToString().Trim()))
                {
                    mInfo.Description = dv.Row["Description"].ToString().Trim();
                }

                if (!string.IsNullOrEmpty(dv.Row["Objectives"].ToString().Trim()))
                {
                    mInfo.ProjectObjectives = dv.Row["Objectives"].ToString().Trim();
                }

                if (!string.IsNullOrEmpty(dv.Row["CompletionStatus(Completed/UnCompleted)"].ToString().Trim()))
                {
                    var tts = dv.Row["CompletionStatus(Completed/UnCompleted)"].ToString().Trim().ToLower();
                    if (tts == "completed")
                    {
                        mInfo.CompletionStatus = 1;
                    }
                    if (tts == "uncompleted")
                    {
                        mInfo.CompletionStatus = 0;
                    }
                }

                if (!string.IsNullOrEmpty(dv.Row["DateCompleted(yyyy/MM/dd)"].ToString().Trim()))
                {
                    DateTime ddt;
                    var      dtResult = DateTime.TryParse(dv.Row["DateCompleted(yyyy/MM/dd)"].ToString().Trim(), out ddt);

                    if (!dtResult)
                    {
                        msg = "Invalid Project Completion Date";
                        return(null);
                    }

                    mInfo.DateCompleted = ddt;
                }

                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }