Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:
if(Math.abs(startPoint.x-endPoint.x) > 180) {
if(startPoint.x < endPoint.x) {
endPoint.x -= 360;
} else {
endPoint.x += 360;
}
}
Update:
Actually the above did not work for more than one revolution around the world. I ended up doing THISTHIS.