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
Show file tree
Hide file tree
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
Remove redundant logging. Declare merge variables as doubles not ints.
  • Loading branch information
zhibek committed Jul 14, 2023
commit 9d848103be8302f0c5257879d1a46ce2a54c2ae8
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A profile configured from a yml file.
Expand All @@ -35,8 +33,6 @@ public class ConfiguredProfile implements Profile {
private final TagValueProducer tagValueProducer;
private final Contexts.Root rootContext;

private static final Logger LOGGER = LoggerFactory.getLogger(ConfiguredProfile.class);

public ConfiguredProfile(SchemaConfig schema, Contexts.Root rootContext) {
this.schema = schema;
this.rootContext = rootContext;
Expand Down Expand Up @@ -102,26 +98,20 @@ public List<VectorTile.Feature> postProcessLayerFeatures(String layer, int zoom,
}

if (featureLayer.postProcess().mergeLineStrings() != null) {
int minLength = featureLayer.postProcess().mergeLineStrings().minLength();
int tolerance = featureLayer.postProcess().mergeLineStrings().tolerance();
int buffer = featureLayer.postProcess().mergeLineStrings().buffer();

LOGGER.debug("mergeLineStrings() minLength={} tolerance={} buffer={}", minLength, tolerance, buffer);
var merge = featureLayer.postProcess().mergeLineStrings();

return FeatureMerge.mergeLineStrings(items,
minLength, // after merging, remove lines that are still less than {minLength}px long
tolerance, // simplify output linestrings using a {tolerance}px tolerance
buffer // remove any detail more than {buffer}px outside the tile boundary
merge.minLength(), // after merging, remove lines that are still less than {minLength}px long
merge.tolerance(), // simplify output linestrings using a {tolerance}px tolerance
merge.buffer() // remove any detail more than {buffer}px outside the tile boundary
);
}

if (featureLayer.postProcess().mergeOverlappingPolygons() != null) {
int minArea = featureLayer.postProcess().mergeOverlappingPolygons().minArea();

LOGGER.debug("mergeOverlappingPolygons() minArea={}", minArea);
var merge = featureLayer.postProcess().mergeOverlappingPolygons();

return FeatureMerge.mergeOverlappingPolygons(items,
minArea // after merging, remove polygons that are still less than {minArea} in square tile pixels
merge.minArea() // after merging, remove polygons that are still less than {minArea} in square tile pixels
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

public record MergeLineStrings(
@JsonProperty("min_length") int minLength,
@JsonProperty() int tolerance,
@JsonProperty() int buffer
@JsonProperty("min_length") double minLength,
@JsonProperty() double tolerance,
@JsonProperty() double buffer
msbarry marked this conversation as resolved.
Show resolved Hide resolved
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import com.fasterxml.jackson.annotation.JsonProperty;

public record MergeOverlappingPolygons(
@JsonProperty("min_area") int minArea
@JsonProperty("min_area") double minArea
) {}