* @param coverage
* @return
*/
private Geometry createGeometry(GridCoverage2D coverage) {
// Selection of the Envelope associated to the Coverage
Envelope2D envelope = coverage.getEnvelope2D();
// Geometry creation
GeometryFactory fact = new GeometryFactory();
Coordinate[] coordinates = new Coordinate[5];
// Populating the Coordinate array in order to create the Polygon
for (int i = 0; i < coordinates.length; i++) {
switch (i) {
case 0:
case 4:
coordinates[i] = new Coordinate(envelope.getMinX(), envelope.getMinY());
break;
case 1:
coordinates[i] = new Coordinate(envelope.getMinX(), envelope.getMinY()
+ envelope.getHeight() / 2);
break;
case 2:
coordinates[i] = new Coordinate(envelope.getMinX() + envelope.getWidth() / 2,
envelope.getMinY() + envelope.getHeight() / 2);
break;
case 3:
coordinates[i] = new Coordinate(envelope.getMinX() + envelope.getWidth() / 2,
envelope.getMinY());
break;
}
}
// polygon creation from the coordinate array
Polygon poly = fact.createPolygon(coordinates);