public void DBTableTest()
        {
            try
            {
                List <Characteristics> results = null;
                var username = Configuration["dbuser"];
                var password = Configuration["dbpassword"];

                string DBConnectionstring = string.Format("Server=test.c69uuui2tzs0.us-east-1.rds.amazonaws.com; database={0}; UID={1}; password={2}", "NavigationDB", username, password);

                using (var dbOps = new NavigationDBOps(DBConnectionstring))
                {
                    results = dbOps.GetCharacteristics(new List <int>()
                    {
                        -504212, -504197
                    }).ToList();
                }

                Assert.NotNull(results);
                Assert.Equal(2, results.Count);
            }
            catch (Exception ex)
            {
                Assert.False(true, ex.Message);
            }
        }
        private void LoadVAAProperties(List <Feature> traceItems)
        {
            try
            {
                using (var NavDBOps = new NavigationDBOps(this.NavDBConnectionstring))
                {
                    DateTime startDateTime = DateTime.Now;

                    List <Int32> comids     = traceItems.Select(i => Convert.ToInt32(i.Properties["nhdplus_comid"])).ToList();
                    var          properties = NavDBOps.GetAvailableProperties(comids);
                    DateTime     DBDateTime = DateTime.Now;

                    traceItems.ForEach(i =>
                    {
                        var comid = Convert.ToInt32(i.Properties["nhdplus_comid"]);
                        var VAA   = properties.FirstOrDefault(p => p.ContainsKey("COMID") && Convert.ToInt32(p["COMID"]) == comid);

                        foreach (var item in VAA.Where(p => p.Key != "COMID" && p.Key != "ID"))
                        {
                            i.Properties.Add(item.Key, item.Value);
                        }//next
                    });
                    DateTime associatedDateTime = DateTime.Now;
                    sm($"count {comids.Count()}; time to query: {(DBDateTime - startDateTime).Seconds} sec, time to associate to features {(associatedDateTime - DBDateTime).Seconds} sec.");
                }
            }
            catch (Exception ex)
            {
                sm($"Failed to load VAA properties with following error {ex.Message}", MessageType.error);
            }
        }
예제 #3
0
        public async Task <IActionResult> Get([FromQuery] Int32?featureid, [FromQuery] double?x, [FromQuery] double?y)
        {
            //returns list of available Navigations
            try
            {
                List <Dictionary <string, object> > results = null;
                if (!featureid.HasValue && (!x.HasValue && !y.HasValue))
                {
                    return(new BadRequestObjectResult("An featureid or location (x,y) must be specified."));
                }

                if (x.HasValue && y.HasValue)
                {
                    var agent = new NLDIServiceAgent(settings.NLDI);

                    featureid = Convert.ToInt32(agent.GetLocalCatchmentAsync(new Point(new Position(y.Value, x.Value))
                    {
                        CRS = new NamedCRS("EPSG:4326")
                    }).Features.FirstOrDefault().Properties["featureid"]);
                }

                using (var NavDBOps = new NavigationDBOps(settings.DBConnectionString))
                {
                    results = NavDBOps.GetAvailableProperties(new List <int>()
                    {
                        featureid.Value
                    }).ToList();
                }//end using

                return(Ok(results));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }