mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 16:20:34 +00:00
Hafas: Normalize product names received from JSON API.
This commit is contained in:
parent
75ef5290ba
commit
c1a309f938
1 changed files with 10 additions and 1 deletions
|
@ -1428,7 +1428,16 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
final int cls = prod.optInt("cls", -1);
|
||||
final Product product = cls != -1 ? intToProduct(cls) : null;
|
||||
final String name = prod.getString("name");
|
||||
final Line line = new Line(null, operator, product, name, lineStyle(operator, product, name));
|
||||
final String normalizedName;
|
||||
if (product == Product.BUS && name.startsWith("Bus "))
|
||||
normalizedName = name.substring(4);
|
||||
else if (product == Product.TRAM && name.startsWith("Tram "))
|
||||
normalizedName = name.substring(5);
|
||||
else if (product == Product.SUBURBAN_TRAIN && name.startsWith("S "))
|
||||
normalizedName = "S" + name.substring(2);
|
||||
else
|
||||
normalizedName = name;
|
||||
final Line line = new Line(null, operator, product, normalizedName, lineStyle(operator, product, normalizedName));
|
||||
lines.add(line);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue