Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* This enum defines the railway class of an edge. It maps the railway=* key of OSM to an enum. All edges that do not fit get OTHER as value.
*/
public enum RailwayClass {
OTHER, RAIL, SUBWAY, TRAM, LIGHT_RAIL, FUNICULAR, CONSTRUCTION, MONORAIL, PROPOSED;
OTHER, RAIL, SUBWAY, TRAM, LIGHT_RAIL, FUNICULAR, CONSTRUCTION, MONORAIL, PROPOSED, NARROW_GAUGE, MINIATURE;
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency and to avoid unexpected ordinal values, consider inserting the new enum constants in alphabetical order or documenting that the order is intentional.

Suggested change
OTHER, RAIL, SUBWAY, TRAM, LIGHT_RAIL, FUNICULAR, CONSTRUCTION, MONORAIL, PROPOSED, NARROW_GAUGE, MINIATURE;
CONSTRUCTION, FUNICULAR, LIGHT_RAIL, MINIATURE, MONORAIL, NARROW_GAUGE, OTHER, PROPOSED, RAIL, SUBWAY, TRAM;

Copilot uses AI. Check for mistakes.

public static final String KEY = "railway_class";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class RailAccessParser extends AbstractAccessParser {

public static final String DEFAULT_NAME = "rail";
private static final Set<String> ALLOWED_RAIL_TYPES = Set.of(
"rail", "light_rail", "tram", "subway", "construction", "proposed", "funicular", "monorail"
"rail", "light_rail", "tram", "subway", "construction", "proposed", "funicular", "monorail", "narrow_gauge", "miniature"
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider sorting the entries in ALLOWED_RAIL_TYPES alphabetically for readability and easier maintenance.

Suggested change
"rail", "light_rail", "tram", "subway", "construction", "proposed", "funicular", "monorail", "narrow_gauge", "miniature"
"construction", "funicular", "light_rail", "miniature", "monorail", "narrow_gauge", "proposed", "rail", "subway", "tram"

Copilot uses AI. Check for mistakes.
);

public RailAccessParser(BooleanEncodedValue accessEnc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void railwayClass() {
way = new ReaderWay(29L);
way.setTag("railway", "narrow_gauge");
parser.handleWayTags(edgeId, edgeIntAccess, way, relFlags);
assertEquals(RailwayClass.OTHER, classEnc.getEnum(false, edgeId, edgeIntAccess));
assertEquals(RailwayClass.NARROW_GAUGE, classEnc.getEnum(false, edgeId, edgeIntAccess));

edgeIntAccess = new ArrayEdgeIntAccess(1);
way = new ReaderWay(29L);
Expand Down Expand Up @@ -88,6 +88,12 @@ void railwayClass() {
way.setTag("railway", "monorail");
parser.handleWayTags(edgeId, edgeIntAccess, way, relFlags);
assertEquals(RailwayClass.MONORAIL, classEnc.getEnum(false, edgeId, edgeIntAccess));

edgeIntAccess = new ArrayEdgeIntAccess(1);
way = new ReaderWay(29L);
way.setTag("railway", "miniature");
parser.handleWayTags(edgeId, edgeIntAccess, way, relFlags);
assertEquals(RailwayClass.MINIATURE, classEnc.getEnum(false, edgeId, edgeIntAccess));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,29 @@ public void testRejectRoad() {
}

@Test
public void testRejectsNarrowGauge() {
public void testAcceptsNarrowGauge() {
PMap properties = new PMap();
RailAccessParser e = createAccessParser(createEncodingManager(), properties);
ReaderWay way = new ReaderWay(1);
way.setTag("railway", "narrow_gauge");
assertEquals(e.getAccess(way), WayAccess.WAY);
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters in assertEquals are reversed. Swap them to assertEquals(WayAccess.WAY, e.getAccess(way)) to match the expected-then-actual convention.

Suggested change
assertEquals(e.getAccess(way), WayAccess.WAY);
assertEquals(WayAccess.WAY, e.getAccess(way));

Copilot uses AI. Check for mistakes.
}

@Test
public void testAcceptsMiniature() {
PMap properties = new PMap();
RailAccessParser e = createAccessParser(createEncodingManager(), properties);
ReaderWay way = new ReaderWay(1);
way.setTag("railway", "miniature");
assertEquals(e.getAccess(way), WayAccess.WAY);
}

@Test
public void testRejectsAbandoned() {
PMap properties = new PMap();
RailAccessParser e = createAccessParser(createEncodingManager(), properties);
ReaderWay way = new ReaderWay(1);
way.setTag("railway", "abandoned");
assertEquals(WayAccess.CAN_SKIP, e.getAccess(way));
}
}
Loading