Skip to main content

Public Transit Stops

|

This API provides access to public transport data including agencies, routes, stops, and trips. Fetch and explore real-time public transportation information from selected positions on the map.

Tip

The public transport data structure follows the General Transit Feed Specification (GTFS) and offers access to a subset of GTFS fields and entities.

Key features:

  • Query public transport overlays by screen position
  • Retrieve information about transport agencies, stops, routes, and trips
  • Access real-time data including delays and cancellations
  • View metadata about accessibility, bike allowances, and platform details
  • Filter trips by route type, route short name, or agency

How it works:

  • Set a position on the map using setCursorScreenPosition
  • Query for public transport overlays with cursorSelectionOverlayItems
  • Retrieve stop information using getPreviewExtendedData() on each overlay item of ECommonOverlayId::OID_PublicTransport type.
  • Use the populated SearchableParameterList object to explore agencies, stops, and trips

Query Public Transit Stops

class MyMapViewListenerImpl : public IMapViewListener
{
public:

void setMapView(StrongPointer<MapView> mv)
{
mapView = mv;
}

void onLongDown(const Xy &pos) override
{
// Set cursor position on the screen.
mapView->setCursorScreenPosition(pos);

// Wait for the map view to fully load the tiles

// Get the overlay items at that position.
auto items = mapView->cursorSelectionOverlayItems();

// For each overlay item at that position.
for (auto item : items)
{
auto overlayId = item.getOverlayUid();

// We're interested only in public tranposrt overlay items.
if(overlayId == ECommonOverlayId::OID_PublicTransport)
{
// Declare the searchable parameter list that will get populated with the public transit data.
SearchableParameterList ptStopInfo;

item.getPreviewExtendedData(ptStopInfo, yourProgressListenerImpl);

// Wait for the operation to complete (replace with your own synchronization mechanism).
WAIT_UNTIL( std::bind( &YourProgressListenerImpl::IsFinished, yourProgressListenerImpl ), 15000 );

// Start using the information, it must contain data now.
if (!ptStopInfo.empty())
{
// Information about agencies.
auto agencies = ptStopInfo.find<gem::SearchableParameterList>(opid::kPT_agencies);

// Information about stops and generic routes
// (routes that don't have `heading` set)
auto stops = ptStopInfo.find<gem::SearchableParameterList>(opid::kPT_stops);

// Information about trips (together with
// route, agency, stop times, real-time info, etc.)
auto trips = ptStopInfo.find<gem::SearchableParameterList>(opid::kPT_trips);

// Go through stops.
for (auto stop : stops.first)
{
// Get the stop details.
auto stopDetails = stop.getValue<gem::SearchableParameterList>();

GEM_INFO_LOG("Stop id: %llu", stopDetails.find<gem::LargeInteger>(opid::kPT_stop_id).first);
GEM_INFO_LOG("Stop name: %s", stopDetails.find<gem::String>(opid::kPT_stop_name).first);

GEM_INFO_LOG("Routes:");

auto stopRoutes = stopDetails.find<gem::SearchableParameterList>(opid::kPT_stop_routes);

// Go through the routes that visit this stop
for (auto route : stopRoutes.first)
{
auto routeDetails = route.getValue<gem::SearchableParameterList>();

GEM_INFO_LOG(" Route id: %llu", routeDetails.find<gem::LargeInteger>(opid::kPT_route_id).first);
GEM_INFO_LOG(" Route short name: %s", routeDetails.find<gem::String>(opid::kPT_route_short_name).first);
GEM_INFO_LOG(" Route long name: %s", routeDetails.find<gem::String>(opid::kPT_route_long_name).first);
}
}
}
}
}

}
private:
StrongPointer<MapView> mapView;
};
Tip

Obtain SearchableParameterList instances with public transit data by performing an overlay search using ECommonOverlayId::OID_PublicTransport. Retrieve the corresponding OverlayItems and use their getPreviewExtendedData method to access stop information.

See the Search on overlays guide for details.

danger

All returned times are local times represented as epoch time values in UTC (timezone offset 0). Use the TimezoneService to convert them to other time zones.

danger

Two types of public transit stops exist on the map:

  • OverlayItem stops selected via cursorSelectionOverlayItems - provide extensive extendedData details and display with a blue icon (default style) - available only in Online mode.
  • Landmark stops selected via cursorSelectionLandmarks - provide limited details and display with a gray icon (default style) - available in Offline mode.

The public transit overlay items might hide the equivalent landmarks in the same area.


Agencies

A SearchableParameterList containing an Agency has the following values:

KeyTypeDescription
agency_idintAgency ID
agency_nameStringFull name of the transit agency.
agency_urlStringOptional URL of the transit agency.

Public Transport Routes

A SearchableParameterList containing a public transit Route has the following values:

KeyTypeDescription
route_idLargeIntegerRoute ID
route_short_nameStringShort name of a route. Often a short, abstract identifier (e.g., "32", "100X") that riders use to identify a route. May be null.
rout_long_nameStringFull name of a route. This name is generally more descriptive than the short name and often includes the route's destination or stop.
route_typeintType of route. Check opid::pt::ERouteType values.
route_colorStringRoute color designation that matches public-facing material. May be used to color the route on the map or to be shown on UI elements. In hex format.
route_text_ColorStringLegible color to use for text drawn against a background of routeColor. In hex format.
route_headingStringOptional heading information.

Route Types

The opid::pt::EPTRouteType enum represents the type of public transport route:

Enum CaseDescription
RT_BusBus, Trolleybus. Used for short and long-distance bus routes.
RT_UndergroundSubway, Metro. Any underground rail system within a metropolitan area.
RT_RailwayRail. Used for intercity or long-distance travel.
RT_TramTram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.
RT_WaterTransportWater transport. Used for ferries and other water-based transit.
RT_MiscMiscellaneous. Includes other types of public transport not covered by the other categories.

Stops

A SearchableParameterList containing a public transit Stop has the following values:

KeyTypeDescription
stop_idLargeIntegerIdentifies a location: stop/platform, station, entrance/exit, node or boarding area
stop_nameStringName of the location. Matches the agency's rider-facing name for the location as printed on a timetable, published online, or represented on signage.
is_stationboolWhether this location is a station or not. A station is considered a physical structure or area that contains one or more platforms.
routesSearchableParameterList Associated routes for the stop. Contains all routes serving this stop, whether active at the given time or not.

Stop Times

A SearchableParameterList containing a public transit Stop Time has the following values:

KeyTypeDescription
stop_nameStringThe name of the serviced stop.
departure_timeintOptional departure time in the local timezone.
has_realtimeboolWhether data is provided in real-time or not.
delayintDelay in seconds. Not available if has_realtime is false.
is_beforeboolWhether the stop time is before the current time.
stop_detailsintBitwise details about bike or wheelchair accessibility.
latdoubleWGS latitude for the stop.
londoubleWGS longitude for the stop.

Trips

A SearchableParameterList containing a public transit Trip has the following values:

KeyTypeDescription
agency_idintAssociated agency id.
trip_indexintTrip index.
trip_dateintThe date of the trip as epoch.
departure_timeintDeparture time of the trip from the first stop as epoch.
has_realtimeboolWhether real-time data is available.
is_cancelledboolWhether the trip is cancelled by realtime.
delay_minutesintDelay in minutes. Not available if has_realtime is false.
stop_timesSearchableParameterListDetails of stop times in the trip.
stop_indexintThe current stop index inside the whole list of stops that this trip passes through. This value changes based on which stop you tap on the map.
stop_platform_codeStringPlatform code. For example inside train stations.
is_wheelchair_accessibleboolWhether the stop is wheelchair accessible.
is_bike_allowedboolWhether bikes are allowed on the stop.
danger

A public transit Route represents the public-facing service riders recognize (e.g., "Bus 42"). A public transit Trip is a single scheduled journey along that route at a specific time with its own stop times and sequence. The route is the line identity; trips are individual vehicle runs throughout the day.


Public Transit Extended Data

A SearchableParameterList containing a public transit extended data has the following values:

KeyTypeDescription
agenciesSearchableParameterListAgencies serving the selected item.
tripsSearchableParameterListTrips in which the selected item is involved.
stopsSearchableParameterListStops associated with the trips.