I'm trying to create regular hexagon polygons, but when visualized on a map they are stretched vertically.
This is how I do it:
List<Geometry> hexagons = new ArrayList<>();
CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
ReferencedEnvelope gridBounds = new ReferencedEnvelope(box[0], box[2], box[1], box[3], sourceCRS);
double sideLen = 0.1;
GridFeatureBuilder builder = new DefaultGridFeatureBuilder();
SimpleFeatureSource grid = Hexagons.createGrid(gridBounds, sideLen, HexagonOrientation.FLAT, builder);
try{
SimpleFeatureCollection collection = grid.getFeatures();
FeatureIterator iterator = collection.features();
while (iterator.hasNext()){
Feature feature = iterator.next();
SimpleFeature sFeature = (SimpleFeature) feature;
Geometry geometry = (Geometry) sFeature.getAttribute(0);
hexagons.add(geometry);
}
} catch(Exception e){
e.printStackTrace();
}
return hexagons;
is how it looks like on a map. I tried to change the orientation from FLAT to ANGLE, but that didn't fix the problem.