diff --git a/README.md b/README.md index 844df2d..41bf544 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Compatible with Android 8+ To integrate the SDK you have to add following dependency: ``` dependencies { - implementation 'io.github.opentdatach:ojp-android:1.3.7' + implementation 'io.github.opentdatach:ojp-android:1.4.0' } ``` @@ -71,21 +71,21 @@ requestLocationsFromCoordinates( ) ``` -#### Get a list of trips including disruption messages +#### Get a list of trips ``` import ch.opentransportdata.ojp.OjpSdk requestTrips( - languageCode = LanguageCode.EN + languageCode = LanguageCode.EN, origin = PlaceReferenceDto( ref = "8507000", - stationName = NameDto(text = "Bern") , - position = null + stationName = NameDto(text = "Bern"), + position = null ), destination = PlaceReferenceDto( ref = "8500010", - stationName = NameDto(text = "Basel SBB") , - position = null + stationName = NameDto(text = "Basel SBB"), + position = null ), via = null, time = LocalDateTime.now(), @@ -94,19 +94,63 @@ requestTrips( numberOfResults = 10, includeIntermediateStops = true, includeAllRestrictedLines = true, - useRealtimeData = RealtimeData.EXPLANATORY + useRealtimeData = RealtimeData.EXPLANATORY, + optimisationMethod = OptimisationMethod.FASTEST, + walkSpeed = 100, + transferLimit = 3, + bikeTransport = false, + modeAndModeOfOperationFilter = listOf( + ModeAndModeOfOperationFilter( + ptMode = listOf(PtMode.RAIL), + exclude = false, + railSubmode = RailSubmode.HIGH_SPEED_RAIL + ) + ) ), -) + individualTransportOption = IndividualTransportOptionDto( + itModeAndModeOfOperation = ItModeAndModeOfOperationDto( + personalMode = "walk" + ), + maxDistance = 500, + maxDuration = Duration.ofMinutes(10) + ) +) ``` -#### Get a list of mocked trips for testing purposes +The `individualTransportOption` parameter allows you to specify individual transport options (e.g. walking, cycling) for the first/last mile of a trip. It accepts an `IndividualTransportOptionDto` with the following optional fields: +- `itModeAndModeOfOperation`: The personal mode and mode of operation (e.g. `walk`, `cycle`) +- `minDistance` / `maxDistance`: Distance constraints in meters +- `minDuration` / `maxDuration`: Duration constraints as `java.time.Duration` + +#### Load previous or next trips +After a `requestTrips` call you can page through results without re-initialising the request: ``` import ch.opentransportdata.ojp.OjpSdk -requestMockTrips(stream = source) +// Load trips before the first result of the current list +requestPreviousTrips(numberOfResults = 5) + +// Load trips after the last result of the current list +requestNextTrips(numberOfResults = 5) ``` #### Update an existing trip +Re-request a single trip with the same origin/destination to get fresh real-time data: +``` +import ch.opentransportdata.ojp.OjpSdk + +updateTripData( + 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, + params = TripParams(useRealtimeData = RealtimeData.FULL), + trip = existingTrip, + individualTransportOption = null +) +``` + +#### Refine a trip ``` import ch.opentransportdata.ojp.OjpSdk @@ -114,16 +158,23 @@ requestTripRefinement( languageCode = Locale.getDefault().language.toOjpLanguageCode(), tripResult = tripResult, params = TripRefineParam( - includeIntermediateStops = true, - includeAllRestrictedLines = true, - includeTurnDescription = true, - includeLegProjection = true, - includeTrackSections = true, - useRealtimeData = RealtimeData.FULL + includeIntermediateStops = true, + includeAllRestrictedLines = true, + includeTurnDescription = true, + includeLegProjection = true, + includeTrackSections = true, + useRealtimeData = RealtimeData.FULL ) ) ``` +#### Get a list of mocked trips for testing purposes +``` +import ch.opentransportdata.ojp.OjpSdk + +requestMockTrips(stream = source) +``` + ## Documentation [Documentation of the Android SDK](https://opentdatach.github.io/ojp-android/) diff --git a/gradle.properties b/gradle.properties index a58d5ac..7926758 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true # Project information -VERSION=1.3.7 +VERSION=1.4.0 GROUP_ID=io.github.opentdatach ARTIFACT_ID=ojp-android # POM meta data diff --git a/sdk/src/main/java/ch/opentransportdata/ojp/domain/model/OptimisationMethod.kt b/sdk/src/main/java/ch/opentransportdata/ojp/domain/model/OptimisationMethod.kt index 1a4ae15..dcb51c4 100644 --- a/sdk/src/main/java/ch/opentransportdata/ojp/domain/model/OptimisationMethod.kt +++ b/sdk/src/main/java/ch/opentransportdata/ojp/domain/model/OptimisationMethod.kt @@ -9,9 +9,12 @@ import kotlinx.serialization.Serializable @Serializable enum class OptimisationMethod { @SerialName("minChanges") - MIN_CHANGES + MIN_CHANGES, + @SerialName("fastest") + FASTEST, } fun OptimisationMethod.serializedName(): String = when (this) { OptimisationMethod.MIN_CHANGES -> "minChanges" + OptimisationMethod.FASTEST -> "fastest" } \ No newline at end of file