public void WriteThenReadVerticalDatum() { VerticalDatumInfo vdi = CreateVDI(); var locationInfo = new LocationInformation(); LocationInformation loc; locationInfo.XOrdinate = 765.432; locationInfo.VerticalDatumInfo = vdi; string path = "a/b/Location Info"; var dssFile = "WriteThenReadVerticalDatum.dss"; File.Delete(dssFile); using (var w = new DssWriter(dssFile)) { w.StoreLocation(path, locationInfo); } using (var r = new DssReader(dssFile)) { loc = r.GetLocationInfo(path); DoAssertions(CreateVDI(), loc.VerticalDatumInfo); Assert.AreEqual(locationInfo.XOrdinate, loc.XOrdinate); } Console.WriteLine(loc.VerticalDatumInfo.ToXml(true)); }
public string RequestWEOID(LocationInformation location) { string url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22" + location.City + "%20" + location.State + "%20" + location.Country + "%22&format=xml"; //string url = @"http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text%3D%22" + @location.City + @"," + @location.State + @", " + location.Country + @"&format=xml"; var doc = new XmlDocument(); doc.Load(url); XmlNodeList nodelstwoeid = doc.GetElementsByTagName("woeid"); var woeid = nodelstwoeid[0].InnerText; var city = location.City; var state = location.State; var country = location.Country; //var zipcode = location.zipcode; var constr = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("spCreateNewWOEID", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@City", SqlDbType.VarChar).Value = city; cmd.Parameters.Add("@State", SqlDbType.VarChar).Value = state; cmd.Parameters.Add("@Country", SqlDbType.VarChar).Value = country; cmd.Parameters.Add("@WOEID", SqlDbType.VarChar).Value = woeid; con.Open(); cmd.ExecuteNonQuery(); } } getTwitterData(WOEID); return(""); }
public void Init() { if (_launcherInfo != null) { Name = AircraftInformation.AircraftFile.Replace(".acf", ""); Livery = GetLastParthOfLiveryPath(AircraftInformation.Livery); Location = new Location(AircraftInformation.Latitude, AircraftInformation.Longitude); SummaryDistanceNauticalMiles = _launcherInfo.SummaryDistanceNauticalMiles; SummaryHours = _launcherInfo.SummaryHours; foreach (Location location in _launcherInfo.TargetLocation) { LocationInformation additionalInformation = null; if (_launcherInfo.LocationInformations != null && _launcherInfo.LocationInformations.ContainsKey(location)) { additionalInformation = _launcherInfo.LocationInformations[location]; } RoutePoint routePoint = new RoutePoint(location, Id); if (additionalInformation != null) { routePoint.Update(additionalInformation.Name, additionalInformation.Comment); } Route.Add(routePoint); } } }
void searchProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { SearchRequestResult result = e.RequestResult; if (result.ResultCode == RequestResultCode.Success) { LocationInformation region = result.SearchRegion; if (region != null) { NavigateTo(region.Location); } else { if (result.SearchResults.Count > 0) { NavigateTo(result.SearchResults[0].Location); } } //DisplayResults(e.RequestResult); } if (result.ResultCode == RequestResultCode.BadRequest) { XtraMessageBox.Show("The Bing Search service does not work for this location."); } }
private void ViewCatalogSelection(object sender, RoutedEventArgs e) { if (!_canExecute()) { return; } DssPath dssPath = (DssPath)dataGrid.SelectedItem; DssCatalogTableVM catalog = (DssCatalogTableVM)DataContext; if (dssPath.RecordType == RecordType.RegularTimeSeries || dssPath.RecordType == RecordType.IrregularTimeSeries) { TimeSeries ts = catalog.File.GetTimeSeries(dssPath, compression: catalogProperties.compression); TimeSeriesWindow tsWindow = new TimeSeriesWindow(ts, catalogProperties, dssFile); tsWindow.DisableEditFeatures(); tsWindow.Show(); } else if (dssPath.RecordType == RecordType.PairedData) { PairedData pd = catalog.File.GetPairedData(dssPath); PairedDataWindow pdWindow = new PairedDataWindow(pd, catalogProperties, dssFile); pdWindow.DisableEditFeatures(); pdWindow.Show(); } else if (dssPath.RecordType == RecordType.LocationInfo) { LocationInformation li = catalog.File.GetLocationInformation(dssPath); LocationInfoWindow liWindow = new LocationInfoWindow(li, catalogProperties); liWindow.Show(); } }
internal override void Parse() { IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Locations") .Elements(GetSchema() + "Location"); foreach (XElement hostedService in rootElements) { var service = new LocationInformation { Name = (string)hostedService.Element(GetSchema() + "Name"), DisplayName = (string)hostedService.Element(GetSchema() + "DisplayName"), VirtualMachineRolesSizes = new List <VmSize>(), WebWorkerRolesSizes = new List <VmSize>() }; foreach (var element in hostedService.Element(GetSchema() + "AvailableServices").Elements(GetSchema() + "AvailableService")) { service.AvailableServices |= (AvailableServices)Enum.Parse(typeof(AvailableServices), element.Value); } foreach (var element in hostedService.Element(GetSchema() + "ComputeCapabilities").Element(GetSchema() + "WebWorkerRoleSizes") .Elements(GetSchema() + "RoleSize")) { service.WebWorkerRolesSizes.Add((VmSize)Enum.Parse(typeof(VmSize), element.Value)); } foreach (var element in hostedService.Element(GetSchema() + "ComputeCapabilities").Element(GetSchema() + "VirtualMachinesRoleSizes") .Elements(GetSchema() + "RoleSize")) { service.VirtualMachineRolesSizes.Add((VmSize)Enum.Parse(typeof(VmSize), element.Value)); } CommandResponse.Add(service); } }
void INavigatorMapViewModel.NewPushpinCreated(MapPushpin newPushpin) { newPushpin.MouseLeftButtonDown += (s, e) => { MapPushpin pushpin = s as MapPushpin; if ((pushpin != null) && (pushpin.State == MapPushpinState.Normal)) { LocationInformation locationInformation = pushpin.Information as LocationInformation; DestinationAddress = locationInformation.Address.FormattedAddress; DestinationLocation = (GeoPoint)pushpin.Location; pushpin.Text = "A"; Regex rx = new Regex("(.*?), (.*?), (.*?) (.*)"); var match = rx.Match(locationInformation.Address.FormattedAddress); string streetLine = match.Groups[1].ToString().Trim(); string city = match.Groups[2].ToString().Trim(); string state = match.Groups[3].ToString().Trim(); string zipcode = match.Groups[4].ToString().Trim(); Destination = new Address { City = city, Line = streetLine, State = state, ZipCode = zipcode, Latitude = DestinationLocation.Latitude, Longitude = DestinationLocation.Longitude }; MapPushpinsService.Clear(); CalculateRouteDriving(); } }; }
private static void RunWriteTest(string dssFile) { using (DssWriter dss = new DssWriter(dssFile)) { DssPathCollection paths = dss.GetCatalog(); var pathsFound = paths.FilterByPart("Basin", "Location", "Flow", "", "1Hour", "C Test"); DssPath path = pathsFound[0]; //string path = PathBuilder.FormPathName("Basin", "Location", "Flow", "", "1Hour", "C Test"); double[] values = new double[300]; for (int i = 0; i < 300; i++) { values[i] = (double)i; } DateTime dateTime = new DateTime(2001, 1, 21, 12, 0, 0, 0); TimeSeries ts = new TimeSeries(); ts.Path = path; ts.Values = values; ts.StartDateTime = dateTime; ts.Units = "cfs"; ts.DataType = "Inst-Val"; //dss.StoreTimeSeriesRegular(path, values, 0, dateTime, "cfs", "Inst-Val"); dss.Write(ts, true); //dss.StoreTimeSeriesRegular("/Basin/Location/Flow//1Hour/C Test/", values, 0, "21Jan2001", "1200", "cfs", "Inst-Val"); ts = dss.GetTimeSeries(path); LocationInformation data = dss.GetLocationInfo(path.FullPath); Console.ReadLine(); } }
private void CheckAddress(object sender, EventArgs e) { if (addressBox.Text.Length == 0) { return; } LocationInformation.OpenAdressInBrowser(addressBox.Text); }
public UserData(string address, double latitude, double longitude, string username) { Init(); this.Address = LocationInformation.FormatAddress(address); this.Latitude = latitude; this.Longitude = longitude; this.Username = username; }
void AddMapItem(LocationInformation locationInformation) { storage.Items.Add(new MapDot() { Location = locationInformation.Location, ToolTipPattern = locationInformation.DisplayName, Size = 20 }); }
private static LocationInformation CreateLocation(string tzName) { LocationInformation loc = new LocationInformation(); loc.TimeZoneName = tzName; loc.HorizontalUnits = 1; // feet loc.VerticalDatum = 1; // nav88 loc.Supplemental = "Supplemental"; return(loc); }
public void CalculateAddress(GeoPoint geoPoint) { //Implement your custom geocode logic here LocationInformation info = new LocationInformation(); info.Address = new Address("Address from your service here " + Environment.NewLine + "Coordinates: " + geoPoint.ToString()); info.Location = new GeoPoint(geoPoint.Latitude, geoPoint.Longitude); Address = info; // RaiseChanged(); }
public UserData(string address, string userName) { Init(); this.Address = LocationInformation.FormatAddress(address); this.Username = userName; MapPoint location = LocationInformation.LatLongFromAddress(address); this.Latitude = location.Latitude; this.Longitude = location.Longitude; }
public Task <int> SaveItemAsync(LocationInformation item) { if (item.Id != 0) { return(database.UpdateAsync(item)); } else { return(database.InsertAsync(item)); } }
/// <summary> /// display get the weather data by longitude and latitude /// </summary> /// <returns>weather data</returns> private WeatherData DisplayGetWeatherByLonLat(out LocationInformation locationInformation) { WeatherData weatherData; double lon, lat; locationInformation = new LocationInformation(); DisplayHeader("Weather by Longitude and latitude"); // // get longitude and latitude from user // do { Console.Write("\tEnter Longitude:"); } while (!double.TryParse(Console.ReadLine(), out lon)); do { Console.Write("\tEnter latitude:"); } while (!double.TryParse(Console.ReadLine(), out lat)); // // acquire weather data from Open Weather Map // weatherData = _businessLogic.GetWeatherByLonLat(new LocationCoordinates() { Longitude = lon, Latitude = lat }, out ResponseStatusCode responseStatusCode); if (responseStatusCode == ResponseStatusCode.COMPLETE) { // // update LocationInformation object // locationInformation.LocationCoordinates = new LocationCoordinates() { Longitude = lon, Latitude = lat }; locationInformation.Name = weatherData.Name; locationInformation.ZipCode = 0; Console.WriteLine($"\tWeather data for Longitude:{lon:0.##} and Latitude:{lat:0.##} acquired."); } else { Console.WriteLine(DisplayResponseStatusErrorMessage(responseStatusCode)); } DisplayContinuePrompt(); return(weatherData); }
private void PushpinMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MapPushpin pushpin = sender as MapPushpin; if ((pushpin != null) && (pushpin.State == MapPushpinState.Normal)) { LocationInformation locationInformation = pushpin.Information as LocationInformation; AddWaypoint(locationInformation == null ? string.Empty : locationInformation.DisplayName, pushpin.Location); geocodeInformationLayer.ClearResults(); } e.Handled = true; }
public bool ChangeAddress(string address) { if (!LocationInformation.IsValidAddress(address)) { return(false); } MapPoint location = LocationInformation.LatLongFromAddress(address); this.Address = LocationInformation.FormatAddress(address); this.Longitude = location.Longitude; this.Latitude = location.Latitude; return(true); }
public async Task Search_InvalidLocation_Error() { var searchText = "Londo"; var location = new LocationInformation(1.0d, null); var results = await searchEngine.Search(searchText, location); Assert.IsFalse(results.IsSuccess); location = new LocationInformation(null, 1.0d); results = await searchEngine.Search(searchText, location); Assert.IsFalse(results.IsSuccess); }
string ProcessLocationInformation(LocationInformation info) { if (info == null) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append(String.Format("{0}\n", info.DisplayName)); sb.Append(String.Format("\tAdress: {0}\n", info.Address)); sb.Append(String.Format("\tLocation: {0}\n", info.Location)); return(sb.ToString()); }
private Repository GetFakeRepo(int number) { var key = number.ToString(); if (repoDictionary.ContainsKey(key)) { return(repoDictionary[key]); } var repository = Repository.Create($"Repository{number}", LocationInformation.CreateOnlineOnlyInformation("http://example.com"), key); repoDictionary.Add(key, repository); return(repository); }
internal override void Parse() { IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Locations") .Elements(GetSchema() + "Location"); foreach (XElement hostedService in rootElements) { var service = new LocationInformation { Name = (string)hostedService.Element(GetSchema() + "Name"), DisplayName = (string)hostedService.Element(GetSchema() + "DisplayName") }; CommandResponse.Add(service); } }
public void Search(string keyword) { Random rnd = new Random(DateTime.Now.Millisecond); addresses.Clear(); int length = keyword.Length; for (int i = 0; i < length; i++) { LocationInformation info = new LocationInformation(); info.Address = new Address(keyword + " " + i.ToString()); info.Location = new GeoPoint(rnd.Next(180) - 90, rnd.Next(360) - 180); addresses.Add(info); } RaiseChanged(); }
public UserData(DataList dataList) { Init(); try { if (dataList == null) { throw new ArgumentNullException(); } object username = dataList.Get("username"); object address = dataList.Get("address"); object latitude = dataList.Get("latitude"); object longitude = dataList.Get("longitude"); object email = dataList.Get("email"); object password = dataList.Get("password"); if (username != null && address != null) { this.Username = (string)username; this.Address = LocationInformation.FormatAddress((string)address); if (latitude == null || longitude == null) { MapPoint location = LocationInformation.LatLongFromAddress(this.Address); this.Latitude = location.Latitude; this.Longitude = location.Longitude; } else { this.Longitude = (double)longitude; this.Latitude = (double)latitude; } } if (email != null && password != null) { this.SavedEmail = (string)email; this.SavedPassword = (string)password; } } catch (Exception e) { this.Username = null; this.Address = null; this.Latitude = 0; this.Longitude = 0; } }
private void Next(object sender, EventArgs e) { if (!LocationInformation.IsValidAddress(addressBox.Text) || (addressBox.Text.Length == 0 && adressCheckBox.Checked) || usernameTextBox.Text.Length == 0) { if (!LocationInformation.IsValidAddress(addressBox.Text) || addressBox.Text.Length == 0) { inputResultLabel.Text = "Invalid address"; addressBox.BackColor = Color.FromArgb(255, 128, 128); } else { addressBox.BackColor = Color.White; } if (usernameTextBox.Text.Length < 3) { inputResultLabel.Text = "Username must be atleast 3 characters"; usernameTextBox.BackColor = Color.FromArgb(255, 128, 128); } else { usernameTextBox.BackColor = Color.White; } return; } UserData user; if (adressCheckBox.Checked) { user = new UserData(addressBox.Text, usernameTextBox.Text); } else { user = new UserData(usernameTextBox.Text); } DataList userData = UserData.ToDataList(user); //Program.SaveUserData(); Program.UserDataManager.UserData = user; Program.UserInfoNaturallyClosed = true; //If some bug occurs in saving related to this form try moving the following statement //to on close function. Program.UserDataManager.Save(); this.Close(); }
private void DisplayMainMenu() { bool runApp = true; WeatherData _weatherData = null; LocationInformation _locationInformation = null; LocationDesignationMethod locationDesignationMethod = LocationDesignationMethod.None; InitializeApplicationWindow(); do { DisplayHeader("\t\tMain Menu"); Console.WriteLine(""); Console.WriteLine("\tA. Get Weather Data by Longitude and Latitude"); Console.WriteLine("\tB. Get Weather Data by Zip Code"); Console.WriteLine("\tC. Display Weather Data Short Format"); Console.WriteLine("\tQ. Quit"); Console.WriteLine(); Console.Write("\tEnter Menu Choice:"); switch (Console.ReadLine().ToLower()) { case "a": _weatherData = DisplayGetWeatherByLonLat(out _locationInformation); locationDesignationMethod = LocationDesignationMethod.LongitudeLatitude; break; case "b": _weatherData = DisplayGetWeatherByZipCode(out _locationInformation); locationDesignationMethod = LocationDesignationMethod.ZipCode; break; case "c": DisplayWeatherDataShortFormat(_weatherData, _locationInformation, locationDesignationMethod); break; case "q": runApp = false; break; default: Console.WriteLine("Please make a selection A-C or Q."); DisplayContinuePrompt(); break; } } while (runApp); }
/// <summary> /// display get the weather data by zip code /// </summary> /// <returns>weather data</returns> private WeatherData DisplayGetWeatherByZipCode(out LocationInformation locationInformation) { WeatherData weatherData; int zipCode; locationInformation = new LocationInformation(); DisplayHeader("Weather by Zip Code"); // // get zip code from user // do { Console.Write("\tEnter Zip Code:"); } while (!int.TryParse(Console.ReadLine(), out zipCode)); // // acquire weather data from Open Weather Map // weatherData = _businessLogic.GetWeatherByZipCode(zipCode, out ResponseStatusCode responseStatusCode); if (responseStatusCode == ResponseStatusCode.COMPLETE) { // // update LocationInformation object // locationInformation.ZipCode = zipCode; locationInformation.Name = weatherData.Name; locationInformation.LocationCoordinates = new LocationCoordinates() { Longitude = weatherData.Coord.Lon, Latitude = weatherData.Coord.Lat }; Console.WriteLine($"\tWeather data for Zip Code:{zipCode} acquired."); } else { Console.WriteLine(DisplayResponseStatusErrorMessage(responseStatusCode)); } DisplayContinuePrompt(); return(weatherData); }
public string GetTrends(string locationInformation) { //Type type = Type.GetType(locationInformation); JObject jObject = JObject.Parse(locationInformation); var location = new LocationInformation(); location.City = (string)jObject["City"]; location.Country = (string)jObject["Country"]; location.CountryCode = (string)jObject["CountryCode"]; location.State = (string)jObject["State"]; location.StateCode = (string)jObject["StateCode"]; location.zipcode = (string)jObject["zipcode"]; var trends = new GetTrends(location); trends.getWOEIDByCity(); return("1"); }
public void WhatIsCostOfStringinSupplemental() { String fn = "WhatIsCostOfStringinSupplemental.dss"; File.Delete(fn); using (var w = new DssWriter(fn)) { for (int i = 1; i < 1000; i++) { var ts = TimeSeriesTest.CreateSampleTimeSeries(DateTime.Now.Date, "cfs", "Per-AVE", size: 1200); ts.Path = new DssPath("/A/" + i.ToString().PadLeft(4, 'B') + "/flow//1Day/ver1/"); LocationInformation loc = new LocationInformation(); loc.Supplemental = "WAT_tag:Realization/" + i + ";"; ts.LocationInformation = loc; w.StoreLocation(ts.Path.FullPath, loc, true); w.Write(ts); } } }
private void DisplayWeatherDataShortFormat(WeatherData weatherData, LocationInformation locationInformation, LocationDesignationMethod locationDesignationMethod) { DisplayHeader("Current Weather Data"); Console.WriteLine($"\tWeather Data for {locationInformation.Name}"); if (locationInformation.ZipCode != 0) { Console.WriteLine("\tZip Code:" + locationInformation.ZipCode); } Console.WriteLine($"\tLongitude: {locationInformation.LocationCoordinates.Longitude:0.##}"); Console.WriteLine($"\tLatitude: {locationInformation.LocationCoordinates.Latitude:0.##}"); Console.WriteLine(); Console.WriteLine($"\tTemperature: {DisplayFahrenheit(weatherData.Main.Temp)}"); Console.WriteLine($"\tHumidity: {weatherData.Main.Humidity:0.}%"); Console.WriteLine($"\tWind: {DisplayMilesPerHour(weatherData.Wind.Speed)} {DisplayCardinalDirection(weatherData.Wind.Deg)}"); DisplayContinuePrompt(); }
/// <summary>ファイルを元にWeatherDataTableを構成する</summary> /// <param name="filePath">読み取りファイルのパス</param> /// <param name="success">読み取り成功の真偽</param> /// <returns>構成されたPWeatherDataオブジェクト</returns> public static WeatherDataTable ToPWeatherData(string filePath, out bool success) { success = false; //読み出しファイルの存在確認 if (File.Exists(filePath)) { WeatherDataTable wdTable = new WeatherDataTable(); using (StreamReader sReader = new StreamReader(filePath)) { string[] buff; DateTime dTime = new DateTime(); //第1行:地点情報 buff = sReader.ReadLine().Split(','); LocationInformation lInfo = new LocationInformation(); lInfo.ID = int.Parse(buff[0]); lInfo.Name = buff[1]; lInfo.EnglishName = buff[2]; lInfo.Latitude = double.Parse(buff[4]); lInfo.Longitude = double.Parse(buff[5]); lInfo.Elevation = double.Parse(buff[6]); for (int i = 0; i < 8760; i++) { WeatherRecord wRecord = new WeatherRecord(); WeatherData wData; //年月日特定 if (i == 0) { buff = sReader.ReadLine().Split(','); dTime = DateTime.ParseExact(buff[0], "MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo); } wRecord.DataDTime = dTime; //日射関連********************************** //大気圏外水平面日射 wData = new WeatherData(double.Parse(buff[2]) / 3600d, WeatherData.DataSource.CalculatedValue, -1); wRecord.SetData(WeatherRecord.RecordType.ExtraterrestrialHorizontalRadiation, wData); //大気圏外法線面日射 wData = new WeatherData(double.Parse(buff[3]) / 3600d, WeatherData.DataSource.CalculatedValue, -1); wRecord.SetData(WeatherRecord.RecordType.ExtraterrestrialDirectNormalRadiation, wData); //水平面全天日射 wData = new WeatherData(double.Parse(buff[4]) / 3600d, WeatherData.DataSource.Unknown, double.Parse(buff[6]) / 100d); wRecord.SetData(WeatherRecord.RecordType.GlobalHorizontalRadiation, wData); //直達日射 wData = new WeatherData(double.Parse(buff[7]) / 3600d, WeatherData.DataSource.Unknown, double.Parse(buff[9]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DirectNormalRadiation, wData); //水平面天空日射 wData = new WeatherData(double.Parse(buff[10]) / 3600d, WeatherData.DataSource.Unknown, double.Parse(buff[12]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DiffuseHorizontalRadiation, wData); //日照関連********************************** //水平面全天照度 wData = new WeatherData(double.Parse(buff[13]), WeatherData.DataSource.Unknown, double.Parse(buff[15]) / 100d); wRecord.SetData(WeatherRecord.RecordType.GlobalHorizontalIlluminance, wData); //法線面直射日射照度 wData = new WeatherData(double.Parse(buff[16]), WeatherData.DataSource.Unknown, double.Parse(buff[18]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DirectNormalIlluminance, wData); //水平面天空照度 wData = new WeatherData(double.Parse(buff[19]), WeatherData.DataSource.Unknown, double.Parse(buff[21]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DiffuseHorizontalIlluminance, wData); //天頂輝度 wData = new WeatherData(double.Parse(buff[22]), WeatherData.DataSource.Unknown, double.Parse(buff[24]) / 100d); wRecord.SetData(WeatherRecord.RecordType.ZenithLuminance, wData); //雲量 wData = new WeatherData(double.Parse(buff[25]), getDSource(buff[26]), double.Parse(buff[27]) / 100d); wRecord.SetData(WeatherRecord.RecordType.TotalSkyCover, wData); //雲量2 wData = new WeatherData(double.Parse(buff[28]), getDSource(buff[29]), double.Parse(buff[30]) / 100d); wRecord.SetData(WeatherRecord.RecordType.OpaqueSkyCover, wData); //空気状態関連********************************** //乾球温度 wData = new WeatherData(double.Parse(buff[31]), getDSource(buff[32]), double.Parse(buff[33]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DryBulbTemperature, wData); //露点温度 wData = new WeatherData(double.Parse(buff[34]), getDSource(buff[35]), double.Parse(buff[36]) / 100d); wRecord.SetData(WeatherRecord.RecordType.DewPointTemperature, wData); //相対湿度 wData = new WeatherData(double.Parse(buff[37]), getDSource(buff[38]), double.Parse(buff[39]) / 100d); wRecord.SetData(WeatherRecord.RecordType.RelativeHumidity, wData); //気圧 wData = new WeatherData(double.Parse(buff[40]) / 10d, getDSource(buff[41]), double.Parse(buff[42]) / 100d); wRecord.SetData(WeatherRecord.RecordType.AtmosphericPressure, wData); //その他********************************** //風向 wData = new WeatherData(double.Parse(buff[43]) - 180d, getDSource(buff[44]), double.Parse(buff[45]) / 100d); wRecord.SetData(WeatherRecord.RecordType.WindDirection, wData); //風速 wData = new WeatherData(double.Parse(buff[46]), getDSource(buff[47]), double.Parse(buff[48]) / 100d); wRecord.SetData(WeatherRecord.RecordType.WindSpeed, wData); //視認距離 wData = new WeatherData(double.Parse(buff[49]), getDSource(buff[50]), double.Parse(buff[51]) / 100d); wRecord.SetData(WeatherRecord.RecordType.Visibility, wData); //雲高さ wData = new WeatherData(double.Parse(buff[52]), getDSource(buff[53]), double.Parse(buff[54]) / 100d); wRecord.SetData(WeatherRecord.RecordType.CeilingHeight, wData); //可降水量 wData = new WeatherData(double.Parse(buff[55]), getDSource(buff[56]), double.Parse(buff[57]) / 100d); wRecord.SetData(WeatherRecord.RecordType.PrecipitableWater, wData); //大気混濁度 wData = new WeatherData(double.Parse(buff[58]), getDSource(buff[59]), double.Parse(buff[60]) / 100d); wRecord.SetData(WeatherRecord.RecordType.AerosolOpticalDepth, wData); //アルベド wData = new WeatherData(double.Parse(buff[61]), getDSource(buff[62]), double.Parse(buff[63]) / 100d); wRecord.SetData(WeatherRecord.RecordType.Albedo, wData); //降水量 wData = new WeatherData(double.Parse(buff[64]), getDSource(buff[66]), double.Parse(buff[67]) / 100d); wRecord.SetData(WeatherRecord.RecordType.PrecipitationLevel, wData); //降水量計測時間はとりあえず無視 //気象データ追加 wdTable.AddWeatherRecord(wRecord); //時刻更新 dTime = dTime.AddHours(1); } } success = true; return wdTable; } else return null; }
/// <summary>ファイルを元にWeatherDataTableを構成する</summary> /// <param name="filePath">読み取りファイルのパス</param> /// <param name="success">読み取り成功の真偽</param> /// <returns>構成されたPWeatherDataオブジェクト</returns> public static WeatherDataTable ToPWeatherData(string filePath, out bool success) { success = false; //読み出しファイルの存在確認 if (!File.Exists(filePath)) return null; WeatherDataTable wdTable = new WeatherDataTable(); using(StreamReader sReader = new StreamReader(filePath)) { string str; bool firstLine = true; while ((str = sReader.ReadLine()) != null) { //初回は地点情報を設定 if (firstLine) { LocationInformation lInfo = new LocationInformation(); lInfo.ID = int.Parse(str.Substring(0, 5)); lInfo.Name = lInfo.EnglishName = "TMY1" + lInfo.ID.ToString("F0"); wdTable.Location = lInfo; firstLine = false; } WeatherRecord wRecord = new WeatherRecord(); WeatherData wData; //日時 int year = int.Parse(str.Substring(5,2)); if (year < 20) year += 2000; else year += 1900; int month = int.Parse(str.Substring(7, 2)); int day = int.Parse(str.Substring(9, 2)); int hour = int.Parse(str.Substring(11, 2)) - 1; int minute = int.Parse(str.Substring(13, 2)); wRecord.DataDTime = new DateTime(year, month, day, hour, minute, 0); //直達日射[W/m2] if (str.Substring(24, 4) == "9999") wData = new WeatherData(0d, getDSource1(str.Substring(23, 1)), -1); else wData = new WeatherData(double.Parse(str.Substring(24, 4)) / 3.6d, getDSource1(str.Substring(23, 1)), -1); wRecord.SetData(WeatherRecord.RecordType.DirectNormalRadiation, wData); //水平面天空日射[W/m2] if (str.Substring(29, 4) == "9999") wData = new WeatherData(0d, getDSource1(str.Substring(28, 1)), -1); else wData = new WeatherData(double.Parse(str.Substring(29, 4)) / 3.6d, getDSource1(str.Substring(28, 1)), -1); wRecord.SetData(WeatherRecord.RecordType.DiffuseHorizontalRadiation, wData); //水平面全天日射[W/m2] if (str.Substring(54, 4) == "9999") wData = new WeatherData(0d, getDSource1(str.Substring(54, 1)), -1); else wData = new WeatherData(double.Parse(str.Substring(54, 4)) / 3.6d, getDSource1(str.Substring(53, 1)), -1); wRecord.SetData(WeatherRecord.RecordType.GlobalHorizontalRadiation, wData); //雲高さ[m] if (str.Substring(72, 4) == "7777") wData = new WeatherData(0d, WeatherData.DataSource.MissingValue, -1); if (str.Substring(72, 4) == "8888") wData = new WeatherData(0d, WeatherData.DataSource.MissingValue, -1); else wData = new WeatherData(double.Parse(str.Substring(72, 4)) * 10, WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.CeilingHeight, wData); //視認距離[km] if (str.Substring(81, 4) == "8888") wData = new WeatherData(160d, WeatherData.DataSource.MeasuredValue, -1); else wData = new WeatherData(double.Parse(str.Substring(81, 4)) * 10, WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.Visibility, wData); //気圧[kPa] wData = new WeatherData(double.Parse(str.Substring(98, 5)) / 100, WeatherData.DataSource.MeasuredValue, -1); double atm = wData.Value; wRecord.SetData(WeatherRecord.RecordType.AtmosphericPressure, wData); //外気乾球温度[C] wData = new WeatherData(double.Parse(str.Substring(103, 4)) / 10, WeatherData.DataSource.MeasuredValue, -1); double dbt = wData.Value; wRecord.SetData(WeatherRecord.RecordType.DryBulbTemperature, wData); //露点温度[C] wData = new WeatherData(double.Parse(str.Substring(107, 4)) / 10, WeatherData.DataSource.MeasuredValue, -1); double dpt = wData.Value; wRecord.SetData(WeatherRecord.RecordType.DewPointTemperature, wData); //その他の空気状態 double ahd = MoistAir.GetSaturatedHumidityRatio(dpt, MoistAir.Property.DryBulbTemperature, atm); MoistAir mAir = MoistAir.GetAirStateFromDBHR(dbt, ahd, atm); //相対湿度[%] wRecord.SetData(WeatherRecord.RecordType.RelativeHumidity, new WeatherData(mAir.RelativeHumidity, WeatherData.DataSource.CalculatedValue, -1)); //絶対湿度[kg/kg(DA)] wRecord.SetData(WeatherRecord.RecordType.HumidityRatio, new WeatherData(mAir.HumidityRatio, WeatherData.DataSource.CalculatedValue, -1)); //風向 wData = new WeatherData(double.Parse(str.Substring(111, 3)), WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.WindDirection, wData); //風速[m/s] wData = new WeatherData(double.Parse(str.Substring(114, 4)) / 10d, WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.WindSpeed, wData); //雲量 double dbl = double.Parse(str.Substring(118, 2)); if (dbl == 99) wData = new WeatherData(double.Parse(str.Substring(118, 2)), WeatherData.DataSource.MissingValue, -1); else wData = new WeatherData(double.Parse(str.Substring(118, 2)), WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.TotalSkyCover, wData); //雲量2 wData = new WeatherData(double.Parse(str.Substring(120, 2)), WeatherData.DataSource.MeasuredValue, -1); wRecord.SetData(WeatherRecord.RecordType.OpaqueSkyCover, wData); //欠測補充 wRecord.FillMissingData(); //気象レコード追加 wdTable.AddWeatherRecord(wRecord); } } success = true; return wdTable; }
/// <summary>ID下3桁をもとに地点情報を取得する</summary> /// <param name="id3">ID下3桁</param> /// <param name="lInfo">地点情報</param> /// <returns>地点情報を取得成功の真偽</returns> public static bool GetLocationInformation(int id3, out LocationInformation lInfo) { int id = id3 + 47000; //←いかにも問題のある処理。直せ! return locationInfos.TryGetValue(id, out lInfo); }