if (layer.getType() == LayerType.FEATURES){
FeaturesLayer features = (FeaturesLayer) layer;
QName ftName = features.getFeatureType();
QueryType query = Wfs20Factory.eINSTANCE.createQueryType();
query.getTypeNames().add(ftName);
if (features.getSrs() == null) {
String ns = ftName.getNamespaceURI() != null
? ftName.getNamespaceURI() : ftName.getPrefix();
FeatureTypeInfo ft =
catalog.getFeatureTypeByName(ns, ftName.getLocalPart());
if (ft != null) {
try {
query.setSrsName(new URI(ft.getSRS()));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}
else {
query.setSrsName(features.getSrs());
}
if (features.getPropertyNames() != null) {
query.getPropertyNames().addAll(features.getPropertyNames());
}
Filter filter = features.getFilter();
//add bbox to filter if there is one
if (features.getBbox() != null){
String defaultGeometry = catalog.getFeatureTypeByName(features.getFeatureType().getLocalPart())
.getFeatureType().getGeometryDescriptor().getLocalName();
Envelope e = features.getBbox();
// HACK: because we are going through wfs 2.0, flip the coordinates (specified in xy)
// which will then be later flipped back to xy
if (query.getSrsName() != null) {
try {
CoordinateReferenceSystem crs = CRS.decode(query.getSrsName().toString());
if (crs instanceof GeographicCRS) {
// flip the bbox
e = new Envelope(e.getMinY(), e.getMaxY(), e.getMinX(), e.getMaxX());
}
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
Filter bboxFilter = filterFactory.bbox(filterFactory.property(defaultGeometry),
ReferencedEnvelope.reference(e));
if (filter == null) {
filter = bboxFilter;
} else {
filter = filterFactory.and(filter, bboxFilter);
}
}
query.setFilter(filter);
GetFeatureType getFeature = Wfs20Factory.eINSTANCE.createGetFeatureType();
getFeature.getAbstractQueryExpression().add(query);
FeatureCollectionResponse fc = getFeatureDelegate.run(GetFeatureRequest.adapt(getFeature));