示例#1
0
        public void test_ApplyCoordinateFilter()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);
            //CoordinateFilter filter = new CoordinateFilter();

            //todo(Ronda): Apply
            //point.Apply(filter);
        }
示例#2
0
		public void test_constructor()
		{
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

			//create a new point
			Point point = gf.CreatePoint(_coor);

			//Make sure the values
			Assertion.AssertEquals("Const-x: ", 1.0, point.X);
			Assertion.AssertEquals("Const-y: ", 2.0, point.Y);
		}
示例#3
0
        public void test_IsSimple()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //check for true - IsSimple always returns true for a point
            Assertion.AssertEquals("IsSimple: ", true, point.IsSimple());
        }
示例#4
0
        public void test_NumPoints()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            Assertion.AssertEquals("NumPoints1: ", 1, point.GetNumPoints());

            //Create a null coordinate to test with
            Coordinate testCoord = new Coordinate();
            testCoord = null;

            //create a point with a null coordinate to test else case
            Point point2 = gf.CreatePoint(testCoord);

            Assertion.AssertEquals("NumPoints2: ", 0, point2.GetNumPoints());
        }
示例#5
0
		public void test_CompareTo()
		{
			//create a coordinate (the z value is not used so there is no need to create it)
			Coordinate coord = new Coordinate(testX, testY);
			//create an equal coordinate
			Coordinate coord2 = new Coordinate(1.0, 2.0);
			//create a coordinate where X is greater & Y is equal
			Coordinate coord3 = new Coordinate(2.0, 2.0);
			//create a coordinate where Y is greater & x is equal
			Coordinate coord4 = new Coordinate(1.0, 3.0);
			//create a coordinate where both X & Y are greater
			Coordinate coord5 = new Coordinate(2.0, 3.0);
			//create a coordinate where X is less & Y is equal
			Coordinate coord6 = new Coordinate(0.0, 2.0);
			//create a coordinate where Y is less & X is equal
			Coordinate coord7 = new Coordinate(1.0, 1.0);
			//create a coordinate where both are less
			Coordinate coord8 = new Coordinate(0.0, 0.0);

			//create a point to send to throw the exception
			_gf = new GeometryFactory(_pm, _srid);
			Point point = _gf.CreatePoint(coord);

			Assertion.AssertEquals("CompareTo1: ", 0, coord.CompareTo(coord2));
			Assertion.AssertEquals("CompareTo2: ", -1, coord.CompareTo(coord3));
			Assertion.AssertEquals("CompareTo3: ", -1, coord.CompareTo(coord4));
			Assertion.AssertEquals("CompareTo4: ", -1, coord.CompareTo(coord5));
			Assertion.AssertEquals("CompareTo5: ", 1, coord.CompareTo(coord6));
			Assertion.AssertEquals("CompareTo6: ", 1, coord.CompareTo(coord7));
			Assertion.AssertEquals("CompareTo7: ", 1, coord.CompareTo(coord8));

			try
			{
				coord.CompareTo(point);
				Assertion.Fail("ArgumentException should have been thrown");
			}
			catch(ArgumentException)
			{
			}
		}
示例#6
0
        public void test_IsEmpty()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            Assertion.AssertEquals("IsEmpty1: ", false, point.IsEmpty());

            //Set point to be empty to test the else
            Coordinate testCoord = null;
            Point point2 = gf.CreatePoint(testCoord);

            Assertion.AssertEquals("IsEmpty2: ", true, point2.IsEmpty());
        }
示例#7
0
        public void test_Constructor()
        {
            //create a new collection
            GeometryCollection geoColl = CreateCollection();

            //make sure the geometrycollection isn't empty
            Assertion.AssertEquals("Constructor-1: ", false, geoColl.IsEmpty());
            //it should have ten elements
            Assertion.AssertEquals("Constructor-2: ", 10, geoColl.Count);

            //make sure all the elements are not empty
            for(int i = 0; i < geoColl.Count; i++)
            {
                Assertion.AssertEquals("Constructor-3: ", false, geoColl.GetGeometryN(i).IsEmpty());
            }

            Coordinate coord = new Coordinate();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coord);
            //check that the contents are as expected
            for(int i = 0; i < geoColl.Count; i++)
            {
                point = geoColl.GetGeometryN(i) as Point;
                Assertion.AssertEquals("Constructor-4: ", true, point.X.Equals((double)i));
                Assertion.AssertEquals("Constructor-5: ", true, point.Y.Equals((double)i+10));
            }
        }
