Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions styles/src/base_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,11 @@ export function nolabels_layers(
type: "line",
source: source,
"source-layer": "boundaries",
filter: ["<=", "kind_detail", 2],
filter: [
"any",
["<=", "kind_detail", 2],
["all", ["==", "kind_detail", 3], ["==", "disputed", true]],
],
paint: {
"line-color": t.boundaries,
"line-width": 0.7,
Expand All @@ -1084,7 +1088,11 @@ export function nolabels_layers(
type: "line",
source: source,
"source-layer": "boundaries",
filter: [">", "kind_detail", 2],
filter: [
"all",
[">", "kind_detail", 2],
["none", ["all", ["==", "kind_detail", 3], ["==", "disputed", true]]],
],
paint: {
"line-color": t.boundaries,
"line-width": 0.4,
Expand Down
19 changes: 19 additions & 0 deletions styles/test/base_layers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,22 @@ test("the nolayers label has no labels", () => {
assert.notEqual("symbol", layer.type);
}
});

test("country boundary styling includes disputed level three boundaries", () => {
const boundaryLayers = nolabels_layers("dummy", LIGHT);
const country = boundaryLayers.find(
(layer) => layer.id === "boundaries_country",
);
const other = boundaryLayers.find((layer) => layer.id === "boundaries");

assert.deepEqual(country?.filter, [
"any",
["<=", "kind_detail", 2],
["all", ["==", "kind_detail", 3], ["==", "disputed", true]],
]);
assert.deepEqual(other?.filter, [
"all",
[">", "kind_detail", 2],
["none", ["all", ["==", "kind_detail", 3], ["==", "disputed", true]]],
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation)
if (relation.hasTag("type", "boundary") &&
relation.hasTag("boundary", "administrative", "disputed", "claim")) {
Integer adminLevel = Parse.parseIntOrNull(relation.getString("admin_level"));
Integer disputed = relation.hasTag("boundary", "disputed") || relation.hasTag("disputed", "yes") ||
boolean occupiedBoundary = adminLevel != null && adminLevel == 3 &&
relation.hasTag("border_type", "occupied");
Integer disputed = occupiedBoundary || relation.hasTag("boundary", "disputed") ||
relation.hasTag("disputed", "yes") ||
relation.hasTag("disputed_by") || relation.hasTag("claimed_by") ? 1 : 0;

if (adminLevel == null || adminLevel > 8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,62 @@ void testDisputedOsm() {
collector);
}

@Test
void testOccupiedAdminLevelThreeIsDisputedRegionBoundary() {
var infos = profile.preprocessOsmRelation(
new OsmElement.Relation(1,
Map.of("type", "boundary", "boundary", "administrative", "admin_level", "3", "border_type", "occupied"),
List.of(new OsmElement.Relation.Member(OsmElement.Type.WAY, 123, ""))));

var way = SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 1, 1),
new HashMap<>(),
"osm",
null,
123,
infos.stream().map(r -> new OsmReader.RelationMember<>("", r)).toList()
);

var collector = featureCollectorFactory.get(way);
profile.processFeature(way, collector);

assertFeatures(6,
List.of(Map.of(
"kind", "region",
"kind_detail", 3,
"disputed", true,
"sort_rank", 288,
"_minzoom", 6)),
collector);
}

@Test
void testOrdinaryAdminLevelThreeRemainsRegionBoundary() {
var infos = profile.preprocessOsmRelation(
new OsmElement.Relation(1, Map.of("type", "boundary", "boundary", "administrative", "admin_level", "3"),
List.of(new OsmElement.Relation.Member(OsmElement.Type.WAY, 123, ""))));

var way = SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 1, 1),
new HashMap<>(),
"osm",
null,
123,
infos.stream().map(r -> new OsmReader.RelationMember<>("", r)).toList()
);

var collector = featureCollectorFactory.get(way);
profile.processFeature(way, collector);

assertFeatures(6,
List.of(Map.of(
"kind", "region",
"kind_detail", 3,
"sort_rank", 289,
"_minzoom", 6)),
collector);
}

@ParameterizedTest
@CsvSource(value = {
"disputed,yes",
Expand Down
Loading