public void test_CoordinateN() { //create a new multipoint MultiPoint mp1 = CreateTester1(); Coordinate coord = new Coordinate(2.0, 2.0); Assertion.AssertEquals("CoordinateN-1: ", coord, mp1.GetCoordinate(2)); coord = new Coordinate(5.0, 5.0); Assertion.AssertEquals("CoordinateN-2: ", coord, mp1.GetCoordinate(5)); coord = new Coordinate(11.0, 12.0); Assertion.AssertEquals("CoordinateN-3: ", coord, mp1.GetCoordinate(12)); coord = new Coordinate(11.0, 20.0); Assertion.AssertEquals("CoordinateN-4: ", coord, mp1.GetCoordinate(20)); }
public void test_Clone() { //create a new multipoint MultiPoint mp = CreateTester1(); //clone that multipoint MultiPoint mp2 = mp.Clone() as MultiPoint; //Test that they are not the same multipoint Assertion.AssertEquals("Clone-1: ", false, mp == mp2); //Test that they have the same coordinates for (int i = 0; i < mp.GetNumGeometries(); i++) { Assertion.AssertEquals("Clone-2: ", true, mp.GetCoordinate(i).X.Equals(mp2.GetCoordinate(i).X)); Assertion.AssertEquals("Clone-3: ", true, mp.GetCoordinate(i).Y.Equals(mp2.GetCoordinate(i).Y)); } }
/// <summary> /// Converts a MultiPoint to <MultiPoint Text> format, then /// Appends it to the writer. /// </summary> /// <param name="multiPoint">The MultiPoint to process.</param> /// <param name="writer">The output stream writer to Append to.</param> protected void AppendMultiPointText(MultiPoint multiPoint, TextWriter writer) { if (multiPoint.IsEmpty()) { //writer.Write("EMPTY"); } else { for (int i = 0; i < multiPoint.GetNumGeometries(); i++) { AppendPointTaggedText(multiPoint.GetCoordinate(i), writer, _precisionModel); } } }
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()); }