if(declaredCRS != null)
transformedFilter = WFSReprojectionUtil.normalizeFilterCRS(filter, source.getSchema(), declaredCRS);
//only handle non-joins for now
QName typeName = (QName) query.getTypeName().get(0);
DefaultQuery dataQuery = new DefaultQuery(typeName.getLocalPart(), transformedFilter, maxFeatures,
props, query.getHandle());
//handle reprojection
CoordinateReferenceSystem target;
if (query.getSrsName() != null) {
try {
target = CRS.decode(query.getSrsName().toString());
} catch (Exception e) {
String msg = "Unable to support srsName: " + query.getSrsName();
throw new WFSException(msg, e);
}
} else {
target = declaredCRS;
}
//if the crs are not equal, then reproject
if (target != null && declaredCRS != null && !CRS.equalsIgnoreMetadata(crs, target)) {
dataQuery.setCoordinateSystemReproject(target);
}
//handle sorting
if (query.getSortBy() != null) {
List sortBy = query.getSortBy();
dataQuery.setSortBy((SortBy[]) sortBy.toArray(new SortBy[sortBy.size()]));
}
//handle version, datastore may be able to use it
if (query.getFeatureVersion() != null) {
dataQuery.setVersion(query.getFeatureVersion());
}
//create the Hints to set at the end
final Hints hints = new Hints();
//handle xlink traversal depth
if (request.getTraverseXlinkDepth() != null) {
//TODO: make this an integer in the model, and have hte NumericKvpParser
// handle '*' as max value
Integer traverseXlinkDepth = traverseXlinkDepth( request.getTraverseXlinkDepth() );
//set the depth as a hint on the query
hints.put(Hints.ASSOCIATION_TRAVERSAL_DEPTH, traverseXlinkDepth);
}
//handle xlink properties
if (!query.getXlinkPropertyName().isEmpty() ) {
for ( Iterator x = query.getXlinkPropertyName().iterator(); x.hasNext(); ) {
XlinkPropertyNameType xlinkProperty = (XlinkPropertyNameType) x.next();
Integer traverseXlinkDepth = traverseXlinkDepth( xlinkProperty.getTraverseXlinkDepth() );
//set the depth and property as hints on the query
hints.put(Hints.ASSOCIATION_TRAVERSAL_DEPTH, traverseXlinkDepth );
PropertyName xlinkPropertyName = filterFactory.property( xlinkProperty.getValue() );
hints.put(Hints.ASSOCIATION_PROPERTY, xlinkPropertyName );
dataQuery.setHints( hints );
//TODO: support multiple properties
break;
}
}
//tell the datastore to use a lite coordinate sequence factory, if possible
hints.put(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory());
//finally, set the hints
dataQuery.setHints(hints);
return dataQuery;
}