Skip to content

Commit

Permalink
Merge pull request #12 from OvertureMaps/buildings-sources
Browse files Browse the repository at this point in the history
set @height_source and @geometry_source helper attributes in building…
  • Loading branch information
bdon authored Jul 24, 2024
2 parents df45bc2 + 8c6cf0e commit 4bf0e83
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions profiles/Buildings.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ public void processFeature(SourceFeature source, FeatureCollector features) {
var polygon = features.polygon(layer);

if (source instanceof ParquetFeature pf) {
var sources = pf.getStruct("sources").asList();

// set @height_source helper
sources.stream().filter(s -> s.get("property").asString().equals("properties/height")).findFirst().ifPresentOrElse(
s -> polygon.setAttr("@height_source", s.get("dataset")),
() -> {
if (pf.hasTag("height")) {
sources.stream().filter(s -> s.get("property").asString().isEmpty()).findFirst().ifPresent(
s -> polygon.setAttr("@height_source", s.get("dataset"))
);
}
}
);

// set @geometry_source helper
sources.stream().filter(s -> s.get("property").asString().equals("properties/geometry")).findFirst().ifPresentOrElse(
s -> polygon.setAttr("@geometry_source", s.get("dataset")),
() -> {
sources.stream().filter(s -> s.get("property").asString().isEmpty()).findFirst().ifPresent(
s -> polygon.setAttr("@geometry_source", s.get("dataset"))
);
}
);

// deprecate me: @source_0_dataset
var source0Dataset = pf.getStruct("sources").get(0).get("dataset");
polygon.setAttr("@source_0_dataset", source0Dataset);
}
Expand Down

0 comments on commit 4bf0e83

Please sign in to comment.