public void DMS_Veci_Manji_VeciJednako_ManjiJednako2_test_ReturnsTrue() { DMS a = new DMS(-55, 34, 5.5); DMS b = new DMS(44, -33, 3); DMS c = new DMS(44, 33, -3); Assert.IsTrue(a > b); Assert.IsTrue(b < a); Assert.IsTrue(b >= c); Assert.IsTrue(c <= b); Assert.IsTrue(a >= c); Assert.IsTrue(c <= a); }
private void LoadStayApply() { var response = DMS.GetStayApply(mainWindow.AccesssToken); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("잔류신청 조회 실패"); mainWindow.NavigatePage(new LoginPage()); return; } SetApplyRadiosFromResponse(response); }
private void LoadGoingoutApply() { var response = DMS.GetGoingoutApply(mainWindow.AccesssToken); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("외출신청 조회 실패"); mainWindow.NavigatePage(new GoingoutApplyPage()); return; } SetGoingoutChecksFromResponse(response); }
private void LoadMyPage() { var response = DMS.MyPage(mainWindow.AccesssToken); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("마이페이지 로딩 실패"); mainWindow.NavigatePage(new LoginPage()); return; } SetMyPageFromReponse(response); }
/// <summary> /// 解析实时计算行结果。相隔一个字符串为内部,2个为外部。 /// </summary> /// <param name="line"></param> /// <returns></returns> public static RtkrcvResultItem Parse(string line) { line = line.Replace(" ", "\t"); string[] items = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); var dateString = items[0]; string one = items[1]; string two = (items[2]); string three = (items[3]); RtkrcvResultItem item = new RtkrcvResultItem(); item.Time = DateTime.Parse(dateString); double lon = 0; double lat = 0; double height = 0; if (one.Trim().Contains(' '))//查看坐标内部是否有空格,如果有,则是度分秒格式。 { lat = DMS.Parse(one).Degrees; lon = DMS.Parse(two).Degrees; height = Double.Parse(three); } else { //查看是否是XYZ坐标,如果是,则需要转换 //通过离地心距离判断 double oneDouble = Double.Parse(one); double twoDouble = Double.Parse(two); double threeDouble = Double.Parse(three); //经纬度如(180, 180, 8848) 到地心的距离小于6000 000(地球下400 000米) 则认为是经纬度,不是米 if (Math.Sqrt(oneDouble * oneDouble + twoDouble * twoDouble + threeDouble * threeDouble) < 6000000) { lat = oneDouble; lon = twoDouble; height = threeDouble; } else { var geoCoord = CoordTransformer.XyzToGeoCoord(new XYZ(oneDouble, twoDouble, threeDouble)); lon = geoCoord.Lon; lat = geoCoord.Lat; height = geoCoord.Height; } } item.Coords = new double[] { lon, lat, height }; return(item); }
/// <summary> /// Get place of the mount. /// </summary> /// <param name="place"> /// Place contains the following fields: /// [*] LATITUDE: Latitude which is formatted as [N|S][DDD]+[MM] /// [*] LONGITUDE: Longitude which is formatted as [E|W][DDD]+[MM] /// [*] TIMEZONE: Timezone which is ranged from [-12] to [14] /// </param> /// <returns>Response string: OK or ERROR:%</returns> /// public Response GetPlace(out Place place) { place = new Place(); Response response = this.Handshake("GETPLACE", out Dictionary <string, string> dictionary); if (response == Response.ErrorUnknown) { bool placeLatitude = false, placeLongitude = false, placeTimezone = false; foreach (KeyValuePair <string, string> item in dictionary) { switch (item.Key) { case "LATITUDE": { if (DMS.TryParse(item.Value, out DMS latitude)) { place.Latitude = latitude; placeLatitude = true; } break; } case "LONGITUDE": { if (DMS.TryParse(item.Value, out DMS longitude)) { place.Longitude = longitude; placeLongitude = true; } break; } case "TIMEZONE": { if (int.TryParse(item.Value, NumberStyles.Number, CultureInfo.InvariantCulture, out int timezone)) { place.Timezone = timezone; placeTimezone = true; } break; } } } if (placeLatitude && placeLongitude && placeTimezone) { response.Assign(Response.OK); } } return(response); }
private void Login() { var id = IDText.Text; var pw = PWText.Password; var response = DMS.Auth(id, pw); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("로그인 실패"); return; } SetTokensFromReponse(response); mainWindow.NavigatePage(new MainPage()); }
public void DMS_Parse_string2_ReturnsTrue() { try { DMS dms = DMS.Parse("1u2 66 11"); Assert.Fail("no exception thrown"); } catch (FormatException ex) { Assert.IsTrue(ex is FormatException); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void DMS_Parse_string_ReturnsTrue() { try { DMS dms = DMS.Parse("12 66 11"); Assert.Fail("no exception thrown"); } catch (ArgumentOutOfRangeException ex) { Assert.IsTrue(ex is ArgumentOutOfRangeException); } catch (Exception ex) { Assert.Fail(ex.Message); } }
private void SubmitStayApply() { var stay = GetStayApplyFromRadios(); var response = DMS.SetStayApply(stay, mainWindow.AccesssToken); if (response.StatusCode != HttpStatusCode.Created) { MessageBox.Show($"잔류신청 실패"); } else { MessageBox.Show($"잔류신청 성공"); } mainWindow.NavigatePage(new MainPage()); }
private void OnConvert(object sender, EventArgs e) { try { double lon = Double.Parse(m_LongitudeTextBox.Text); double lat = Double.Parse(m_latitudeTextBox.Text); m_longitudeDMSTextBox.Text = DMS.Encode(lon, 5, DMS.Flag.LONGITUDE, 0); m_latitudeDMSTextBox.Text = DMS.Encode(lat, 5, DMS.Flag.LATITUDE, 0); string tmp = ""; Geohash.Forward(lat, lon, 12, out tmp); m_geohashTextBox.Text = tmp; } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void SiderealTime() { double jd = 2446895.5; // Nutation in longitude double deltaPsi = -3.788 / 3600; // True obliquity double epsilon = new DMS("23* 26' 36.85''").ToDecimalAngle(); // AA(II), example 12.a Assert.AreEqual(new HMS("13h 10m 46.3668s"), new HMS(Date.MeanSiderealTime(jd))); Assert.AreEqual(new HMS("13h 10m 46.1351s"), new HMS(Date.ApparentSiderealTime(jd, deltaPsi, epsilon))); // AA(II), example 12.b Assert.AreEqual(128.7378734, Date.MeanSiderealTime(2446896.30625), 1e-6); }
private void OnConvertGeohash(object sender, EventArgs e) { try { double lat, lon; int len; Geohash.Reverse(m_geohashTextBox.Text, out lat, out lon, out len, true); m_LongitudeTextBox.Text = lon.ToString(); m_latitudeTextBox.Text = lat.ToString(); m_longitudeDMSTextBox.Text = DMS.Encode(lon, 5, DMS.Flag.LONGITUDE, 0); m_latitudeDMSTextBox.Text = DMS.Encode(lat, 5, DMS.Flag.LATITUDE, 0); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SubmitApply() { var saturdayGoingout = (bool)SaturdayGoingoutCheck.IsChecked; var sundayGoingout = (bool)SundayGoingoutCheck.IsChecked; var response = DMS.SetGoingoutApply(saturdayGoingout, sundayGoingout, mainWindow.AccesssToken); if (response.StatusCode != HttpStatusCode.Created) { MessageBox.Show("외출신청 실패"); } else { MessageBox.Show("외출신청 성공"); } mainWindow.NavigatePage(new MainPage()); }
private void OnConvertDMS(object sender, EventArgs e) { try { DMS.Flag ind; double lon = DMS.Decode(m_longitudeDMSTextBox.Text, out ind); m_LongitudeTextBox.Text = lon.ToString(); double lat = DMS.Decode(m_latitudeDMSTextBox.Text, out ind); m_latitudeTextBox.Text = lat.ToString(); string tmp = ""; Geohash.Forward(lat, lon, 12, out tmp); m_geohashTextBox.Text = tmp; } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual string Format(object value) { double angle = Convert.ToDouble(value); var a = new DMS(angle); if (angle >= 1) { return(string.Format(CultureInfo.InvariantCulture, "{0:D}° {1:D2}\u2032 {2:00.##}\u2033", a.Degrees, a.Minutes, a.Seconds)); } else if (angle >= 1.0 / 60) { return(string.Format(CultureInfo.InvariantCulture, "{0:D2}\u2032 {1:00.##}\u2033", a.Minutes, a.Seconds)); } else { return(string.Format(CultureInfo.InvariantCulture, "{0:0.##}\u2033", a.Seconds)); } }
private void button_degreeToRad_Click(object sender, EventArgs e) { var degreesLines = textBox_degree.Lines; StringBuilder sb = new StringBuilder(); foreach (var item in degreesLines) { if (String.IsNullOrWhiteSpace(item)) { continue; } var rad = DMS.Parse(item).Degrees; sb.AppendLine(rad + ""); } textBox_rad.Text = sb.ToString(); }
private void button_radToDegree_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); var radsLines = textBox_rad.Lines; foreach (var item in radsLines) { if (String.IsNullOrWhiteSpace(item)) { continue; } var a = double.Parse(item); var rad = new DMS(a, AngleUnit.Degree).ToString(); sb.AppendLine(rad + ""); } textBox_degree.Text = sb.ToString(); }
private void LoadTodayMeals() { var now = DateTime.Now; var response = DMS.Meal(now.Year, now.Month, now.Day); TodayLabel.Content = $"{now.Year}년 " + $"{now.Month:00}월 " + $"{now.Day:00}일 " + ParseDayOfWeek(now.DayOfWeek); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("식단 로딩 실패"); return; } SetTodayMealsFromResponse(response); }
/// <summary> /// Attempts to parse a latitude and longitude string into a /// new GeoCoordinate instance /// </summary> /// <param name="input">The longitude and latitude string</param> /// <param name="output">A newly created GeoCoordinate instance</param> /// <returns>true if the parsing was succesful; otherwsie false</returns> public static bool TryParse(string input, out GeoCoordinate output) { // Validate input parameter if (string.IsNullOrEmpty(input)) { output = null; return(false); } // TODO: SUPPORT MGRS IN THE FUTURE // The regex below parses Longitude and Latitude values and supports // the following different formats: // - 38° 47’ 44” N 077° 36’ 50” W // - 38°47’44”N077°36’50”W // - 38°47’44”N,077°36’50”W // - 384744N 0773650W // - 38°47’44”N 077°36’50”W // - 38 47 44 N 77 36 50 W // - 38 47 44.23 N 77 36 50.77 W //const string longlatParseString = "^(?<lat_degrees>\\d{2})[°]?\\s*(?<lat_minutes>\\d{2})[’']?\\s*(?<lat_seconds>[\\d\\.]+)[”\\\"]?\\s*(?<lat_direction>[NnSs]{1})[\\s,_-]?(?<lng_degrees>\\d{2,3})[°]?\\s*(?<lng_minutes>\\d{2})[’']?\\s*(?<lng_seconds>[\\d\\.]+)[”\\\"]?\\s*(?<lng_direction>[EeWw]{1})$"; const string longlatParseString = @"^(?<lat_degrees>\d{2})[°]?\s*(?<lat_minutes>\d{2})[’']?\s*(?<lat_seconds>[\d\.]+)[”\""]?\s*(?<lat_direction>[NnSs]{1})[\s,_-]?(?<lng_degrees>\d{2,3})[°]?\s*(?<lng_minutes>\d{2})[’']?\s*(?<lng_seconds>[\d\.]+)[”\""]?\s*(?<lng_direction>[EeWw]{1})$"; Regex regex = new Regex(longlatParseString); // Check if the regex matches the provided value if (regex.IsMatch(input)) { Match match = regex.Match(input); //TODO: VALIDATE THE GROUPS // Create a DMS instance for Latitude and Longitude DMS latitude = new DMS(int.Parse(match.Groups["lat_degrees"].Value), int.Parse(match.Groups["lat_minutes"].Value), int.Parse(match.Groups["lat_seconds"].Value), (char)match.Groups["lat_direction"].Value[0]); DMS longitude = new DMS(int.Parse(match.Groups["lng_degrees"].Value), int.Parse(match.Groups["lng_minutes"].Value), int.Parse(match.Groups["lng_seconds"].Value), (char)match.Groups["lng_direction"].Value[0]); output = new GeoCoordinate(latitude, longitude); return(true); } // The regex does not match so the provided input cannot be parsed as a longitude and latitude output = null; return(false); }
static void Main(string[] args) { try { { string dms = "30d14'45.6\"S"; DMS.Flag type; double ang = DMS.Decode(dms, out type); Console.WriteLine(String.Format("Type: {0} String: {1}", type, ang)); } { double ang = -30.245715; string dms = DMS.Encode(ang, 6, DMS.Flag.LATITUDE, 0); Console.WriteLine(String.Format("Latitude: {0}", dms)); } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
public static void LoadProject(string path, bool tempfile) { EditingLayer = null; SetSidebar(SidebarPages.Layers); if (dms != null) { dms.FileUpdated -= FU_DMS; dms.FileStatusChanged -= FSC_DMS; } project = new ProjectData(); dms = new DMS <ProjectData>(DMS_ID, ref project, path); dms.FileUpdated += FU_DMS; dms.FileStatusChanged += FSC_DMS; if (path != "" && System.IO.File.Exists(path)) { if (tempfile) { dms.LoadFileAndClearPath(); } else { dms.LoadFromSource(); } } else { SetSidebar(SidebarPages.Layers); } //TITLE BAR if (mainwindowobj != null) { ((MainWindow)mainwindowobj).FSC(tempfile, tempfile ? "" : path); } //RECENT PROJECTS if (!tempfile) { rp_container.AddItem(path); rp.CheckChanges(); rp.SaveChanges(); } }
public static void InsertTest() { string body = "-你是谁fdfd😚😎😋🤥🤗😋fdfdf😉🙂🤗fdfdfd"; PostMST entity = new PostMST { MemberName = "17704007627", CurrentType = 30, Image = string.Empty, Body = body, PostKey = Guid.NewGuid(), CreateTime = DateTime.Now, Remark = "谁😚😎😋🤥", }; int flag = DMS.Create <PostMST>() .Insert(entity); //for (int i = 0; i < 2; i++) //{ // pro_PostMST_Insert param = new pro_PostMST_Insert() // { // MemberName = "17704007627", // CurrentType = 30, // Image = "201712/201712941238110228975616.jpg", // Body = i + body, // PostKey = Guid.NewGuid(), // CreateTime = DateTime.Now, // }; // DMSStoredProcedureHandler s = new DMSStoredProcedureHandler(); // string errMsg = string.Empty; // bool result = s.ExecuteNoQuery(param, ref errMsg); // if (result) // { // } //} }
public void Hours_Constructors_ReturnsTrue() { Hours kut = new Hours(3); Hours h = new Hours(3); HMS hms = new HMS(3, 0, 0); Degrees d = new Degrees(45); DMS dms = new DMS(45, 0, 0); Seconds s = new Seconds(45 * 180 * 60 * 60 / Math.PI); Gradians g = new Gradians(50); Assert.IsTrue((kut - h).Angle < tolerance, "Hours"); Assert.IsTrue((kut - hms).Angle < tolerance, "HMS"); Assert.IsTrue((kut - d).Angle < tolerance, "Degrees"); Assert.IsTrue((kut - dms).Angle < tolerance, "DMS"); Assert.IsTrue((kut - s).Angle < tolerance, "Seconds"); Assert.IsTrue((kut - g).Angle < tolerance, "Gradians"); }
private void button_geoToxyz_Click(object sender, EventArgs e) { try { AngleUnit unit = AngleUnit; Geo.Referencing.Ellipsoid ellipsoid = Ellipsoid; List <GeoCoord> sources = new List <GeoCoord>(); foreach (var item in this.textBox_geo.Lines) { if (item == "") { continue; } string[] strs = item.Split(new char[] { ',', '\t', ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); DMS lon = DMS.Parse(strs[0], unit); DMS lat = DMS.Parse(strs[1], unit); double height = Double.Parse(strs[2]); sources.Add(new GeoCoord(lon.Degrees, lat.Degrees, height, AngleUnit.Degree)); } StringBuilder sb = new StringBuilder(); var spliter = IsOutSplitByTab ? "\t" : ", "; foreach (var item in sources) { XYZ xYZ = CoordTransformer.GeoCoordToXyz(item, ellipsoid); sb.AppendLine(xYZ.ToString("0.0000000", spliter)); } this.textBox_xyz.Text = sb.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static bool ParseCombinedLine(TotalStationResultFile file, bool isStarted, string[] items) { var startName = items[0]; var endName = items[1]; var lineName = new GnssBaseLineName(endName, startName); var Azimuth = Geo.Utils.StringUtil.ParseDouble(items[2]); var MA = Geo.Utils.StringUtil.ParseDouble(items[3]); var S = Geo.Utils.StringUtil.ParseDouble(items[4]); var MS = Geo.Utils.StringUtil.ParseDouble(items[5]); var SPerMS = Geo.Utils.StringUtil.ParseDouble(items[6]); var E = Geo.Utils.StringUtil.ParseDouble(items[7]); var F = Geo.Utils.StringUtil.ParseDouble(items[8]); var T = Geo.Utils.StringUtil.ParseDouble(items[9]); var azi = new DMS(Azimuth, AngleUnit.D_MS).Degrees; var t = new DMS(T, AngleUnit.D_MS).Degrees; if (S != 0 && SPerMS != 0 && E != 0) { isStarted = true; file.CombinedResults[lineName] = new TotalStationCombinedResult(lineName) { Azimuth = azi, MA = MA, Distance = S, MS = MS, DisPerMs = SPerMS, E = E, F = F, T = t }; } return(isStarted); }
partial void GenerateWeightsOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.WeightGenerationMethod method, DMS.Web.Host.Models.GenerateWeightsRequestModel viewModel);
public override System.Web.Mvc.ActionResult GenerateWeights(int id, DMS.Domain.WeightGenerationMethod method, DMS.Web.Host.Models.GenerateWeightsRequestModel viewModel) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.GenerateWeights); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "method", method); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "viewModel", viewModel); GenerateWeightsOverride(callInfo, id, method, viewModel); return callInfo; }
static void ProgressInfo(DMS.DirTree.DirTreeProgressInfo Info) { Debug.WriteLine("Anz.Verz: " + Info.DirCount + ", AnzDateien: " + Info.FileCount); }
partial void LogOnOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, DMS.Web.Host.Models.LogOnModel model, string returnUrl);
partial void FillProbabilitiesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.AggregationType aggregationType, DMS.Web.Host.Models.FillRatingsViewModel viewModel);
partial void InputLambdaOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.AggregationType aggregationType, DMS.Web.Host.Models.InputLambdaViewModel viewModel);
public void ConicProj0_CheckFixForAlbersEqualArea_ReverseBug() { var aea = new AlbersEqualArea(Ellipsoid.WGS84, DMS.DecodeAzimuth("40d58"), DMS.DecodeAzimuth("39d56"), 1); var(lat, lon) = aea.Reverse(DMS.DecodeAzimuth("77d45W"), 220e3, -52e3, out var gamma, out var k); Assert.AreEqual(39.95, lat, 0.01); Assert.AreEqual(-75.17, lon, 0.01); Assert.AreEqual(1.67, gamma, 0.01); Assert.AreEqual(0.99, k, 0.01); }
partial void FillProbabilitiesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.AggregationType aggregationType);
/// <summary> /// 定时任务 /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <SendTaskReply> SendTaskMessage(SendTaskRequest request, ServerCallContext context) { SendTaskReply result = new SendTaskReply(); List <TaskMessage> listTasks = DMS.Create <TaskMessage>().Where(p => p.SendStatu == 0 && p.SendTime <= DateTime.Now && p.DeleteFlag == false).ToList(); int success = 0, err = 0; string msg = string.Empty; RabbitMQHelper help = new RabbitMQHelper(); listTasks.ForEach(p => { try { if (p.TaskMessageType == EnumTaskMessageType.Notice) { Notice notice = new Notice() { SendMessage = p.SendMessage, Users = p.Users, TagMessage = p.TagMessage, Title = p.Title, Body = p.Body, TaskMessageType = p.TaskMessageType, UserType = p.UserType, TaskMessageID = p.TaskMessageID }; help.Send <Notice>("Notice", notice); } else { Activity activity = new Activity() { SendMessage = p.SendMessage, Users = p.Users, TagMessage = p.TagMessage, CurrentType = p.CurrentType, Relation = p.RelationID, TaskMessageType = p.TaskMessageType, UserType = p.UserType, TaskMessageID = p.TaskMessageID }; help.Send <Activity>("Activity", activity); } success++; } catch (Exception ex) { err++; msg = ex.Message; } }); //更新状态 DMS.Create <TaskMessage>().Edit(new TaskMessage() { SendStatu = 1 }, p => p.SendStatu == 0 && p.SendTime <= DateTime.Now && p.DeleteFlag == false); result.SuccessCount = success; result.ErrCount = err; result.ErrMsg = msg; return(Task.FromResult <SendTaskReply>(result)); }
public override System.Web.Mvc.ActionResult LogOn(DMS.Web.Host.Models.LogOnModel model, string returnUrl) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.LogOn); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "returnUrl", returnUrl); LogOnOverride(callInfo, model, returnUrl); return callInfo; }
/// <summary> /// Initializes a new instance of the <see cref="GeoCoordinate"/> class using /// the two provided DMS instances (which represent latitude /// and longitude) /// </summary> /// <param name="latitude">Latitude coordinates</param> /// <param name="longitude">Longitude coordinates</param> public GeoCoordinate(DMS latitude, DMS longitude) { this.Latitude = latitude; this.Longitude = longitude; }
partial void ManualAssessmentOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Web.Host.Models.ManualAssessmentViewModel viewModel);
partial void DoAggregationOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.AggregationType aggregationType, decimal? lambda);
/// <summary> /// Attempts to parse a latitude and longitude string into a /// new GeoCoordinate instance /// </summary> /// <param name="input">The longitude and latitude string</param> /// <param name="output">A newly created GeoCoordinate instance</param> /// <returns>true if the parsing was succesful; otherwsie false</returns> public static bool TryParse(string input, out GeoCoordinate output) { // Validate input parameter if (string.IsNullOrEmpty(input)) { output = null; return false; } // TODO: SUPPORT MGRS IN THE FUTURE // The regex below parses Longitude and Latitude values and supports // the following different formats: // - 38° 47’ 44” N 077° 36’ 50” W // - 38°47’44”N077°36’50”W // - 38°47’44”N,077°36’50”W // - 384744N 0773650W // - 38°47’44”N 077°36’50”W // - 38 47 44 N 77 36 50 W // - 38 47 44.23 N 77 36 50.77 W //const string longlatParseString = "^(?<lat_degrees>\\d{2})[°]?\\s*(?<lat_minutes>\\d{2})[’']?\\s*(?<lat_seconds>[\\d\\.]+)[”\\\"]?\\s*(?<lat_direction>[NnSs]{1})[\\s,_-]?(?<lng_degrees>\\d{2,3})[°]?\\s*(?<lng_minutes>\\d{2})[’']?\\s*(?<lng_seconds>[\\d\\.]+)[”\\\"]?\\s*(?<lng_direction>[EeWw]{1})$"; const string longlatParseString = @"^(?<lat_degrees>\d{2})[°]?\s*(?<lat_minutes>\d{2})[’']?\s*(?<lat_seconds>[\d\.]+)[”\""]?\s*(?<lat_direction>[NnSs]{1})[\s,_-]?(?<lng_degrees>\d{2,3})[°]?\s*(?<lng_minutes>\d{2})[’']?\s*(?<lng_seconds>[\d\.]+)[”\""]?\s*(?<lng_direction>[EeWw]{1})$"; Regex regex = new Regex(longlatParseString); // Check if the regex matches the provided value if (regex.IsMatch(input)) { Match match = regex.Match(input); //TODO: VALIDATE THE GROUPS // Create a DMS instance for Latitude and Longitude DMS latitude = new DMS(int.Parse(match.Groups["lat_degrees"].Value), int.Parse(match.Groups["lat_minutes"].Value), int.Parse(match.Groups["lat_seconds"].Value), (char)match.Groups["lat_direction"].Value[0]); DMS longitude = new DMS(int.Parse(match.Groups["lng_degrees"].Value), int.Parse(match.Groups["lng_minutes"].Value), int.Parse(match.Groups["lng_seconds"].Value), (char)match.Groups["lng_direction"].Value[0]); output = new GeoCoordinate(latitude, longitude); return true; } // The regex does not match so the provided input cannot be parsed as a longitude and latitude output = null; return false; }
public override System.Web.Mvc.ActionResult DoAggregation(int id, DMS.Domain.AggregationType aggregationType, decimal? lambda) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.DoAggregation); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "aggregationType", aggregationType); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "lambda", lambda); DoAggregationOverride(callInfo, id, aggregationType, lambda); return callInfo; }
public static bool TryParse(object text, out DMS result) { result = null; if (!(text is string) || string.IsNullOrEmpty((string)text)) return false; var match = Regex.Match(((string)text).Trim(), "^([^°]+)° ?([^']+')? ?([^\"]+\")? ?([NS]) +([^°]+)° ?([^']+')? ?([^\"]+\")? ?([WE])$"); double latD, latM, latS, lonD, lonM, lonS; if (!(match.Groups[0].Success && double.TryParse(match.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out latD) && double.TryParse("0" + match.Groups[2].Value.TrimEnd('\''), NumberStyles.Float, CultureInfo.InvariantCulture, out latM) && double.TryParse("0" + match.Groups[3].Value.TrimEnd('"'), NumberStyles.Float, CultureInfo.InvariantCulture, out latS) && double.TryParse(match.Groups[5].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out lonD) && double.TryParse("0" + match.Groups[6].Value.TrimEnd('\''), NumberStyles.Float, CultureInfo.InvariantCulture, out lonM) && double.TryParse("0" + match.Groups[7].Value.TrimEnd('"'), NumberStyles.Float, CultureInfo.InvariantCulture, out lonS))) return false; var latCar = match.Groups[4].Value[0]; var lonCar = match.Groups[8].Value[0]; result = new DMS { LatDegree = latD, LatMinute = latM, LatSecond = latS, LatHemis = latCar, LongDegree = lonD, LongMinute = lonM, LongSecond = lonS, LongHemis = lonCar }; return true; }
public override System.Web.Mvc.ActionResult FillProbabilities(int id, DMS.Domain.AggregationType aggregationType) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.FillProbabilities); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "aggregationType", aggregationType); FillProbabilitiesOverride(callInfo, id, aggregationType); return callInfo; }
partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Web.Host.Models.AddProjectViewModel viewModel);
partial void InputLambdaOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.AggregationType aggregationType);
public static DD DMS2DD(DMS dms) { var Convert = new ConversionDMS2DD(); return Convert.Convert(dms); }
public override System.Web.Mvc.ActionResult InputLambda(int id, DMS.Domain.AggregationType aggregationType, DMS.Web.Host.Models.InputLambdaViewModel viewModel) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.InputLambda); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "aggregationType", aggregationType); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "viewModel", viewModel); InputLambdaOverride(callInfo, id, aggregationType, viewModel); return callInfo; }
partial void GenerateWeightsOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, DMS.Domain.WeightGenerationMethod method);
public override System.Web.Mvc.ActionResult Edit(int id, DMS.Web.Host.Models.AddProjectViewModel viewModel) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "viewModel", viewModel); EditOverride(callInfo, id, viewModel); return callInfo; }
public void VaciarDMS(EntityConnectionStringBuilder connection, DMS dm) { var context = new samEntities(connection.ToString()); context.DELETE_dms_avisos_MDL(dm.QMNUM); }