-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GeometryPipeline #1118
GeometryPipeline #1118
Conversation
Full logs: https://github.com/onthegomap/planetiler/actions/runs/12338616800 |
Amazing, thanks for introducing this! I am playing a bit around with it and post things that come to mind below... |
First question, if I do features.polygon("forest")
.setPixelTolerance(0.0)
.setMinPixelSize(0.0)
.transformScaledGeometry(GeometryPipeline.simplifyDP(2.0 / 256)); in the processFeature function, will setPixelTolerance have any effect? |
One thing that I always found a little bit disturbing about Douglas Peucker simplification was that you get these sharp corners all over the place. Would the recommended way to remove those be something like this? features.polygon("waterway")
.setPixelTolerance(0.0)
.transformScaledGeometry(
GeometryPipeline.simplifyDP(1/256d)
.andThen(GeometryPipeline.smoothChaikin(1))
)
.setMinPixelSize(0.0);
} |
Thanks for taking a look!
transformScaledGeometry replaces simplification, but I added a utility so you can do
Yes that could work! You end up adding points back to remove the sharp corners. You could also add points back by just using a smaller DP tolerance, but adding them back with chaikin smoothing results in a globbier shape. You could also try |
|
@wipfli I'm going to merge this now, let me know if you have any feedback using it on main branch and we can adjust if necessary! |
This PR adds a new
GeometryPipeline
interface for operations that transform aGeometry
to anotherGeometry
and also:feature.transformScaledGeometry(GeometryPipeline)
which tells planetiler to apply that transform to the feature each time it is scaled to tile coordinates (where 1=width of tile at that zoom level) before slicing the feature into tiles at that zoomfeature.transformScaledGeometryByZoom((zoom) -> GeometryPipeline)
which lets you dynamically change the transform applied to scaled geometries at each zoom levelFeatureMerge
mergeLineStrings()
andmergeNearbyPolygons
to accept a geometry pipeline to apply to each merged feature in tile coordinates (where 256=width of the tile)DouglasPeuckerSimplifier
andVWSimplifier
to implementGeometryPipeline
MidpointSmoother
to implement midpoint smoothingDualMidpointSmoother
to implement Chaikin smoothingGeometryPipeline
for these common transforms (simplifyDP, simplifyVW, smoothChaikin, smoothMidpoint)You can also pass simple functions where a GeometryPipeline is expected, for example:
And you can chain transforms using
andThen
:.andThen(GeometryPipeline.defaultSimplify(feature))
Here is a joke example using Visvalingam Whyatt simplification and Chaikin smoothing on OSM ocean polygons: