I am having trouble creating geotools buffers around objects (lines), all objects seem crooked, I think it happens because the difference in CRSs is very noticable on buffers. I figuered out I probably need to set CRS that my app is using, i want it to be EPSG:4326 but i cant get my head on how i can do it.
Reading geotools guide i've seen examples on how to do it knowing the CRS used before via transform but i can only get SRID code and not the CRS. Any help is apreciated
In the code shown below I im trying to constuct buffer over a line and get coordinates of the buffer on the different radiuses. It works just fine, but seems realy uneven on the map. I also tried creating geometry factory specifying SRID assuming the int code would be the same as in CRS, there is no difference in displaying coordinates in different factories whatsoever
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
GeometryFactory factory = JTSFactoryFinder.getGeometryFactory();
LineString lineString = geometryFactory.createLineString(mapCoords(pipeline));
for (double radius : radiuses){
Coordinate[] coordinates = lineString.buffer(radius).getCoordinates();
List<Point> points = mapPoints(coordinates);
radiusesPoints.add(points);
}
So, as it was said in the comments, since there is no way to getCoordinates and getCoordinateReferenceSystem on the same object I used a workaround, which is basicly using postgresql fucntions to do the same thing, but on db request level. The task was solved a while ago, but if you would like to see a solution tag me in the comments and I'll find the db request for you