public override object GetTimeSeries( locationParam lp, VariableParam vp, Nullable <W3CDateTime> startDate, Nullable <W3CDateTime> endDate) { if (lp.isGeometry) { throw new WaterOneFlowException("Geometry not supported "); } TimeSeriesResponseType result = null; //string Network; //string SiteCode; ////WSUtils.ParseSiteId(siteId, out Network, out SiteCode); //try //{ // locationParam sq = new locationParam(siteNumber); // Network = sq.Network; // SiteCode = sq.SiteCode; // if (sq.isGeometry) // { // throw new WaterOneFlowException("Location by Geometry not accepted: " + siteNumber); // } //} //catch (WaterOneFlowException we) //{ // log.Info("Bad SiteID:" + siteNumber); // throw; //} //catch (Exception e) //{ // log.Error("Uncaught exception:" + e.Message); // throw new WaterOneFlowException("Sorry. Your submitted site ID for this getSiteInfo request caused an problem that we failed to catch programmatically: " + e.Message); //} //// string WaterQualityList = "¶meter_cd=" + variable; //string[] StationsList = new string[] { SiteCode }; string[] StationsList = new string[] { lp.SiteCode }; //VariableParam vp; //try //{ // vp = new VariableParam(variable); //} //catch (WaterOneFlowException we) //{ // log.Info("Bad Variable Request '" + variable + "'"); // throw; //} //catch (Exception e) //{ // log.Error("uncaught exception duing Variable Request '" + variable + "'"); // throw new WaterOneFlowException("Sorry. Your variable parameter caused an exception that we failed to catch:" + e.Message); //} result = CuahsiBuilder.CreateTimeSeriesObject(); //// all data are provisional //List<note> notes = new List<note>(); //note urlNote = new note(); //urlNote.title = "USGS Data Provisional"; //urlNote.href = "http://waterdata.usgs.gov/nwis/help/?provisional"; //urlNote.Value = "All data are provisional, and subject to revision"; //notes.Add(urlNote); //result.queryInfo.note = notes.ToArray(); result.queryInfo.criteria.locationParam = lp.ToString(); result.queryInfo.criteria.variableParam = vp.ToString(); // result.queryInfo.criteria.timeParam = CuahsiBuilder.createQueryInfoTimeCriteria(startDate, endDate); // look for siteInfoType in cache, and use if it is there /* SiteInfoType sit = (SiteInfoType)appCache[sitCache + SiteCode]; * if (sit == null) * { * // just use the values for now. * ((SiteInfoType)result.timeSeries.sourceInfo).siteCode[0].Value = SiteCode; * ((SiteInfoType)result.timeSeries.sourceInfo).siteCode[0].network = "NWIS"; * * } * else * { * // in the cache, use it * result.timeSeries.sourceInfo = sit; * } * */ result.timeSeries.sourceInfo = DataInfoService.GetSite(lp); // vaiable info // result.timeSeries.variable = vp.getVariableSchemaType(); //result.timeSeries.variable = NwisVariableCatalog.getVariable(vp.Code, variableDataSet); //result.timeSeries.variable = ODvariables.getVariable(vp.Code, variableDataSet)[0]; // not fully correct, but just choose the first one. VariableInfoType[] vits = DataInfoService.GetVariableInfoObject(vp); result.timeSeries.variable = vits[0]; string aURL = GroundWater(startDate, endDate, StationsList, USGSCommon.option2AgencyCode(lp)); try { // refactor too much abstraction //CreateRealTimeSeriesObject(result, RealTime(StationsList)); result.timeSeries.values = CreateGWTimeSeriesObject(vp, aURL); } catch (WaterOneFlowException e) { //log.Error(e.Message + e.StackTrace); throw; } catch (WaterOneFlowSourceException e) { //log.Error(e.Message + e.StackTrace); throw; } catch (WebException e) { log.Error(e.Message + e.StackTrace); throw new WaterOneFlowException("Connecting to External resource failed.", e); } catch (Exception e) { log.Error(e.Message + e.StackTrace); throw new WaterOneFlowException("An External resource failed.", e); } result.timeSeries.sourceInfo = DataInfoService.GetSite(lp); List <NoteType> notes = new List <NoteType>(); NoteType urlNote = new NoteType(); urlNote.title = "USGS URL"; urlNote.Value = aURL; notes.Add(urlNote); result.queryInfo.note = notes.ToArray(); return(result); }
public override object GetTimeSeries( locationParam lp, VariableParam vp, Nullable <W3CDateTime> startDate, Nullable <W3CDateTime> endDate) { if (lp.isGeometry) { throw new WaterOneFlowException("Geometry not supported "); } TimeSeriesResponseType result = null; string[] StationsList = new string[] { lp.SiteCode }; result = CuahsiBuilder.CreateTimeSeriesObject(); result.queryInfo.criteria.locationParam = lp.ToString(); result.queryInfo.criteria.variableParam = vp.ToString(); result.timeSeries.sourceInfo = DataInfoService.GetSite(lp); // not fully correct, but just choose the first one. VariableInfoType[] vits = DataInfoService.GetVariableInfoObject(vp); result.timeSeries.variable = vits[0]; string aURL = InstantaneousData(startDate, endDate, new string[] { vp.Code }, StationsList, USGSCommon.option2AgencyCode(lp)); try { result.timeSeries.values = CreateWQTimeSeriesObject(vp, aURL); } catch (WaterOneFlowException e) { throw; } catch (WaterOneFlowSourceException e) { throw; } catch (Exception e) { log.Error(e.Message + e.StackTrace); throw new WaterOneFlowException("An External resource failed.", e); } List <NoteType> notes = new List <NoteType>(); NoteType urlNote = new NoteType(); urlNote.title = "USGS URL"; urlNote.Value = aURL; notes.Add(urlNote); result.queryInfo.note = notes.ToArray(); return(result); }