code: public int removeShapesNotWithinMap(BoundingBox boundingBox, String database, String table) {
  
          int count = 0;
  
          Map<Long, FeatureShape> featureIds = getFeatureIds(database, table);
  
          if (featureIds != null) {
  
              List<Long> deleteFeatureIds = new ArrayList<>();
  
              for (long featureId : featureIds.keySet()) {
  
                  FeatureShape featureShape = getFeatureShape(featureIds, featureId);
  
                  if (featureShape != null) {
  
                      boolean delete = true;
                      for (GoogleMapShape mapShape : featureShape.getShapes()) {
                          BoundingBox mapShapeBoundingBox = mapShape.boundingBox();
                          boolean allowEmpty = mapShape.getGeometryType() == GeometryType.POINT;
                          if (TileBoundingBoxUtils.overlap(mapShapeBoundingBox, boundingBox, ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH, allowEmpty) != null) {
                              delete = false;
                              break;
                          }
                      }
                      if (delete) {
                          deleteFeatureIds.add(featureId);
                      }
                  }
              }
  
              for (long deleteFeatureId : deleteFeatureIds) {
  
                  FeatureShape featureShape = getFeatureShape(featureIds, deleteFeatureId);
  
                  if (featureShape != null) {
                      featureShape.remove();
                      featureIds.remove(deleteFeatureId);
                  }
                  count++;
              }
          }
  
          return count;
      }
docs: Remove all map shapes in the database and table that are not visible in the bounding box
  
  @param boundingBox bounding box
  @param database    GeoPackage database
  @return count of removed features