mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 08:40:29 +00:00
fixed exception when autocompleted station has no coordinate
This commit is contained in:
parent
4c315fcaf7
commit
dee454c1e3
2 changed files with 25 additions and 7 deletions
|
@ -489,7 +489,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
final String request = "<MLcReq><MLc n=\"" + constraint + "?\" t=\"ALLTYPE\" /></MLcReq>";
|
final String request = "<MLcReq><MLc n=\"" + constraint + "?\" t=\"ALLTYPE\" /></MLcReq>";
|
||||||
final String wrappedRequest = wrap(request, xmlMlcResEncoding);
|
final String wrappedRequest = wrap(request, xmlMlcResEncoding);
|
||||||
|
|
||||||
// ParserUtils.printXml(ParserUtils.scrape(apiUri, true, wrappedRequest, xmlMlcResEncoding, null));
|
// ParserUtils.printXml(ParserUtils.scrape(apiUri, wrappedRequest, xmlMlcResEncoding, null));
|
||||||
|
|
||||||
Reader reader = null;
|
Reader reader = null;
|
||||||
|
|
||||||
|
@ -535,16 +535,26 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name = XmlPullUtil.attr(pp, "n");
|
final String name = XmlPullUtil.attr(pp, "n");
|
||||||
|
final String[] placeAndName = splitPlaceAndName(name);
|
||||||
|
|
||||||
final String r = pp.getAttributeValue(null, "r");
|
final String r = pp.getAttributeValue(null, "r");
|
||||||
final Matcher iMatcherLonLat = P_XML_MLC_REQ_LONLAT.matcher(i != null ? i : r);
|
final Matcher iMatcherLonLat = P_XML_MLC_REQ_LONLAT.matcher(i != null ? i : r);
|
||||||
if (!iMatcherLonLat.matches())
|
final int lat;
|
||||||
throw new IllegalStateException("cannot parse lon/lat: '" + i + "' or '" + r + "'");
|
final int lon;
|
||||||
final int lon = Integer.parseInt(iMatcherLonLat.group(1));
|
if (iMatcherLonLat.matches())
|
||||||
final int lat = Integer.parseInt(iMatcherLonLat.group(2));
|
{
|
||||||
|
lon = Integer.parseInt(iMatcherLonLat.group(1));
|
||||||
|
lat = Integer.parseInt(iMatcherLonLat.group(2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lat = 0;
|
||||||
|
lon = 0;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] placeAndName = splitPlaceAndName(name);
|
final Location location = new Location(type, id, lat, lon, placeAndName[0], placeAndName[1]);
|
||||||
results.add(new Location(type, id, lat, lon, placeAndName[0], placeAndName[1]));
|
if (location.hasLocation())
|
||||||
|
results.add(location);
|
||||||
|
|
||||||
XmlPullUtil.next(pp);
|
XmlPullUtil.next(pp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,14 @@ public class ShProviderLiveTest extends AbstractProviderLiveTest
|
||||||
print(autocompletes);
|
print(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void autocompleteWithoutCoordinatesInResult() throws Exception
|
||||||
|
{
|
||||||
|
final List<Location> autocompletes = provider.autocompleteStations("aachen");
|
||||||
|
|
||||||
|
print(autocompletes);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shortConnection() throws Exception
|
public void shortConnection() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue