Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
4b601aff
Commit
4b601aff
authored
Oct 27, 2022
by
Volker Krause
Browse files
Return full station objects from the UIC 918.3 parser
Prepares this for handling ERA FCB data as well.
parent
6b87ead4
Pipeline
#256470
passed with stage
in 12 minutes and 37 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/scriptenginedata/Testw_VOW8XG6_A9E8DXL_0.bin.json
View file @
4b601aff
...
...
@@ -32,8 +32,50 @@
"url"
:
""
},
"name"
:
"Normalpreis"
,
"outboundArrivalStationId"
:
""
,
"outboundDepartureStationId"
:
""
,
"outboundArrivalStation"
:
{
"address"
:
{
"addressCountry"
:
""
,
"addressLocality"
:
""
,
"addressRegion"
:
""
,
"className"
:
"PostalAddress"
,
"isEmpty"
:
true
,
"postalCode"
:
""
,
"streetAddress"
:
""
},
"className"
:
"TrainStation"
,
"geo"
:
{
"className"
:
"GeoCoordinates"
,
"isValid"
:
false
,
"latitude"
:
null
,
"longitude"
:
null
},
"geoUri"
:
""
,
"identifier"
:
""
,
"name"
:
"Frankfurt(Main)+City"
,
"telephone"
:
""
},
"outboundDepartureStation"
:
{
"address"
:
{
"addressCountry"
:
""
,
"addressLocality"
:
""
,
"addressRegion"
:
""
,
"className"
:
"PostalAddress"
,
"isEmpty"
:
true
,
"postalCode"
:
""
,
"streetAddress"
:
""
},
"className"
:
"TrainStation"
,
"geo"
:
{
"className"
:
"GeoCoordinates"
,
"isValid"
:
false
,
"latitude"
:
null
,
"longitude"
:
null
},
"geoUri"
:
""
,
"identifier"
:
""
,
"name"
:
"Köln"
,
"telephone"
:
""
},
"person"
:
{
"className"
:
"Person"
,
"email"
:
""
,
...
...
@@ -83,8 +125,50 @@
"url"
:
""
},
"name"
:
"Normalpreis"
,
"outboundArrivalStationId"
:
""
,
"outboundDepartureStationId"
:
""
,
"outboundArrivalStation"
:
{
"address"
:
{
"addressCountry"
:
""
,
"addressLocality"
:
""
,
"addressRegion"
:
""
,
"className"
:
"PostalAddress"
,
"isEmpty"
:
true
,
"postalCode"
:
""
,
"streetAddress"
:
""
},
"className"
:
"TrainStation"
,
"geo"
:
{
"className"
:
"GeoCoordinates"
,
"isValid"
:
false
,
"latitude"
:
null
,
"longitude"
:
null
},
"geoUri"
:
""
,
"identifier"
:
""
,
"name"
:
"Frankfurt(Main)+City"
,
"telephone"
:
""
},
"outboundDepartureStation"
:
{
"address"
:
{
"addressCountry"
:
""
,
"addressLocality"
:
""
,
"addressRegion"
:
""
,
"className"
:
"PostalAddress"
,
"isEmpty"
:
true
,
"postalCode"
:
""
,
"streetAddress"
:
""
},
"className"
:
"TrainStation"
,
"geo"
:
{
"className"
:
"GeoCoordinates"
,
"isValid"
:
false
,
"latitude"
:
null
,
"longitude"
:
null
},
"geoUri"
:
""
,
"identifier"
:
""
,
"name"
:
"Köln"
,
"telephone"
:
""
},
"person"
:
{
"className"
:
"Person"
,
"email"
:
""
,
...
...
autotests/uic918-3/valid/Testw_VOW8XG6_A9E8DXL_0.json
View file @
4b601aff
...
...
@@ -8,6 +8,14 @@
"identifier"
:
"uic:0080"
},
"name"
:
"Normalpreis"
,
"outboundArrivalStation"
:
{
"@type"
:
"TrainStation"
,
"name"
:
"Frankfurt(Main)+City"
},
"outboundDepartureStation"
:
{
"@type"
:
"TrainStation"
,
"name"
:
"Köln"
},
"person"
:
{
"@type"
:
"Person"
,
"familyName"
:
"häöür Räß"
,
...
...
src/lib/scripts/deutschebahn.js
View file @
4b601aff
...
...
@@ -141,8 +141,8 @@ function parseTicket(text, uic918ticket) {
// for outward journeys we have station ids from the UIC 918-3 code
if
(
uic918ticket
&&
header
[
1
]
===
"
Hin
"
)
{
reservations
[
0
].
reservationFor
.
departureStation
.
identifier
=
uic918ticket
.
outboundDepartureStation
Id
;
reservations
[
reservations
.
length
-
1
].
reservationFor
.
arrivalStation
.
identifier
=
uic918ticket
.
outboundArrivalStation
Id
;
reservations
[
0
].
reservationFor
.
departureStation
.
identifier
=
uic918ticket
.
outboundDepartureStation
.
identifier
;
reservations
[
reservations
.
length
-
1
].
reservationFor
.
arrivalStation
.
identifier
=
uic918ticket
.
outboundArrivalStation
.
identifier
;
returnResIndex
=
reservations
.
length
;
}
else
{
// propagate station ids from outward to return journey
...
...
@@ -290,15 +290,13 @@ function parseUic9183(code, node) {
// domestic ticket code
const
bl
=
code
.
block
(
'
0080BL
'
);
if
(
bl
)
{
if
(
bl
&&
code
.
outboundDepartureStation
.
name
&&
code
.
outboundArrivalStation
.
name
)
{
let
res
=
JsonLd
.
newTrainReservation
();
res
.
reservedTicket
=
node
.
result
[
0
];
applyUic9183ToReservation
(
res
,
code
);
res
.
reservationFor
.
departureDay
=
JsonLd
.
toDateTime
(
bl
.
findSubBlock
(
'
031
'
).
content
,
'
dd.mm.yyyy
'
,
'
de
'
);
res
.
reservationFor
.
departureStation
.
name
=
bl
.
findSubBlock
(
'
015
'
).
content
;
res
.
reservationFor
.
departureStation
.
identifier
=
code
.
outboundDepartureStationId
;
res
.
reservationFor
.
arrivalStation
.
name
=
bl
.
findSubBlock
(
'
016
'
).
content
;
res
.
reservationFor
.
arrivalStation
.
identifier
=
code
.
outboundArrivalStationId
;
res
.
reservationFor
.
departureStation
=
JsonLd
.
toJson
(
code
.
outboundDepartureStation
);
res
.
reservationFor
.
arrivalStation
=
JsonLd
.
toJson
(
code
.
outboundArrivalStation
);
if
(
!
bl
.
findSubBlock
(
'
017
'
))
{
return
res
;
...
...
@@ -309,9 +307,9 @@ function parseUic9183(code, node) {
applyUic9183ToReservation
(
ret
,
code
);
ret
.
reservationFor
.
departureDay
=
JsonLd
.
toDateTime
(
bl
.
findSubBlock
(
'
032
'
).
content
,
'
dd.mm.yyyy
'
,
'
de
'
);
ret
.
reservationFor
.
departureStation
.
name
=
bl
.
findSubBlock
(
'
017
'
).
content
;
ret
.
reservationFor
.
departureStation
.
identifier
=
ret
.
reservationFor
.
departureStation
.
name
===
res
.
reservationFor
.
arrivalStation
.
name
?
code
.
outboundArrivalStation
Id
:
undefined
;
ret
.
reservationFor
.
departureStation
.
identifier
=
ret
.
reservationFor
.
departureStation
.
name
===
res
.
reservationFor
.
arrivalStation
.
name
?
code
.
outboundArrivalStation
.
identifier
:
undefined
;
ret
.
reservationFor
.
arrivalStation
.
name
=
bl
.
findSubBlock
(
'
018
'
).
content
;
ret
.
reservationFor
.
arrivalStation
.
identifier
=
ret
.
reservationFor
.
arrivalStation
.
name
===
res
.
reservationFor
.
departureStation
.
name
?
code
.
outboundDepartureStation
Id
:
undefined
;
ret
.
reservationFor
.
arrivalStation
.
identifier
=
ret
.
reservationFor
.
arrivalStation
.
name
===
res
.
reservationFor
.
departureStation
.
name
?
code
.
outboundDepartureStation
.
identifier
:
undefined
;
return
[
res
,
ret
];
}
...
...
src/lib/uic9183/uic9183parser.cpp
View file @
4b601aff
...
...
@@ -399,34 +399,42 @@ Person Uic9183Parser::person() const
return
{};
}
QString
Uic9183Parser
::
outboundDepartureStation
Id
()
const
TrainStation
Uic9183Parser
::
outboundDepartureStation
()
const
{
const
auto
b
=
findBlock
<
Vendor0080BLBlock
>
();
if
(
b
.
isValid
())
{
TrainStation
station
;
if
(
const
auto
b
=
findBlock
<
Vendor0080BLBlock
>
();
b
.
isValid
())
{
if
(
const
auto
sblock
=
b
.
findSubBlock
(
"015"
);
!
sblock
.
isNull
())
{
station
.
setName
(
sblock
.
toString
());
}
// S035 contains the IBNR, possible with leading '80' country code and leading 0 stripped
const
auto
sblock
=
b
.
findSubBlock
(
"035"
);
if
(
!
sblock
.
isNull
()
&&
sblock
.
contentSize
()
<=
7
)
{
if
(
const
auto
sblock
=
b
.
findSubBlock
(
"035"
);
!
sblock
.
isNull
()
&&
sblock
.
contentSize
()
<=
7
)
{
QString
ibnr
=
QStringLiteral
(
"ibnr:8000000"
);
const
auto
s
=
sblock
.
toString
();
return
ibnr
.
replace
(
ibnr
.
size
()
-
s
.
size
(),
s
.
size
(),
s
);
station
.
setIdentifier
(
ibnr
.
replace
(
ibnr
.
size
()
-
s
.
size
(),
s
.
size
(),
s
)
)
;
}
}
return
{};
return
station
;
}
QString
Uic9183Parser
::
outboundArrivalStation
Id
()
const
TrainStation
Uic9183Parser
::
outboundArrivalStation
()
const
{
const
auto
b
=
findBlock
<
Vendor0080BLBlock
>
();
if
(
b
.
isValid
())
{
TrainStation
station
;
if
(
const
auto
b
=
findBlock
<
Vendor0080BLBlock
>
();
b
.
isValid
())
{
if
(
const
auto
sblock
=
b
.
findSubBlock
(
"016"
);
!
sblock
.
isNull
())
{
station
.
setName
(
sblock
.
toString
());
}
// S036 contains the IBNR, possible with leading '80' country code and leading 0 stripped
const
auto
sblock
=
b
.
findSubBlock
(
"036"
);
if
(
!
sblock
.
isNull
()
&&
sblock
.
contentSize
()
<=
7
)
{
if
(
const
auto
sblock
=
b
.
findSubBlock
(
"036"
);
!
sblock
.
isNull
()
&&
sblock
.
contentSize
()
<=
7
)
{
QString
ibnr
=
QStringLiteral
(
"ibnr:8000000"
);
const
auto
s
=
sblock
.
toString
();
return
ibnr
.
replace
(
ibnr
.
size
()
-
s
.
size
(),
s
.
size
(),
s
);
station
.
setIdentifier
(
ibnr
.
replace
(
ibnr
.
size
()
-
s
.
size
(),
s
.
size
(),
s
)
)
;
}
}
return
{};
return
station
;
}
static
QString
fcbClassCodeToString
(
Fcb
::
TravelClassType
classCode
)
...
...
src/lib/uic9183/uic9183parser.h
View file @
4b601aff
...
...
@@ -10,6 +10,7 @@
#include
<KItinerary/Organization>
#include
<KItinerary/Person>
#include
<KItinerary/Place>
#include
<QExplicitlySharedDataPointer>
#include
<QMetaType>
...
...
@@ -43,8 +44,8 @@ class KITINERARY_EXPORT Uic9183Parser
Q_PROPERTY
(
QDateTime
validFrom
READ
validFrom
)
Q_PROPERTY
(
QDateTime
validUntil
READ
validUntil
)
Q_PROPERTY
(
KItinerary
::
Person
person
READ
person
)
Q_PROPERTY
(
QString
outboundDepartureStation
Id
READ
outboundDepartureStation
Id
)
Q_PROPERTY
(
QString
outboundArrivalStation
Id
READ
outboundArrivalStation
Id
)
Q_PROPERTY
(
KItinerary
::
TrainStation
outboundDepartureStation
READ
outboundDepartureStation
)
Q_PROPERTY
(
KItinerary
::
TrainStation
outboundArrivalStation
READ
outboundArrivalStation
)
Q_PROPERTY
(
QString
seatingType
READ
seatingType
)
/** U_TLAY ticket layout block, if present, @c null otherwise. */
Q_PROPERTY
(
QVariant
ticketLayout
READ
ticketLayoutVariant
)
...
...
@@ -82,10 +83,10 @@ public:
/** The person this ticket is issued to. */
Person
person
()
const
;
/** Station
identifier
for the departure station of the outbound trip. */
QString
outboundDepartureStation
Id
()
const
;
/** Station
identifier
for the arrival station of the outbound trip. */
QString
outboundArrivalStation
Id
()
const
;
/** Station
object
for the departure station of the outbound trip. */
TrainStation
outboundDepartureStation
()
const
;
/** Station
object
for the arrival station of the outbound trip. */
TrainStation
outboundArrivalStation
()
const
;
/** @see Ticket::seatingType */
QString
seatingType
()
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment