GeoPipes
GeoPipes 示例
下面列出了一些有趣的 GeoPipes,这些管道可以链接在一起,构建一个地理处理系统,同时尝试使用迭代器尽可能地保持处理的延迟性,从而通过不同的步骤。
仿射变换
此管道对每个几何体应用仿射变换。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.applyAffineTransform(AffineTransformation.translationInstance(2, 3));
输出

将所有几何体分解为点并创建密度岛
此示例演示了一些链接在一起的管道,以创建一个完整的地理处理管道。
示例
//step1
GeoPipeline pipeline = OSMGeoPipeline.startOsm(tx, osmLayer)
//step2
.extractOsmPoints()
//step3
.groupByDensityIslands(0.0005)
//step4
.toConvexHull()
//step5
.toBuffer(0.0004);
步骤 1 - startOsm

步骤 2 - extractOsmPoints

步骤 3 - groupByDensityIslands

步骤 4 - toConvexHull

步骤 5- toBuffer

加密
此管道在几何体中的线段上插入额外的顶点。加密的几何体不包含任何长度超过给定距离容差的线段。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, concaveLayer).densify(5).extractPoints();
输出

差
差管道计算一个几何体,该几何体表示构成项几何体的点,而这些点不构成给定几何体。
示例
WKTReader reader = new WKTReader(intersectionLayer.getGeometryFactory());
Geometry geometry = reader.read("POLYGON ((3 3, 3 5, 7 7, 7 3, 3 3))");
GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer).difference(geometry);
输出

终点
EndPoint 管道查找项几何体的结束点。
示例
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toEndPoint();
输出

包络
Envelope 管道计算项几何体的最小边界框。
示例
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toEnvelope();
输出

导出到 GML
此管道将每个几何体导出为 GML 代码段。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).createGML();
for (GeoPipeFlow flow : pipeline) {
System.out.println(flow.getProperties().get("GML"));
}
输出
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>
2.0,3.0 2.0,5.0 6.0,5.0 6.0,3.0 2.0,3.0
</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>
12.0,26.0 12.0,27.0 13.0,27.0 13.0,26.0 12.0,26.0
</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
使用 bbox 过滤 CQL
此管道根据 CQL 边界框描述进行过滤。
示例
GeoPipeline cqlFilter = GeoPipeline.start(tx, osmLayer).cqlFilter(tx, "BBOX(the_geom, 10, 40, 20, 56.0583531)");
使用复杂 CQL 过滤 CQL
此管道根据复杂 CQL 描述进行过滤。
示例
long counter = GeoPipeline.start(tx, osmLayer)
.cqlFilter(tx, "highway is not null and geometryType(the_geom) = 'LineString'").count();
全部相交
Intersect All 管道与管道中包含的每个项的几何体相交。此管道将管道中的每个项分组到一个项中,该项包含相交结果的几何体输出。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer).intersectAll();
输出

相交窗口
FilterIntersectWindow 管道查找与给定矩形相交的几何体。
示例
GeoPipeline pipeline = GeoPipeline
.start(tx, boxesLayer)
.windowIntersectionFilter(new Envelope(0, 10, 0, 10));
输出

相交
Intersection 管道计算一个几何体,该几何体表示项几何体与给定几何体之间的交点。
示例
WKTReader reader = new WKTReader(intersectionLayer.getGeometryFactory());
Geometry geometry = reader.read("POLYGON ((3 3, 3 5, 7 7, 7 3, 3 3))");
GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer).intersect(geometry);
输出

最大值
Max 管道计算指定属性的最大值,并丢弃值小于最大值的项。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.calculateArea()
.getMax("Area");
输出

最小值
Min 管道计算指定属性的最小值,并丢弃值大于最小值的项。
示例
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.calculateArea()
.getMin("Area");
输出

在几何体中搜索
此管道在此示例中执行几何体内的搜索,当使用封闭矩形包络搜索时,应在两个 OSM 街道几何体中找到这两个几何体。
示例
GeoPipeline pipeline = GeoPipeline
.startWithinSearch(tx, osmLayer,
osmLayer.getGeometryFactory().toGeometry(new Envelope(10, 20, 50, 60)));
起点
StartPoint 管道查找项几何体的起点。
示例
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toStartPoint();
输出

联合
Union 管道将项几何体与给定几何体合并。
示例
WKTReader reader = new WKTReader(intersectionLayer.getGeometryFactory());
Geometry geometry = reader.read("POLYGON ((3 3, 3 5, 7 7, 7 3, 3 3))");
SearchFilter filter = new SearchIntersectWindow(intersectionLayer, new Envelope(7, 10, 7, 10));
GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer, filter).union(geometry);
输出
