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

If configured, add subway station entrances from OSM to walk steps #6343

Open
wants to merge 48 commits into
base: dev-2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1d19a05
Add subway station entrances to walk steps
HenrikSundell Sep 18, 2024
67f4b1b
Add entity to walk steps
HenrikSundell Oct 2, 2024
9d18269
Add more parameters to Entrance
HenrikSundell Oct 3, 2024
3b88288
Move StepEntity classes
HenrikSundell Oct 7, 2024
0a62bf8
Remove default name for subway station entrances
HenrikSundell Oct 16, 2024
528ab55
Add option to turn on osm subway entrances in osmDefaults
HenrikSundell Oct 18, 2024
3e4ae96
Merge remote-tracking branch 'otp/dev-2.x' into station-entrances
HenrikSundell Oct 19, 2024
401a405
Fix walk step generation
HenrikSundell Oct 21, 2024
438bc31
Add step entity to graphql tests
HenrikSundell Oct 23, 2024
97c2de6
Rename variables to match with graphql
HenrikSundell Oct 25, 2024
d844561
Rename variables
HenrikSundell Oct 25, 2024
02a07ea
Rename function
HenrikSundell Oct 27, 2024
5dc74dd
Fix comments
HenrikSundell Oct 28, 2024
5d55646
Remove println
HenrikSundell Oct 28, 2024
d1067c6
Remove unnecessary imports
HenrikSundell Oct 28, 2024
5c97ad1
Add accessibilty information to entrances
HenrikSundell Oct 28, 2024
e10e0a2
Use existing entrance class for walk steps
HenrikSundell Nov 7, 2024
34761fe
Fix EntranceImpl
HenrikSundell Nov 7, 2024
c84b7cf
Add id to walk step entrances
HenrikSundell Nov 8, 2024
2ea8a52
Remove old file
HenrikSundell Nov 8, 2024
39b0db3
Fix otp version
HenrikSundell Nov 8, 2024
3b6bf3f
Remove unused import
HenrikSundell Nov 8, 2024
36be3dc
Merge remote-tracking branch 'otp/dev-2.x' into station-entrances
HenrikSundell Nov 8, 2024
c9df52d
Require entranceId
HenrikSundell Nov 10, 2024
7a9a8f6
Rename methods
HenrikSundell Nov 10, 2024
c9139e3
Update dosumentation
HenrikSundell Nov 11, 2024
7b21024
Update documentation
HenrikSundell Nov 11, 2024
ce7719c
Remove redundant null check
HenrikSundell Nov 11, 2024
b737411
Add feature union to steps
HenrikSundell Nov 14, 2024
f547e07
Return feature based on relativeDirection
HenrikSundell Nov 14, 2024
18b84f0
Remove StepFeature class
HenrikSundell Nov 14, 2024
a327594
Merge remote-tracking branch 'upstream/dev-2.x' into station-entrances
leonardehrenfried Dec 17, 2024
04d35b7
Clean up code a little
leonardehrenfried Dec 17, 2024
c4d665d
Reformat code and schema
leonardehrenfried Dec 17, 2024
bf89f49
Fix tests
leonardehrenfried Dec 17, 2024
2eb0e7b
Add documentation
leonardehrenfried Dec 18, 2024
4fd0f68
Merge remote-tracking branch 'upstream/dev-2.x' into station-entrances
leonardehrenfried Dec 18, 2024
977d8eb
Clean up
leonardehrenfried Dec 18, 2024
b7cc6fd
Remove enum mapper test for REST API
leonardehrenfried Dec 18, 2024
e473061
Fix highway exits
leonardehrenfried Dec 18, 2024
713143b
Use three states for accessibility
leonardehrenfried Jan 2, 2025
0b6a74a
Update documentation
leonardehrenfried Jan 2, 2025
5b12c7f
Update docs
leonardehrenfried Jan 6, 2025
8c6fda4
Extract entrance from transit link
leonardehrenfried Jan 6, 2025
bd94b13
Add test for extracting entrance from pathway data
leonardehrenfried Jan 6, 2025
74106b5
Update schema docs
leonardehrenfried Jan 6, 2025
628bf95
Rename 'code' to 'publicCode'
leonardehrenfried Jan 7, 2025
4248ffe
Fix mapping in Transmodel API
leonardehrenfried Jan 10, 2025
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
@@ -0,0 +1,33 @@
package org.opentripplanner.apis.transmodel.mapping;

import org.opentripplanner.model.plan.RelativeDirection;

/**
* This mapper makes sure that only those values are returned which have a mapping in the Transmodel API,
* as we don't really want to return all of them.
*/
public class RelativeDirectionMapper {

public static RelativeDirection map(RelativeDirection relativeDirection) {
return switch (relativeDirection) {
case DEPART,
SLIGHTLY_LEFT,
HARD_LEFT,
LEFT,
CONTINUE,
SLIGHTLY_RIGHT,
RIGHT,
HARD_RIGHT,
CIRCLE_CLOCKWISE,
CIRCLE_COUNTERCLOCKWISE,
ELEVATOR,
UTURN_LEFT,
UTURN_RIGHT -> relativeDirection;
// for these the Transmodel API doesn't have a mapping. should it?
case ENTER_STATION,
EXIT_STATION,
ENTER_OR_EXIT_STATION,
FOLLOW_SIGNS -> RelativeDirection.CONTINUE;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import org.opentripplanner.apis.transmodel.mapping.RelativeDirectionMapper;
import org.opentripplanner.apis.transmodel.model.EnumTypes;
import org.opentripplanner.framework.graphql.GraphQLUtils;
import org.opentripplanner.model.plan.WalkStep;
Expand All @@ -31,7 +32,9 @@ public static GraphQLObjectType create(GraphQLObjectType elevationStepType) {
.name("relativeDirection")
.description("The relative direction of this step.")
.type(EnumTypes.RELATIVE_DIRECTION)
.dataFetcher(environment -> ((WalkStep) environment.getSource()).getRelativeDirection())
.dataFetcher(environment ->
RelativeDirectionMapper.map(((WalkStep) environment.getSource()).getRelativeDirection())
)
.build()
)
.field(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package org.opentripplanner.apis.transmodel.model;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.opentripplanner.apis.transmodel.model.EnumTypes.RELATIVE_DIRECTION;
import static org.opentripplanner.apis.transmodel.model.EnumTypes.ROUTING_ERROR_CODE;
import static org.opentripplanner.apis.transmodel.model.EnumTypes.map;

import graphql.GraphQLContext;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.opentripplanner.apis.transmodel.mapping.RelativeDirectionMapper;
import org.opentripplanner.framework.doc.DocumentedEnum;
import org.opentripplanner.model.plan.RelativeDirection;
import org.opentripplanner.routing.api.response.RoutingErrorCode;

class EnumTypesTest {
Expand Down Expand Up @@ -75,6 +84,18 @@ void testMap() {
assertEquals("DocumentedEnumMapping[apiName=iH, internal=Hi]", mapping.toString());
}

@ParameterizedTest
@EnumSource(RelativeDirection.class)
Copy link
Member

Choose a reason for hiding this comment

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

Cool, didn't know this was possible.

void serializeRelativeDirection(RelativeDirection direction) {
var value = RELATIVE_DIRECTION.serialize(
RelativeDirectionMapper.map(direction),
GraphQLContext.getDefault(),
Locale.ENGLISH
);
assertInstanceOf(String.class, value);
assertNotNull(value);
}

@Test
void assertAllRoutingErrorCodesAreMapped() {
var expected = EnumSet.allOf(RoutingErrorCode.class);
Expand Down
Loading