private static double[] nextPointAroundLine(double lat1,double lon1,double lat2,double lon2){
  double x1=lon1;
  double x2=lon2;
  double y1=lat1;
  double y2=lat2;
  double minX=Math.min(x1,x2);
  double maxX=Math.max(x1,x2);
  double minY=Math.min(y1,y2);
  double maxY=Math.max(y1,y2);
  if (minX == maxX) {
    return new double[]{nextLatitudeBetween(minY,maxY),nextLongitudeNear(minX,0.01 * (maxY - minY))};
  }
 else   if (minY == maxY) {
    return new double[]{nextLatitudeNear(minY,0.01 * (maxX - minX)),nextLongitudeBetween(minX,maxX)};
  }
 else {
    double x=nextLongitudeBetween(minX,maxX);
    double y=(y1 - y2) / (x1 - x2) * (x - x1) + y1;
    if (Double.isFinite(y) == false) {
      y=Math.copySign(90,x1);
    }
    double delta=(maxY - minY) * 0.01;
    y=Math.min(90,y);
    y=Math.max(-90,y);
    return new double[]{nextLatitudeNear(y,delta),x};
  }
}

private static double [ ] nextPointAroundLine ( double lat1 , double lon1 , double lat2 , double lon2 ) { double x1 = lon1 ; double x2 = lon2 ; double y1 = lat1 ; double y2 = lat2 ; double minX = Math . min ( x1 , x2 ) ; double maxX = Math . max ( x1 , x2 ) ; double minY = Math . min ( y1 , y2 ) ; double maxY = Math . max ( y1 , y2 ) ; if ( minX == maxX ) { return new double [ ] { nextLatitudeBetween ( minY , maxY ) , nextLongitudeNear ( minX , 0.01 * ( maxY - minY ) ) } ; } else if ( minY == maxY ) { return new double [ ] { nextLatitudeNear ( minY , 0.01 * ( maxX - minX ) ) , nextLongitudeBetween ( minX , maxX ) } ; } else { double x = nextLongitudeBetween ( minX , maxX ) ; double y = ( y1 - y2 ) / ( x1 - x2 ) * ( x - x1 ) + y1 ; if ( Double . isFinite ( y ) == false ) { y = Math . copySign ( 90 , x1 ) ; } double delta = ( maxY - minY ) * 0.01 ; y = Math . min ( 90 , y ) ; y = Math . max ( - 90 , y ) ; return new double [ ] { nextLatitudeNear ( y , delta ) , x } ; } }
returns the next point around a line ( more or less )
