将 JTS 几何扩展到北极/南极

问题描述 投票:0回答:1

我正在开发一个项目,需要将任意几何图形扩展任意米数。我的解决方案基于 Geotools:wgs84 中缓冲区的边界框 的答案。除了会在两极上扩展的几何形状之外,它运行良好。当我尝试这些几何形状时,它们不会正确扩展。我相信这是因为几何图形转换为WGS84。

例如,当我尝试扩展到北极上方时。原始几何

POLYGON ((-119.67774694525636 80.37445153512789, -119.67774694525636 88.85624864362437, -92.01074221005827 88.85624864362437, -92.01074221005827 80.37445153512789, -119.67774694525636 80.37445153512789))

结果

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
对反子午线所做的那样。我花了好几天谷歌搜索这个问题,但没有找到任何解决方案。是否有库函数可以处理这个问题?如果没有好的方法来做到这一点,是否有可靠的方法来检测原始几何图形是否会跨越极点(或者扩展的几何图形是否已跨越极点)?

java geospatial geotools jts
1个回答
0
投票

你的问题是你选择使用

AUTO2:42001
,这是一个横向墨卡托投影,所以你越接近极点,它的性能就越差,直到它在实际极点变得无限宽。我会尝试使用
AUTO2:97002
,它是立体图像,应该能更好地处理靠近极点的情况。

摘自手册

支持的自动代码有:

  • 42001,通用横轴墨卡托
  • 42002,横轴墨卡托
  • 42003,正交
  • 42004,等距圆柱
  • 97001,Gnonomic(GeoTools 扩展)
  • 97002,立体(GeoTools 扩展)
  • 97003,等距方位角(GeoTools 扩展)
© www.soinside.com 2019 - 2024. All rights reserved.