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
Libraries
KOSMIndoorMap
Commits
663141f1
Commit
663141f1
authored
Feb 04, 2022
by
Volker Krause
Browse files
Fill in missing country/state information based on the coordinate
Gives us correct location-aware address formatting in more cases.
parent
8ff9e614
Pipeline
#133136
passed with stages
in 1 minute and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/map-quick/CMakeLists.txt
View file @
663141f1
...
...
@@ -11,6 +11,7 @@ add_library(KOSMIndoorMapQuick STATIC
target_link_libraries
(
KOSMIndoorMapQuick PUBLIC
Qt5::Quick
KF5::I18n
KF5::I18nLocaleData
KOSMIndoorMap
)
...
...
src/map-quick/osmaddress.cpp
View file @
663141f1
...
...
@@ -6,6 +6,9 @@
#include
"osmaddress.h"
#include
<KCountry>
#include
<KCountrySubdivision>
using
namespace
KOSMIndoorMap
;
OSMAddress
::
OSMAddress
()
=
default
;
...
...
@@ -38,10 +41,22 @@ QString OSMAddress::city() const
QString
OSMAddress
::
state
()
const
{
return
QString
::
fromUtf8
(
m_element
.
tagValue
(
"addr:state"
));
const
auto
state
=
QString
::
fromUtf8
(
m_element
.
tagValue
(
"addr:state"
));
if
(
!
state
.
isEmpty
())
{
return
state
;
}
const
auto
s
=
KCountrySubdivision
::
fromLocation
(
m_element
.
center
().
latF
(),
m_element
.
center
().
lonF
());
return
s
.
isValid
()
?
s
.
code
().
left
(
3
)
:
QString
();
}
QString
OSMAddress
::
country
()
const
{
return
QString
::
fromUtf8
(
m_element
.
tagValue
(
"addr:country"
,
"contact:country"
));
const
auto
country
=
QString
::
fromUtf8
(
m_element
.
tagValue
(
"addr:country"
,
"contact:country"
));
if
(
!
country
.
isEmpty
())
{
return
country
;
}
const
auto
c
=
KCountry
::
fromLocation
(
m_element
.
center
().
latF
(),
m_element
.
center
().
lonF
());
return
c
.
alpha2
();
}
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