Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KPublicTransport
Commits
0f7e6930
Commit
0f7e6930
authored
Aug 07, 2021
by
Volker Krause
Browse files
Split up EFA parse polygon parsing
Needed for handling transfer sections.
parent
e354c250
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/backends/efacompactparser.cpp
View file @
0f7e6930
...
...
@@ -379,7 +379,7 @@ JourneySection EfaCompactParser::parseTripSection(ScopedXmlStreamReader &&reader
}
section
.
setIntermediateStops
(
std
::
move
(
stops
));
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"pt"
))
{
section
.
setPath
(
parsePathCoordinatesElement
(
reader
));
section
.
setPath
(
polygonToPath
(
parsePathCoordinatesElement
(
reader
))
)
;
}
// TODO interchange tag - should we turn this into transfer sections?
}
...
...
src/lib/backends/efaparser.cpp
View file @
0f7e6930
...
...
@@ -60,7 +60,7 @@ Line::Mode EfaParser::motTypeToLineMode(int mot)
return
Line
::
Unknown
;
}
Path
EfaParser
::
parsePathCoordinatesElement
(
ScopedXmlStreamReader
&
reader
)
QPolygonF
EfaParser
::
parsePathCoordinatesElement
(
ScopedXmlStreamReader
&
reader
)
{
QPolygonF
poly
;
// TODO do we need to support the format attributes, or is this always the same anyway?
...
...
@@ -72,7 +72,11 @@ Path EfaParser::parsePathCoordinatesElement(ScopedXmlStreamReader &reader)
poly
.
push_back
({
p
[
0
].
toDouble
(),
p
[
1
].
toDouble
()});
}
}
return
poly
;
}
Path
EfaParser
::
polygonToPath
(
const
QPolygonF
&
poly
)
{
PathSection
section
;
section
.
setPath
(
poly
);
Path
path
;
...
...
src/lib/backends/efaparser.h
View file @
0f7e6930
...
...
@@ -18,6 +18,7 @@
#include <vector>
class
QByteArray
;
class
QPolygonF
;
namespace
KPublicTransport
{
...
...
@@ -53,7 +54,9 @@ protected:
static
Line
::
Mode
motTypeToLineMode
(
int
mot
);
/** Parse path encoded as a space separated string of coordinate pairs. */
static
Path
parsePathCoordinatesElement
(
ScopedXmlStreamReader
&
reader
);
static
QPolygonF
parsePathCoordinatesElement
(
ScopedXmlStreamReader
&
reader
);
/** Turn a polygon into a section path. */
static
Path
polygonToPath
(
const
QPolygonF
&
poly
);
/** Returns @c true if the given stop id is a dummy value used for non-stops. */
static
bool
isDummyStopId
(
QStringView
id
);
...
...
src/lib/backends/efaxmlparser.cpp
View file @
0f7e6930
...
...
@@ -303,6 +303,7 @@ std::vector<JourneySection> EfaXmlParser::parseTripPartialRoute(ScopedXmlStreamR
section
.
setMode
(
JourneySection
::
Walking
);
}
QPolygonF
sectionPoly
,
transferPoly
;
while
(
reader
.
readNextSibling
())
{
if
(
reader
.
name
()
==
QLatin1String
(
"itdPoint"
))
{
const
auto
type
=
reader
.
attributes
().
value
(
QLatin1String
(
"usage"
));
...
...
@@ -347,18 +348,28 @@ std::vector<JourneySection> EfaXmlParser::parseTripPartialRoute(ScopedXmlStreamR
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"itdStopSeq"
))
{
section
.
setIntermediateStops
(
parsePartialTripStopSequence
(
reader
.
subReader
()));
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"itdPathCoordinates"
))
{
section
.
setPath
(
parsePathCoordinates
(
reader
.
subReader
()));
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"itdITPathDescription"
)
&&
!
section
.
path
().
isEmpty
())
{
sectionPoly
=
parsePathCoordinates
(
reader
.
subReader
());
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"itdInterchangePathCoordinates"
))
{
auto
subreader
=
reader
.
subReader
();
while
(
subreader
.
readNextSibling
())
{
if
(
subreader
.
name
()
==
QLatin1String
(
"itdPathCoordinates"
))
{
transferPoly
=
parsePathCoordinates
(
subreader
.
subReader
());
}
}
}
else
if
(
reader
.
name
()
==
QLatin1String
(
"itdITPathDescription"
)
&&
!
sectionPoly
.
isEmpty
())
{
auto
subreader
=
reader
.
subReader
();
while
(
subreader
.
readNextSibling
())
{
if
(
subreader
.
name
()
==
QLatin1String
(
"itdITPathDescriptionList"
))
{
const
auto
fullPath
=
section
.
path
();
section
.
setPath
(
parsePathDescriptionList
(
subreader
.
subReader
(),
fullPath
.
sections
()[
0
].
path
()));
section
.
setPath
(
parsePathDescriptionList
(
subreader
.
subReader
(),
sectionPoly
));
}
}
}
}
if
(
!
sectionPoly
.
isEmpty
()
&&
section
.
path
().
isEmpty
())
{
section
.
setPath
(
polygonToPath
(
sectionPoly
));
}
return
result
;
}
...
...
@@ -405,15 +416,15 @@ QStringList EfaXmlParser::parseInfoLink(ScopedXmlStreamReader &&reader) const
return
l
;
}
Path
EfaXmlParser
::
parsePathCoordinates
(
ScopedXmlStreamReader
&&
reader
)
const
QPolygonF
EfaXmlParser
::
parsePathCoordinates
(
ScopedXmlStreamReader
&&
reader
)
const
{
Path
path
;
QPolygonF
poly
;
while
(
reader
.
readNextSibling
())
{
if
(
reader
.
name
()
==
QLatin1String
(
"itdCoordinateString"
))
{
p
ath
=
parsePathCoordinatesElement
(
reader
);
p
oly
=
parsePathCoordinatesElement
(
reader
);
}
}
return
p
ath
;
return
p
oly
;
}
Path
EfaXmlParser
::
parsePathDescriptionList
(
ScopedXmlStreamReader
&&
reader
,
const
QPolygonF
&
poly
)
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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