我正在做一个项目,我需要将任意几何体扩展任意数量的米。我的解决方案基于Geotools: bounding box for a buffer in wgs84的答案。它工作得很好,除了几何体会在极点上扩展。当我尝试这些几何体时,它们不会正确扩展。我相信这是因为几何体被转换为WGS 84。
例如,当我试图在北极展开时,
第一个月
导致POLYGON ((-119.55257624947963 80.28744411777537, -119.65814347054986 80.28500161369493, -119.76447712889755 80.28613664783931, -119.86739993993893 80.29080449554324, -119.96285816866265 80.29882150830288, -120.04706960992401 80.3098717917805, -120.1166650856837 80.3235187633621, -120.16881949162571 80.3392213016671, -120.20136796158704 80.3563540602452, -120.21290227443447 80.3742313628052, -124.15475233860748 88.85263605573168, -124.14126324286381 88.86963400856264, -123.96241179725793 88.88626922229325, -123.61768091729581 88.90191266863626, -123.11386648703106 88.91594632209528, -122.4658992603797 88.92779235841586, -121.69707374945384 88.9369447058929, -120.83845159310151 88.94300026164407, -90.84999117562393 88.94300044247781, -89.99142129012581 88.93694561607559, -89.22261804630503 88.92779455542474, -88.57463779931913 88.91595022725265, -88.07077605279002 88.9019185390308, -87.72596967454402 88.88627713741018, -87.54702303857012 88.86964386779418, -87.5334268757033 88.85264758335717, -91.47545228015971 80.37421056485957, -91.48701040052279 80.35633253328805, -91.51958070268685 80.3391997037143, -91.57175443294304 80.32349758227612, -91.64136646933562 80.30985134031737, -91.72559172072657 80.29880193070304, -91.8210612719182 80.29078578493424, -91.92399339943785 80.28611867341851, -92.0303350262948 80.28498415631333, -92.13590964833129 80.28742691213384, -119.55257624947963 80.28744411777537))
个
在南极,我只是在转换到AUTO2 CRS时遇到了一个例外。
下面是我使用的确切代码。
private List<Geometry> expandGeometry(Geometry geometry, CoordinateReferenceSystem originalCrs)
throws FactoryException, TransformException {
Point centroid = geometry.getCentroid();
CoordinateReferenceSystem autoCrs =
CRS.decode("AUTO2:42001," + centroid.getCoordinate().x + "," + centroid.getCoordinate().y);
MathTransform toAutoTransform = CRS.findMathTransform(originalCrs, autoCrs);
MathTransform fromAutoTransform = CRS.findMathTransform(autoCrs, originalCrs);
Geometry geometryUsingMeters = JTS.transform(geometry, toAutoTransform);
Geometry bufferedGeometry = geometryUsingMeters.buffer(expansionInMeters);
bufferedGeometry = JTS.transform(bufferedGeometry, fromAutoTransform);
Geometry splitGeometry = new JtsGeometry(bufferedGeometry, JtsSpatialContext.GEO, true, false)
.getGeom();
return IntStream.range(0, splitGeometry.getNumGeometries())
.mapToObj(splitGeometry::getGeometryN)
.collect(Collectors.toList());
}
字符串originalCrs
始终是WGS:84。我使用JtsGeometry
来处理分割扩展的几何体,如果它穿过反子午线。
理想情况下,我希望将扩展的几何体拆分为多个等效的几何体,就像JtsGeometry
对反子午线所做的那样。我花了几天时间在谷歌上搜索这个问题,但没有找到任何解决方案。有没有库函数来处理这个问题?如果没有一个好的方法来做到这一点,是否有可靠的方法来检测原始几何形状是否会穿过极点(或者扩展的几何形状是否已经穿过极点)?
1条答案
按热度按时间wfveoks01#
你的问题是,你选择使用
AUTO2:42001
,这是一个横向墨卡托投影,所以越接近极点,它的表现就越差,直到它在实际极点处变得无限宽。我会尝试使用AUTO2:97002
,它是立体的,应该更好地处理极点附近。关于manual:
支持的验证码包括: