unparsed = readFlat(bbox, INNER_DELIMETER);
i = unparsed.listIterator();
// check to make sure that the bounding box has 4 coordinates
if (unparsed.size() != 4) {
throw new WfsException("Requested bounding box contains wrong"
+ "number of coordinates (should have " + "4): "
+ unparsed.size());
// if it does, store them in an array of doubles
} else {
int j = 0;
while (i.hasNext()) {
try {
rawCoords[j] = Double.parseDouble((String) i.next());
j++;
} catch (NumberFormatException e) {
throw new WfsException("Bounding box coordinate " + j
+ " is not parsable:" + unparsed.get(j));
}
}
}
// turn the array of doubles into an appropriate geometry filter
// TODO 2:
// hack alert: because we do not yet know the schema, we have
// used the '@' symbol for the attribute expression, to be
// replaced later by the appropriate attribute. I would argue
// that this is a failure in the specification because there
// should always be explicit designation of geometry attibutes
// within the filter. The BBOX element is ambiguous, since
// features may contain multiple geometries. For now, we will
// parse it and keep a record of a 'primary geometry' in the
// server.
try {
GeometryFilter finalFilter = factory.createGeometryFilter(AbstractFilter.GEOMETRY_INTERSECTS);
//leave as null and postgisDatSource will use default geom.
//AttributeExpression leftExpression =
// factory.createAttributeExpression(null);
//leftExpression.setAttributePath("@");
// Creates coordinates for the linear ring
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(rawCoords[0], rawCoords[1]);
coords[1] = new Coordinate(rawCoords[0], rawCoords[3]);
coords[2] = new Coordinate(rawCoords[2], rawCoords[3]);
coords[3] = new Coordinate(rawCoords[2], rawCoords[1]);
coords[4] = new Coordinate(rawCoords[0], rawCoords[1]);
LinearRing outerShell = new LinearRing(coords,
new PrecisionModel(), 0);
Geometry polygon = new Polygon(outerShell,
new PrecisionModel(), 0);
LiteralExpression rightExpression = factory
.createLiteralExpression(polygon);
//finalFilter.addLeftGeometry(leftExpression);
finalFilter.addRightGeometry(rightExpression);
filters.add(finalFilter);
return filters;
} catch (IllegalFilterException e) {
throw new WfsException("Filter creation problem: "
+ e.getMessage());
}
// handles unconstrained case
} else if ((bbox == null) && (fid == null) && (filter == null)) {
return new ArrayList();
// handles error when more than one filter specified
} else {
throw new WfsException("GetFeature KVP request contained "
+ "conflicting filters. Filter: " + filter + ", fid: " + fid
+ ", bbox:" + bbox);
}
}