public void TestInvertedItalicNTSConforming() { AffineTransformationBuilder atb = new AffineTransformationBuilder( new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(0, 100), new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(20, 100)); IGeometry geom = _wktReader.Read(NTS); //Apply italic effect geom = atb.GetTransformation().Transform(geom); Console.WriteLine(geom.AsText()); IGeometry constraint = ((IPolygon)geom).GetInteriorRingN(0); constraint = geom.Factory.CreatePolygon((ILinearRing)constraint, null); constraint = ((IPolygon)constraint.Buffer(-1)).Shell; Coordinate[] coordinates = constraint.Coordinates; coordinates[coordinates.Length - 1].X -= 1e-7; coordinates[coordinates.Length - 1].Y -= 1e-7; constraint = geom.Factory.CreateLineString(coordinates); Console.WriteLine(constraint.AsText()); //Setup ConformingDelaunayTriangulationBuilder dtb = new ConformingDelaunayTriangulationBuilder { Constraints = constraint }; dtb.SetSites(geom); IMultiLineString result = dtb.GetEdges(geom.Factory); Console.WriteLine(result.AsText()); }
public void Test2() { IGeometry geom = _wktReader.Read("POLYGON ((0 0, 0 10, 4 10, 4 8, 6 8, 6 10, 10 10, 10 0, 0 0))"); ConformingDelaunayTriangulationBuilder dtb = new ConformingDelaunayTriangulationBuilder(); dtb.SetSites(geom); IMultiLineString resultEdges = dtb.GetEdges(geom.Factory); Console.WriteLine(resultEdges.AsText()); IGeometryCollection resultTriangles = dtb.GetTriangles(geom.Factory); Console.WriteLine(resultTriangles.AsText()); }
public void TestInvertedItalicNTS() { AffineTransformationBuilder atb = new AffineTransformationBuilder( new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(0, 100), new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(20, 100)); IGeometry geom = _wktReader.Read(NTS); //Apply italic effect geom = atb.GetTransformation().Transform(geom); Console.WriteLine(geom.AsText()); //Setup DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder(); dtb.SetSites(geom); IMultiLineString result = dtb.GetEdges(geom.Factory); Console.WriteLine(result.AsText()); }
public void ParseMultiLineString() { string multiLinestring = "MULTILINESTRING((10 10,40 50),(20 20,30 20),(20 20,50 20,50 60,20 20))"; IMultiLineString geom = GeometryFromWKT.Parse(multiLinestring) as IMultiLineString; Assert.IsNotNull(geom); Assert.AreEqual(3, geom.NumGeometries); Assert.AreEqual(180, geom.Length); Assert.AreEqual(120, geom.Geometries[2].Length); Assert.IsFalse((geom.Geometries[0] as ILineString).IsClosed, "[0].IsClosed"); Assert.IsFalse((geom.Geometries[1] as ILineString).IsClosed, "[1].IsClosed"); Assert.IsTrue((geom.Geometries[2] as ILineString).IsClosed, "[2].IsClosed"); Assert.IsTrue((geom.Geometries[0] as ILineString).IsSimple, "[0].IsSimple"); Assert.IsTrue((geom.Geometries[1] as ILineString).IsSimple, "[1].IsSimple"); Assert.IsTrue((geom.Geometries[2] as ILineString).IsSimple, "[2].IsSimple"); Assert.IsTrue((geom.Geometries[2] as ILineString).IsRing, "Third line is a ring"); Assert.AreEqual(multiLinestring, geom.AsText()); Assert.IsTrue(GeometryFromWKT.Parse("MULTILINESTRING EMPTY").IsEmpty); geom = GeometryFromWKT.Parse("MULTILINESTRING((10 10,40 50),(20 20,30 20),EMPTY,(20 20,50 20,50 60,20 20))") as IMultiLineString; Assert.IsNotNull(geom); Assert.IsTrue(geom[2].IsEmpty); Assert.AreEqual(4, geom.NumGeometries); Assert.AreEqual("MULTILINESTRING EMPTY", GeometryFactory.CreateMultiLineString(null).AsText()); }