code: public static double[] getOutRectangle( double latitude, double longitude, double r )
    {
      double boundLat = latitude + (180 * r) / (Math.PI * EARTH_RADIUS) * (latitude > 0 ? 1 : -1);
      double littleRadius = countLittleRadius( boundLat );
      double westLong, eastLong, northLat, southLat;
  
      if( littleRadius > r )
      {
        westLong = longitude - (180 * r) / littleRadius;
        eastLong = 2 * longitude - westLong;
  
        westLong = updateDegree( westLong );
        eastLong = eastLong % 360 == 180 ? 180 : updateDegree( eastLong );
      }
      else
      {
        westLong = -180;
        eastLong = 180;
      }
  
      if( latitude > 0 )
      {
        northLat = boundLat;
        southLat = 2 * latitude - boundLat;
      }
      else
      {
        southLat = boundLat;
        northLat = 2 * latitude - boundLat;
      }
  
      return new double[] { Math.min( northLat, 90 ), westLong, Math.max( southLat, -90 ), eastLong };
    }
docs: for circle