示例#8
0
        private GeometryCollection CreateCollection3()
        {
            //create a new geometries array
            Geometry[] geom = new Geometry[10];

            Coordinate coordinate = new Coordinate();
            Coordinates coords = new Coordinates();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coordinate);

            LineString lineString = gf.CreateLineString(coords);

            for(int c = 0; c < 5; c++)
            {
                for(int i = c; i < c+5; i++)
                {
                    //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                    coordinate = new Coordinate();
                    //make the x coordinate equal to the iterator
                    coordinate.X = (double)i;
                    //make the y coordinate equal to the iterator plus 10
                    coordinate.Y = (double)i + 10;
                    coords.Add(coordinate);
                }
                lineString = gf.CreateLineString(coords);
                geom[c] = lineString;
            }
            for(int i = 5; i < 10; i++)
            {
                //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                coordinate = new Coordinate();
                //make the x coordinate equal to the iterator
                coordinate.X = (double)i;
                //make the y coordinate equal to the iterator plus 10
                coordinate.Y = (double)i + 10;
                //create a new point to put in the geometry
                point = gf.CreatePoint(coordinate);
                //put the point in the geometies
                geom[i] = point;
            }
            //put the geometries into a geometry collection
            GeometryCollection geoColl = gf.CreateGeometryCollection(geom);

            return geoColl;
        }
示例#9
0
        /// <summary>
        /// Method to create a MultiPoint for testing purposes
        /// </summary>
        /// <returns>A MultiPoint</returns>
        private MultiPoint CreateTester1()
        {
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

            Point[] points = new Point[23];

            for(int i = 0; i < 12; i++)
            {
                points[i] = gf.CreatePoint(new Coordinate(i, i));
            }
            points[12] = gf.CreatePoint(new Coordinate(11, 12));
            points[13] = gf.CreatePoint(new Coordinate(10, 13));
            points[14] = gf.CreatePoint(new Coordinate(9, 14));
            points[15] = gf.CreatePoint(new Coordinate(8, 15));
            points[16] = gf.CreatePoint(new Coordinate(9, 16));
            points[17] = gf.CreatePoint(new Coordinate(10, 17));
            points[18] = gf.CreatePoint(new Coordinate(11, 18));
            points[19] = gf.CreatePoint(new Coordinate(12, 19));
            points[20] = gf.CreatePoint(new Coordinate(11, 20));
            points[21] = gf.CreatePoint(new Coordinate(10, 21));
            points[22] = gf.CreatePoint(new Coordinate(9, 22));

            MultiPoint mp = gf.CreateMultiPoint(points);
            return mp;
        }
示例#10
0
		public void test_PointN()
		{
			LineString ls = SimpleOpen();

			Coordinate coord = new Coordinate(11.0, 12.0);
			Coordinate coord2 = new Coordinate(11.0, 20.0);
			Coordinate coord3 = new Coordinate(0.0, 0.0);
			
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
			Point point = gf.CreatePoint(coord);
			Point point2 = gf.CreatePoint(coord2);
			Point point3 = gf.CreatePoint(coord);
	
			Point testPoint = ls.GetPointN(11) as Point;
			Assertion.AssertEquals("PointN: ", true, testPoint.Equals(point));
		}
示例#11
0
        public void test_Coords()
        {
            PrecisionModel precisionModel = new PrecisionModel();

            //Set the coord to be empty
            Coordinate coord = new Coordinate();
            coord = null;
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coord);

            //test that true is returned because the coordinates are empty.
            Assertion.AssertEquals("Coords - true: ", true, point.IsEmpty());

            //Put something into the coordinates
            Coordinate coordinate = new Coordinate(1.0,2.0);

            //create a new point
            point = gf.CreatePoint(coordinate);

            //test that false is returned because the coordinates are not empty.
            Assertion.AssertEquals("Coords - false: ", false, point.IsEmpty());
        }
