GeoPipes
Base Layers
These are the different base layers being used for the following examples:
OsmLayer:
IntersectionLayer:
LinesLayer:
BoxesLayer:
ConcaveLayer:
EqualLayer:
GeoPipes Examples
Below follows a non-exhaustive lists of interesting GeoPipes that can be chained together to contruct a geoprocessing system in while trying to keep the processing as lazy as possible using iterators through the different steps.
Affine Transformation
This pipe applies an affine transformation to every geometry.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.applyAffineTransform(AffineTransformation.translationInstance(2, 3));
Output:
Boundary
The boundary pipe calculates boundary of every geometry in the pipeline.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toBoundary();
Output:
Break up all geometries into points and make density islands
This example demonstrates the some pipes chained together to make a full geoprocessing pipeline.
Example:
//step1
GeoPipeline pipeline = OSMGeoPipeline.startOsm(tx, osmLayer)
//step2
.extractOsmPoints()
//step3
.groupByDensityIslands(0.0005)
//step4
.toConvexHull()
//step5
.toBuffer(0.0004);
Step 1 - startOsm:
Step 2 - extractOsmPoints:
Step 3 - groupByDensityIslands:
Step 4 - toConvexHull:
Step 5- toBuffer:
Buffer
This pipe applies a buffer to geometries.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toBuffer(0.5);
Output:
Centroid
This pipe calculates geometry centroid.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).toCentroid();
Output:
Convex Hull
This pipe calculates geometry convex hull.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, concaveLayer).toConvexHull();
Output:
Densify
This pipe inserts extra vertices along the line segments in the geometry. The densified geometry contains no line segment which is longer than the given distance tolerance.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, concaveLayer).densify(5).extractPoints();
Output:
Difference
The Difference pipe computes a geometry representing the points making up item geometry that do not make up the given geometry.
Example:
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);
Output:
End Point
The EndPoint pipe finds the ending point of item geometry.
Example:
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toEndPoint();
Output:
Envelope
The Envelope pipe computes the minimum bounding box of item geometry.
Example:
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toEnvelope();
Output:
Export to GML
This pipe exports every geometry as a GML snippet.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).createGML();
for (GeoPipeFlow flow : pipeline) {
System.out.println(flow.getProperties().get("GML"));
}
Output:
<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>
Extract Points
This pipe extracts every point from a geometry.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).extractPoints();
Output:
Filter by cql using bbox
This pipe is filtering according to a CQL Bounding Box description.
Example:
GeoPipeline cqlFilter = GeoPipeline.start(tx, osmLayer).cqlFilter(tx, "BBOX(the_geom, 10, 40, 20, 56.0583531)");
Filter by cql using complex cql
This pipe is filtering according to a complex CQL description.
Example:
long counter = GeoPipeline.start(tx, osmLayer)
.cqlFilter(tx, "highway is not null and geometryType(the_geom) = 'LineString'").count();
Intersect All
The Intersect All pipe intersects geometries of every item contained in the pipeline. This pipe groups every item in the pipeline in a single item containing the geometry output of the intersection.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, intersectionLayer).intersectAll();
Output:
Intersecting Windows
The FilterIntersectWindow pipe finds geometries that intersects a given rectangle.
Example:
GeoPipeline pipeline = GeoPipeline
.start(tx, boxesLayer)
.windowIntersectionFilter(new Envelope(0, 10, 0, 10));
Output:
Intersection
The Intersection pipe computes a geometry representing the intersection between item geometry and the given geometry.
Example:
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);
Output:
Max
The Max pipe computes the maximum value of the specified property and discard items with a value less than the maximum.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.calculateArea()
.getMax("Area");
Output:
Min
The Min pipe computes the minimum value of the specified property and discard items with a value greater than the minimum.
Example:
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer)
.calculateArea()
.getMin("Area");
Output:
Search within geometry
This pipe performs a search within a geometry in this example, both OSM street geometries should be found in when searching with an enclosing rectangle Envelope.
Example:
GeoPipeline pipeline = GeoPipeline
.startWithinSearch(tx, osmLayer,
osmLayer.getGeometryFactory().toGeometry(new Envelope(10, 20, 50, 60)));
Start Point
The StartPoint pipe finds the starting point of item geometry.
Example:
GeoPipeline pipeline = GeoPipeline
.start(tx, linesLayer)
.toStartPoint();
Output:
Union
The Union pipe unites item geometry with a given geometry.
Example:
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);
Output: