mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 20:49:50 +00:00
VGN: Migrate to JSON stopfinder.
This commit is contained in:
parent
37ccc96156
commit
6a4f2a6b9b
2 changed files with 0 additions and 46 deletions
|
@ -345,44 +345,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
|||
}
|
||||
}
|
||||
|
||||
protected SuggestLocationsResult xmlStopfinderRequest(final Location constraint) throws IOException {
|
||||
final HttpUrl.Builder url = stopFinderEndpoint.newBuilder();
|
||||
appendStopfinderRequestParameters(url, constraint, "XML");
|
||||
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
|
||||
|
||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
||||
@Override
|
||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
||||
try {
|
||||
final XmlPullParser pp = parserFactory.newPullParser();
|
||||
pp.setInput(body.byteStream(), null); // Read encoding from XML declaration
|
||||
final ResultHeader header = enterItdRequest(pp);
|
||||
|
||||
final List<SuggestedLocation> locations = new ArrayList<>();
|
||||
|
||||
XmlPullUtil.enter(pp, "itdStopFinderRequest");
|
||||
|
||||
processItdOdv(pp, "sf", new ProcessItdOdvCallback() {
|
||||
@Override
|
||||
public void location(final String nameState, final Location location, final int matchQuality) {
|
||||
locations.add(new SuggestedLocation(location, matchQuality));
|
||||
}
|
||||
});
|
||||
|
||||
XmlPullUtil.skipExit(pp, "itdStopFinderRequest");
|
||||
|
||||
result.set(new SuggestLocationsResult(header, locations));
|
||||
} catch (final XmlPullParserException x) {
|
||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||
|
||||
return result.get();
|
||||
}
|
||||
|
||||
protected SuggestLocationsResult mobileStopfinderRequest(final Location constraint) throws IOException {
|
||||
final HttpUrl.Builder url = stopFinderEndpoint.newBuilder();
|
||||
appendStopfinderRequestParameters(url, constraint, "XML");
|
||||
|
|
|
@ -17,16 +17,13 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
import de.schildbach.pte.dto.TripOptions;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
@ -63,11 +60,6 @@ public class VgnProvider extends AbstractEfaProvider {
|
|||
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return xmlStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||
final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue