Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
d043c24c
Commit
d043c24c
authored
Mar 26, 2014
by
WillRam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy of current OpenPilot file. Proxy fixed
Proxy now follows system proxy
parent
49b9228e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
18 deletions
+59
-18
urlfactory.cpp
libs/opmapcontrol/src/core/urlfactory.cpp
+59
-18
No files found.
libs/opmapcontrol/src/core/urlfactory.cpp
View file @
d043c24c
...
@@ -37,9 +37,9 @@ namespace core {
...
@@ -37,9 +37,9 @@ namespace core {
/// <summary>
/// <summary>
/// timeout for map connections
/// timeout for map connections
/// </summary>
/// </summary>
QNetworkProxyFactory
::
setUseSystemConfiguration
(
true
);
Proxy
.
setType
(
QNetworkProxy
::
NoProxy
);
/// <summary>
/// <summary>
/// Gets or sets the value of the User-agent HTTP header.
/// Gets or sets the value of the User-agent HTTP header.
/// </summary>
/// </summary>
...
@@ -54,19 +54,24 @@ namespace core {
...
@@ -54,19 +54,24 @@ namespace core {
UrlFactory
::~
UrlFactory
()
UrlFactory
::~
UrlFactory
()
{
{
}
}
QString
UrlFactory
::
TileXYToQuadKey
(
const
int
&
tileX
,
const
int
&
tileY
,
const
int
&
levelOfDetail
)
const
QString
UrlFactory
::
TileXYToQuadKey
(
const
int
&
tileX
,
const
int
&
tileY
,
const
int
&
levelOfDetail
)
const
{
{
QString
quadKey
;
QString
quadKey
;
for
(
int
i
=
levelOfDetail
;
i
>
0
;
i
--
)
for
(
int
i
=
levelOfDetail
;
i
>
0
;
i
--
)
{
{
char
digit
=
'0'
;
char
digit
=
'0'
;
int
mask
=
1
<<
(
i
-
1
);
int
mask
=
1
<<
(
i
-
1
);
if
((
tileX
&
mask
)
!=
0
)
if
((
tileX
&
mask
)
!=
0
)
{
{
digit
++
;
digit
++
;
}
}
if
((
tileY
&
mask
)
!=
0
)
if
((
tileY
&
mask
)
!=
0
)
{
{
digit
++
;
digit
++
;
digit
++
;
digit
++
;
}
}
...
@@ -90,9 +95,19 @@ namespace core {
...
@@ -90,9 +95,19 @@ namespace core {
void
UrlFactory
::
TryCorrectGoogleVersions
()
void
UrlFactory
::
TryCorrectGoogleVersions
()
{
{
static
bool
versionRetrieved
=
false
;
if
(
versionRetrieved
)
{
return
;
}
QMutexLocker
locker
(
&
mutex
);
QMutexLocker
locker
(
&
mutex
);
if
(
CorrectGoogleVersions
&&
!
IsCorrectGoogleVersions
())
if
(
CorrectGoogleVersions
&&
!
IsCorrectGoogleVersions
())
{
{
QNetworkReply
*
reply
;
QNetworkReply
*
reply
;
QNetworkRequest
qheader
;
QNetworkRequest
qheader
;
QNetworkAccessManager
network
;
QNetworkAccessManager
network
;
...
@@ -106,8 +121,8 @@ namespace core {
...
@@ -106,8 +121,8 @@ namespace core {
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Correct GoogleVersion"
;
qDebug
()
<<
"Correct GoogleVersion"
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
setIsCorrectGoogleVersions
(
true
);
//
setIsCorrectGoogleVersions(true);
QString
url
=
"http://maps.google.com"
;
QString
url
=
"http
s
://maps.google.com"
;
qheader
.
setUrl
(
QUrl
(
url
));
qheader
.
setUrl
(
QUrl
(
url
));
qheader
.
setRawHeader
(
"User-Agent"
,
UserAgent
);
qheader
.
setRawHeader
(
"User-Agent"
,
UserAgent
);
...
@@ -116,6 +131,7 @@ namespace core {
...
@@ -116,6 +131,7 @@ namespace core {
q
.
exec
();
q
.
exec
();
if
(
!
tT
.
isActive
())
if
(
!
tT
.
isActive
())
return
;
return
;
tT
.
stop
();
tT
.
stop
();
if
(
(
reply
->
error
()
!=
QNetworkReply
::
NoError
))
if
(
(
reply
->
error
()
!=
QNetworkReply
::
NoError
))
{
{
...
@@ -125,28 +141,30 @@ namespace core {
...
@@ -125,28 +141,30 @@ namespace core {
return
;
return
;
}
}
QString
html
=
QString
(
reply
->
readAll
());
QString
html
=
QString
(
reply
->
readAll
());
QRegExp
reg
(
"
\"
*http
://mt
0.google.com/vt/lyrs=m@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
QRegExp
reg
(
"
\"
*http
s://mts
0.google.com/vt/lyrs=m@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
if
(
reg
.
indexIn
(
html
)
!=-
1
)
if
(
reg
.
indexIn
(
html
)
!=-
1
)
{
{
QStringList
gc
=
reg
.
capturedTexts
();
QStringList
gc
=
reg
.
capturedTexts
();
VersionGoogleMap
=
QString
(
"m@%1"
).
arg
(
gc
[
1
]);
VersionGoogleMap
=
QString
(
"m@%1"
).
arg
(
gc
[
1
]);
VersionGoogleMapChina
=
VersionGoogleMap
;
VersionGoogleMapChina
=
VersionGoogleMap
;
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleMap: "
<<
VersionGoogleMap
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleMap: "
<<
VersionGoogleMap
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
}
}
reg
=
QRegExp
(
"
\"
*http://mt
0.google.com/vt/lyrs=h@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*https://mts
0.google.com/vt/lyrs=h@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
if
(
reg
.
indexIn
(
html
)
!=-
1
)
if
(
reg
.
indexIn
(
html
)
!=-
1
)
{
{
QStringList
gc
=
reg
.
capturedTexts
();
QStringList
gc
=
reg
.
capturedTexts
();
VersionGoogleLabels
=
QString
(
"h@%1"
).
arg
(
gc
[
1
]);
VersionGoogleLabels
=
QString
(
"h@%1"
).
arg
(
gc
[
1
]);
VersionGoogleLabelsChina
=
VersionGoogleLabels
;
VersionGoogleLabelsChina
=
VersionGoogleLabels
;
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleLabels: "
<<
VersionGoogleLabels
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleLabels: "
<<
VersionGoogleLabels
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
}
}
reg
=
QRegExp
(
"
\"
*http
://khm
0.google.com/kh/v=(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*http
s://khms
0.google.com/kh/v=(
\\
d*)"
,
Qt
::
CaseInsensitive
);
if
(
reg
.
indexIn
(
html
)
!=-
1
)
if
(
reg
.
indexIn
(
html
)
!=-
1
)
{
{
QStringList
gc
=
reg
.
capturedTexts
();
QStringList
gc
=
reg
.
capturedTexts
();
...
@@ -157,18 +175,20 @@ namespace core {
...
@@ -157,18 +175,20 @@ namespace core {
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleSatellite: "
<<
VersionGoogleSatellite
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleSatellite: "
<<
VersionGoogleSatellite
;
}
}
reg
=
QRegExp
(
"
\"
*http
://mt
0.google.com/vt/lyrs=t@(
\\
d*),r@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*http
s://mts
0.google.com/vt/lyrs=t@(
\\
d*),r@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
if
(
reg
.
indexIn
(
html
)
!=-
1
)
if
(
reg
.
indexIn
(
html
)
!=-
1
)
{
{
QStringList
gc
=
reg
.
capturedTexts
();
QStringList
gc
=
reg
.
capturedTexts
();
VersionGoogleTerrain
=
QString
(
"t@%1,r@%2"
).
arg
(
gc
[
1
]).
arg
(
gc
[
2
]);
VersionGoogleTerrain
=
QString
(
"t@%1,r@%2"
).
arg
(
gc
[
1
]).
arg
(
gc
[
2
]);
VersionGoogleTerrainChina
=
VersionGoogleTerrain
;
VersionGoogleTerrainChina
=
VersionGoogleTerrain
;
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleTerrain: "
<<
VersionGoogleTerrain
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleTerrain: "
<<
VersionGoogleTerrain
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
}
}
reply
->
deleteLater
();
reply
->
deleteLater
();
}
}
}
}
...
@@ -180,50 +200,52 @@ namespace core {
...
@@ -180,50 +200,52 @@ namespace core {
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
switch
(
type
)
switch
(
type
)
{
{
case
MapType
:
:
GoogleMap
:
case
MapType
:
:
GoogleMap
:
{
{
QString
server
=
"mt"
;
QString
server
=
"mt
s
"
;
QString
request
=
"vt"
;
QString
request
=
"vt"
;
QString
sec1
=
""
;
// after &x=...
QString
sec1
=
""
;
// after &x=...
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
return
QString
(
"http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleMap
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleMap
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleSatellite
:
case
MapType
:
:
GoogleSatellite
:
{
{
QString
server
=
"khm"
;
QString
server
=
"khm
s
"
;
QString
request
=
"kh"
;
QString
request
=
"kh"
;
QString
sec1
=
""
;
// after &x=...
QString
sec1
=
""
;
// after &x=...
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
return
QString
(
"http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatellite
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatellite
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleLabels
:
case
MapType
:
:
GoogleLabels
:
{
{
QString
server
=
"mt"
;
QString
server
=
"mt
s
"
;
QString
request
=
"vt"
;
QString
request
=
"vt"
;
QString
sec1
=
""
;
// after &x=...
QString
sec1
=
""
;
// after &x=...
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
return
QString
(
"http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabels
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabels
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleTerrain
:
case
MapType
:
:
GoogleTerrain
:
{
{
QString
server
=
"mt"
;
QString
server
=
"mt
s
"
;
QString
request
=
"vt"
;
QString
request
=
"vt"
;
QString
sec1
=
""
;
// after &x=...
QString
sec1
=
""
;
// after &x=...
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
return
QString
(
"http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleTerrain
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleTerrain
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleMapChina
:
case
MapType
:
:
GoogleMapChina
:
...
@@ -286,9 +308,13 @@ namespace core {
...
@@ -286,9 +308,13 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
//http://mt3.gmaptiles.co.kr/mt/v=kr1.11&hl=lt&x=109&y=49&z=7&s=
//http://mt3.gmaptiles.co.kr/mt/v=kr1.11&hl=lt&x=109&y=49&z=7&s=
QString
ret
=
QString
(
"http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleMapKorea
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
QString
ret
=
QString
(
"https://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleMapKorea
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
ret
;
return
ret
;
}
}
break
;
break
;
...
@@ -300,6 +326,7 @@ namespace core {
...
@@ -300,6 +326,7 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
// http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s=
// http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s=
return
QString
(
"http://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatelliteKorea
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatelliteKorea
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
...
@@ -313,9 +340,10 @@ namespace core {
...
@@ -313,9 +340,10 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
// http://mt1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G
// http://mt1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G
return
QString
(
"http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabelsKorea
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabelsKorea
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
YahooMap
:
case
MapType
:
:
YahooMap
:
...
@@ -487,12 +515,14 @@ namespace core {
...
@@ -487,12 +515,14 @@ namespace core {
sec2
=
SecGoogleWord
.
left
(
seclen
);
sec2
=
SecGoogleWord
.
left
(
seclen
);
if
(
pos
.
Y
()
>=
10000
&&
pos
.
Y
()
<
100000
)
if
(
pos
.
Y
()
>=
10000
&&
pos
.
Y
()
<
100000
)
{
{
sec1
=
"&s="
;
sec1
=
"&s="
;
}
}
}
}
QString
UrlFactory
::
MakeGeocoderUrl
(
QString
keywords
)
QString
UrlFactory
::
MakeGeocoderUrl
(
QString
keywords
)
{
{
QString
key
=
keywords
.
replace
(
' '
,
'+'
);
QString
key
=
keywords
.
replace
(
' '
,
'+'
);
return
QString
(
"http://maps.google.com/maps/geo?q=%1&output=csv&key=%2"
).
arg
(
key
).
arg
(
GoogleMapsAPIKey
);
return
QString
(
"http://maps.google.com/maps/geo?q=%1&output=csv&key=%2"
).
arg
(
key
).
arg
(
GoogleMapsAPIKey
);
}
}
QString
UrlFactory
::
MakeReverseGeocoderUrl
(
internals
::
PointLatLng
&
pt
,
const
QString
&
language
)
QString
UrlFactory
::
MakeReverseGeocoderUrl
(
internals
::
PointLatLng
&
pt
,
const
QString
&
language
)
...
@@ -542,7 +572,9 @@ namespace core {
...
@@ -542,7 +572,9 @@ namespace core {
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
QTime
time
;
QTime
time
;
time
.
start
();
time
.
start
();
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
...
@@ -563,6 +595,7 @@ namespace core {
...
@@ -563,6 +595,7 @@ namespace core {
// cache geocoding
// cache geocoding
if
(
useCache
&&
geo
.
startsWith
(
"200"
))
if
(
useCache
&&
geo
.
startsWith
(
"200"
))
{
{
Cache
::
Instance
()
->
CacheGeocoder
(
urlEnd
,
geo
);
Cache
::
Instance
()
->
CacheGeocoder
(
urlEnd
,
geo
);
}
}
}
}
...
@@ -577,9 +610,11 @@ namespace core {
...
@@ -577,9 +610,11 @@ namespace core {
QStringList
values
=
geo
.
split
(
','
);
QStringList
values
=
geo
.
split
(
','
);
if
(
values
.
count
()
==
4
)
if
(
values
.
count
()
==
4
)
{
{
status
=
(
GeoCoderStatusCode
::
Types
)
QString
(
values
[
0
]).
toInt
();
status
=
(
GeoCoderStatusCode
::
Types
)
QString
(
values
[
0
]).
toInt
();
if
(
status
==
GeoCoderStatusCode
::
G_GEO_SUCCESS
)
if
(
status
==
GeoCoderStatusCode
::
G_GEO_SUCCESS
)
{
{
double
lat
=
QString
(
values
[
2
]).
toDouble
();
double
lat
=
QString
(
values
[
2
]).
toDouble
();
double
lng
=
QString
(
values
[
3
]).
toDouble
();
double
lng
=
QString
(
values
[
3
]).
toDouble
();
...
@@ -602,6 +637,7 @@ namespace core {
...
@@ -602,6 +637,7 @@ namespace core {
{
{
Placemark
ret
(
""
);
Placemark
ret
(
""
);
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Entered GetPlacemarkFromReverseGeocoderUrl:"
;
qDebug
()
<<
"Entered GetPlacemarkFromReverseGeocoderUrl:"
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
...
@@ -636,7 +672,9 @@ namespace core {
...
@@ -636,7 +672,9 @@ namespace core {
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
QTime
time
;
QTime
time
;
time
.
start
();
time
.
start
();
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
#ifdef DEBUG_URLFACTORY
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
...
@@ -660,6 +698,7 @@ namespace core {
...
@@ -660,6 +698,7 @@ namespace core {
// cache geocoding
// cache geocoding
if
(
useCache
&&
reverse
.
startsWith
(
"200"
))
if
(
useCache
&&
reverse
.
startsWith
(
"200"
))
{
{
Cache
::
Instance
()
->
CachePlacemark
(
urlEnd
,
reverse
);
Cache
::
Instance
()
->
CachePlacemark
(
urlEnd
,
reverse
);
}
}
}
}
...
@@ -672,6 +711,7 @@ namespace core {
...
@@ -672,6 +711,7 @@ namespace core {
// false: 602,0,0,0
// false: 602,0,0,0
if
(
reverse
.
startsWith
(
"200"
))
if
(
reverse
.
startsWith
(
"200"
))
{
{
QString
acc
=
reverse
.
left
(
reverse
.
indexOf
(
'\"'
));
QString
acc
=
reverse
.
left
(
reverse
.
indexOf
(
'\"'
));
ret
=
Placemark
(
reverse
.
remove
(
reverse
.
indexOf
(
'\"'
)));
ret
=
Placemark
(
reverse
.
remove
(
reverse
.
indexOf
(
'\"'
)));
ret
.
SetAccuracy
((
int
)
((
(
QString
)
acc
.
split
(
','
)[
1
]).
toInt
())
);
ret
.
SetAccuracy
((
int
)
((
(
QString
)
acc
.
split
(
','
)[
1
]).
toInt
())
);
...
@@ -690,6 +730,7 @@ namespace core {
...
@@ -690,6 +730,7 @@ namespace core {
double
a
=
pow
(
sin
(
dLatitude
/
2
),
2
)
+
cos
(
dLat1InRad
)
*
cos
(
dLat2InRad
)
*
pow
(
sin
(
dLongitude
/
2
),
2
);
double
a
=
pow
(
sin
(
dLatitude
/
2
),
2
)
+
cos
(
dLat1InRad
)
*
cos
(
dLat2InRad
)
*
pow
(
sin
(
dLongitude
/
2
),
2
);
double
c
=
2
*
atan2
(
sqrt
(
a
),
sqrt
(
1
-
a
));
double
c
=
2
*
atan2
(
sqrt
(
a
),
sqrt
(
1
-
a
));
double
dDistance
=
EarthRadiusKm
*
c
;
double
dDistance
=
EarthRadiusKm
*
c
;
return
dDistance
;
return
dDistance
;
}
}
}
}
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