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
e9c55413
Commit
e9c55413
authored
Sep 03, 2021
by
Volker Krause
Browse files
Filter out garbage address values
Seems to be a problem in some GBFS feeds.
parent
353f7e32
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/gbfs/gbfsbackend.cpp
View file @
e9c55413
...
...
@@ -21,6 +21,8 @@
#include
<QJsonDocument>
#include
<QJsonObject>
#include
<functional>
using
namespace
KPublicTransport
;
GBFSBackend
::
GBFSBackend
()
=
default
;
...
...
@@ -85,6 +87,15 @@ static RentalVehicle::VehicleType gbfs2kptVehicleType(const GBFSVehicleType &veh
return
RentalVehicle
::
Unknown
;
}
// we get some address values just being " , "...
static
QString
cleanAddress
(
const
QString
&
input
)
{
if
(
std
::
any_of
(
input
.
begin
(),
input
.
end
(),
std
::
mem_fn
(
&
QChar
::
isLetter
)))
{
return
input
;
}
return
{};
}
static
void
appendResults
(
const
GBFSService
&
service
,
const
LocationRequest
&
req
,
QueryContext
*
context
)
{
GBFSStore
store
(
service
.
systemId
);
...
...
@@ -112,7 +123,7 @@ static void appendResults(const GBFSService &service, const LocationRequest &req
loc
.
setName
(
station
.
value
(
QLatin1String
(
"name"
)).
toString
());
const
auto
stationId
=
stationIdToString
(
station
.
value
(
QLatin1String
(
"station_id"
)));
loc
.
setIdentifier
(
service
.
systemId
,
stationId
);
loc
.
setStreetAddress
(
station
.
value
(
QLatin1String
(
"address"
)).
toString
());
loc
.
setStreetAddress
(
cleanAddress
(
station
.
value
(
QLatin1String
(
"address"
)).
toString
())
)
;
loc
.
setPostalCode
(
station
.
value
(
QLatin1String
(
"post_code"
)).
toString
());
// TODO cover more properties
...
...
Write
Preview
Supports
Markdown
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