Commit 23b353a8 authored by Volker Krause's avatar Volker Krause
Browse files

Clean up OJP locality names for location by name queries

The stop name is repeated in the locality field in that case.
parent 24aaaf30
[
{
"identifier": {
"uic": "8503016"
},
"latitude": 47.45038986206055,
"locality": "Kloten",
"longitude": 8.562399864196777,
"name": "Zürich Flughafen",
"type": "Stop"
},
{
"identifier": {
"uic": "8580301"
},
"latitude": 47.4526481628418,
"locality": "Kloten",
"longitude": 8.56566047668457,
"name": "Zürich Flughafen, OPC",
"type": "Stop"
}
]
<?xml version="1.0" encoding="UTF-8"?>
<siri:OJP xmlns:siri="http://www.siri.org.uk/siri" xmlns:ojp="http://www.vdv.de/ojp" version="1.0"><siri:OJPResponse><siri:ServiceDelivery><siri:ResponseTimestamp>2021-09-08T19:26:07Z</siri:ResponseTimestamp><siri:ProducerRef>OJPCH_Prod</siri:ProducerRef><siri:Status>true</siri:Status><ojp:OJPLocationInformationDelivery><siri:ResponseTimestamp>2021-09-08T19:26:07Z</siri:ResponseTimestamp><siri:Status>true</siri:Status><ojp:CalcTime>16</ojp:CalcTime><ojp:Location><ojp:Location><ojp:StopPlace><ojp:StopPlaceRef>8503016</ojp:StopPlaceRef><ojp:StopPlaceName><ojp:Text>Zürich Flughafen</ojp:Text></ojp:StopPlaceName><ojp:TopographicPlaceRef>23026062:5</ojp:TopographicPlaceRef></ojp:StopPlace><ojp:LocationName><ojp:Text xml:lang="de">Zürich Flughafen (Kloten)</ojp:Text></ojp:LocationName><ojp:GeoPosition><siri:Longitude>8.56240</siri:Longitude><siri:Latitude>47.45039</siri:Latitude></ojp:GeoPosition></ojp:Location><ojp:Complete>true</ojp:Complete><ojp:Probability>1</ojp:Probability></ojp:Location><ojp:Location><ojp:Location><ojp:StopPlace><ojp:StopPlaceRef>8580301</ojp:StopPlaceRef><ojp:StopPlaceName><ojp:Text>Zürich Flughafen, OPC</ojp:Text></ojp:StopPlaceName><ojp:TopographicPlaceRef>23026062:5</ojp:TopographicPlaceRef></ojp:StopPlace><ojp:LocationName><ojp:Text xml:lang="de">Zürich Flughafen, OPC (Kloten)</ojp:Text></ojp:LocationName><ojp:GeoPosition><siri:Longitude>8.56566</siri:Longitude><siri:Latitude>47.45265</siri:Latitude></ojp:GeoPosition></ojp:Location><ojp:Complete>true</ojp:Complete><ojp:Probability>0.978999972</ojp:Probability></ojp:Location></ojp:OJPLocationInformationDelivery></siri:ServiceDelivery></siri:OJPResponse></siri:OJP>
......@@ -45,6 +45,9 @@ private Q_SLOTS:
QTest::newRow("ch-location-by-coord")
<< s(SOURCE_DIR "/data/ojp/ch-location-by-coord.xml")
<< s(SOURCE_DIR "/data/ojp/ch-location-by-coord.json");
QTest::newRow("ch-location-by-name")
<< s(SOURCE_DIR "/data/ojp/ch-location-by-name.xml")
<< s(SOURCE_DIR "/data/ojp/ch-location-by-name.json");
}
void testParseLocations()
......
......@@ -116,6 +116,15 @@ Location OpenJourneyPlannerParser::parseLocationInformationLocationInner(ScopedX
loc.setLocality(parseTextElement(r.subReader()));
}
}
// cleanup locality also containing the stop name
if (loc.locality().startsWith(loc.name()) && loc.locality().endsWith(QLatin1Char(')'))) {
const auto idx = loc.locality().lastIndexOf(QLatin1Char('('));
if (idx > 0) {
loc.setLocality(loc.locality().mid(idx + 1, loc.locality().size() - idx - 2));
}
}
return loc;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment