This SDK is targeting Android applications seeking to integrate Open Journey Planner(OJP) APIs to support distributed journey planning according to the European (CEN) Technical Specification entitled “Intelligent transport systems – Public transport – Open API for distributed journey planning”
Available APIs:
- Location Information Request
- Trip Request
- Trip Refinement Request
Coming soon:
Compatible with Android 6+
To integrate the SDK you have to add following dependency:
dependencies {
implementation 'io.github.opentdatach:ojp-android:1.2.1'
}
Additionally you may need to enable coreLibraryDesugaring to use Java8 features below API 26 (we use LocalDateTime for parsing)
compileOptions {
isCoreLibraryDesugaringEnabled = true
...
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
...
}
Initialize the SDK with your custom configuration:
OjpSdk(
baseUrl = "Your Base URL",
endpoint = "Your Endpoint",
requesterReference = "Your Requester Reference",
httpHeaders = hashMapOf(
"Authorization" to "Bearer myAccessToken",
"Custom-Header" to "CustomValue"
),
defaultTimeZone = ZoneId.of("Europe/Zurich")
)
import ch.opentransportdata.ojp.OjpSdk
requestLocationsFromSearchTerm(
languageCode = LanguageCode.EN,
term = "Bern",
restrictions = LocationInformationParams(
types = listOf(PlaceTypeRestriction.STOP, PlaceTypeRestriction.ADDRESS),
numberOfResults = 10,
ptModeIncluded = true
)
)
import ch.opentransportdata.ojp.OjpSdk
requestLocationsFromCoordinates(
languageCode = LanguageCode.EN,
longitude = 5.6,
latitude = 2.3,
restrictions = LocationInformationParams(
types = listOf(PlaceTypeRestriction.STOP),
numberOfResults = 10,
ptModeIncluded = true
)
)
import ch.opentransportdata.ojp.OjpSdk
requestTrips(
languageCode = LanguageCode.EN
origin = PlaceReferenceDto(
ref = "8507000",
stationName = NameDto(text = "Bern") ,
position = null
),
destination = PlaceReferenceDto(
ref = "8500010",
stationName = NameDto(text = "Basel SBB") ,
position = null
),
via = null,
time = LocalDateTime.now(),
isSearchForDepartureTime = true,
params = TripParams(
numberOfResults = 10,
includeIntermediateStops = true,
includeAllRestrictedLines = true,
useRealtimeData = RealtimeData.EXPLANATORY
),
)
import ch.opentransportdata.ojp.OjpSdk
requestMockTrips(stream = source)
import ch.opentransportdata.ojp.OjpSdk
requestTripRefinement(
languageCode = Locale.getDefault().language.toOjpLanguageCode(),
tripResult = tripResult,
params = TripRefineParam(
includeIntermediateStops = true,
includeAllRestrictedLines = true,
includeTurnDescription = true,
includeLegProjection = true,
includeTrackSections = true,
useRealtimeData = RealtimeData.FULL
)
)
Documentation of the Android SDK
Contributions are welcomed. Feel free to create an issue or a feature request, or fork the project and submit a pull request.
Apache License, see LICENSE
Create an issue or contact opentransportdata.swiss