mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 17:10:30 +00:00
migrate Stockholm to binary connections query
This commit is contained in:
parent
e8fdea2932
commit
81b68bbb5f
2 changed files with 49 additions and 5 deletions
|
@ -18,8 +18,11 @@
|
|||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -28,6 +31,8 @@ import de.schildbach.pte.dto.Location;
|
|||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryConnectionsContext;
|
||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
||||
|
@ -65,13 +70,13 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
return 'S';
|
||||
if (value == 2) // Tunnelbana
|
||||
return 'U';
|
||||
if (value == 4) // Lokaltåg
|
||||
if (value == 4) // Lokalbanor
|
||||
return 'R';
|
||||
if (value == 8) // Buss
|
||||
if (value == 8) // Bussar
|
||||
return 'B';
|
||||
if (value == 16) // Flygbussar
|
||||
return 'B';
|
||||
if (value == 64) // Båt
|
||||
if (value == 64) // Waxholmsbåtar
|
||||
return 'F';
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
|
@ -108,7 +113,7 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Båt
|
||||
productBits.setCharAt(6, '1'); // Waxholmsbåtar
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
|
@ -119,7 +124,7 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*?) \\((.{4,}?)\\)");
|
||||
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*) \\((.{4,}?)\\)");
|
||||
|
||||
@Override
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
|
@ -188,6 +193,31 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
return jsonGetStops(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomConnectionsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
uri.append("&h2g-direct=11"
|
||||
+ "&REQ0HafasSearchIndividual=1&REQ0HafasSearchPublic=1"
|
||||
+ "&existIntermodalDep_enable=yes&existIntermodalDest_enable=yes&existTotal_enable=yes"
|
||||
+ "&REQ0JourneyDep_Foot_enable=1&REQ0JourneyDep_Foot_maxDist=5000&REQ0JourneyDep_Foot_minDist=0&REQ0JourneyDep_Foot_speed=100&REQ0JourneyDep_Bike_enable=0&REQ0JourneyDep_ParkRide_enable=0"
|
||||
+ "&REQ0JourneyDest_Foot_enable=1&REQ0JourneyDest_Foot_maxDist=5000&REQ0JourneyDest_Foot_minDist=0&REQ0JourneyDest_Foot_speed=100&REQ0JourneyDest_Bike_enable=0&REQ0JourneyDest_ParkRide_enable=0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final int maxNumConnections, final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility,
|
||||
final Set<Option> options) throws IOException
|
||||
{
|
||||
return queryConnectionsBinary(from, via, to, date, dep, maxNumConnections, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later, final int numConnections)
|
||||
throws IOException
|
||||
{
|
||||
return queryMoreConnectionsBinary(contextObj, later, numConnections);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLineAndType(final String lineAndType)
|
||||
{
|
||||
|
@ -244,6 +274,8 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
return 'F';
|
||||
if ("BÅT".equals(ucType))
|
||||
return 'F';
|
||||
if ("FÄRJA".equals(ucType))
|
||||
return 'F';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -92,4 +92,16 @@ public class StockholmProviderLiveTest extends AbstractProviderLiveTest
|
|||
final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addressToStationConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = queryConnections(
|
||||
new Location(LocationType.ADDRESS, 0, 59360519, 17989266, null, "Sommarvägen 1, Solna"), null, new Location(LocationType.STATION,
|
||||
300109205, 59340518, 18081532, "Stockholm", "Stadion"), new Date(), true, Product.ALL, WalkSpeed.NORMAL,
|
||||
Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue