Skip to content
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

Permit post-process merging in custommap schemas #626

Merged
merged 19 commits into from
Aug 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test ConfiguredProfile.postProcessLayerFeatures()
  • Loading branch information
zhibek committed Jul 15, 2023
commit 42c9b5b5bbe07fdb16eecfc3063dee706c6cc130
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureCollector.Feature;
import com.onthegomap.planetiler.Profile;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.custommap.configschema.DataSourceType;
Expand All @@ -17,6 +18,8 @@
import com.onthegomap.planetiler.custommap.configschema.PostProcess;
import com.onthegomap.planetiler.custommap.configschema.SchemaConfig;
import com.onthegomap.planetiler.custommap.util.TestConfigurableUtils;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.geo.GeoUtils;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.stats.Stats;
Expand Down Expand Up @@ -160,6 +163,89 @@ private void testLinestring(Function<String, Path> pathFunction, String schemaFi
testFeature(pathFunction, schemaFilename, sf, test, expectedMatchCount);
}

@Test
void testFeaturePostProcessorNoop() throws GeometryException {
var config = """
sources:
osm:
type: osm
url: geofabrik:rhode-island
local_path: data/rhode-island.osm.pbf
layers:
- id: testLayer
features:
- source: osm
geometry: point
""";
var profile = loadConfig(config);

VectorTile.Feature feature = new VectorTile.Feature(
"testLayer",
1,
VectorTile.encodeGeometry(GeoUtils.point(0, 0)),
Map.of()
);
assertEquals(List.of(feature), profile.postProcessLayerFeatures("testLayer", 0, List.of(feature)));
}

@Test
void testFeaturePostProcessorMergeLineStrings() throws GeometryException {
var config = """
sources:
osm:
type: osm
url: geofabrik:rhode-island
local_path: data/rhode-island.osm.pbf
layers:
- id: testLayer
features:
- source: osm
geometry: point
post_process:
merge_line_strings:
min_length: 1
tolerance: 5
buffer: 10
""";
var profile = loadConfig(config);

VectorTile.Feature feature = new VectorTile.Feature(
"testLayer",
1,
VectorTile.encodeGeometry(GeoUtils.point(0, 0)),
Map.of()
);
assertEquals(List.of(feature), profile.postProcessLayerFeatures("testLayer", 0, List.of(feature)));
}

@Test
void testFeaturePostProcessorMergeOverlappingPolygons() throws GeometryException {
var config = """
sources:
osm:
type: osm
url: geofabrik:rhode-island
local_path: data/rhode-island.osm.pbf
layers:
- id: testLayer
features:
- source: osm
geometry: point
post_process:
merge_overlapping_polygons:
min_area: 3
""";
var profile = loadConfig(config);

VectorTile.Feature feature = new VectorTile.Feature(
"testLayer",
1,
VectorTile.encodeGeometry(GeoUtils.point(0, 0)),
Map.of()
);
assertEquals(List.of(feature), profile.postProcessLayerFeatures("testLayer", 0, List.of(feature)));
}

@Test
void testStaticAttributeTest() {
testPolygon(TEST_RESOURCE, "static_attribute.yml", waterTags, f -> {
Expand Down