public void test_GetBoundary() { Polygon poly = Poly1(); MultiLineString mls = poly.GetBoundary() as MultiLineString; Assertion.AssertEquals("GetBoundary-1: ", 1, mls.GetNumGeometries()); Assertion.AssertEquals("GetBoundary-2: ", 9, mls.GetNumPoints()); Coordinates coords = mls.GetCoordinates(); for (int i = 0; i < 9; i++) { Assertion.AssertEquals("GetBoundary-3: ", true, coords[i].Equals(_exterior1.GetCoordinateN(i))); } }
public void test_NumPoints() { //create a geomerty collection MultiLineString multiLS = CreateMLS(); Assertion.AssertEquals("NumPoints-1: ", 100, multiLS.GetNumPoints()); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); multiLS = gf.CreateMultiLineString(null); Assertion.AssertEquals("NumPoints-2: ", 0, multiLS.GetNumPoints()); //now try it with a different geometry collection multiLS = closedMLS(); Assertion.AssertEquals("NumPoints-3: ", 30, multiLS.GetNumPoints()); //now try it with a mixed geometry collection multiLS = nonSimpleMLS(); Assertion.AssertEquals("NumPoints-4: ", 18, multiLS.GetNumPoints()); }
/// <summary> /// Writes to the given stream the equilivent shape file record given a Geometry object. /// </summary> /// <param name="geometry">The geometry object to write.</param> /// <param name="file">The stream to write to.</param> /// <param name="geometryFactory">The geometry factory to use.</param> public override void Write(Geometry geometry, System.IO.BinaryWriter file, GeometryFactory geometryFactory) { MultiLineString multi = (MultiLineString)geometry; file.Write(int.Parse(Enum.Format(typeof(ShapeType), this.ShapeType, "d"))); Envelope box = multi.GetEnvelopeInternal(); file.Write(box.MinX); file.Write(box.MinY); file.Write(box.MaxX); file.Write(box.MaxY); int numParts = multi.GetNumGeometries(); int numPoints = multi.GetNumPoints(); file.Write(numParts); file.Write(numPoints); //LineString[] lines = new LineString[numParts]; // write the offsets int offset = 0; for (int i = 0; i < numParts; i++) { Geometry g = multi.GetGeometryN(i); file.Write(offset); offset = offset + g.GetNumPoints(); } Coordinate external; for (int part = 0; part < numParts; part++) { Coordinates points = multi.GetGeometryN(part).GetCoordinates(); for (int i = 0; i < points.Count; i++) { external = geometryFactory.PrecisionModel.ToExternal(points[i]); file.Write(external.X); file.Write(external.Y); } } }