【发布时间】:2017-03-16 10:34:13
【问题描述】:
我正在尝试读取 WKT 多边形(数十万个)并将它们组合成更大的“包含”多边形以减少数据大小。为简洁起见,我省略了我将使用的循环,因此两个多边形应作为示例。
我从未使用过 JTS,所以我的幼稚做法是这样的:
static Geometry combineIntoOneGeometry()
{
WKTReader wkt = new WKTReader();
Geometry[] geometries;
try
{
Geometry polygon1 = (Geometry) wkt.read("...");
Geometry polygon2 = (Geometry) wkt.read("...");
geometries = new Geometry[] { }; //add them here ?
geometries.add(polygon1, polygon2); //add doesn't exist, of course...
}
catch (ParseException e)
{
e.printStackTrace();
}
GeometryCollection gc = new GeometryFactory().createGeometryCollection(geometries); //can't instantiate GeometryFactory
return gc.union();
}
有几个问题:
- 我无法实例化 GeometryCollection
- GeometryCollection 似乎没有接受/添加几何的方法 - 如何使用几何“填充”几何集合?
- 无法添加几何体数组,我还没有找到通过构造函数实现的方法
- 我无法在几何上调用 union
除了问题:如果我要合并的某些多边形是不相交的,那会导致多多边形吗?没关系,只是好奇。
谢谢!
【问题讨论】: