Closed ear7h closed 5 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
testing/dynamic_geoms.go | 10 | 11 | 90.91% | ||
planar/simplify/douglaspeucker.go | 13 | 21 | 61.9% | ||
planar/planar.go | 0 | 15 | 0.0% | ||
<!-- | Total: | 23 | 47 | 48.94% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
planar/simplify/douglaspeucker.go | 1 | 59.42% | ||
<!-- | Total: | 1 | --> |
Totals | |
---|---|
Change from base Build 287: | 0.07% |
Covered Lines: | 5782 |
Relevant Lines: | 9955 |
Update: the postgis reference tests will fail due to #73
Firstly I added a couple more complicated test cases and benchmarks. The benchmarks include smooth circular geometries, a zig zag (causes the algorithm to degrade to
O(n^2)
) and a real geometry from the Natural Earth data set.Modified
simplify
to only allocate memory once per call. I looked at other possible optimizations, like unrolling thedist
loop, but it did not improve the algorithm (likely because the distance function is a variable and not being inlined).The memory optimizations alone show significant time improvements, especially for larger geometries. However, the overall size of the allocations is much higher because we are preallocating an slice the same size as the original. The benchmarks where this is a problem is only in simple cases
*Circle
which can be heavily simplified. In the case of South Africa and the Zig Zag, the allocation size is still less than the original.