-
|
Problem: I need crisp cut-off on exact geometry, for example a county border which I have as a geoJSON. What I've done: public static Geometry createPolygonFromCoordArray(double[] c) {
Coordinate[] coords = new Coordinate[c.length / 2];
for (int i = 0; i < coords.length; i++) {
int ii = i * 2;
coords[i] = new Coordinate(c[ii], c[ii + 1]);
}
return GeoUtils.latLonToWorldCoords(GeoUtils.JTS_FACTORY.createPolygon(coords));
}I then pass the bounds geometry to all layer processors as an argument: var landuse = new Landuse(bounds);
registerHandler(landuse);
registerSourceHandler("osm", landuse::processOsm);When features are processed, I check if they are in bounds and omit if necessary: if (!this.bounds.covers(feat.getGeometry())) {
// only omitting at the moment, nothing is cut into bounds
feat.omit();
return;
}Questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Maybe you can take some inspiration from the protomaps Clip.java file: |
Beta Was this translation helpful? Give feedback.
Maybe you can take some inspiration from the protomaps Clip.java file:
https://github.com/protomaps/basemaps/blob/main/tiles/src/main/java/com/protomaps/basemap/postprocess/Clip.java