示例#12
0
        public void test_Dimension()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //check for zero - dimension always returns 0 for a point
            Assertion.AssertEquals("Dimension: ", 0, point.GetDimension());
        }
示例#13
0
        public void test_Coordinates()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //returns a coordinates object
            Coordinates coordinates = point.GetCoordinates();

            //test to make sure only one coordinate is returned for a point
            Assertion.AssertEquals("Coordinates1: ", 1, coordinates.Count);

            foreach(Coordinate coord in coordinates)
            {
                //test to make sure that the coordinates returned are equal to the coordinates sent
                Assertion.AssertEquals("test :", true, coord.Equals(_coor));

                //testing each coordinate just to be sure
                Assertion.AssertEquals("Coordinates2: ", _coor.X, coord.X);
                Assertion.AssertEquals("Coordinates3: ", _coor.Y, coord.Y);
            }
        }
示例#14
0
        public void test_Clone()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);
            //clone that point
            Point point2 = point.Clone() as Point;

            //Test that they are not the same point
            Assertion.AssertEquals("Clone-1: ", false, point==point2);

            //Test that they have the same coordinates
            Assertion.AssertEquals("Clone-2: ", true, point.X==point2.X);
            Assertion.AssertEquals("Clone-3: ", true, point.Y==point2.Y);
        }
示例#15
0
		public void test_Equals()
		{
			LineString ls1 = SimpleOpen();
			LineString ls2 = NonSimpleOpen();
			LineString ls3 = SimpleOpen();
			Coordinate coord = new Coordinate(5.0, 2.0);
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
			Point point = gf.CreatePoint(coord);

			Assertion.AssertEquals("Equals-1: ", true, ls1.Equals(ls3));
			//todo(Ronda): fix when geometry.equals is working
			Assertion.AssertEquals("Equals-2: ", false, ls1.Equals(ls2));
			Assertion.AssertEquals("Equals-3: ", true, ls3.Equals(ls1));
			Assertion.AssertEquals("Equals-4: ", false, ls2.Equals(point));
		}
示例#16
0
        public void test_Y()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            Assertion.AssertEquals("Y: ", 2.0, point.Y);
        }
示例#17
0
        /// <summary>
        /// Method to create a MultiPoint for testing purposes
        /// </summary>
        /// <returns>A MultiPoint</returns>
        private MultiPoint CreateTester3()
        {
            Point[] points = new Point[21];

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

            points[0] = gf.CreatePoint(new Coordinate(10, 13));
            points[1] = gf.CreatePoint(new Coordinate(11, 13));
            points[2] = gf.CreatePoint(new Coordinate(12, 13));
            points[3] = gf.CreatePoint(new Coordinate(13, 14));
            points[4] = gf.CreatePoint(new Coordinate(14, 15));
            points[5] = gf.CreatePoint(new Coordinate(15, 16));
            points[6] = gf.CreatePoint(new Coordinate(15, 17));
            points[7] = gf.CreatePoint(new Coordinate(15, 18));
            points[8] = gf.CreatePoint(new Coordinate(14, 19));
            points[9] = gf.CreatePoint(new Coordinate(13, 20));
            points[10] = gf.CreatePoint(new Coordinate(12, 21));
            points[11] = gf.CreatePoint(new Coordinate(11, 21));
            points[12] = gf.CreatePoint(new Coordinate(10, 21));
            points[13] = gf.CreatePoint(new Coordinate(9, 20));
            points[14] = gf.CreatePoint(new Coordinate(8, 19));
            points[15] = gf.CreatePoint(new Coordinate(7, 18));
            points[16] = gf.CreatePoint(new Coordinate(7, 17));
            points[17] = gf.CreatePoint(new Coordinate(7, 16));
            points[18] = gf.CreatePoint(new Coordinate(8, 15));
            points[19] = gf.CreatePoint(new Coordinate(9, 14));
            points[20] = gf.CreatePoint(new Coordinate(10, 13));

            MultiPoint mp = gf.CreateMultiPoint(points);
            return mp;
        }
