kopia lustrzana https://github.com/onthegomap/planetiler
tested out building merge
rodzic
3b70fdeddd
commit
27f993cdd8
|
@ -31,11 +31,6 @@ import org.slf4j.LoggerFactory;
|
|||
public class FeatureMerge {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FeatureMerge.class);
|
||||
private static final BufferParameters bufferOps = new BufferParameters();
|
||||
|
||||
static {
|
||||
bufferOps.setJoinStyle(BufferParameters.JOIN_MITRE);
|
||||
}
|
||||
|
||||
public static List<VectorTileEncoder.Feature> mergeLineStrings(List<VectorTileEncoder.Feature> items,
|
||||
double minLength, double tolerance, double clip) throws GeometryException {
|
||||
|
@ -131,6 +126,12 @@ public class FeatureMerge {
|
|||
}
|
||||
}
|
||||
|
||||
private static final BufferParameters bufferOps = new BufferParameters();
|
||||
|
||||
static {
|
||||
bufferOps.setJoinStyle(BufferParameters.JOIN_MITRE);
|
||||
}
|
||||
|
||||
public static List<VectorTileEncoder.Feature> mergePolygons(List<VectorTileEncoder.Feature> features, double minArea,
|
||||
double minDist, double buffer) throws GeometryException {
|
||||
List<VectorTileEncoder.Feature> result = new ArrayList<>(features.size());
|
||||
|
|
|
@ -2,9 +2,11 @@ package com.onthegomap.flatmap.profiles;
|
|||
|
||||
import com.graphhopper.reader.ReaderRelation;
|
||||
import com.onthegomap.flatmap.FeatureCollector;
|
||||
import com.onthegomap.flatmap.FeatureMerge;
|
||||
import com.onthegomap.flatmap.Profile;
|
||||
import com.onthegomap.flatmap.SourceFeature;
|
||||
import com.onthegomap.flatmap.VectorTileEncoder;
|
||||
import com.onthegomap.flatmap.geo.GeometryException;
|
||||
import com.onthegomap.flatmap.read.OpenStreetMapReader;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -12,6 +14,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class OpenMapTilesProfile implements Profile {
|
||||
|
||||
private static boolean MERGE_Z13_BUILDINGS = false;
|
||||
|
||||
public static final String LAKE_CENTERLINE_SOURCE = "lake_centerlines";
|
||||
public static final String WATER_POLYGON_SOURCE = "water_polygons";
|
||||
public static final String NATURAL_EARTH_SOURCE = "natural_earth";
|
||||
|
@ -24,7 +28,10 @@ public class OpenMapTilesProfile implements Profile {
|
|||
|
||||
@Override
|
||||
public List<VectorTileEncoder.Feature> postProcessLayerFeatures(String layer, int zoom,
|
||||
List<VectorTileEncoder.Feature> items) {
|
||||
List<VectorTileEncoder.Feature> items) throws GeometryException {
|
||||
if (MERGE_Z13_BUILDINGS && "building".equals(layer) && zoom == 13) {
|
||||
return FeatureMerge.mergePolygons(items, 4, 0.5, 0.5);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -88,7 +95,7 @@ public class OpenMapTilesProfile implements Profile {
|
|||
if (sourceFeature.hasTag("building")) {
|
||||
features.polygon("building")
|
||||
.setZoomRange(13, 14)
|
||||
.setMinPixelSize(4);
|
||||
.setMinPixelSize(MERGE_Z13_BUILDINGS ? 0 : 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -527,9 +527,9 @@ public class FeatureMergeTest {
|
|||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"2477, 3028, 13, 876",
|
||||
"2481, 3026, 13, 806",
|
||||
"2479, 3028, 13, 884"
|
||||
"2477, 3028, 13, 1026",
|
||||
"2481, 3026, 13, 789",
|
||||
"2479, 3028, 13, 963"
|
||||
})
|
||||
public void testMergeManyPolygons(int x, int y, int z, int expected)
|
||||
throws IOException, GeometryException {
|
||||
|
@ -537,7 +537,7 @@ public class FeatureMergeTest {
|
|||
byte[] tileData = db.getTile(x, y, z);
|
||||
byte[] gunzipped = TestUtils.gunzip(tileData);
|
||||
List<VectorTileEncoder.Feature> features = VectorTileEncoder.decode(gunzipped);
|
||||
List<VectorTileEncoder.Feature> merged = FeatureMerge.mergePolygons(features, 1, 1, 1);
|
||||
List<VectorTileEncoder.Feature> merged = FeatureMerge.mergePolygons(features, 4, 0.5, 0.5);
|
||||
int total = 0;
|
||||
for (var feature : merged) {
|
||||
Geometry geometry = feature.geometry().decode();
|
||||
|
|
Ładowanie…
Reference in New Issue