Skip to content

Commit

Permalink
add bikeRentalStationsByBbox
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDiaconu97 committed Sep 13, 2023
1 parent c353378 commit f08b23d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -3164,6 +3164,38 @@ public int compare(TripTimeShort tripTimeShort, TripTimeShort t1) {
.findFirst()
.orElse(null))
.build())
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("bikeRentalStationsByBbox")
.description("Get all bikeRentalStations for the specified graph in a bounding box")
.type(new GraphQLList(bikeRentalStationType))
.argument(GraphQLArgument.newArgument()
.name("minLat")
.type(Scalars.GraphQLFloat)
.build())
.argument(GraphQLArgument.newArgument()
.name("minLon")
.type(Scalars.GraphQLFloat)
.build())
.argument(GraphQLArgument.newArgument()
.name("maxLat")
.type(Scalars.GraphQLFloat)
.build())
.argument(GraphQLArgument.newArgument()
.name("maxLon")
.type(Scalars.GraphQLFloat)
.build())
.dataFetcher(environment -> {
Envelope envelope = new Envelope(
new Coordinate(environment.getArgument("minLon"), environment.getArgument("minLat")),
new Coordinate(environment.getArgument("maxLon"), environment.getArgument("maxLat")));
return new ArrayList<>(index.graph.getService(BikeRentalStationService.class) != null
? index.graph.getService(BikeRentalStationService.class).getBikeRentalStations()
.stream()
.filter(station -> envelope.contains(new Coordinate(station.x,station.y)))
.collect(Collectors.toList())
: Collections.EMPTY_LIST);
})
.build())
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("bikeParks")
.description("Get all bike parks")
Expand Down

0 comments on commit f08b23d

Please sign in to comment.