mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 09:29:49 +00:00
helper for reverse migration of Berlin station ids
This commit is contained in:
parent
ee6199ce1c
commit
384dc47240
2 changed files with 28 additions and 0 deletions
|
@ -742,4 +742,20 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
{
|
||||
return Berlin.BOUNDARY;
|
||||
}
|
||||
|
||||
public static int migrateStationIdReverse(final int stationId)
|
||||
{
|
||||
if (stationId < 100000000 || stationId >= 1000000000)
|
||||
return stationId;
|
||||
|
||||
final int low = stationId % 100000;
|
||||
final int middle = (stationId % 100000000) - low;
|
||||
|
||||
if (middle != 1000000)
|
||||
return stationId;
|
||||
|
||||
final int high = stationId - (stationId % 100000000);
|
||||
|
||||
return high / 1000 + low;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,4 +192,16 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest
|
|||
final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStationIdReverse() throws Exception
|
||||
{
|
||||
Assert.assertEquals(BvgProvider.migrateStationIdReverse(101000316), 100316);
|
||||
Assert.assertEquals(BvgProvider.migrateStationIdReverse(301000316), 300316);
|
||||
|
||||
// no conversions
|
||||
Assert.assertEquals(BvgProvider.migrateStationIdReverse(102000316), 102000316);
|
||||
Assert.assertEquals(BvgProvider.migrateStationIdReverse(1101000316), 1101000316);
|
||||
Assert.assertEquals(BvgProvider.migrateStationIdReverse(11000316), 11000316);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue