protected override CoordinateSequence TransformCoordinates(CoordinateSequence coords, Geometry parent) { var inputPts = coords.ToCoordinateArray(); Coordinate[] newPts; if (inputPts.Length == 0) { newPts = new Coordinate[0]; } else { newPts = VWLineSimplifier.Simplify(inputPts, _distanceTolerance); } return(Factory.CoordinateSequenceFactory.Create(newPts)); }
public void TestNewResultsIdenticalToOldResults() { // at 0.02, Simplify deletes about 50% of world.wkt points const double DistanceTolerance = 0.02; int pointsRemoved = 0; int totalPointCount = 0; // track how long the new takes compared to the old long oldTicks = 0; long newTicks = 0; using (var file = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.world.wkt")) { foreach (LineString line in IOUtil.ReadWKTFile(new StreamReader(file)).SelectMany(LinearComponentExtracter.GetLines)) { var coordinates = line.Coordinates; var sw = Stopwatch.StartNew(); var oldResults = OldVWLineSimplifier.Simplify(coordinates, DistanceTolerance); sw.Stop(); oldTicks += sw.ElapsedTicks; sw.Restart(); var newResults = VWLineSimplifier.Simplify(coordinates, DistanceTolerance); sw.Stop(); newTicks += sw.ElapsedTicks; CollectionAssert.AreEqual(oldResults, newResults); pointsRemoved += coordinates.Length - newResults.Length; totalPointCount += coordinates.Length; } } TestContext.WriteLine("Total: Removed {0} of {1} points (reduction: {2:P0}).", pointsRemoved, totalPointCount, pointsRemoved / (double)totalPointCount); TestContext.WriteLine("Old: {0:N3} seconds. New: {1:N3} seconds (reduction: {2:P0}).", oldTicks / (double)Stopwatch.Frequency, newTicks / (double)Stopwatch.Frequency, (oldTicks - newTicks) / (double)oldTicks); }