Example #1
0
 private void edt_LatLong_TextChanged(object sender, EventArgs e)
 {
     if (!_Changing)
     {
         GeoPoint geoPoint = null;
         UtmPoint utmPoint = null;
         try
         {
             _Changing      = true;
             geoPoint       = new GeoPoint(edt_LatLong.Text);
             geoPoint.Datum = (GeoDatum)cbx_datum.SelectedItem;
             GeoPoint lGeoOtherDatum = new GeoPoint(geoPoint);
             lGeoOtherDatum.Datum = (GeoDatum)cbx_datum.SelectedItem;
             utmPoint             = lGeoOtherDatum.CalcUTM();
         }
         catch
         {
             // invalid string
             geoPoint = null;
             utmPoint = null;
         }
         SetValues(geoPoint, utmPoint, sender);
         _Changing = false;
     }
 }
Example #2
0
 private UtmPoint GetUtmPoint()
 {
     if (_UtmPoint == null)
     {
         GeoPoint geoPointWithOtherDatum = new GeoPoint(Location);
         geoPointWithOtherDatum.Datum = Datum;
         _UtmPoint = geoPointWithOtherDatum.CalcUTM();
     }
     return(_UtmPoint);
 }
Example #3
0
        public void TestCalcUTM()
        {
            // Dresden according to Wikipedia : 13° 44' 29"E 51° 02' 55"N
            GeoPoint basePoint = new GeoPoint(51.0 + 02.0 / 60.0 + 55.0 / 3600.0, 13.0 + 44.0 / 60.0 + 29.0 / 3600.0);
            UtmPoint utmPoint = basePoint.CalcUTM();

            // Expected result: Zone 33 North, Northing 5655984 Easting 411777
            UtmPoint expected = new UtmPoint(411777, 5655984, 33, true);
            Assert.IsTrue(expected.Equals(utmPoint));
        }
Example #4
0
        public void TestCalcUTM()
        {
            // Dresden according to Wikipedia : 13° 44' 29"E 51° 02' 55"N
            GeoPoint basePoint = new GeoPoint(51.0 + 02.0 / 60.0 + 55.0 / 3600.0, 13.0 + 44.0 / 60.0 + 29.0 / 3600.0);
            UtmPoint utmPoint  = basePoint.CalcUTM();

            // Expected result: Zone 33 North, Northing 5655984 Easting 411777
            UtmPoint expected = new UtmPoint(411777, 5655984, 33, true);

            Assert.IsTrue(expected.Equals(utmPoint));
        }
Example #5
0
 private Boolean SameZone(UtmPoint point)
 {
     GeoPoint geoPoint = new GeoPoint(point, Datum);
     UtmPoint realUtm = geoPoint.CalcUTM();
     Boolean result = (CentralPoint.ZoneNumber == realUtm.ZoneNumber);
     return result;
 }
Example #6
0
 private UtmPoint LimitToZone(UtmPoint point)
 {
     UtmPoint result = new UtmPoint(point);
     Int32 minEasting = 0;
     Int32 maxEasting = 0;
     if ( point.Easting < CentralPoint.Easting )
     {
         minEasting = point.Easting;
         maxEasting = minEasting + GridSize(_Digits);
     }
     else
     {
         maxEasting = point.Easting;
         minEasting = maxEasting - GridSize(_Digits);
     }
     Int32 leftZone = 0;
     {
         UtmPoint tempUtmPoint = new UtmPoint(point);
         tempUtmPoint.Easting = minEasting;
         GeoPoint tempGeoPoint = new GeoPoint(tempUtmPoint, Datum);
         tempUtmPoint = tempGeoPoint.CalcUTM();
         leftZone = tempUtmPoint.ZoneNumber;
     }
     Int32 eastingDiff = maxEasting - minEasting;
     while ( eastingDiff > 1 )
     {
         Int32 tempEasting = minEasting + eastingDiff / 2;
         result = new UtmPoint(point);
         result.Easting = tempEasting;
         GeoPoint tempGeoPoint = new GeoPoint(result, Datum);
         UtmPoint empUtmPoint = tempGeoPoint.CalcUTM();
         if ( empUtmPoint.ZoneNumber > leftZone )
         {
             maxEasting = tempEasting;
         }
         else
         {
             minEasting = tempEasting;
         }
         eastingDiff = eastingDiff / 2;
     }
     return result;
 }
Example #7
0
 private void edt_LatLong_TextChanged(object sender, EventArgs e)
 {
     if ( !_Changing )
     {
         GeoPoint geoPoint = null;
         UtmPoint utmPoint = null;
         try
         {
             _Changing = true;
             geoPoint = new GeoPoint(edt_LatLong.Text);
             geoPoint.Datum = (GeoDatum)cbx_datum.SelectedItem;
             GeoPoint lGeoOtherDatum = new GeoPoint(geoPoint);
             lGeoOtherDatum.Datum = (GeoDatum)cbx_datum.SelectedItem;
             utmPoint = lGeoOtherDatum.CalcUTM();
         }
         catch
         {
             // invalid string
             geoPoint = null;
             utmPoint = null;
         }
         SetValues(geoPoint, utmPoint, sender);
         _Changing = false;
     }
 }