public virtual void TestParseMultiPolygon() { IShape p1 = new PolygonBuilder(ctx) .Point(100, 0) .Point(101, 0) //101 .Point(101, 2) //101 .Point(100, 1) .Point(100, 0) .Build(); IShape p2 = new PolygonBuilder(ctx) .Point(100, 0) .Point(102, 0) //102 .Point(102, 2) //102 .Point(100, 1) .Point(100, 0) .Build(); IShape s = ctx.MakeCollection( (new IShape[] { p1, p2 }).ToList() ); AssertParses("MULTIPOLYGON(" + "((100 0, 101 0, 101 2, 100 1, 100 0))" + ',' + "((100 0, 102 0, 102 2, 100 1, 100 0))" + ")", s); AssertParses("MULTIPOLYGON EMPTY", ctx.MakeCollection(new List <IShape>())); }
public virtual void TestParsePolygon() { IShape polygonNoHoles = new PolygonBuilder(ctx) .Point(100, 0) .Point(101, 0) .Point(101, 1) .Point(100, 2) .Point(100, 0) .Build(); string polygonNoHolesSTR = "POLYGON ((100 0, 101 0, 101 1, 100 2, 100 0))"; AssertParses(polygonNoHolesSTR, polygonNoHoles); AssertParses("POLYGON((100 0,101 0,101 1,100 2,100 0))", polygonNoHoles); AssertParses("GEOMETRYCOLLECTION ( " + polygonNoHolesSTR + ")", ctx.MakeCollection(new List <IShape>(new IShape[] { polygonNoHoles }))); IShape polygonWithHoles = new PolygonBuilder(ctx) .Point(100, 0) .Point(101, 0) .Point(101, 1) .Point(100, 1) .Point(100, 0) .NewHole() .Point(100.2, 0.2) .Point(100.8, 0.2) .Point(100.8, 0.8) .Point(100.2, 0.8) .Point(100.2, 0.2) .EndHole() .Build(); AssertParses("POLYGON ((100 0, 101 0, 101 1, 100 1, 100 0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2))", polygonWithHoles); GeometryFactory gf = ctx.GeometryFactory; AssertParses("POLYGON EMPTY", ctx.MakeShape( gf.CreatePolygon(gf.CreateLinearRing(new Coordinate[] { }), null) )); }
/** * Creates a new PolygonHoleBuilder * * @param polygonBuilder PolygonBuilder that the hole built by this builder * will be added to */ internal PolygonHoleBuilder(PolygonBuilder polygonBuilder) { this.polygonBuilder = polygonBuilder; }