mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-20 01:10:02 +00:00
Remove support for unused MLcReq (Hafas).
This commit is contained in:
parent
64d243cbcb
commit
9bfa490c8e
11 changed files with 12 additions and 107 deletions
|
@ -89,7 +89,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
private String clientType;
|
||||
private Charset jsonGetStopsEncoding;
|
||||
private Charset jsonNearbyStationsEncoding;
|
||||
private final Charset xmlMlcResEncoding;
|
||||
private boolean dominantPlanStopTime = false;
|
||||
private boolean canDoEquivs = true;
|
||||
private boolean useIso8601 = false;
|
||||
|
@ -147,11 +146,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint, final int numProductBits)
|
||||
{
|
||||
this(stationBoardEndpoint, getStopEndpoint, queryEndpoint, numProductBits, ISO_8859_1, ISO_8859_1);
|
||||
this(stationBoardEndpoint, getStopEndpoint, queryEndpoint, numProductBits, ISO_8859_1);
|
||||
}
|
||||
|
||||
public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint,
|
||||
final int numProductBits, final Charset jsonEncoding, final Charset xmlMlcResEncoding)
|
||||
final int numProductBits, final Charset jsonEncoding)
|
||||
{
|
||||
this.stationBoardEndpoint = stationBoardEndpoint;
|
||||
this.getStopEndpoint = getStopEndpoint;
|
||||
|
@ -159,7 +158,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
this.numProductBits = numProductBits;
|
||||
this.jsonGetStopsEncoding = jsonEncoding;
|
||||
this.jsonNearbyStationsEncoding = jsonEncoding;
|
||||
this.xmlMlcResEncoding = xmlMlcResEncoding;
|
||||
}
|
||||
|
||||
protected void setClientType(final String clientType)
|
||||
|
@ -417,99 +415,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_XML_MLC_REQ_ID = Pattern.compile(".*?@L=0*(\\d+)@.*?");
|
||||
private static final Pattern P_XML_MLC_REQ_LONLAT = Pattern.compile(".*?@X=(-?\\d+)@Y=(-?\\d+)@.*?");
|
||||
|
||||
protected final List<Location> xmlMLcReq(final CharSequence constraint) throws IOException
|
||||
{
|
||||
final String mlcReq = "<MLcReq><MLc n=\"" + constraint + "?\" t=\"ALLTYPE\" /></MLcReq>";
|
||||
final String request = wrapReqC(mlcReq, xmlMlcResEncoding);
|
||||
|
||||
// ParserUtils.printXml(ParserUtils.scrape(queryEndpoint, request, xmlMlcResEncoding, null));
|
||||
|
||||
Reader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader = new InputStreamReader(ParserUtils.scrapeInputStream(queryEndpoint, request, xmlMlcResEncoding, null, null, 3), xmlMlcResEncoding);
|
||||
|
||||
final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
||||
final XmlPullParser pp = factory.newPullParser();
|
||||
pp.setInput(reader);
|
||||
|
||||
final List<Location> results = new ArrayList<Location>();
|
||||
|
||||
XmlPullUtil.enter(pp, "ResC");
|
||||
XmlPullUtil.enter(pp, "MLcRes");
|
||||
|
||||
while (XmlPullUtil.test(pp, "MLc"))
|
||||
{
|
||||
final String t = XmlPullUtil.attr(pp, "t");
|
||||
final LocationType type;
|
||||
if ("ST".equals(t))
|
||||
type = LocationType.STATION;
|
||||
else if ("POI".equals(t))
|
||||
type = LocationType.POI;
|
||||
else if ("ADR".equals(t))
|
||||
type = LocationType.ADDRESS;
|
||||
else
|
||||
throw new IllegalStateException("cannot handle: '" + t + "'");
|
||||
|
||||
final String id;
|
||||
final String i = pp.getAttributeValue(null, "i");
|
||||
if (i != null)
|
||||
{
|
||||
final Matcher iMatcherId = P_XML_MLC_REQ_ID.matcher(i);
|
||||
if (!iMatcherId.matches())
|
||||
throw new IllegalStateException("cannot parse id: '" + i + "'");
|
||||
id = iMatcherId.group(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = null;
|
||||
}
|
||||
|
||||
final String name = XmlPullUtil.attr(pp, "n");
|
||||
final String[] placeAndName = splitPlaceAndName(name);
|
||||
|
||||
final String r = pp.getAttributeValue(null, "r");
|
||||
final Matcher iMatcherLonLat = P_XML_MLC_REQ_LONLAT.matcher(i != null ? i : r);
|
||||
final int lat;
|
||||
final int lon;
|
||||
if (iMatcherLonLat.matches())
|
||||
{
|
||||
lon = Integer.parseInt(iMatcherLonLat.group(1));
|
||||
lat = Integer.parseInt(iMatcherLonLat.group(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
lat = 0;
|
||||
lon = 0;
|
||||
}
|
||||
|
||||
final Location location = new Location(type, id, lat, lon, placeAndName[0], placeAndName[1]);
|
||||
if (location.hasLocation())
|
||||
results.add(location);
|
||||
|
||||
XmlPullUtil.next(pp);
|
||||
}
|
||||
|
||||
XmlPullUtil.exit(pp, "MLcRes");
|
||||
XmlPullUtil.exit(pp, "ResC");
|
||||
|
||||
return results;
|
||||
}
|
||||
catch (final XmlPullParserException x)
|
||||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected StringBuilder xmlQueryDeparturesParameters(final String stationId)
|
||||
{
|
||||
final StringBuilder parameters = new StringBuilder();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
|
||||
public InvgProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
||||
|
||||
setStyles(STYLES);
|
||||
setExtXmlEndpoint(API_BASE + "extxml.exe");
|
||||
|
|
|
@ -40,7 +40,7 @@ public class JetProvider extends AbstractHafasProvider
|
|||
|
||||
public JetProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", 4, UTF_8, null);
|
||||
super(API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", 4, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -35,7 +35,7 @@ public class LuProvider extends AbstractHafasProvider
|
|||
|
||||
public LuProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", 9, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", 9, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -36,7 +36,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
|
||||
public NvvProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 12, UTF_8, null);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 12, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -40,7 +40,7 @@ public class PlProvider extends AbstractHafasProvider
|
|||
|
||||
public PlProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", 7, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", 7, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RtProvider extends AbstractHafasProvider
|
|||
|
||||
public RtProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, null);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SeProvider extends AbstractHafasProvider
|
|||
|
||||
public SeProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 14, UTF_8, null);
|
||||
super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 14, UTF_8);
|
||||
|
||||
setClientType("ANDROID");
|
||||
setCanDoEquivs(false);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ShProvider extends AbstractHafasProvider
|
|||
|
||||
public ShProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -49,7 +49,7 @@ public class VbbProvider extends AbstractHafasProvider
|
|||
|
||||
public VbbProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 7, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 7, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
|
||||
public ZvvProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
||||
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue