GeoPipes

基础图层

以下示例使用了不同的基础图层

OsmLayer

osmLayer

IntersectionLayer

intersectionLayer

LinesLayer

linesLayer

BoxesLayer

boxesLayer

ConcaveLayer

concaveLayer

EqualLayer

equalLayer

GeoPipes 示例

下面列出了 GeoPipes 中一些有趣的、可以链接在一起构建地理处理系统的管道,同时通过不同步骤中的迭代器,尽量保持处理的延迟性。

仿射变换

此管道对每个几何图形应用仿射变换。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
		.applyAffineTransform(AffineTransformation.translationInstance(2, 3));

输出

affine transformation

边界

边界管道计算管道中每个几何图形的边界。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toBoundary();

输出

boundary

将所有几何图形分解为点并生成密度岛

此示例演示了将一些管道链式连接起来以构建一个完整的地理处理流水线。

示例

//step1
GeoPipeline pipeline = OSMGeoPipeline.startOsm(tx, osmLayer)
		//step2
		.extractOsmPoints()
		//step3
		.groupByDensityIslands(0.0005)
		//step4
		.toConvexHull()
		//step5
		.toBuffer(0.0004);

步骤 1 - startOsm

step1 break up all geometries into points and make density islands

步骤 2 - extractOsmPoints

step2 break up all geometries into points and make density islands

步骤 3 - groupByDensityIslands

step3 break up all geometries into points and make density islands

步骤 4 - toConvexHull

step4 break up all geometries into points and make density islands

步骤 5 - toBuffer

step5 break up all geometries into points and make density islands

缓冲区

此管道对几何图形应用缓冲区。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toBuffer(0.5);

输出

buffer

质心

此管道计算几何图形的质心。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toCentroid();

输出

centroid

凸包

此管道计算几何图形的凸包。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, concaveLayer).toConvexHull();

输出

convex hull

加密

此管道沿几何图形中的线段插入额外的顶点。加密后的几何图形不包含比给定距离容差更长的线段。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, concaveLayer).densify(5).extractPoints();

输出

densify

差集

差集管道计算一个几何图形,该几何图形表示构成项目几何图形中但不构成给定几何图形的点。

示例

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);

输出

difference

终点

EndPoint 管道查找项目几何图形的终点。

示例

GeoPipeline pipeline = GeoPipeline
		.start(tx, linesLayer)
		.toEndPoint();

输出

end point

外包矩形

Envelope 管道计算项目几何图形的最小边界框。

示例

GeoPipeline pipeline = GeoPipeline
		.start(tx, linesLayer)
		.toEnvelope();

输出

envelope

导出为 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>

提取点

此管道从几何图形中提取每个点。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).extractPoints();

输出

extract points

使用 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();

输出

intersect all

相交窗口

FilterIntersectWindow 管道查找与给定矩形相交的几何图形。

示例

GeoPipeline pipeline = GeoPipeline
		.start(tx, boxesLayer)
		.windowIntersectionFilter(new Envelope(0, 10, 0, 10));

输出

intersecting windows

相交

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);

输出

intersection

最大值

Max 管道计算指定属性的最大值,并丢弃值小于最大值的项目。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
		.calculateArea()
		.getMax("Area");

输出

max

最小值

Min 管道计算指定属性的最小值,并丢弃值大于最小值的项目。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
		.calculateArea()
		.getMin("Area");

输出

min

在几何图形内搜索

此管道在此示例中在几何图形内执行搜索,使用外包矩形 Envelope 进行搜索时,应能找到所有 OSM 街道几何图形。

示例

GeoPipeline pipeline = GeoPipeline
		.startWithinSearch(tx, osmLayer,
				osmLayer.getGeometryFactory().toGeometry(new Envelope(10, 20, 50, 60)));

起点

StartPoint 管道查找项目几何图形的起点。

示例

GeoPipeline pipeline = GeoPipeline
		.start(tx, linesLayer)
		.toStartPoint();

输出

start point

并集

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);

输出

union

全部合并

Union All 管道合并管道中包含的每个项目的几何图形。此管道将管道中的每个项目分组到单个项目中,该项目包含合并的几何图形输出。

示例

GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer).unionAll();

输出

unite all
© . All rights reserved.