コード例 #1
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        /// <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;
        }
コード例 #2
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        /// <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;
        }
コード例 #3
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        /// <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;
        }
コード例 #4
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        /// <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;
        }
コード例 #5
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        public void test_NumPoints()
        {
            //create a new multipoint
            MultiPoint mp = CreateTester1();

            Assertion.AssertEquals("NumPoints1: ", 23, mp.GetNumPoints());

            //Create a null coordinate to test with
            Coordinates testCoords = new Coordinates();

            //create a multipoint with a null coordinate to test else case
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            testCoords = new Coordinates();
            MultiPoint mp2 = gf.CreateMultiPoint(testCoords);

            Assertion.AssertEquals("NumPoints2: ", 0, mp2.GetNumPoints());
        }
コード例 #6
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        public void test_IsEmpty()
        {
            //create a new multipoint
            MultiPoint mp = CreateTester1();

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

            //Set multipoint to be empty to test the else
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Coordinates coords = new Coordinates();
            MultiPoint mp2 = gf.CreateMultiPoint(coords);

            Assertion.AssertEquals("IsEmpty2: ", true, mp2.IsEmpty());
        }
コード例 #7
0
ファイル: MultiPointTest.cs プロジェクト: vmoll/geotools
        public void test_Envelope()
        {
            //create a new multipoint
            MultiPoint mp = CreateTester1();
            Geometry geom = mp.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();
            //check the first set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-2: ", 0.0, coords[0].X);
            Assertion.AssertEquals("Envelope-3: ", 0.0, coords[0].Y);

            //check the second set of coordinates (maxX, minY)
            Assertion.AssertEquals("Envelope-4: ", 12.0, coords[1].X);
            Assertion.AssertEquals("Envelope-5: ", 0.0, coords[1].Y);

            //check the third set of coordinates (maxX, maxY)
            Assertion.AssertEquals("Envelope-6: ", 12.0, coords[2].X);
            Assertion.AssertEquals("Envelope-7: ", 22.0, coords[2].Y);

            //check the forth set of coordinates (minX, maxY)
            Assertion.AssertEquals("Envelope-8: ", 0.0, coords[3].X);
            Assertion.AssertEquals("Envelope-9: ", 22.0, coords[3].Y);

            //check the fifth set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-10: ", 0.0, coords[4].X);
            Assertion.AssertEquals("Envelope-11: ", 0.0, coords[4].Y);

            //create a new multipoint
            mp = CreateTester3();
            geom = mp.GetEnvelope() as Geometry;

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

            //get the coordinates out of the geometry
            coords = geom.GetCoordinates();
            //check the first set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-13: ", 7.0, coords[0].X);
            Assertion.AssertEquals("Envelope-14: ", 13.0, coords[0].Y);

            //check the second set of coordinates (maxX, minY)
            Assertion.AssertEquals("Envelope-15: ", 15.0, coords[1].X);
            Assertion.AssertEquals("Envelope-16: ", 13.0, coords[1].Y);

            //check the third set of coordinates (maxX, maxY)
            Assertion.AssertEquals("Envelope-17: ", 15.0, coords[2].X);
            Assertion.AssertEquals("Envelope-18: ", 21.0, coords[2].Y);

            //check the forth set of coordinates (minX, maxY)
            Assertion.AssertEquals("Envelope-19: ", 7.0, coords[3].X);
            Assertion.AssertEquals("Envelope-20: ", 21.0, coords[3].Y);

            //check the fifth set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-21: ", 7.0, coords[4].X);
            Assertion.AssertEquals("Envelope-22: ", 13.0, coords[4].Y);

            coords = new Coordinates();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            coords = new Coordinates();
            mp = gf.CreateMultiPoint(coords);
            geom = mp.GetEnvelope() as Geometry;

            //make sure there is something in the envelope
            Assertion.AssertEquals("Envelope-23: ", true, geom.IsEmpty());
        }
コード例 #8
0
		public void test_CompareToSameClass()
		{
			LineString ls = SimpleOpen();
			LineString ls2 = SimpleOpen();
			LineString ls3 = SimpleClosed();
			Point[] coords  = new Point[]{};
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
			MultiPoint mp = gf.CreateMultiPoint(coords);

			Assertion.AssertEquals("CompareToSameClass-1: ", 0, ls.CompareToSameClass(ls2));
			Assertion.AssertEquals("CompareToSameClass-2: ", 1, ls.CompareToSameClass(ls3));
			Assertion.AssertEquals("CompareToSameClass-3: ", 1, ls.CompareToSameClass(mp));
			Assertion.AssertEquals("CompareToSameClass-4: ", -1, ls3.CompareToSameClass(ls));
			Assertion.AssertEquals("CompareToSameClass-5: ", -1, mp.CompareToSameClass(ls));
		}
コード例 #9
0
		public void test_GetBoundary()
		{
			//try on a simple-open linestring
			LineString ls = SimpleOpen();
			Geometry geom =  ls.GetBoundary();
            
			Assertion.AssertEquals("GetBoundary-1: ", false, geom.IsEmpty());

			Assertion.AssertEquals("GetBoundary-2: ", 2, geom.GetNumPoints());

			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
			MultiPoint mp = gf.CreateMultiPoint(geom.GetCoordinates());
			for(int i = 0; i < mp.GetNumPoints(); i++)
			{
				switch(i)
				{
					case 0:
						Assertion.AssertEquals("GetBoundary-3: ", 1.0, mp.GetCoordinate(i).X);
						Assertion.AssertEquals("GetBoundary-4: ", 1.0, mp.GetCoordinate(i).Y);
						break;
					case 1:
						Assertion.AssertEquals("GetBoundary-5: ", 9.0, mp.GetCoordinate(i).X);
						Assertion.AssertEquals("GetBoundary-6: ", 22.0, mp.GetCoordinate(i).Y);
						break;
					default:
						Assertion.Fail("This should never be reached");
						break;
				}
			}

			//try on a simple-closed linestring
			ls = SimpleClosed();
			geom =  ls.GetBoundary();
            
			Assertion.AssertEquals("GetBoundary-7: ", true, geom.IsEmpty());

			Assertion.AssertEquals("GetBoundary-8: ", 0, geom.GetNumPoints());

			//try on a nonsimple-open linestring
			ls = NonSimpleOpen();
			geom =  ls.GetBoundary();
            
			Assertion.AssertEquals("GetBoundary-9: ", false, geom.IsEmpty());

			Assertion.AssertEquals("GetBoundary-10: ", 2, geom.GetNumPoints());

			mp = gf.CreateMultiPoint(geom.GetCoordinates());

			for(int i = 0; i < mp.GetNumPoints(); i++)
			{
				switch(i)
				{
					case 0:
						Assertion.AssertEquals("GetBoundary-11: ", 2.0, mp.GetCoordinate(i).X);
						Assertion.AssertEquals("GetBoundary-12: ", 2.0, mp.GetCoordinate(i).Y);
						break;
					case 1:
						Assertion.AssertEquals("GetBoundary-13: ", 3.0, mp.GetCoordinate(i).X);
						Assertion.AssertEquals("GetBoundary-14: ", 9.0, mp.GetCoordinate(i).Y);
						break;
					default:
						Assertion.Fail("This should never be reached");
						break;
				}
			}

			//try on a simple-closed linestring
			ls = NonSimpleClosed();
			geom =  ls.GetBoundary();
            
			Assertion.AssertEquals("GetBoundary-15: ", true, geom.IsEmpty());

			Assertion.AssertEquals("GetBoundary-16: ", 0, geom.GetNumPoints());
		}