-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6343 from leonardehrenfried/station-entrances
If configured, add subway station entrances from OSM to walk steps
- Loading branch information
Showing
42 changed files
with
516 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/EntranceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.opentripplanner.apis.gtfs.datafetchers; | ||
|
||
import graphql.schema.DataFetcher; | ||
import org.opentripplanner.apis.gtfs.GraphQLUtils; | ||
import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; | ||
import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; | ||
import org.opentripplanner.transit.model.site.Entrance; | ||
|
||
public class EntranceImpl implements GraphQLDataFetchers.GraphQLEntrance { | ||
|
||
@Override | ||
public DataFetcher<String> publicCode() { | ||
return environment -> { | ||
Entrance entrance = environment.getSource(); | ||
return entrance.getCode(); | ||
}; | ||
} | ||
|
||
@Override | ||
public DataFetcher<String> entranceId() { | ||
return environment -> { | ||
Entrance entrance = environment.getSource(); | ||
return entrance.getId().toString(); | ||
}; | ||
} | ||
|
||
@Override | ||
public DataFetcher<String> name() { | ||
return environment -> { | ||
Entrance entrance = environment.getSource(); | ||
return org.opentripplanner.framework.graphql.GraphQLUtils.getTranslation( | ||
entrance.getName(), | ||
environment | ||
); | ||
}; | ||
} | ||
|
||
@Override | ||
public DataFetcher<GraphQLTypes.GraphQLWheelchairBoarding> wheelchairAccessible() { | ||
return environment -> { | ||
Entrance entrance = environment.getSource(); | ||
return GraphQLUtils.toGraphQL(entrance.getWheelchairAccessibility()); | ||
}; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ion/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StepFeatureTypeResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.opentripplanner.apis.gtfs.datafetchers; | ||
|
||
import graphql.TypeResolutionEnvironment; | ||
import graphql.schema.GraphQLObjectType; | ||
import graphql.schema.GraphQLSchema; | ||
import graphql.schema.TypeResolver; | ||
import org.opentripplanner.transit.model.site.Entrance; | ||
|
||
public class StepFeatureTypeResolver implements TypeResolver { | ||
|
||
@Override | ||
public GraphQLObjectType getType(TypeResolutionEnvironment environment) { | ||
Object o = environment.getObject(); | ||
GraphQLSchema schema = environment.getSchema(); | ||
|
||
if (o instanceof Entrance) { | ||
return schema.getObjectType("Entrance"); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...on/src/main/java/org/opentripplanner/apis/transmodel/mapping/RelativeDirectionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.