尽管您以另一种方式处理它,但我对此有另一种解决方案。结果将比您提出的解决方案更精确。
GeometryFactory GEOMETRY_FACTORY = JTSFactoryFinder.getGeometryFactory();
// Remember, order is (longitude, latitude)
Coordinate center = Coordinate(2.29443, 48.85816);
Point point = GEOMETRY_FACTORY.createPoint(center);
// Buffer 50KM around the point, then get the envelope
Envelope envelopeInternal = buffer(point, 50000).getEnvelopeInternal();
// Then you can play with the envelope, e.g.,
double minX = envelopeInternal.getMinX();
double maxX = envelopeInternal.getMaxX();
// The buffer using distanceInMeters
private Geometry buffer(Geometry geometry, double distanceInMeters) throws FactoryException, TransformException {
String code = "AUTO:42001," + geometry.getCentroid().getCoordinate().x + "," + geometry.getCentroid().getCoordinate().y;
CoordinateReferenceSystem auto = CRS.decode(code);
MathTransform toTransform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);
MathTransform fromTransform = CRS.findMathTransform(auto, DefaultGeographicCRS.WGS84);
Geometry pGeom = JTS.transform(geometry, toTransform);
Geometry pBufferedGeom = pGeom.buffer(distanceInMeters);
return JTS.transform(pBufferedGeom, fromTransform);
}
这是带有结果的地图,红色为缓冲区,黑色为信封。