示例#18
0
        public void test_Envelope()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);
            Geometry geom = point.GetEnvelope() as Geometry;

            //make sure there is something in the envelope
            Assertion.AssertEquals("Envelope-1: ", false, geom.IsEmpty());

            //get the coordinates out of the geometry
            Coordinates coords = geom.GetCoordinates();
            //a point is returned as the envelope of a point
            Assertion.AssertEquals("Envelope-2: ", 1.0, coords[0].X);
            Assertion.AssertEquals("Envelope-3: ", 2.0, coords[0].Y);
        }
示例#19
0
		public void test_StartPoint()
		{
			LineString ls = SimpleOpen();
			Coordinate coord = new Coordinate(0, 0);
			Coordinate coord2 = new Coordinate(1.0, 1.0);
			
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
			Point point = gf.CreatePoint(coord);
			Point point2 = gf.CreatePoint(coord2);
			Point point3 = gf.CreatePoint(coord);

			point = ls.GetStartPoint() as Point;

			Assertion.AssertEquals("StartPoint-1: ", true, point.Equals(point2));
			Assertion.AssertEquals("StartPoint-2: ", false, point.Equals(point3));
		}
示例#20
0
        /// <summary>
        /// Method to create a MultiPoint for testing purposes
        /// </summary>
        /// <returns>A MultiPoint</returns>
        private MultiPoint CreateTester2()
        {
            Point[] points = new Point[18];

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

            points[0] = gf.CreatePoint(new Coordinate(2, 2));
            points[1] = gf.CreatePoint(new Coordinate(3, 3));
            points[2] = gf.CreatePoint(new Coordinate(4, 4));
            points[3] = gf.CreatePoint(new Coordinate(5, 5));
            points[4] = gf.CreatePoint(new Coordinate(6, 6));
            points[5] = gf.CreatePoint(new Coordinate(7, 7));
            points[6] = gf.CreatePoint(new Coordinate(8, 8));
            points[7] = gf.CreatePoint(new Coordinate(9, 7));
            points[8] = gf.CreatePoint(new Coordinate(10, 6));
            points[9] = gf.CreatePoint(new Coordinate(10, 5));
            points[10] = gf.CreatePoint(new Coordinate(9, 4));
            points[11] = gf.CreatePoint(new Coordinate(8, 3));
            points[12] = gf.CreatePoint(new Coordinate(7, 4));
            points[13] = gf.CreatePoint(new Coordinate(7, 5));
            points[14] = gf.CreatePoint(new Coordinate(6, 6));
            points[15] = gf.CreatePoint(new Coordinate(5, 7));
            points[16] = gf.CreatePoint(new Coordinate(4, 8));
            points[17] = gf.CreatePoint(new Coordinate(3, 9));

            MultiPoint mp = gf.CreateMultiPoint(points);
            return mp;
        }
示例#21
0
        public void test_Equals()
        {
            //create a new point to test for a true result
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);
            Point testPoint1 = gf.CreatePoint(_coor);

            //create a new coordinate and point to test for a false result
            Coordinate coord = new Coordinate(2.0, 1.0);
            Point testPoint2 = gf.CreatePoint(coord);

            //create a new type of geometry to test for another aoptional pest control procedure

            Assertion.AssertEquals("EqualsTrue: ", true, point.Equals(testPoint1));
            Assertion.AssertEquals("EqualsFalse: ", false, point.Equals(testPoint2));
        }
