spatial4j
spatial4j copied to clipboard
Improve BufferedLine geodesic skew compensation
BufferedLineString expands each of it's BufferedLine's buffer by a fixed amount depending on how close to a pole it is (see the "expandBufForLongitudeSkew" option). But this implementation is poor since it uniformly increases the buffer on both axis by this amount, which might be too much as well. BufferedLine should maintain a distinct buffer distance for both axis, since each axis will have a different stretch factor dependent on not only the latitude but the angle (slope) of the line. For example a vertical line will have the full stretch applied to the "linePrimary" axis, while the "linePerp" will have no stretch. The reverse for a horizontal line. And for in-between (e.g. a 45-degree line), it should be mixed proportionally.
Another adjustment is that linePerp will not be completely perpendicular to linePrimary due to the stretching. Without stretching it's 90 degrees difference but stretch an X and it flattens and the angle isn't 90 any more.
What we do assume here that technically isn't true, is that the stretching is completely uniform.
A side-effect of this feature is that BufferedLine will additionally be usable without an end-cap buffer (i.e. it chops off at both points). So if we want a circular end-cap style we simply need to add a circle shape to the mix without altering BufferedLine.
I will be working on this.
Awesome. As part of this we should also add some sort of dateline spanning solution (either built-in or more likely by breaking the line into two). And we can address the TODO in BufferedLine pertaining to specifying a flat end-cap, versus boxing-out that it currently does.
on the back burner for now...