Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 68 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```

Expand Down Expand Up @@ -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(),
Expand All @@ -94,36 +94,87 @@ 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

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/)

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading