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
31c42dc6
Commit
31c42dc6
authored
Apr 18, 2021
by
Volker Krause
Browse files
Port stopover queries to use the new coverage data
parent
cf89ec37
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/manager.cpp
View file @
31c42dc6
...
...
@@ -406,17 +406,6 @@ bool ManagerPrivate::queryJourney(const AbstractBackend* backend, const JourneyR
bool
ManagerPrivate
::
queryStopover
(
const
AbstractBackend
*
backend
,
const
StopoverRequest
&
req
,
StopoverReply
*
reply
)
{
if
(
shouldSkipBackend
(
backend
,
req
))
{
return
false
;
}
if
(
req
.
mode
()
==
StopoverRequest
::
QueryArrival
&&
(
backend
->
capabilities
()
&
AbstractBackend
::
CanQueryArrivals
)
==
0
)
{
qCDebug
(
Log
)
<<
"Skipping backend due to not supporting arrival queries:"
<<
backend
->
backendId
();
return
false
;
}
if
(
backend
->
isLocationExcluded
(
req
.
stop
()))
{
qCDebug
(
Log
)
<<
"Skipping backend based on location filter:"
<<
backend
->
backendId
();
return
false
;
}
reply
->
addAttribution
(
backend
->
attribution
());
auto
cache
=
Cache
::
lookupDeparture
(
backend
->
backendId
(),
req
.
cacheKey
());
...
...
@@ -595,9 +584,32 @@ StopoverReply* Manager::queryStopover(const StopoverRequest &req) const
// first time/direct query
if
(
req
.
contexts
().
empty
())
{
for
(
const
auto
&
backend
:
d
->
m_backends
)
{
if
(
d
->
queryStopover
(
BackendPrivate
::
impl
(
backend
),
req
,
reply
))
{
++
pendingOps
;
QSet
<
QString
>
triedBackends
;
bool
foundNonGlobalCoverage
=
false
;
for
(
const
auto
coverageType
:
{
CoverageArea
::
Realtime
,
CoverageArea
::
Regular
,
CoverageArea
::
Any
})
{
for
(
const
auto
&
b
:
d
->
m_backends
)
{
const
auto
backend
=
BackendPrivate
::
impl
(
b
);
if
(
triedBackends
.
contains
(
backend
->
backendId
())
||
d
->
shouldSkipBackend
(
backend
,
req
))
{
continue
;
}
if
(
req
.
mode
()
==
StopoverRequest
::
QueryArrival
&&
(
backend
->
capabilities
()
&
AbstractBackend
::
CanQueryArrivals
)
==
0
)
{
qCDebug
(
Log
)
<<
"Skipping backend due to not supporting arrival queries:"
<<
backend
->
backendId
();
continue
;
}
const
auto
coverage
=
b
.
coverageArea
(
coverageType
);
if
(
coverage
.
isEmpty
()
||
!
coverage
.
coversLocation
(
req
.
stop
()))
{
continue
;
}
triedBackends
.
insert
(
backend
->
backendId
());
foundNonGlobalCoverage
|=
!
coverage
.
isGlobal
();
if
(
d
->
queryStopover
(
backend
,
req
,
reply
))
{
++
pendingOps
;
}
}
if
(
pendingOps
&&
foundNonGlobalCoverage
)
{
break
;
}
}
...
...
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