mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 08:10:46 +00:00
Parse itdCoordinateBaseElemList where itdCoordinateString is not available
This commit is contained in:
parent
5f45e84a4b
commit
373c02546f
2 changed files with 47 additions and 4 deletions
|
@ -105,6 +105,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
private boolean httpPost = false;
|
||||
private boolean useRouteIndexAsTripId = true;
|
||||
private boolean useLineRestriction = true;
|
||||
private boolean useStringCoordListOutputFormat = true;
|
||||
private float fareCorrectionFactor = 1f;
|
||||
|
||||
private final XmlPullParserFactory parserFactory;
|
||||
|
@ -213,6 +214,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
this.useLineRestriction = useLineRestriction;
|
||||
}
|
||||
|
||||
protected void setUseStringCoordListOutputFormat(final boolean useStringCoordListOutputFormat)
|
||||
{
|
||||
this.useStringCoordListOutputFormat = useStringCoordListOutputFormat;
|
||||
}
|
||||
|
||||
protected void setCanAcceptPoiId(final boolean canAcceptPoiId)
|
||||
{
|
||||
this.canAcceptPoiId = canAcceptPoiId;
|
||||
|
@ -581,6 +587,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
final StringBuilder parameters = new StringBuilder();
|
||||
appendCommonRequestParams(parameters, "XML");
|
||||
parameters.append("&coord=").append(String.format(Locale.ENGLISH, "%2.6f:%2.6f:WGS84", latLonToDouble(lon), latLonToDouble(lat)));
|
||||
if (useStringCoordListOutputFormat)
|
||||
parameters.append("&coordListOutputFormat=STRING");
|
||||
parameters.append("&max=").append(maxStations != 0 ? maxStations : 50);
|
||||
parameters.append("&inclFilter=1&radius_1=").append(maxDistance != 0 ? maxDistance : 1320);
|
||||
|
@ -2096,8 +2103,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private static final void appendCommonXsltTripRequest2Params(final StringBuilder uri)
|
||||
private final void appendCommonXsltTripRequest2Params(final StringBuilder uri)
|
||||
{
|
||||
if (useStringCoordListOutputFormat)
|
||||
uri.append("&coordListOutputFormat=STRING");
|
||||
uri.append("&calcNumberOfTrips=4");
|
||||
}
|
||||
|
@ -3068,7 +3076,19 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
if (!"GEO_DECIMAL".equals(type))
|
||||
throw new IllegalStateException("unknown type: " + type);
|
||||
|
||||
final List<Point> path = processCoordinateStrings(pp, "itdCoordinateString");
|
||||
final List<Point> path;
|
||||
if (XmlPullUtil.test(pp, "itdCoordinateString"))
|
||||
{
|
||||
path = processCoordinateStrings(pp, "itdCoordinateString");
|
||||
}
|
||||
else if (XmlPullUtil.test(pp, "itdCoordinateBaseElemList"))
|
||||
{
|
||||
path = processCoordinateBaseElems(pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException(pp.getPositionDescription());
|
||||
}
|
||||
|
||||
XmlPullUtil.exit(pp, "itdPathCoordinates");
|
||||
|
||||
|
@ -3086,6 +3106,28 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return path;
|
||||
}
|
||||
|
||||
private List<Point> processCoordinateBaseElems(final XmlPullParser pp) throws XmlPullParserException, IOException
|
||||
{
|
||||
final List<Point> path = new LinkedList<Point>();
|
||||
|
||||
XmlPullUtil.enter(pp, "itdCoordinateBaseElemList");
|
||||
|
||||
while (XmlPullUtil.test(pp, "itdCoordinateBaseElem"))
|
||||
{
|
||||
XmlPullUtil.enter(pp, "itdCoordinateBaseElem");
|
||||
|
||||
final int lon = Math.round(Float.parseFloat(requireValueTag(pp, "x")));
|
||||
final int lat = Math.round(Float.parseFloat(requireValueTag(pp, "y")));
|
||||
path.add(new Point(lat, lon));
|
||||
|
||||
XmlPullUtil.exit(pp, "itdCoordinateBaseElem");
|
||||
}
|
||||
|
||||
XmlPullUtil.exit(pp, "itdCoordinateBaseElemList");
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private Point coordStrToPoint(final String coordStr)
|
||||
{
|
||||
if (coordStr == null)
|
||||
|
|
|
@ -41,6 +41,7 @@ public class VvoProvider extends AbstractEfaProvider
|
|||
super(apiBase);
|
||||
|
||||
setUseRealtime(false);
|
||||
setUseStringCoordListOutputFormat(false);
|
||||
setRequestUrlEncoding(UTF_8);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue