*/
public class ViewFeatureOrientation implements IOp {
public void op( final Display display, Object target, IProgressMonitor monitor ) throws Exception {
ILayer selectedLayer = (ILayer) target;
SimpleFeatureSource featureSource = (SimpleFeatureSource) selectedLayer.getResource(FeatureSource.class,
new SubProgressMonitor(monitor, 1));
if (featureSource == null) {
return;
}
GeometryDescriptor geometryDescriptor = featureSource.getSchema().getGeometryDescriptor();
ReferencedEnvelope bounds = ApplicationGIS.getActiveMap().getViewportModel().getBounds();
CoordinateReferenceSystem mapCrs = bounds.getCoordinateReferenceSystem();
ReferencedEnvelope featureBounds = featureSource.getBounds();
if (featureBounds == null || featureBounds.isNull()){
return;
}
CoordinateReferenceSystem featureCrs = featureBounds.getCoordinateReferenceSystem();
ReferencedEnvelope tBounds = bounds.transform(featureCrs, true);
boolean crsEqual = CRS.equalsIgnoreMetadata(featureCrs, mapCrs);
MathTransform mathTransform = CRS.findMathTransform(featureCrs, mapCrs, true);
String name = geometryDescriptor.getLocalName();
Filter bboxFilter = getBboxFilter(name, tBounds);
SimpleFeatureCollection featureCollection = featureSource.getFeatures(bboxFilter);
FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
IViewportModel viewPort = ApplicationGIS.getActiveMap().getViewportModel();
List<AbstractDrawCommand> commands = new ArrayList<AbstractDrawCommand>();
while( featureIterator.hasNext() ) {