Requires that the output edge must avoid the given disc. "disc_on_left" specifies whether the disc must be to the left or right of the edge. (This feature allows the simplified edge to preserve the topology of the original polyline with respect to other nearby points.)
Returns true if the edge (src, dst) satisfies all of the targeting requirements so far. Returns false if the edge would be longer than 90 degrees (such edges are not supported).
Starts a new simplified edge at "src".
Requires that the output edge must pass through the given disc.
This is a helper class for simplifying polylines. It allows you to compute a maximal edge that intersects a sequence of discs, and that optionally avoids a different sequence of discs. The results are conservative in that the edge is guaranteed to intersect or avoid the specified discs using exact arithmetic (see s2predicates.h).
Note that S2Builder can also simplify polylines and supports more features (e.g., snapping to S2CellId centers), so it is only recommended to use this class if S2Builder does not meet your needs.
Here is a simple example showing how to simplify a polyline into a sequence of edges that stay within "max_error" of the original edges:
vector<S2Point> v = { ... }; S2PolylineSimplifier simplifier; simplifier.Init(v[0]); for (int i = 1; i < v.size(); ++i) { if (!simplifier.Extend(vi)) { OutputEdge(simplifier.src(), v[i-1]); simplifier.Init(v[i-1]); } simplifier.TargetDisc(vi, max_error); } OutputEdge(simplifer.src(), v.back());
Note that the points targeted by TargetDisc do not need to be the same as the candidate endpoints passed to Extend. So for example, you could target the original vertices of a polyline, but only consider endpoints that are snapped to E7 coordinates or S2CellId centers.
Please be aware that this class works by maintaining a range of acceptable angles (bearings) from the start vertex to the hypothetical destination vertex. It does not keep track of distances to any of the discs to be targeted or avoided. Therefore to use this class correctly, constraints should be added in increasing order of distance. (The actual requirement is slightly weaker than this, which is why it is not enforced, but basically you should only call TargetDisc() and AvoidDisc() with arguments that you want to constrain the immediately following call to Extend().)