示例#22
0
        /// <summary>
        /// Method to create a MultiPoint for testing purposes
        /// </summary>
        /// <returns>A MultiPoint</returns>
        private MultiPoint CreateTester4()
        {
            Point[] points = new Point[32];

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

            points[0] = gf.CreatePoint(new Coordinate(2, 2));
            points[1] = gf.CreatePoint(new Coordinate(3, 1));
            points[2] = gf.CreatePoint(new Coordinate(4, 2));
            points[3] = gf.CreatePoint(new Coordinate(5, 3));
            points[4] = gf.CreatePoint(new Coordinate(6, 4));
            points[5] = gf.CreatePoint(new Coordinate(7, 5));
            points[6] = gf.CreatePoint(new Coordinate(7, 6));
            points[7] = gf.CreatePoint(new Coordinate(7, 7));
            points[8] = gf.CreatePoint(new Coordinate(7, 8));
            points[9] = gf.CreatePoint(new Coordinate(7, 9));
            points[10] = gf.CreatePoint(new Coordinate(6, 10));
            points[11] = gf.CreatePoint(new Coordinate(5, 11));
            points[12] = gf.CreatePoint(new Coordinate(6, 12));
            points[13] = gf.CreatePoint(new Coordinate(7, 13));
            points[14] = gf.CreatePoint(new Coordinate(8, 14));
            points[15] = gf.CreatePoint(new Coordinate(9, 13));
            points[16] = gf.CreatePoint(new Coordinate(10, 12));
            points[17] = gf.CreatePoint(new Coordinate(10, 11));
            points[18] = gf.CreatePoint(new Coordinate(10, 10));
            points[19] = gf.CreatePoint(new Coordinate(10, 9));
            points[20] = gf.CreatePoint(new Coordinate(9, 8));
            points[21] = gf.CreatePoint(new Coordinate(8, 7));
            points[22] = gf.CreatePoint(new Coordinate(7, 7));
            points[23] = gf.CreatePoint(new Coordinate(6, 7));
            points[24] = gf.CreatePoint(new Coordinate(5, 8));
            points[25] = gf.CreatePoint(new Coordinate(4, 8));
            points[26] = gf.CreatePoint(new Coordinate(3, 7));
            points[27] = gf.CreatePoint(new Coordinate(2, 6));
            points[28] = gf.CreatePoint(new Coordinate(1, 5));
            points[29] = gf.CreatePoint(new Coordinate(2, 4));
            points[30] = gf.CreatePoint(new Coordinate(1, 3));
            points[31] = gf.CreatePoint(new Coordinate(2, 2));

            MultiPoint mp = gf.CreateMultiPoint(points);
            return mp;
        }
示例#23
0
        public void test_GeometryType()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //check for "point" - GeometryType always returns "point" for a point
            Assertion.AssertEquals("GeometryType: ", "Point", point.GetGeometryType());
        }
示例#24
0
        public void test_geometry()
        {
            //create a new collection
            GeometryCollection geoColl = CreateCollection();

            //create a new coordinate
            Coordinate coord = new Coordinate(0.0, 10.0);
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coord);
            //make sure that geometry returns the expected points
            for(int count = 0; count < geoColl.Count; count++)
            {
                point = geoColl.GetGeometryN(count) as Point;
                Assertion.AssertEquals("geometry-1: ", (double)count, point.X);
                Assertion.AssertEquals("geometry-2: ", (double)count+10, point.Y);
            }
        }
示例#25
0
        public void test_GetBoundary()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //get the boundary of the point
            Geometry geoColl = point.GetBoundary();

            //should return true always - a point has no boundary
            Assertion.AssertEquals("GetBoundary: ", true, geoColl.IsEmpty());
        }
示例#26
0
        private GeometryCollection CreateCollection4()
        {
            //this is used to prevent having to rewrite this code over & over

            //create a new coordinate
            Coordinate coordinate = new Coordinate();
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coordinate);
            //create a new geometries array
            Geometry[] geom = new Geometry[10];
            int c = 0;
            //fill with points
            for(int i = 9; i < 19 ; i++)
            {
                //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                coordinate = new Coordinate();
                //make the x coordinate equal to the iterator
                coordinate.X = (double)i;
                //make the y coordinate equal to the iterator plus 10
                coordinate.Y = (double)i + 10;
                //create a new point to put in the geometry
                point = gf.CreatePoint(coordinate);
                //put the point in the geometies
                geom[c] = point;
                c++;
            }
            //put the geometries into a geometry collection
            GeometryCollection geoColl = gf.CreateGeometryCollection(geom);

            return geoColl;
        }
示例#27
0
        public void test_GetBoundryDimension()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);

            //GetBoundryDimension allways returns false(-1) for Point
            Assertion.AssertEquals("GetBoundryDimension: ", -1, point.GetBoundaryDimension());
        }