Hi Roger,
the problem is caused by the routine that removes obsolete
points from straigt lines.
This routine doesn't care (enough) about the spherical
distortian.
The routine uses herons formula to "calculate distance of point
in the middle to line c1,c2".
This formula is for 2D, but used to work good enough with the
rather short ways
we have in OSM. (The formula is also used in the Douglas-Peucker
filter).
With long lines the as in your data, the errors are too big and
the routine returns garbage.
If I got that right, we have to use the formula for the
"Cross-track distance" as described here:
http://www.movable-type.co.uk/scripts/latlong.html
Unfortunately, this routine uses more trigonometrical
calculations, so it will be slower.
@Programmers: Any other ideas?
Gerd