code: public static double[] getOutRectangle( List<GeoPoint> geoPoints )
    {
      double nwLat = geoPoints.get( 0 ).getLatitude();
      double nwLon = geoPoints.get( 0 ).getLongitude();
      double seLat = geoPoints.get( 0 ).getLatitude();
      double seLon = geoPoints.get( 0 ).getLongitude();
      double minLon = 0, maxLon = 0, lon = 0;
  
      for( int i = 1; i < geoPoints.size(); i++ )
      {
        if( geoPoints.get( i ).getLatitude() > nwLat )
        {
          nwLat = geoPoints.get( i ).getLatitude();
        }
  
        if( geoPoints.get( i ).getLatitude() < seLat )
        {
          seLat = geoPoints.get( i ).getLatitude();
        }
  
        double deltaLon = geoPoints.get( i ).getLongitude() - geoPoints.get( i - 1 ).getLongitude();
  
        if( deltaLon < 0 && deltaLon > -180 || deltaLon > 270 )
        {
          if( deltaLon > 270 )
            deltaLon -= 360;
          lon += deltaLon;
  
          if( lon < minLon )
            minLon = lon;
        }
        else if( deltaLon > 0 && deltaLon <= 180 || deltaLon <= -270 )
        {
          if( deltaLon <= -270 )
            deltaLon += 360;
          lon += deltaLon;
  
          if( lon > maxLon )
            maxLon = lon;
        }
      }
      nwLon += minLon;
      seLon += maxLon;
  
      if( seLon - nwLon >= 360 )
      {
        seLon = 180;
        nwLon = -180;
      }
      else
      {
        seLon = updateDegree( seLon );
        nwLon = updateDegree( nwLon );
      }
  
      return new double[] { nwLat, nwLon, seLat, seLon };
    }
docs: for shape