OpenLayers.Geometry.LineString.prototype.getRotationAngle = function( getAsRadians ){
	var endpoints = this.getVertices(true);
	var radian = 0;
	if (endpoints.length === 2) {
		var pi_half = Math.PI/2;
		var delta_x = endpoints[0].x - endpoints[1].x;
		var delta_y = endpoints[0].y - endpoints[1].y;
		if (delta_y != 0) {
			if (delta_x != 0) {
				var relation = delta_x / delta_y;
                radian = Math.atan( relation );
                // Korrigiere für u. re.
                // und u. li. 
                if ( delta_y > 0) {
                    // the slope is now clear, but the value needs to be corrected
		            // this is so because the slope of LINE(0 0, 5 5) == slope of LINE(5 5, 0 0)
                    radian += Math.PI;
                }
			} else {
				radian = pi_half;
			}
		} else {
			radian = 0;
		}
	}
	if (getAsRadians) {
		return radian;
	} else {
		return (radian * (180 / Math.PI));
	}
};
