code: public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception {
          String query = "SELECT min(" + //
                  GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), max(" + //
                  GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), min(" + //
                  GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + "), max(" + //
                  GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ") " + //
                  " FROM " + TABLE_GPSLOG_DATA;
          try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) {
              if (rs.next()) {
                  double minX = rs.getDouble(1);
                  double maxX = rs.getDouble(2);
                  double minY = rs.getDouble(3);
                  double maxY = rs.getDouble(4);
  
                  ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84);
                  return env;
              }
          }
  
          return null;
      }
docs: Get the current data envelope.
  
  @param connection the db connection.
  @return the envelope.
  @throws Exception