openlayers/ol3 — pull request #1408 by twpayne (2013-12-17 16:47:49+00:00)
Title: [vector-api] Topology-preserving simplification is used incorrectly

CC @tschaub

This is a fairly subtle bug in `vector-api` which is related to #1376.

Currently `vector-api` uses a heuristic to detect whether a call to `ol.geom.Geometry#getSimplifiedGeometry(squaredTolerance)` actually simplifies the geometry or not. This heuristic is: does the simplified geometry have fewer points than the original? If yes, then we know simplification occurred. If not, we believe that it did not and so we return the original geometry. This saves both CPU (we can short cut future calls if we know that simplification will not occur) and memory (we avoid storing multiple copies of the same geometry for different resolutions). There is more explanation in [this comment](https://github.com/openlayers/ol3/blob/vector-api/src/ol/geom/simplegeometry.js#L144-149).

This heuristic fails with the simplification by quantisation then point elimination approach, because this does not necessarily reduce the number of points. This means that as soon as quantisation / point elimination does not reduce the number of points, the original geometry is used instead. This means that original geometries can be drawn next to quantised geometries - breaking the desired topology-preserving properties of the quantisation approach.

One way to handle this would be for a quantisation step to be added when batches are being created, to handle non-quantised geometries.