Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into route-button
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Sep 30, 2024
2 parents 31577c9 + f285066 commit 4637e26
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 182 deletions.
6 changes: 6 additions & 0 deletions client/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ServerInfoTooltip } from './ServerInfoTooltip.tsx';
import { useRef, useState } from 'react';
import logo from '../../static/img/otp-logo.svg';
import GraphiQLRouteButton from './GraphiQLRouteButton.tsx';
import WheelchairAccessibleCheckBox from './WheelchairAccessibleCheckBox.tsx';

type SearchBarProps = {
onRoute: () => void;
Expand Down Expand Up @@ -50,6 +51,11 @@ export function SearchBar({ onRoute, tripQueryVariables, setTripQueryVariables,
tripQueryVariables={tripQueryVariables}
setTripQueryVariables={setTripQueryVariables}
/>
<WheelchairAccessibleCheckBox
tripQueryVariables={tripQueryVariables}
setTripQueryVariables={setTripQueryVariables}
/>

<div className="search-bar-route-button-wrapper">
<ButtonGroup>
<Button variant="primary" onClick={() => onRoute()} disabled={loading}>
Expand Down
35 changes: 35 additions & 0 deletions client/src/components/SearchBar/WheelchairAccessibleCheckBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Form } from 'react-bootstrap';
import wheelchairIcon from '../../static/img/wheelchair.svg';
import { TripQueryVariables } from '../../gql/graphql.ts';

export default function WheelchairAccessibleCheckBox({
tripQueryVariables,
setTripQueryVariables,
}: {
tripQueryVariables: TripQueryVariables;
setTripQueryVariables: (tripQueryVariables: TripQueryVariables) => void;
}) {
return (
<Form.Group>
<Form.Label column="sm" htmlFor="wheelchairAccessibleCheck">
<img
alt="Wheelchair Accessible Trip"
title="Wheelchair Accessible Trip"
src={wheelchairIcon}
width="20"
height="20"
className="d-inline-block align-middle"
/>
</Form.Label>
<Form.Check
id="wheelchairAccessible"
onChange={(e) => {
setTripQueryVariables({
...tripQueryVariables,
wheelchairAccessible: e.target.checked,
});
}}
></Form.Check>
</Form.Group>
);
}
6 changes: 6 additions & 0 deletions client/src/static/img/wheelchair.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions client/src/static/query/tripQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const query = graphql(`
$searchWindow: Int
$modes: Modes
$itineraryFiltersDebug: ItineraryFilterDebugProfile
$wheelchairAccessible: Boolean
$pageCursor: String
) {
trip(
Expand All @@ -22,6 +23,7 @@ export const query = graphql(`
searchWindow: $searchWindow
modes: $modes
itineraryFilters: { debug: $itineraryFiltersDebug }
wheelchairAccessible: $wheelchairAccessible
pageCursor: $pageCursor
) {
previousPageCursor
Expand Down
2 changes: 2 additions & 0 deletions doc/user/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Extra leg when transferring at the same stop [#5984](https://github.com/opentripplanner/OpenTripPlanner/pull/5984)
- Filter vector tiles stops by current service week [#6003](https://github.com/opentripplanner/OpenTripPlanner/pull/6003)
- Add a matcher API for filters in the transit service used for datedServiceJourneyQuery [#5713](https://github.com/opentripplanner/OpenTripPlanner/pull/5713)
- Refetch transit leg with a leg query of GTFS GraphQL API [#6045](https://github.com/opentripplanner/OpenTripPlanner/pull/6045)
- Remove deprecated support for GTFS flex stop areas [#6074](https://github.com/opentripplanner/OpenTripPlanner/pull/6074)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.6.0 (2024-09-18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.opentripplanner.model.plan.StreetLeg;
import org.opentripplanner.model.plan.TransitLeg;
import org.opentripplanner.model.plan.WalkStep;
import org.opentripplanner.model.plan.legreference.LegReferenceSerializer;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.alternativelegs.AlternativeLegs;
import org.opentripplanner.routing.alternativelegs.AlternativeLegsFilter;
Expand Down Expand Up @@ -189,10 +190,12 @@ public DataFetcher<Boolean> realTime() {
return environment -> getSource(environment).getRealTime();
}

// TODO
@Override
public DataFetcher<String> realtimeState() {
return environment -> null;
return environment -> {
var state = getSource(environment).getRealTimeState();
return (state != null) ? state.name() : null;
};
}

@Override
Expand Down Expand Up @@ -324,4 +327,15 @@ public DataFetcher<Iterable<Leg>> nextLegs() {
public DataFetcher<Double> accessibilityScore() {
return environment -> NumberMapper.toDouble(getSource(environment).accessibilityScore());
}

@Override
public DataFetcher<String> id() {
return environment -> {
var ref = getSource(environment).getLegReference();
if (ref == null) {
return null;
}
return LegReferenceSerializer.encode(ref);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.gtfs.mapping.DirectionMapper;
import org.opentripplanner.model.TripTimeOnDate;
import org.opentripplanner.model.plan.Leg;
import org.opentripplanner.model.plan.legreference.LegReference;
import org.opentripplanner.model.plan.legreference.LegReferenceSerializer;
import org.opentripplanner.routing.alertpatch.EntitySelector;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.api.request.RouteRequest;
Expand Down Expand Up @@ -362,6 +365,20 @@ public DataFetcher<Connection<PlaceAtDistance>> nearest() {
};
}

@Override
public DataFetcher<Leg> leg() {
return environment -> {
TransitService transitService = getTransitService(environment);
var args = new GraphQLTypes.GraphQLQueryTypeLegArgs(environment.getArguments());
String id = args.getGraphQLId();
LegReference ref = LegReferenceSerializer.decode(id);
if (ref == null) {
return null;
}
return ref.getLeg(transitService);
};
}

@Override
public DataFetcher<Object> node() {
return environment -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ public interface GraphQLLeg {

public DataFetcher<String> headsign();

public DataFetcher<String> id();

public DataFetcher<Boolean> interlineWithPreviousLeg();

public DataFetcher<Boolean> intermediatePlace();
Expand Down Expand Up @@ -779,6 +781,8 @@ public interface GraphQLQueryType {

public DataFetcher<Trip> fuzzyTrip();

public DataFetcher<Leg> leg();

public DataFetcher<Connection<PlaceAtDistance>> nearest();

public DataFetcher<Object> node();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,25 @@ public void setGraphQLTime(Integer time) {
}
}

public static class GraphQLQueryTypeLegArgs {

private String id;

public GraphQLQueryTypeLegArgs(Map<String, Object> args) {
if (args != null) {
this.id = (String) args.get("id");
}
}

public String getGraphQLId() {
return this.id;
}

public void setGraphQLId(String id) {
this.id = id;
}
}

public static class GraphQLQueryTypeNearestArgs {

private String after;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ private GraphQLSchema create() {
GraphQLFieldDefinition
.newFieldDefinition()
.name("leg")
.description("Refetch a single leg based on its id")
.description("Refetch a single transit leg based on its id")
.withDirective(gqlUtil.timingData)
.type(LegType.REF)
.argument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public static GraphQLObjectType create(
GraphQLFieldDefinition
.newFieldDefinition()
.name("id")
.description("An identifier for the leg, which can be used to re-fetch the information.")
.description(
"An identifier for the leg, which can be used to re-fetch transit leg information."
)
.type(Scalars.GraphQLID)
.dataFetcher(env -> LegReferenceSerializer.encode(leg(env).getLegReference()))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class GTFSToOtpTransitServiceMapper {

private final FareTransferRuleMapper fareTransferRuleMapper;

private final StopAreaMapper stopAreaMapper;
private final DirectionMapper directionMapper;

private final DataImportIssueStore issueStore;
Expand Down Expand Up @@ -112,9 +111,6 @@ public GTFSToOtpTransitServiceMapper(
boardingAreaMapper = new BoardingAreaMapper(translationHelper, stopLookup);
locationMapper = new LocationMapper(builder.stopModel(), issueStore);
locationGroupMapper = new LocationGroupMapper(stopMapper, locationMapper, builder.stopModel());
// the use of stop areas were reverted in the spec
// this code will go away, please migrate now!
stopAreaMapper = new StopAreaMapper(stopMapper, locationMapper, builder.stopModel());
pathwayMapper =
new PathwayMapper(stopMapper, entranceMapper, pathwayNodeMapper, boardingAreaMapper);
routeMapper = new RouteMapper(agencyMapper, issueStore, translationHelper);
Expand All @@ -126,7 +122,6 @@ public GTFSToOtpTransitServiceMapper(
stopMapper,
locationMapper,
locationGroupMapper,
stopAreaMapper,
tripMapper,
bookingRuleMapper,
translationHelper
Expand Down Expand Up @@ -166,7 +161,6 @@ public void mapStopTripAndRouteDataIntoBuilder() {
// Stop areas and Stop groups are only used in FLEX routes
builder.stopModel().withAreaStops(locationMapper.map(data.getAllLocations()));
builder.stopModel().withGroupStops(locationGroupMapper.map(data.getAllLocationGroups()));
builder.stopModel().withGroupStops(stopAreaMapper.map(data.getAllStopAreas()));
}

builder.getPathways().addAll(pathwayMapper.map(data.getAllPathways()));
Expand Down
72 changes: 0 additions & 72 deletions src/main/java/org/opentripplanner/gtfs/mapping/StopAreaMapper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.onebusaway.gtfs.model.Location;
import org.onebusaway.gtfs.model.LocationGroup;
import org.onebusaway.gtfs.model.Stop;
import org.onebusaway.gtfs.model.StopArea;
import org.opentripplanner.framework.collection.MapUtils;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.model.StopTime;
Expand All @@ -22,7 +21,6 @@ class StopTimeMapper {
private final LocationMapper locationMapper;

private final LocationGroupMapper locationGroupMapper;
private final StopAreaMapper stopAreaMapper;

private final TripMapper tripMapper;
private final BookingRuleMapper bookingRuleMapper;
Expand All @@ -35,15 +33,13 @@ class StopTimeMapper {
StopMapper stopMapper,
LocationMapper locationMapper,
LocationGroupMapper locationGroupMapper,
StopAreaMapper stopAreaMapper,
TripMapper tripMapper,
BookingRuleMapper bookingRuleMapper,
TranslationHelper translationHelper
) {
this.stopMapper = stopMapper;
this.locationMapper = locationMapper;
this.locationGroupMapper = locationGroupMapper;
this.stopAreaMapper = stopAreaMapper;
this.tripMapper = tripMapper;
this.bookingRuleMapper = bookingRuleMapper;
this.translationHelper = translationHelper;
Expand Down Expand Up @@ -71,8 +67,6 @@ private StopTime doMap(org.onebusaway.gtfs.model.StopTime rhs) {
case Stop stop -> lhs.setStop(stopMapper.map(stop));
case Location location -> lhs.setStop(locationMapper.map(location));
case LocationGroup locGroup -> lhs.setStop(locationGroupMapper.map(locGroup));
// TODO: only here for backwards compatibility, this will be removed in the future
case StopArea area -> lhs.setStop(stopAreaMapper.map(area));
default -> throw new IllegalArgumentException(
"Unknown location type: %s".formatted(stopLocation)
);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/opentripplanner/model/plan/Leg.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.organization.Operator;
import org.opentripplanner.transit.model.site.FareZone;
import org.opentripplanner.transit.model.timetable.RealTimeState;
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
import org.opentripplanner.transit.model.timetable.booking.BookingInfo;
Expand Down Expand Up @@ -244,6 +245,10 @@ default boolean getRealTime() {
return false;
}

default RealTimeState getRealTimeState() {
return null;
}

/**
* Whether this Leg describes a flexible trip. The reason we need this is that FlexTrip does not
* inherit from Trip, so that the information that the Trip is flexible would be lost when
Expand Down
Loading

0 comments on commit 4637e26

Please sign in to comment.