创建 geotools 对象时如何使用特定的 CRS?

How to use specific CRS when creating geotools objects?

我在围绕对象(线)创建 geotools 缓冲区时遇到问题,所有对象看起来都歪了,我认为这是因为 CRS 的差异在缓冲区上非常明显。我发现我可能需要设置我的应用程序正在使用的 CRS,我希望它是 EPSG:4326,但我不知道该怎么做。


阅读 geotools 指南我已经看到关于如何通过转换知道之前使用的 CRS 的示例,但我只能获得 SRID 代码而不是 CRS。感谢任何帮助


在下面显示的代码中,我试图在一条线上构造缓冲区并获取缓冲区在不同半径上的坐标。它工作得很好,但在地图上看起来确实不均匀。我还尝试创建指定 SRID 的几何工厂,假设 int 代码与 CRS 中的代码相同,在不同工厂中显示坐标没有任何区别

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);
    }

所以,正如评论中所说,由于无法在同一个对象上获取坐标和获取坐标参考系统,我使用了一个变通方法,它基本上使用 postgresql 函数来做同样的事情,但在数据库请求级别.该任务不久前已解决,但如果您想在评论中标记我的解决方案,我会为您找到数据库请求