Closed barbeau closed 7 years ago
This will need to be enabled via feature in https://github.com/OneBusAway/onebusaway-client-library/issues/16.
This feature is now supported in the library (via https://github.com/OneBusAway/onebusaway-client-library/commit/723ac7400ef9dbeb084f4782c0fbe28197857683, fixed in https://github.com/OneBusAway/onebusaway-client-library/issues/16), so this issue is unblocked.
Here's an example code of how to request ETAs vs. clock times:
// Make HTTP request and get the response from the OBA server
ObaArrivalInfoResponse response =
new ObaArrivalInfoRequest.Builder("Hillsborough%20Area%20Regional%20Transit_10001").build().call();
ObaArrivalInfo[] arrivals = response.getArrivalInfo();
boolean includeArriveDepartLabels = true;
final String SEPARATOR = "\n";
boolean clocktime = true; // true for clock times like "arriving at 10:05 PM", false for ETAs like "arriving in 9 minutes"
List<ArrivalInfo> arrivalInfo = ArrivalInfo.convertObaArrivalInfo(arrivals, null,
response.getCurrentTime(), includeArriveDepartLabels, clocktime);
String summary = UIUtils.getArrivalInfoSummary(arrivalInfo, SEPARATOR, clocktime);
Spoke too soon - there is a timezone issue that still needs to be resolved in the library - see https://github.com/OneBusAway/onebusaway-client-library/issues/19#issuecomment-279198900 for details.
In case anyone following this issue already knows the answer to this - is there a built-in way to get the timezone of a device for an incoming Alexa request?
This issue is unblocked again - there is now a timeZone
parameter for the related methods which allows the application to specify which timezone should be used when calculating the clock time. For example:
// Make HTTP request and get the response from the OBA server
ObaArrivalInfoResponse response =
new ObaArrivalInfoRequest.Builder("Hillsborough%20Area%20Regional%20Transit_10001").build().call();
ObaArrivalInfo[] arrivals = response.getArrivalInfo();
boolean includeArriveDepartLabels = true;
final String SEPARATOR = "\n";
boolean clocktime = true; // true for clock times like "arriving at 10:05 PM", false for ETAs like "arriving in 9 minutes"
String timeZoneText = "America/New_York";
TimeZone timeZone = TimeZone.getTimeZone(timeZoneText);
List<ArrivalInfo> arrivalInfo = ArrivalInfo.convertObaArrivalInfo(arrivals, null,
response.getCurrentTime(), includeArriveDepartLabels, clocktime, timeZone);
String summary = UIUtils.getArrivalInfoSummary(arrivalInfo, SEPARATOR, clocktime, timeZone);
Also, if we can't get the time zone from the device for an incoming Alexa request, we can make a call to the regional OneBusAway server to retrieve this info via the agencies-with-coverage method: http://api.tampa.onebusaway.org/api/api/where/agencies-with-coverage.json?key=TEST
A timezone
is returned for each agency in the references block:
"disclaimer": "",
"email": "gohart.service@gmail.com",
"fareUrl": "",
"id": "Hillsborough Area Regional Transit",
"lang": "en",
"name": "Hillsborough Area Regional Transit",
"phone": "813-254-4278",
"privateService": false,
"timezone": "America/New_York",
"url": "http://www.gohart.org"
I'm working on this.
Summary:
A user requested that we allow the skill to say times in clock times (10:32) instead of ETA (9 minutes):
Steps to reproduce:
Expected behavior:
Add an option so the skill can announce "Route 5 to Downtown will arrive at 10:32 am".
Observed behavior:
Always announces "Route 5 to Downtown will arrive in 9 minutes".
Device:
N/A
Audio or video:
N/A