public async Task <IActionResult> Get(string region, double x, double y, string crs, [FromQuery] Int32 count = 5) { //ProjectionServiceAgent sa = null; List <Site> gageList = null; try { if (x == 0 || y == 0 || String.IsNullOrEmpty(crs) || String.IsNullOrEmpty(region)) { return(new BadRequestObjectResult("One or more of the parameters are invalid.")); } if (!agent.Load(region, count)) { throw new Exception("Krig failed to load."); } if (!string.Equals(crs.Trim(), agent.SR.Trim(), StringComparison.OrdinalIgnoreCase)) { var sa = new ProjectionServiceAgent(this.projectionSettings); if (!sa.ProjectPointAsync(ref x, ref y, crs, agent.SR)) { throw new Exception("Failed to project point. try passing in sr of " + agent.SR); } } //end if if (agent.IndexGages.Count < 1) { return(new BadRequestObjectResult(new Error(errorEnum.e_error, "No Index Gages"))); } if (!agent.Execute(x, y)) { throw new Exception("Kriging Failed"); } gageList = agent.TopCorrelatedGages.Select(g => new Site(g.Value.ID, g.Value.Name, g.Value.X, g.Value.Y, g.Value.crs, g.Value.DrainageArea, g.Key )).ToList(); return(Ok(gageList)); } catch (Exception ex) { return(HandleException(ex)); } }
public OperationResult Get(String state, Double x, Double Y, string wkid, [Optional]Int32 count) { Krig thisKrig = null; ProjectionServiceAgent sa = null; List<Site> gageList = null; if (count < 1) count = 5; try { thisKrig = new Krig(GetStateByName(state).ToString(), count); if(!string.Equals(wkid.Trim(),thisKrig.SR.Trim(), StringComparison.OrdinalIgnoreCase)) { sa = new ProjectionServiceAgent(); if(!sa.ProjectPoint(ref x, ref Y, wkid, thisKrig.SR)) throw new Exception("Failed to project point. try passing in sr of "+ thisKrig.SR); }//end if if (thisKrig.IndexGages.Count < 1) return new OperationResult.BadRequest { ResponseResource = "No Index Gages"}; if (thisKrig.StartKrigging(x, Y)) return new OperationResult.InternalServerError { ResponseResource = "Kriging Failed" }; gageList = thisKrig.TopCorrelatedGages.Select(g => new Site(g.Value.ID, g.Value.Name, g.Value.LocationX, g.Value.LocationY, g.Value.DrainageArea, g.Key )).ToList(); return new OperationResult.OK { ResponseResource = gageList }; } catch (Exception ex) { return new OperationResult.InternalServerError { ResponseResource = ex.Message.ToString() }; } }//end HttpMethod.GET