private void CheckDP(string wkt, double tolerance, string wktExpected) { var geom = Read(wkt); var result = DouglasPeuckerSimplifier.Simplify(geom, tolerance); var expected = Read(wktExpected); CheckEqual(expected, result); }
public static IGeometry[] GetResult(String wkt, double tolerance) { IGeometry[] ioGeom = new IGeometry[2]; ioGeom[0] = Rdr.Read(wkt); ioGeom[1] = DouglasPeuckerSimplifier.Simplify(ioGeom[0], tolerance); Console.WriteLine(ioGeom[1]); return(ioGeom); }
public static Geometry[] GetResult(string wkt, double tolerance) { var ioGeom = new Geometry[2]; ioGeom[0] = Rdr.Read(wkt); ioGeom[1] = DouglasPeuckerSimplifier.Simplify(ioGeom[0], tolerance); //TestContext.WriteLine(ioGeom[1]); return(ioGeom); }
/// <summary> /// /// </summary> private void PerformTest(IGeometryFactory factory) { IGeometry path = new WKTReader(factory).Read(GeomText); Assert.IsNotNull(path); Debug.WriteLine(String.Format("Original Points: {0}", path.NumPoints)); IGeometry simplified = DouglasPeuckerSimplifier.Simplify(path, 2); Assert.IsNotNull(simplified); Debug.WriteLine(String.Format("Simplified Points: {0}", simplified.NumPoints)); IGeometry buffered = simplified.Buffer(1.143); Assert.IsNotNull(buffered); Debug.WriteLine(buffered); }
/// <summary> /// /// </summary> private static void PerformTest(NtsGeometryServices factory) { var path = new WKTReader(factory).Read(GeomText); Assert.IsNotNull(path); Debug.WriteLine("Original Points: {0}", path.NumPoints); var simplified = DouglasPeuckerSimplifier.Simplify(path, 2); Assert.IsNotNull(simplified); Debug.WriteLine("Simplified Points: {0}", simplified.NumPoints); var buffered = simplified.Buffer(1.143); Assert.IsNotNull(buffered); Debug.WriteLine(buffered); }
public static LinearRing FullySimplify(this LinearRing _ring, double _threshold = 0.02) { //first round of simplify var roughSimplifyGeom = DouglasPeuckerSimplifier.Simplify(_ring, _threshold); if (roughSimplifyGeom is LinearRing == false) { return(null); } var roughSimplify = roughSimplifyGeom as LinearRing; //check the starting point of each polygon's contours //shift to a corner if it lies on en edge //otherwise cannot be full simplified var shifted = ShiftStartToCorner(roughSimplify); var fullySimplified = DouglasPeuckerSimplifier.Simplify(shifted, _threshold) as LinearRing; return(fullySimplified); }
private List <LineString> SimplifyLines(IEnumerable <LineString> lineStings) { var lines = new List <LineString>(); foreach (var lineSting in lineStings) { var simpleLine = DouglasPeuckerSimplifier.Simplify(lineSting, _options.SimplificationDistanceTolerance) as LineString; if (simpleLine == null) { continue; } simpleLine = RadialDistanceByAngleSimplifier.Simplify(simpleLine, _options.MinimalMissingSelfLoopPartLegth, _options.RadialSimplificationAngle); if (simpleLine == null) { continue; } lines.Add(simpleLine); } return(lines); }
public void TestSimplifyBadPoly() { var geom = new Polygon(new LinearRing(new ICoordinate[] { new Coordinate(1, 1), new Coordinate(1, 1), new Coordinate(1, 1), new Coordinate(1, 1), new Coordinate(1, 1) })); Debug.WriteLine("Bad polygon: " + geom); var simple = DouglasPeuckerSimplifier.Simplify(geom, 0.1); Debug.WriteLine("Simple bad polygon: " + simple); Assert.AreEqual(geom.GetType(), simple.GetType()); Assert.AreNotEqual(geom, simple, "Simplify didn't do anything to this invalid polygon."); // This happens with JTS 1.9.0, 1.8.0 still returns GeometryCollection.Empty Assert.AreEqual(geom.GetType(), Polygon.Empty); }
public static IGeometry simplifyDP(IGeometry g, double distance) { return(DouglasPeuckerSimplifier.Simplify(g, distance)); }