コード例 #1
0
ファイル: GeoPoint_Test.cs プロジェクト: PaulCharlton/tambon
        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));
        }
コード例 #2
0
 public UtmPoint NorthEastCornerUtm()
 {
     String value = CentralPoint.ToUtmString(_Digits);
     UtmPoint result = new UtmPoint(value);
     result.Easting += GridSize(_Digits);
     if ( !SameZone(result) )
     {
         result = LimitToZone(result);
     }
     return result;
 }
コード例 #3
0
 public UtmPoint ActualCentralPoint()
 {
     String value = CentralPoint.ToUtmString(_Digits);
     UtmPoint west = new UtmPoint(value);
     west.Northing += GridSize(_Digits) / 2;
     UtmPoint east = new UtmPoint(west);
     east.Easting += GridSize(_Digits);
     if ( !SameZone(west) )
     {
         west = LimitToZone(west);
     }
     if ( !SameZone(east) )
     {
         east = LimitToZone(east);
     }
     UtmPoint result = new UtmPoint(value);
     result.Northing += GridSize(_Digits) / 2;
     result.Easting = (west.Easting + east.Easting) / 2;
     return result;
 }
コード例 #4
0
 private Boolean SameZone(UtmPoint point)
 {
     GeoPoint geoPoint = new GeoPoint(point, Datum);
     UtmPoint realUtm = geoPoint.CalcUTM();
     Boolean result = (CentralPoint.ZoneNumber == realUtm.ZoneNumber);
     return result;
 }
コード例 #5
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;
 }
コード例 #6
0
 private static UtmPoint MakeCentral(UtmPoint point, Int16 digits)
 {
     String value = point.ToUtmString(digits);
     UtmPoint utmPoint = new UtmPoint(value);
     Double distance = 0.5 * GridSize(digits);
     Double easting = utmPoint.Easting + distance;
     Double northing = utmPoint.Northing + distance;
     UtmPoint middlePoint = new UtmPoint(easting, northing, utmPoint.ZoneNumber, utmPoint.IsNorthernHemisphere);
     return middlePoint;
 }
コード例 #7
0
ファイル: GeoPoint_Test.cs プロジェクト: PaulCharlton/tambon
 public void TestUTMToMGRS()
 {
     UtmPoint utmPoint = new UtmPoint("33U 0411777 5655984");
     String mgrs = utmPoint.ToMgrsString(7).Replace(" ", "");
     Assert.AreEqual("33UVS1177755984", mgrs);
 }
コード例 #8
0
ファイル: GeoPoint_Test.cs プロジェクト: PaulCharlton/tambon
 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));
 }
コード例 #9
0
ファイル: GeoPoint_Test.cs プロジェクト: PaulCharlton/tambon
 public void TestParseMGRS()
 {
     UtmPoint utmPoint = UtmPoint.ParseMgrsString("33UVS1177755984");
     UtmPoint utmPointExpected = new UtmPoint("33U 0411777 5655984");
     Assert.IsTrue(utmPointExpected.Equals(utmPoint));
 }