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
a8a65d0c
Commit
a8a65d0c
authored
Jun 09, 2021
by
Volker Krause
Browse files
Use a location type dependent distance threshold for merging
For rental bikes this needs to be much smaller than for e.g. for stops.
parent
c4f9a96c
Pipeline
#64937
passed with stage
in 23 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/datatypes/location.cpp
View file @
a8a65d0c
...
...
@@ -243,6 +243,22 @@ static bool isCompatibleLocationType(Location::Type lhs, Location::Type rhs)
return
lhs
==
Location
::
Stop
;
}
static
int
isSameDistanceThreshold
(
Location
::
Type
type
)
{
switch
(
type
)
{
case
Location
::
Place
:
case
Location
::
Stop
:
case
Location
::
CarpoolPickupDropoff
:
return
10
;
// meter
case
Location
::
RentedVehicleStation
:
return
5
;
case
Location
::
Equipment
:
case
Location
::
RentedVehicle
:
return
3
;
}
Q_UNREACHABLE
();
}
bool
Location
::
isSame
(
const
Location
&
lhs
,
const
Location
&
rhs
)
{
const
auto
dist
=
Location
::
distance
(
lhs
.
latitude
(),
lhs
.
longitude
(),
rhs
.
latitude
(),
rhs
.
longitude
());
...
...
@@ -294,8 +310,8 @@ bool Location::isSame(const Location &lhs, const Location &rhs)
// TODO consider the address properties here?
// anything
less than 10m apart
is assumed to be the same
if
(
lhs
.
hasCoordinate
()
&&
rhs
.
hasCoordinate
()
&&
dist
<
10
)
{
// anything
sufficiently close together
is assumed to be the same
if
(
lhs
.
hasCoordinate
()
&&
rhs
.
hasCoordinate
()
&&
dist
<
std
::
min
(
isSameDistanceThreshold
(
lhs
.
type
()),
isSameDistanceThreshold
(
rhs
.
type
()))
)
{
return
true
;
}
...
...
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