/**
  * It retrieves the features falling into the query condition. If the filter is not changed from
  * the previous filter and the layer is not marked to be forcibly refreshed, it does not ask for
  * features from the server, but it returns the former ones
  *
  * @param query The query (geotools) used to filter features
  * @return
  * @throws IOException
  */
 @Override
 public PojoFeatureCollection getFeatures(Query query) throws IOException {
   Filter filter = query.getFilter();
   if (filter == null) {
     throw new UnsupportedOperationException(GisMessage.GENERAL_EXCEPTION_FILTER_NOTFOUND);
   }
   if (!(filter instanceof org.opengis.filter.spatial.BBOX)) {
     throw new UnsupportedOperationException(GisMessage.GENERAL_EXCEPTION_TYPE_NOTSUPPORTED);
   }
   org.opengis.filter.spatial.BBOX bboxFilter = (org.opengis.filter.spatial.BBOX) filter;
   org.geotools.filter.LiteralExpressionImpl literalExpression =
       (org.geotools.filter.LiteralExpressionImpl) bboxFilter.getExpression2();
   Geometry filteringGeometry = (Geometry) literalExpression.getValue();
   Envelope boundingBox = (Envelope) filteringGeometry.getEnvelopeInternal();
   double west = boundingBox.getMinX();
   double east = boundingBox.getMaxX();
   double south = boundingBox.getMinY();
   double north = boundingBox.getMaxY();
   this.ModifyFeatureCollection(west, south, east, north);
   return this.collection;
 }
  /**
   * Set the bbox for this expression
   *
   * @param env The envelope to set as the bounds.
   * @throws IllegalFilterException If the box can not be created.
   * @task HACK: currently sets the SRID to null, which can cause problems with JTS when it comes to
   *     doing spatial tests
   */
  public final void setBounds(Envelope env) throws IllegalFilterException {
    Coordinate[] coords = new Coordinate[5];
    coords[0] = new Coordinate(env.getMinX(), env.getMinY());
    coords[1] = new Coordinate(env.getMinX(), env.getMaxY());
    coords[2] = new Coordinate(env.getMaxX(), env.getMaxY());
    coords[3] = new Coordinate(env.getMaxX(), env.getMinY());
    coords[4] = new Coordinate(env.getMinX(), env.getMinY());

    LinearRing ring = null;

    try {
      ring = gfac.createLinearRing(coords);
    } catch (TopologyException tex) {
      throw new IllegalFilterException(tex.toString());
    }

    Polygon polygon = gfac.createPolygon(ring, null);
    if (env instanceof ReferencedEnvelope) {
      ReferencedEnvelope refEnv = (ReferencedEnvelope) env;
      polygon.setUserData(refEnv.getCoordinateReferenceSystem());
    }
    super.setValue(polygon);
  }