Skip to content

Commit 70ba4a7

Browse files
committed
More tests
1 parent 6a304e6 commit 70ba4a7

File tree

2 files changed

+167
-23
lines changed

2 files changed

+167
-23
lines changed

tiles/src/main/java/com/protomaps/basemap/layers/Roads.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -239,60 +239,60 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
239239

240240
// non-highway features
241241
// todo: exclude railway stations, levels
242-
if (sf.canBeLine() && (sf.hasTag("railway") ||
243-
sf.hasTag("aerialway", "cable_car") ||
244-
sf.hasTag("man_made", "pier") ||
245-
sf.hasTag("route", "ferry") ||
246-
sf.hasTag("aeroway", "runway", "taxiway")) &&
242+
if (sf.canBeLine() && (sf.hasTag("railway") || //
243+
sf.hasTag("aerialway", "cable_car") || //
244+
sf.hasTag("man_made", "pier") || //
245+
sf.hasTag("route", "ferry") || //
246+
sf.hasTag("aeroway", "runway", "taxiway")) && //
247247
(!sf.hasTag("building") /* see https://github.com/protomaps/basemaps/issues/249 */) &&
248248
(!sf.hasTag("railway", "abandoned", "razed", "demolished", "removed", "construction", "platform", "proposed"))) {
249249

250250
int minZoom = 11;
251251

252252
if (sf.hasTag("aeroway", "runway")) {
253-
minZoom = 9;
253+
minZoom = 9; //
254254
} else if (sf.hasTag("aeroway", "taxiway")) {
255-
minZoom = 10;
255+
minZoom = 10; //
256256
} else if (sf.hasTag("service", "yard", "siding", "crossover")) {
257257
minZoom = 13;
258258
} else if (sf.hasTag("man_made", "pier")) {
259-
minZoom = 13;
259+
minZoom = 13; //
260260
}
261261

262262
String kind = "other";
263263
String kindDetail = "";
264264
if (sf.hasTag("aeroway")) {
265-
kind = "aeroway";
266-
kindDetail = sf.getString("aeroway");
265+
kind = "aeroway"; //
266+
kindDetail = sf.getString("aeroway"); //
267267
} else if (sf.hasTag("railway", "disused", "funicular", "light_rail", "miniature", "monorail", "narrow_gauge",
268268
"preserved", "subway", "tram")) {
269-
kind = "rail";
270-
kindDetail = sf.getString("railway");
271-
minZoom = 14;
269+
kind = "rail"; //
270+
kindDetail = sf.getString("railway"); //
271+
minZoom = 14; //
272272

273273
if (sf.hasTag("railway", "disused")) {
274-
minZoom = 15;
274+
minZoom = 15; //
275275
}
276276
} else if (sf.hasTag("railway")) {
277-
kind = "rail";
278-
kindDetail = sf.getString("railway");
277+
kind = "rail"; //
278+
kindDetail = sf.getString("railway"); //
279279

280280
if (kindDetail.equals("service")) {
281-
minZoom = 13;
281+
minZoom = 13; //
282282

283283
// eg a rail yard
284284
if (sf.hasTag("service")) {
285-
minZoom = 14;
285+
minZoom = 14; //
286286
}
287287
}
288288
} else if (sf.hasTag("route", "ferry")) {
289-
kind = "ferry";
289+
kind = "ferry"; //
290290
} else if (sf.hasTag("man_made", "pier")) {
291-
kind = "path";
292-
kindDetail = "pier";
291+
kind = "path"; //
292+
kindDetail = "pier"; //
293293
} else if (sf.hasTag("aerialway")) {
294-
kind = "aerialway";
295-
kindDetail = sf.getString("aerialway");
294+
kind = "aerialway"; //
295+
kindDetail = sf.getString("aerialway"); //
296296
}
297297

298298
var feature = features.line(this.name())

tiles/src/test/java/com/protomaps/basemap/layers/RoadsTest.java

+144
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,148 @@ void testService() {
285285
)
286286
);
287287
}
288+
289+
@Test
290+
void testRailway() {
291+
assertFeatures(12,
292+
List.of(Map.of("kind", "rail",
293+
"kind_detail", "a",
294+
"_minzoom", 11
295+
)),
296+
processWithRelationAndCoords("",
297+
0, 0, 1, 1,
298+
"railway", "a"
299+
)
300+
);
301+
302+
assertFeatures(12,
303+
List.of(Map.of("kind", "rail",
304+
"kind_detail", "service",
305+
"_minzoom", 13
306+
)),
307+
processWithRelationAndCoords("",
308+
0, 0, 1, 1,
309+
"railway", "service"
310+
)
311+
);
312+
313+
assertFeatures(12,
314+
List.of(Map.of("kind", "rail",
315+
"kind_detail", "service",
316+
"_minzoom", 14
317+
)),
318+
processWithRelationAndCoords("",
319+
0, 0, 1, 1,
320+
"railway", "service",
321+
"service", "a"
322+
)
323+
);
324+
}
325+
326+
@ParameterizedTest
327+
@CsvSource({
328+
"funicular",
329+
"light_rail",
330+
"miniature",
331+
"monorail",
332+
"narrow_gauge",
333+
"preserved",
334+
"subway",
335+
"tram"
336+
})
337+
void testRailwaysSpecial(String railway) {
338+
assertFeatures(12,
339+
List.of(Map.of("kind", "rail",
340+
"kind_detail", railway,
341+
"_minzoom", 14
342+
)),
343+
processWithRelationAndCoords("",
344+
0, 0, 1, 1,
345+
"railway", railway
346+
)
347+
);
348+
}
349+
350+
@Test
351+
void testRailwayDisused() {
352+
assertFeatures(12,
353+
List.of(Map.of("kind", "rail",
354+
"kind_detail", "disused",
355+
"_minzoom", 15
356+
)),
357+
processWithRelationAndCoords("",
358+
0, 0, 1, 1,
359+
"railway", "disused"
360+
)
361+
);
362+
}
363+
364+
@Test
365+
void testAerialwayCableCar() {
366+
assertFeatures(12,
367+
List.of(Map.of("kind", "aerialway",
368+
"kind_detail", "cable_car",
369+
"_minzoom", 11
370+
)),
371+
processWithRelationAndCoords("",
372+
0, 0, 1, 1,
373+
"aerialway", "cable_car"
374+
)
375+
);
376+
}
377+
378+
@Test
379+
void testManMadePier() {
380+
assertFeatures(12,
381+
List.of(Map.of("kind", "path",
382+
"kind_detail", "pier",
383+
"_minzoom", 13
384+
)),
385+
processWithRelationAndCoords("",
386+
0, 0, 1, 1,
387+
"man_made", "pier"
388+
)
389+
);
390+
}
391+
392+
@Test
393+
void testRouteFerry() {
394+
assertFeatures(12,
395+
List.of(Map.of("kind", "ferry",
396+
"_minzoom", 11
397+
)),
398+
processWithRelationAndCoords("",
399+
0, 0, 1, 1,
400+
"route", "ferry"
401+
)
402+
);
403+
}
404+
405+
@Test
406+
void testAerowayTaxiway() {
407+
assertFeatures(12,
408+
List.of(Map.of("kind", "aeroway",
409+
"kind_detail", "taxiway",
410+
"_minzoom", 10
411+
)),
412+
processWithRelationAndCoords("",
413+
0, 0, 1, 1,
414+
"aeroway", "taxiway"
415+
)
416+
);
417+
}
418+
419+
@Test
420+
void testAerowayRunway() {
421+
assertFeatures(12,
422+
List.of(Map.of("kind", "aeroway",
423+
"kind_detail", "runway",
424+
"_minzoom", 9
425+
)),
426+
processWithRelationAndCoords("",
427+
0, 0, 1, 1,
428+
"aeroway", "runway"
429+
)
430+
);
431+
}
288432
}

0 commit comments

Comments
 (0)