Inheritance: System.Point
 public void AddLine(double x, double y, double? z)
 {
     SmGeometries.Point point=null;
     if (z.HasValue)
         point=new SmGeometries.Point3D(x, y, z.Value);
     else
         point=new SmGeometries.Point(x, y);
     _CurrentPoints.Add(point);
 }
Beispiel #2
0
 public void AddLine(double x, double y, double?z)
 {
     SmGeometries.Point point = null;
     if (z.HasValue)
     {
         point = new SmGeometries.Point3D(x, y, z.Value);
     }
     else
     {
         point = new SmGeometries.Point(x, y);
     }
     _CurrentPoints.Add(point);
 }
Beispiel #3
0
    private void TestGeocentric()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84,
                                                                                PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North));
        IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich);

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs);

        SharpMap.Geometries.Point3D pGeo  = new SharpMap.Geometries.Point3D(2.12955, 53.80939444, 73);
        SharpMap.Geometries.Point3D pGc   = new Point3D(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point3D pGeo2 = new Point3D(trans.MathTransform.Inverse().Transform(pGc.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Point3D(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test");

        return;
    }
Beispiel #4
0
        public void Point3D()
        {
            //Do various Point method calls to cover the point class with sufficient testing
            Point3D p0 = new Point3D();
            Point p = new Point(23, 21);
            Point3D p1 = new Point3D(450, 120, 34);
            Point3D p2 = new Point3D(p, 94);
            Assert.IsTrue(p0.IsEmpty());
            Assert.IsFalse(p1.IsEmpty());
            Assert.IsFalse(p2.IsEmpty());

            Assert.AreNotEqual(p, p2);
            Assert.AreEqual(94, p2.Z);

            Assert.AreNotSame(p1.Clone(), p1);
            p0 = p1.Clone();
            p0.X += 100;
            p0.Y = 150;
            p0.Z += 499;
            p0[2] += p0[2];
            Assert.AreEqual(new Point3D(550, 150, 1066), p0);
            Assert.AreEqual(p2.AsPoint(), p2.GetBoundingBox().Min);
            Assert.AreEqual(p2.AsPoint(), p2.GetBoundingBox().Max);
            Assert.AreEqual(3, p2.NumOrdinates);
            Assert.AreEqual(new Point3D(-27, 1, 123), p2 + new Point3D(-50, -20, 29));
            Assert.AreEqual(new Point(73, 1), p2 - new Point(-50, 20));
            Assert.AreEqual(new Point3D(46, 42, 188), p2*2);
            Assert.AreEqual(0, p2.Dimension);
            Assert.AreEqual(23, p2[0]);
            Assert.AreEqual(21, p2[1]);
            Assert.AreEqual(94, p2[2]);
            Assert.IsNull(p2.Boundary());
            Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.Z.GetHashCode() ^ p2.IsEmpty().GetHashCode(),
                            p2.GetHashCode());
            Assert.Less(p2.CompareTo(p1), 0);
            Assert.Greater(p1.CompareTo(p2), 0);
            Assert.AreEqual(0, p2.CompareTo(new Point3D(23, 21, 94)));
            Assert.AreEqual(0, p2.CompareTo(new Point(23, 21)));
        }
Beispiel #5
0
 /// <summary>
 /// Checks whether the two points are spatially equal
 /// </summary>
 /// <param name="p1">Point 1</param>
 /// <param name="p2">Point 2</param>
 /// <returns>true if the points a spatially equal</returns>
 public bool Equals(Point3D p1, Point3D p2)
 {
     return(p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z);
 }
Beispiel #6
0
 /// <summary>
 /// Checks whether this instance is spatially equal to the Point 'o'
 /// </summary>
 /// <param name="p">Point to compare to</param>
 /// <returns></returns>
 public bool Equals(Point3D p)
 {
     return(base.Equals(p) && p.Z == _z);
 }
Beispiel #7
0
 /// <summary>
 /// Comparator used for ordering point first by ascending X, then by ascending Y and then by ascending Z.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual int CompareTo(Point3D other)
 {
     if (X < other.X || X <= other.X && Y < other.Y || X <= other.X && Y <= other.Y && Z < other.Z)
         return -1;
     if (X > other.X || X >= other.X && Y > other.Y || X >= other.X && Y >= other.Y && Z > other.Z)
         return 1;
     return 0;
 }
Beispiel #8
0
 /// <summary>
 /// Checks whether the two points are spatially equal
 /// </summary>
 /// <param name="p1">Point 1</param>
 /// <param name="p2">Point 2</param>
 /// <returns>true if the points a spatially equal</returns>
 public bool Equals(Point3D p1, Point3D p2)
 {
     return (Math.Abs(p1.X - p2.X) < double.Epsilon && Math.Abs(p1.Y - p2.Y) < double.Epsilon && Math.Abs(p1.Z - p2.Z) < double.Epsilon);
 }
Beispiel #9
0
 /// <summary>
 /// Checks whether this instance is spatially equal to the Point 'o'
 /// </summary>
 /// <param name="p">Point to compare to</param>
 /// <returns></returns>
 public bool Equals(Point3D p)
 {
     return base.Equals(p) && Math.Abs(p.Z - z) < double.Epsilon;
 }
Beispiel #10
0
		/// <summary>
		/// Checks whether the two points are spatially equal
		/// </summary>
		/// <param name="p1">Point 1</param>
		/// <param name="p2">Point 2</param>
		/// <returns>true if the points a spatially equal</returns>
		public bool Equals(Point3D p1, Point3D p2)
		{
			return (p1.X==p2.X && p1.Y==p2.Y && p1.Z==p2.Z);
		}
Beispiel #11
0
		/// <summary>
		/// Comparator used for ordering point first by ascending X, then by ascending Y and then by ascending Z.
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public virtual int CompareTo(Point3D other)
		{
			if (this.X < other.X || this.X == other.X && this.Y < other.Y || this.X == other.X && this.Y == other.Y && this.Z < other.Z)
				return -1;
			else if (this.X > other.X || this.X == other.X && this.Y > other.Y || this.X == other.X && this.Y == other.Y && this.Z > other.Z)
				return 1;
			else// (this.X == other.X && this.Y == other.Y && this.Z == other.Z)
				return 0;
		}
Beispiel #12
0
		/// <summary>
		/// Checks whether this instance is spatially equal to the Point 'o'
		/// </summary>
		/// <param name="p">Point to compare to</param>
		/// <returns></returns>
		public bool Equals(Point3D p)
		{
			return base.Equals(p) && p.Z == _Z;
		}
		private bool ToleranceLessThan(Point3D p1, Point3D p2, double tolerance)
		{
			return Math.Abs(p1.X - p2.X) < tolerance && Math.Abs(p1.Y - p2.Y) < tolerance && Math.Abs(p1.Z - p2.Z) < tolerance;
		}
		public void TestDatumTransform()
		{
			CoordinateSystemFactory cFac = new CoordinateSystemFactory();
			//Define datums
			HorizontalDatum wgs72 = HorizontalDatum.WGS72;
			HorizontalDatum ed50 = HorizontalDatum.ED50;

			//Define geographic coordinate systems
			IGeographicCoordinateSystem gcsWGS72 = cFac.CreateGeographicCoordinateSystem("WGS72 Geographic", AngularUnit.Degrees, wgs72, PrimeMeridian.Greenwich,
				new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

			IGeographicCoordinateSystem gcsWGS84 = cFac.CreateGeographicCoordinateSystem("WGS84 Geographic", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich,
				new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

			IGeographicCoordinateSystem gcsED50 = cFac.CreateGeographicCoordinateSystem("ED50 Geographic", AngularUnit.Degrees, ed50, PrimeMeridian.Greenwich,
				new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

			//Define geocentric coordinate systems
			IGeocentricCoordinateSystem gcenCsWGS72 = cFac.CreateGeocentricCoordinateSystem("WGS72 Geocentric", wgs72, LinearUnit.Metre, PrimeMeridian.Greenwich);
			IGeocentricCoordinateSystem gcenCsWGS84 = cFac.CreateGeocentricCoordinateSystem("WGS84 Geocentric", HorizontalDatum.WGS84, LinearUnit.Metre, PrimeMeridian.Greenwich);
			IGeocentricCoordinateSystem gcenCsED50 = cFac.CreateGeocentricCoordinateSystem("ED50 Geocentric", ed50, LinearUnit.Metre, PrimeMeridian.Greenwich);

			//Define projections
            //System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>(5);
            System.Collections.ObjectModel.Collection<ProjectionParameter> parameters = new System.Collections.ObjectModel.Collection<ProjectionParameter>();
			parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
			parameters.Add(new ProjectionParameter("central_meridian", 9));
			parameters.Add(new ProjectionParameter("scale_factor", 0.9996));
			parameters.Add(new ProjectionParameter("false_easting", 500000));
			parameters.Add(new ProjectionParameter("false_northing", 0));
			IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);
			IProjectedCoordinateSystem utmED50 = cFac.CreateProjectedCoordinateSystem("ED50 UTM Zone 32N", gcsED50, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
			IProjectedCoordinateSystem utmWGS84 = cFac.CreateProjectedCoordinateSystem("WGS84 UTM Zone 32N", gcsWGS84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

			//Set TOWGS84 parameters
			wgs72.Wgs84Parameters = new Wgs84ConversionInfo(0, 0, 4.5, 0, 0, 0.554, 0.219);			
			ed50.Wgs84Parameters = new Wgs84ConversionInfo(-81.0703, -89.3603, -115.7526,
														   -0.48488, -0.02436, -0.41321,
														   -0.540645); //Parameters for Denmark
			
			//Set up coordinate transformations
			CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
			ICoordinateTransformation ctForw = ctFac.CreateFromCoordinateSystems(gcsWGS72, gcenCsWGS72); //Geographic->Geocentric (WGS72)
			ICoordinateTransformation ctWGS84_Gcen2Geo = ctFac.CreateFromCoordinateSystems(gcenCsWGS84, gcsWGS84);  //Geocentric->Geographic (WGS84)
			ICoordinateTransformation ctWGS84_Geo2UTM = ctFac.CreateFromCoordinateSystems(gcsWGS84, utmWGS84);  //UTM ->Geographic (WGS84)
			ICoordinateTransformation ctED50_UTM2Geo = ctFac.CreateFromCoordinateSystems(utmED50, gcsED50);  //UTM ->Geographic (ED50)
			ICoordinateTransformation ctED50_Geo2Gcen = ctFac.CreateFromCoordinateSystems(gcsED50, gcenCsED50); //Geographic->Geocentric (ED50)

			//Test datum-shift from WGS72 to WGS84
			//Point3D pGeoCenWGS72 = ctForw.MathTransform.Transform(pLongLatWGS72) as Point3D;
			Point3D pGeoCenWGS72 = new Point3D(3657660.66, 255768.55, 5201382.11);			
			ICoordinateTransformation geocen_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(gcenCsWGS72, gcenCsWGS84);
			Point3D pGeoCenWGS84 = geocen_ed50_2_Wgs84.MathTransform.Transform(pGeoCenWGS72) as Point3D;
			//Point3D pGeoCenWGS84 = wgs72.Wgs84Parameters.Apply(pGeoCenWGS72);

			Assert.IsTrue(ToleranceLessThan(new Point3D(3657660.78, 255778.43, 5201387.75), pGeoCenWGS84, 0.01));

			ICoordinateTransformation utm_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(utmED50, utmWGS84);
			Point pUTMED50 = new Point(600000, 6100000);
			Point pUTMWGS84 = utm_ed50_2_Wgs84.MathTransform.Transform(pUTMED50);
			Assert.IsTrue(ToleranceLessThan(new Point(599928.6, 6099790.2), pUTMWGS84, 0.1));
			//Perform reverse
			ICoordinateTransformation utm_Wgs84_2_Ed50 = ctFac.CreateFromCoordinateSystems(utmWGS84, utmED50);
			pUTMED50 = utm_Wgs84_2_Ed50.MathTransform.Transform(pUTMWGS84);
			Assert.IsTrue(ToleranceLessThan(new Point(600000, 6100000), pUTMED50, 0.1));
			//Assert.IsTrue(Math.Abs((pUTMWGS84 as Point3D).Z - 36.35) < 0.5);
			//Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
			//ED50_to_WGS84_Denmark: datum.Wgs84Parameters = new Wgs84ConversionInfo(-89.5, -93.8, 127.6, 0, 0, 4.5, 1.2);

		}
		public void TestGeocentric()
		{			
			CoordinateSystemFactory cFac = new CoordinateSystemFactory();
			IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich,
				new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
			IGeocentricCoordinateSystem gcenCs = cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich);
			CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory();
			ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs,gcenCs);
			Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
			Point3D pExpected3D = new Point3D(pExpected.X, pExpected.Y, 73.0);
			Point3D p0 = new Point3D(3771793.97, 140253.34, 5124304.35);
			Point3D p1 = ct.MathTransform.Transform(pExpected3D) as Point3D;
			Point3D p2 = ct.MathTransform.Inverse().Transform(p1) as Point3D;
			Assert.IsTrue(ToleranceLessThan(p1, p0, 0.01));
			Assert.IsTrue(ToleranceLessThan(p2, pExpected, 0.00001));
		}
Beispiel #16
0
	private void TestGeocentric()
	{
		CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

		IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84,
			PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),	new AxisInfo("Lat", AxisOrientationEnum.North));
		IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich);

		ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs);

		SharpMap.Geometries.Point3D pGeo = new SharpMap.Geometries.Point3D(2.12955, 53.80939444, 73);
        SharpMap.Geometries.Point3D pGc = new Point3D(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
		SharpMap.Geometries.Point3D pGeo2 = new Point3D(trans.MathTransform.Inverse().Transform(pGc.ToDoubleArray()));

		result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Point3D(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test");
		
		return;
	}