int mainComponentIndex = -1;
int component = 0;
for (Integer key : componentCoordinates.keySet()) {
List<Coordinate> coords = componentCoordinates.get(key);
Coordinate[] coordArray = new Coordinate[coords.size()];
ConvexHull hull = new ConvexHull(coords.toArray(coordArray), GeometryUtils.getGeometryFactory());
Geometry geom = hull.getConvexHull();
// buffer components which are mere lines so that they do not disappear.
if (geom instanceof LineString) {
geom = geom.buffer(0.01); // ~10 meters
} else if (geom instanceof Point) {
geom = geom.buffer(0.05); // ~50 meters, so that it shows up