* @param spatialClause the spatial clause to append
*/
private void appendSpatialClause(Element parent, SpatialClause spatialClause) {
// check the envelope
Envelope envelope = spatialClause.getBoundingEnvelope();
if ((envelope == null) || envelope.isEmpty()) {
// TODO: throw Exception
//String sErr = "The SpatialClause.boundingEnvelope is empty.";
//throw new DiscoveryException(sErr);
}
String opName= "";
if (spatialClause instanceof SpatialClause.GeometryBBOXIntersects) {
opName = "BBOX";
} else if (spatialClause instanceof SpatialClause.GeometryContains) {
opName = "Contains";
} else if (spatialClause instanceof SpatialClause.GeometryIntersects) {
opName = "Intersects";
} else if (spatialClause instanceof SpatialClause.GeometryIsDisjointTo) {
opName = "Disjoint";
} else if (spatialClause instanceof SpatialClause.GeometryIsEqualTo) {
opName = "Equal";
} else if (spatialClause instanceof SpatialClause.GeometryIsWithin) {
opName = "Within";
} else if (spatialClause instanceof SpatialClause.GeometryOverlaps) {
opName = "Overlaps";
} else {
// TODO: throw Exception
//sErr = "Unrecognized spatial clause type: ";
//throw new DiscoveryException(sErr+spatialClause.getClass().getName());
}
// make and append the spatial clause
Element elClause = getDom().createElementNS(CswNamespaces.URI_OGC,"ogc:"+opName);
String sName = spatialClause.getTarget().getMeaning().getDcElement().getElementName();
Element elName = getDom().createElementNS(CswNamespaces.URI_OGC,"ogc:PropertyName");
elName.setTextContent(sName);
elClause.appendChild(elName);
Element elEnv = getDom().createElementNS(CswNamespaces.URI_GML,"gml:Envelope");
Element elLower = getDom().createElementNS(CswNamespaces.URI_GML,"gml:lowerCorner");
Element elUpper = getDom().createElementNS(CswNamespaces.URI_GML,"gml:upperCorner");
elLower.setTextContent(envelope.getMinX()+" "+envelope.getMinY());
elUpper.setTextContent(envelope.getMaxX()+" "+envelope.getMaxY());
elEnv.appendChild(elLower);
elEnv.appendChild(elUpper);
elClause.appendChild(elEnv);
parent.appendChild(elClause);