mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 19:28:49 +00:00
split place and name for some Frankfurt stations
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@463 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
0184b5dee3
commit
b2ba8a1c79
3 changed files with 32 additions and 2 deletions
|
@ -64,6 +64,11 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
||||||
this.accessId = accessId;
|
this.accessId = accessId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String[] splitNameAndPlace(final String name)
|
||||||
|
{
|
||||||
|
return new String[] { null, name };
|
||||||
|
}
|
||||||
|
|
||||||
private final String wrap(final String request)
|
private final String wrap(final String request)
|
||||||
{
|
{
|
||||||
return "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" //
|
return "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" //
|
||||||
|
@ -766,7 +771,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
||||||
parsedLat = Integer.parseInt(mFineCoords.group(2));
|
parsedLat = Integer.parseInt(mFineCoords.group(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
stations.add(new Station(parsedId, null, parsedName, null, parsedLat, parsedLon, 0, null, null));
|
final String[] nameAndPlace = splitNameAndPlace(parsedName);
|
||||||
|
stations.add(new Station(parsedId, nameAndPlace[0], nameAndPlace[1], parsedName, parsedLat, parsedLon, 0, null, null));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,19 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
|
||||||
|
"Darmstadt", "Aschaffenburg" };
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] splitNameAndPlace(final String name)
|
||||||
|
{
|
||||||
|
for (final String place : PLACES)
|
||||||
|
if (name.startsWith(place + " "))
|
||||||
|
return new String[] { place, name.substring(place.length() + 1) };
|
||||||
|
|
||||||
|
return super.splitNameAndPlace(name);
|
||||||
|
}
|
||||||
|
|
||||||
private static final String NAME_URL = API_BASE + "stboard.exe/dox?input=";
|
private static final String NAME_URL = API_BASE + "stboard.exe/dox?input=";
|
||||||
private static final Pattern P_SINGLE_NAME = Pattern.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#(\\d+)\" />.*",
|
private static final Pattern P_SINGLE_NAME = Pattern.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#(\\d+)\" />.*",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
|
@ -522,7 +535,8 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, null, location), departures, null);
|
final String[] nameAndPlace = splitNameAndPlace(location);
|
||||||
|
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, nameAndPlace[0], nameAndPlace[1]), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,12 +14,14 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.schildbach.pte.live;
|
package de.schildbach.pte.live;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.RmvProvider;
|
import de.schildbach.pte.RmvProvider;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -35,4 +37,12 @@ public class RmvProviderLiveTest
|
||||||
|
|
||||||
System.out.println(result.stations.size() + " " + result.stations);
|
System.out.println(result.stations.size() + " " + result.stations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void departures() throws Exception
|
||||||
|
{
|
||||||
|
final QueryDeparturesResult queryDepartures = provider.queryDepartures("3000001", 0);
|
||||||
|
|
||||||
|
System.out.println(queryDepartures.departures);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue