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

Add feed publisher name and url to GTFS GraphQL API #5835

Merged
merged 10 commits into from
Jun 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ protected static GraphQLSchema buildSchema() {
.type(typeWiring.build(DepartureRowImpl.class))
.type(typeWiring.build(elevationProfileComponentImpl.class))
.type(typeWiring.build(FeedImpl.class))
.type(typeWiring.build(FeedImpl.class))
.type(typeWiring.build(GeometryImpl.class))
.type(typeWiring.build(ItineraryImpl.class))
.type(typeWiring.build(LegImpl.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ public DataFetcher<String> feedId() {
return this::getSource;
}

@Override
public DataFetcher<String> publisherName() {
return environment -> {
String id = getSource(environment);
return getTransitService(environment).getFeedInfo(id).getPublisherName();
};
}

@Override
public DataFetcher<String> publisherUrl() {
return environment -> {
String id = getSource(environment);
return getTransitService(environment).getFeedInfo(id).getPublisherUrl();
};
}

private List<Agency> getAgencies(DataFetchingEnvironment environment) {
String id = getSource(environment);
return getTransitService(environment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ public interface GraphQLFeed {
public DataFetcher<Iterable<TransitAlert>> alerts();

public DataFetcher<String> feedId();

public DataFetcher<String> publisherName();

public DataFetcher<String> publisherUrl();
}

public interface GraphQLGeometry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ type Feed {
"""List of agencies which provide data to this feed"""
agencies: [Agency]

"""Name of feed publisher"""
publisherName: String!

"""Web address of feed publisher"""
publisherUrl: String!

"""
Alerts relevant for the feed.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.i18n.NonLocalizedString;
import org.opentripplanner.framework.model.Grams;
import org.opentripplanner.model.FeedInfo;
import org.opentripplanner.model.fare.FareMedium;
import org.opentripplanner.model.fare.FareProduct;
import org.opentripplanner.model.fare.ItineraryFares;
Expand Down Expand Up @@ -84,6 +85,7 @@
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.BikeAccess;
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.timetable.RealTimeTripTimes;
Expand Down Expand Up @@ -151,6 +153,18 @@ static void setup() {

transitModel.addTripPattern(id("pattern-1"), pattern);

var feedId = "testfeed";
var feedInfo = FeedInfo.dummyForTest(feedId);
transitModel.addFeedInfo(feedInfo);

var agency = Agency
.of(new FeedScopedId(feedId, "agency-xx"))
.withName("speedtransit")
.withUrl("www.otp-foo.bar")
.withTimezone("Europe/Berlin")
.build();
transitModel.addAgency(agency);

transitModel.initTimeZone(ZoneIds.BERLIN);
transitModel.index();
var routes = Arrays
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data" : {
"feeds" : [
{
"agencies" : [
{
"name" : "speedtransit",
"url" : "www.otp-foo.bar"
}
],
"publisherUrl" : "www.z.org",
"publisherName" : "publisher"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
feeds {
agencies {
name
url
}
publisherUrl
vesameskanen marked this conversation as resolved.
Show resolved Hide resolved
publisherName
}
}
Loading