private void GeoCoordinateForm_Load(object sender, EventArgs e) { cbx_datum.Items.Add(GeoDatum.DatumWGS84()); cbx_datum.SelectedIndex = 0; cbx_datum.Items.Add(GeoDatum.DatumIndian1975()); cbx_datum.Items.Add(GeoDatum.DatumIndian1954()); }
private void edit_MGRS_TextChanged(object sender, EventArgs e) { if (!_Changing) { String value = TambonHelper.ReplaceThaiNumerals(edt_MGRS.Text.ToUpper()).Trim(); GeoPoint geoPoint = null; UtmPoint utmPoint = null; try { _Changing = true; if (!TambonHelper.IsNumeric(value.Substring(0, 2))) { value = ZoneForThailandMgrs(value) + value; } utmPoint = UtmPoint.ParseMgrsString(value); geoPoint = new GeoPoint(utmPoint, (GeoDatum)cbx_datum.SelectedItem); geoPoint.Datum = GeoDatum.DatumWGS84(); } catch { // invalid string utmPoint = null; geoPoint = null; } SetValues(geoPoint, utmPoint, sender); _Changing = false; } }
public void TestUTMToGeo() { // Dresden according to Wikipedia : 13° 44' 29"E 51° 02' 55"N = UTM 33U 0411777 5655984 UtmPoint utmPoint = new UtmPoint("33U 0411777 5655984"); GeoPoint geoPoint = new GeoPoint(utmPoint, GeoDatum.DatumWGS84()); GeoPoint expected = new GeoPoint(51.0 + 02.0 / 60.0 + 55.0 / 3600.0, 13.0 + 44.0 / 60.0 + 29.0 / 3600.0); Assert.IsTrue(expected.Equals(geoPoint)); }
public void TestDatumConversion() { // example as of http://www.colorado.edu/geography/gcraft/notes/datum/gif/molodens.gif GeoPoint point = new GeoPoint(30, -100, 232, GeoDatum.DatumNorthAmerican27MeanConus()); point.Datum = GeoDatum.DatumWGS84(); GeoPoint expected = new GeoPoint(30.0002239, -100.0003696, 194.816, GeoDatum.DatumWGS84()); Assert.IsTrue(expected.Equals(point)); }
public GeoLocationSensorSample(GeoLocationProvider provider, double time, GeoPoint3 location, GeoDatum geoDatum, double?bearing, double?speed, double?accuracy) { _provider = provider; _time = time; _location = location; _geoDatum = geoDatum; _bearing = bearing; _speed = speed; _accuracy = accuracy; }
/// <summary> /// Initializes a new instance of the GeoDataViewModel class. /// </summary> public GeoDataViewModel(GeoDataModel model) { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real": Connect to service, etc... ////} Model = model; Model.PropertyChanged += (s, e) => { if (e.PropertyName == GeoDataModel.DatumPropertyName) { RaisePropertyChanged(CurrentGeoDatumPropertyName); } if (e.PropertyName == GeoDataModel.LocationPropertyName) { RaisePropertyChanged(GeoHashPropertyName); RaisePropertyChanged(GeoLocationPropertyName); RaisePropertyChanged(UtmLocationPropertyName); RaisePropertyChanged(MgrsLocationPropertyName); RaisePropertyChanged(L7018FramePropertyName); } GeoPoint point = new GeoPoint(Model.Location); point.Datum = Model.Datum; RaisePropertyChanged(GeoPointPropertyName, _oldLocation, point, true); _oldLocation = point; }; GeoDatums = new ObservableCollection <GeoDatum>(); GeoDatums.Add(GeoDatum.DatumWGS84()); GeoDatums.Add(GeoDatum.DatumIndian1975()); GeoDatums.Add(GeoDatum.DatumIndian1954()); L7018Index = new ObservableCollection <RtsdMapFrame>(); RtsdMapIndex.CalcIndexList(); foreach (var entry in RtsdMapIndex.MapIndexL7018.OrderBy(x => x.Name)) { L7018Index.Add(entry); } _oldLocation = new GeoPoint(Model.Location); _oldLocation.Datum = Model.Datum; }
internal void SetUtmLocation(String value) { String myValue = TambonHelper.ReplaceThaiNumerals(value.ToUpper()).Trim(); GeoPoint geoPoint = null; UtmPoint utmPoint = null; try { utmPoint = UtmPoint.ParseUtmString(myValue); geoPoint = new GeoPoint(utmPoint, _currentGeoDatum); geoPoint.Datum = GeoDatum.DatumWGS84(); SetLocationValue(geoPoint, utmPoint); } catch (ArgumentException) { } }
/// <summary><para>Die Funktion verschiebt das aktuelle <see cref="GeoUtility.GeoSystem.Helper.GeoDatum">geodätische Datum</see>. /// Mögliche Werte sind: <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84">WGS84</see> (Standard, international) oder /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see>.</para></summary> /// /// <example>Das folgende Beispiel berechnet die neuen Koordinatenwerte, die sich durch /// das Setzen des geodätischen Datums vom initialen (internationalen) Datum /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84">WGS84</see> in das nur in /// Deutschland verwendete <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see> ändern. /// <code> /// using GeoUtility.GeoSystem; /// Geographic geo = new Geographic(8.12345, 50.56789, GeoDatum.WGS84); // initial WGS84 /// geo.SetDatum(GeoDatum.Potsdam); // neues Datum /// </code> /// </example> /// /// <param name="datum">Das neu zu setzende <see cref="GeoUtility.GeoSystem.Helper.GeoDatum">geodätische Datum</see>.</param> public void SetDatum(GeoDatum datum) { if (datum != this.Datum) { this.Datum = datum; Geographic g = null; if (datum == GeoDatum.Potsdam) { g = Transform.WGSPOD(this); } else { g = Transform.PODWGS(this); } this.Longitude = g.Longitude; this.Latitude = g.Latitude; } }
internal void SetMgrsLocation(String value) { String myValue = TambonHelper.ReplaceThaiNumerals(value.ToUpper()).Trim(); GeoPoint geoPoint = null; UtmPoint utmPoint = null; try { if (!TambonHelper.IsNumeric(value.Substring(0, 2))) { value = ZoneForThailandMgrs(value) + value; } utmPoint = UtmPoint.ParseMgrsString(value); geoPoint = new GeoPoint(utmPoint, _currentGeoDatum); geoPoint.Datum = GeoDatum.DatumWGS84(); SetLocationValue(geoPoint, utmPoint); } catch (ArgumentException) { } }
private void edit_UTM_TextChanged(object sender, EventArgs e) { if (!_Changing) { String value = TambonHelper.ReplaceThaiNumerals(edt_UTM.Text.ToUpper()).Replace(",", "").Trim(); GeoPoint geoPoint = null; UtmPoint utmPoint = null; try { _Changing = true; utmPoint = UtmPoint.ParseUtmString(value); geoPoint = new GeoPoint(utmPoint, (GeoDatum)cbx_datum.SelectedItem); geoPoint.Datum = GeoDatum.DatumWGS84(); } catch { // invalid string utmPoint = null; geoPoint = null; } SetValues(geoPoint, utmPoint, sender); _Changing = false; } }
public void TestGeoPointCopyConstructor() { GeoPoint basePoint = new GeoPoint(_LatitudeBangkok, _LongitudeBangkok, _AltitudeBangkok, GeoDatum.DatumWGS84()); GeoPoint clonePoint = new GeoPoint(basePoint); Assert.IsTrue(basePoint.Equals(clonePoint)); // Assert.AreEqual<GeoPoint>(lClonePoint, lBasePoint); // does not use the IEquatable }
/// <summary><para>Konstruktor mit Parametern für den Längen- und Breitengrad und das /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum">Datum</see>.</para></summary> /// /// <example>Das folgende Beispiel erzeugt eine Instanz der GeoUtility.GeoSystem.Helper Klasse und übergibt /// dabei die Parameter für den <see cref="Longitude">Längengrad</see> und den <see cref="Latitude">Breitengrad</see> /// und das <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see> (nur Deutschland). /// Achtung: International wird üblicherweise wird das /// <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84">WGS84-Datum</see> verwendet: /// <code> /// using GeoUtility.GeoSystem; /// Geographic geo = new Geographic(8.12345, 50.56789, GeoDatum.Potsdam); /// </code> /// </example> /// /// <param name="lon">Geographische Länge ((<see cref="Longitude"/>) in Dezimalgrad.</param> /// <param name="lat">Geographische Breite (<see cref="Latitude"/>) in Dezimalgrad.</param> /// <param name="datum">Geodätisches Datum (<see cref="GeoUtility.GeoSystem.Helper.GeoDatum.WGS84"/> oder <see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam"/>).</param> public Geographic(double lon, double lat, GeoDatum datum) { this.Longitude = lon; this.Latitude = lat; this.Datum = datum; }
public PopulationDataEntry Parse(StreamReader reader) { // Column 1 : is number, then use // Column 2 : Amphoe name // Column 3 : Tambon name // Column 4 : Code // Column 5 : Name // Column 6 : Muban number // Column 7 : Location source/placemark // Column 8 : Location UTM Easting (47N, Indian 1974) // Column 9 : Location UTM Northing (47N, Indian 1974) String currentLine = String.Empty; PopulationDataEntry currentChangwat = new PopulationDataEntry(); PopulationDataEntry currentAmphoe = new PopulationDataEntry(); PopulationDataEntry currentTambon = new PopulationDataEntry(); while ((currentLine = reader.ReadLine()) != null) { var subStrings = currentLine.Split(new Char[] { '\t' }); if ((subStrings.Length > 0) & (!String.IsNullOrEmpty(subStrings[0])) & TambonHelper.IsNumeric(subStrings[0])) { PopulationDataEntry currentMuban = new PopulationDataEntry(); String amphoe = subStrings[1].Replace('"', ' ').Trim(); String tambon = subStrings[2].Replace('"', ' ').Trim(); String geocode = subStrings[3].Replace('"', ' ').Replace(" ", "").Trim(); currentMuban.Geocode = Convert.ToInt32(geocode); currentMuban.Name = subStrings[4].Replace('"', ' ').Trim(); currentMuban.Type = EntityType.Muban; String comment = subStrings[6].Replace('"', ' ').Trim(); String easting = subStrings[7].Replace('"', ' ').Replace('E', ' ').Trim(); String northing = subStrings[8].Replace('"', ' ').Replace('N', ' ').Trim(); if (TambonHelper.IsNumeric(easting) && TambonHelper.IsNumeric(northing)) { EntityOffice office = new EntityOffice(); office.Type = OfficeType.VillageHeadmanOffice; UtmPoint utmLocation = new UtmPoint(Convert.ToInt32(easting), Convert.ToInt32(northing), 47, true); office.Location = new GeoPoint(utmLocation, GeoDatum.DatumIndian1975()); office.Location.Datum = GeoDatum.DatumWGS84(); currentMuban.Offices.Add(office); } String mubanString = subStrings[5].Replace('"', ' ').Trim(); if (TambonHelper.IsNumeric(mubanString)) { Int32 muban = Convert.ToInt32(mubanString); if (muban != (currentMuban.Geocode % 100)) { comment = comment + Environment.NewLine + "Code is " + currentMuban.Geocode.ToString() + ','; comment = comment + " Muban number is " + muban.ToString(); currentMuban.Geocode = currentMuban.Geocode - (currentMuban.Geocode % 100) + muban; } } if ((currentMuban.Geocode / 10000) != currentAmphoe.Geocode) { currentAmphoe = new PopulationDataEntry(); currentAmphoe.Name = tambon; currentAmphoe.Type = EntityType.Amphoe; currentAmphoe.Geocode = (currentMuban.Geocode / 10000); currentChangwat.SubEntities.Add(currentAmphoe); } if ((currentMuban.Geocode / 100) != currentTambon.Geocode) { currentTambon = new PopulationDataEntry(); currentTambon.Name = tambon; currentTambon.Type = EntityType.Tambon; currentTambon.Geocode = (currentMuban.Geocode / 100); currentAmphoe.SubEntities.Add(currentTambon); } currentMuban.Comment = comment; currentTambon.SubEntities.Add(currentMuban); } } currentChangwat.Type = EntityType.Changwat; return(currentChangwat); }
public GeoDataModel() { _location = GeoDataGlobals.Instance.DefaultLocation; _currentGeoDatum = GeoDatum.DatumWGS84(); }