FeatureCollection<? extends FeatureType, ? extends Feature> result = null;
FeatureSource<? extends FeatureType, ? extends Feature> featureSource = this
.getMapLayer().getFeatureSource();
if (featureSource != null) {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools
.getDefaultHints());
Filter geometryFilter = null;
Geometry geometry = queryParam.getGeometry();
if (geometry != null) {
SpatialFilterType spatialFilterType = queryParam
.getSpatialFilterType();
String geomtryField = featureSource.getSchema()
.getGeometryDescriptor().getLocalName();
PropertyName geometryPropertyName = ff.property(geomtryField);
if (spatialFilterType.equals(SpatialFilterType.INTERSECTS)) {
geometryFilter = ff.intersects(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType.equals(SpatialFilterType.CONTAINS)) {
geometryFilter = ff.contains(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType.equals(SpatialFilterType.CROSSES)) {
geometryFilter = ff.crosses(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType
.equals(SpatialFilterType.ENVELOPE_INTERSECTS)) {
geometryFilter = ff.intersects(ff.literal(geometry
.getEnvelope()), geometryPropertyName);
} else if (spatialFilterType
.equals(SpatialFilterType.INDEX_INTERSECTS)) {
// TODO
// It is from ArcGIS, but not clear what means
geometryFilter = ff.intersects(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType.equals(SpatialFilterType.OVERLAPS)) {
geometryFilter = ff.overlaps(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType.equals(SpatialFilterType.TOUCHES)) {
geometryFilter = ff.touches(ff.literal(geometry),
geometryPropertyName);
} else if (spatialFilterType.equals(SpatialFilterType.WITHIN)) {
geometryFilter = ff.within(ff.literal(geometry),
geometryPropertyName);
}
}
Filter attributesFilter = null;