// try getting an envelope out of the crs
org.opengis.geometry.Envelope envelope = CRS.getEnvelope(crs);
if (envelope != null) {
bounds = new ReferencedEnvelope(envelope.getLowerCorner()
.getOrdinate(0), envelope.getUpperCorner().getOrdinate(0),
envelope.getLowerCorner().getOrdinate(1), envelope
.getUpperCorner().getOrdinate(1), crs);
} else {
// TODO: perhaps access a preference which indicates
// whether to do a full table scan
// bounds = new ReferencedEnvelope(new Envelope(),crs);
// as a last resort do the full scan
bounds = new ReferencedEnvelope(new Envelope(), crs);
FeatureIterator<SimpleFeature> iter = source.getFeatures().features();
try {
while( iter.hasNext() ) {
SimpleFeature element = iter.next();
if (bounds.isNull())
bounds.init(element.getBounds());
else
bounds.include(element.getBounds());
}
} finally {
iter.close();
}
}
}
} catch (DataSourceException e) {
MySQLPlugin.log("Exception while generating MySQLGeoResource.", e); //$NON-NLS-1$
} catch (Exception e) {
CatalogPlugin
.getDefault()
.getLog()
.log(
new org.eclipse.core.runtime.Status(
IStatus.WARNING,
"org.locationtech.udig.catalog", 0, Messages.MySQLGeoResource_error_layer_bounds, e)); //$NON-NLS-1$
bounds = new ReferencedEnvelope(new Envelope(), null);
}
}
return super.getBounds();
}