public void test_Constructor() { //create a MultiPoint MultiPoint mp1 = CreateTester1(); Assertion.AssertEquals("Constructor-1: ", false, mp1.IsEmpty()); Assertion.AssertEquals("Constructor-1a: ", 23, mp1.GetNumPoints()); //create a MultiPoint MultiPoint mp2 = CreateTester2(); Assertion.AssertEquals("Constructor-2: ", false, mp2.IsEmpty()); Assertion.AssertEquals("Constructor-2a: ", 18, mp2.GetNumPoints()); //create a MultiPoint MultiPoint mp3 = CreateTester3(); Assertion.AssertEquals("Constructor-3: ", false, mp3.IsEmpty()); Assertion.AssertEquals("Constructor-3a: ", 21, mp3.GetNumPoints()); //create a MultiPoint MultiPoint mp4 = CreateTester4(); Assertion.AssertEquals("Constructor-4: ", false, mp4.IsEmpty()); Assertion.AssertEquals("Constructor-4a: ", 32, mp4.GetNumPoints()); }
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()); }
/// <summary> /// Writes a multipoint. /// </summary> /// <param name="mp">The multipoint to be written.</param> private void WriteMultiPoint(MultiPoint mp, byte format) { //Get the number of points in this multipoint. int numPoints = mp.GetNumPoints(); //Write the number of points. _bWriter.Write(numPoints); //Loop on the number of points. for (int i = 0; i < numPoints; i++) { //write the multipoint header _bWriter.Write(format); _bWriter.Write(4); _bWriter.Write(numPoints); //Write each point. WritePoint((Point)mp[i]); } }
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()); }