mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 00:30:31 +00:00
better platform parsing
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@529 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
a4f9f125e8
commit
28d7ed0c7d
1 changed files with 25 additions and 11 deletions
|
@ -1568,21 +1568,38 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
return Currency.getInstance(currencyStr);
|
||||
}
|
||||
|
||||
private static final Pattern P_PLATFORM_GLEIS = Pattern.compile("(Gleis|Bstg\\.)\\s*(\\d+[a-z]?)(?: ([A-Z])\\s*-\\s*([A-Z]))?");
|
||||
private static final Pattern P_PLATFORM = Pattern.compile("#?(\\d+)", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern P_PLATFORM_NAME = Pattern.compile("(?:Gleis|Gl\\.|Bstg\\.)?\\s*" + //
|
||||
"(\\d+)\\s*" + //
|
||||
"(?:([A-Z])\\s*(?:-\\s*([A-Z]))?)?", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private static final String normalizePlatform(final String platform, final String platformName)
|
||||
{
|
||||
if (platform != null && platform.length() > 0)
|
||||
{
|
||||
final Matcher m = P_PLATFORM.matcher(platform);
|
||||
if (m.matches())
|
||||
{
|
||||
return Integer.toString(Integer.parseInt(m.group(1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
|
||||
if (platformName != null && platformName.length() > 0)
|
||||
{
|
||||
final Matcher mGleis = P_PLATFORM_GLEIS.matcher(platformName);
|
||||
if (mGleis.matches())
|
||||
final Matcher m = P_PLATFORM_NAME.matcher(platformName);
|
||||
if (m.matches())
|
||||
{
|
||||
if (mGleis.group(3) == null)
|
||||
return mGleis.group(2);
|
||||
else if (mGleis.group(1).equals("Gleis"))
|
||||
return "Gl. " + mGleis.group(2) + " " + mGleis.group(3) + "-" + mGleis.group(4);
|
||||
final String simple = Integer.toString(Integer.parseInt(m.group(1)));
|
||||
if (m.group(2) != null && m.group(3) != null)
|
||||
return simple + m.group(2) + "-" + m.group(3);
|
||||
else if (m.group(2) != null)
|
||||
return simple + m.group(2);
|
||||
else
|
||||
return mGleis.group(1) + " " + mGleis.group(2) + " " + mGleis.group(3) + "-" + mGleis.group(4);
|
||||
return simple;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1590,9 +1607,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
if (platform != null && platform.length() > 0)
|
||||
return platform;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue