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
f576d9e0
Commit
f576d9e0
authored
May 07, 2014
by
WillRam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whitespace
parent
d043c24c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
42 deletions
+10
-42
urlfactory.cpp
libs/opmapcontrol/src/core/urlfactory.cpp
+10
-42
No files found.
libs/opmapcontrol/src/core/urlfactory.cpp
View file @
f576d9e0
...
...
@@ -54,24 +54,19 @@ namespace core {
UrlFactory
::~
UrlFactory
()
{
}
QString
UrlFactory
::
TileXYToQuadKey
(
const
int
&
tileX
,
const
int
&
tileY
,
const
int
&
levelOfDetail
)
const
{
QString
quadKey
;
for
(
int
i
=
levelOfDetail
;
i
>
0
;
i
--
)
{
char
digit
=
'0'
;
int
mask
=
1
<<
(
i
-
1
);
if
((
tileX
&
mask
)
!=
0
)
{
digit
++
;
}
if
((
tileY
&
mask
)
!=
0
)
{
digit
++
;
digit
++
;
}
...
...
@@ -99,15 +94,11 @@ namespace core {
if
(
versionRetrieved
)
{
return
;
}
QMutexLocker
locker
(
&
mutex
);
if
(
CorrectGoogleVersions
&&
!
IsCorrectGoogleVersions
())
{
QNetworkReply
*
reply
;
QNetworkRequest
qheader
;
QNetworkAccessManager
network
;
...
...
@@ -131,7 +122,6 @@ namespace core {
q
.
exec
();
if
(
!
tT
.
isActive
())
return
;
tT
.
stop
();
if
(
(
reply
->
error
()
!=
QNetworkReply
::
NoError
))
{
...
...
@@ -159,7 +149,6 @@ namespace core {
QStringList
gc
=
reg
.
capturedTexts
();
VersionGoogleLabels
=
QString
(
"h@%1"
).
arg
(
gc
[
1
]);
VersionGoogleLabelsChina
=
VersionGoogleLabels
;
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleLabels: "
<<
VersionGoogleLabels
;
#endif //DEBUG_URLFACTORY
...
...
@@ -171,7 +160,6 @@ namespace core {
VersionGoogleSatellite
=
gc
[
1
];
VersionGoogleSatelliteKorea
=
VersionGoogleSatellite
;
VersionGoogleSatelliteChina
=
"s@"
+
VersionGoogleSatellite
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleSatellite: "
<<
VersionGoogleSatellite
;
}
...
...
@@ -181,14 +169,12 @@ namespace core {
QStringList
gc
=
reg
.
capturedTexts
();
VersionGoogleTerrain
=
QString
(
"t@%1,r@%2"
).
arg
(
gc
[
1
]).
arg
(
gc
[
2
]);
VersionGoogleTerrainChina
=
VersionGoogleTerrain
;
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleTerrain: "
<<
VersionGoogleTerrain
;
#endif //DEBUG_URLFACTORY
}
reply
->
deleteLater
();
}
}
...
...
@@ -200,7 +186,6 @@ namespace core {
#endif //DEBUG_URLFACTORY
switch
(
type
)
{
case
MapType
:
:
GoogleMap
:
{
QString
server
=
"mts"
;
...
...
@@ -245,6 +230,7 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
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
(
VersionGoogleTerrain
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
break
;
...
...
@@ -295,6 +281,7 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
// http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
return
QString
(
"http://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleTerrainChina
).
arg
(
"zh-CN"
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
...
...
@@ -308,12 +295,8 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
//http://mt3.gmaptiles.co.kr/mt/v=kr1.11&hl=lt&x=109&y=49&z=7&s=
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
;
}
...
...
@@ -326,7 +309,6 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
// 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
);
...
...
@@ -340,7 +322,6 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
// http://mt1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G
return
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
(
VersionGoogleLabelsKorea
).
arg
(
language
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
...
...
@@ -515,14 +496,12 @@ namespace core {
sec2
=
SecGoogleWord
.
left
(
seclen
);
if
(
pos
.
Y
()
>=
10000
&&
pos
.
Y
()
<
100000
)
{
sec1
=
"&s="
;
}
}
QString
UrlFactory
::
MakeGeocoderUrl
(
QString
keywords
)
{
QString
key
=
keywords
.
replace
(
' '
,
'+'
);
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
)
...
...
@@ -572,9 +551,7 @@ namespace core {
#endif //DEBUG_URLFACTORY
QTime
time
;
time
.
start
();
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
#endif //DEBUG_URLFACTORY
...
...
@@ -595,7 +572,6 @@ namespace core {
// cache geocoding
if
(
useCache
&&
geo
.
startsWith
(
"200"
))
{
Cache
::
Instance
()
->
CacheGeocoder
(
urlEnd
,
geo
);
}
}
...
...
@@ -610,11 +586,9 @@ namespace core {
QStringList
values
=
geo
.
split
(
','
);
if
(
values
.
count
()
==
4
)
{
status
=
(
GeoCoderStatusCode
::
Types
)
QString
(
values
[
0
]).
toInt
();
if
(
status
==
GeoCoderStatusCode
::
G_GEO_SUCCESS
)
{
double
lat
=
QString
(
values
[
2
]).
toDouble
();
double
lng
=
QString
(
values
[
3
]).
toDouble
();
...
...
@@ -637,7 +611,6 @@ namespace core {
{
Placemark
ret
(
""
);
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Entered GetPlacemarkFromReverseGeocoderUrl:"
;
#endif //DEBUG_URLFACTORY
...
...
@@ -672,9 +645,7 @@ namespace core {
#endif //DEBUG_URLFACTORY
QTime
time
;
time
.
start
();
while
(
(
!
(
reply
->
isFinished
())
||
(
time
.
elapsed
()
>
(
6
*
Timeout
)))
){
QCoreApplication
::
processEvents
(
QEventLoop
::
AllEvents
);}
#ifdef DEBUG_URLFACTORY
qDebug
()
<<
"Finished?"
<<
reply
->
error
()
<<
" abort?"
<<
(
time
.
elapsed
()
>
Timeout
*
6
);
#endif //DEBUG_URLFACTORY
...
...
@@ -698,7 +669,6 @@ namespace core {
// cache geocoding
if
(
useCache
&&
reverse
.
startsWith
(
"200"
))
{
Cache
::
Instance
()
->
CachePlacemark
(
urlEnd
,
reverse
);
}
}
...
...
@@ -711,7 +681,6 @@ namespace core {
// false: 602,0,0,0
if
(
reverse
.
startsWith
(
"200"
))
{
QString
acc
=
reverse
.
left
(
reverse
.
indexOf
(
'\"'
));
ret
=
Placemark
(
reverse
.
remove
(
reverse
.
indexOf
(
'\"'
)));
ret
.
SetAccuracy
((
int
)
((
(
QString
)
acc
.
split
(
','
)[
1
]).
toInt
())
);
...
...
@@ -730,7 +699,6 @@ namespace core {
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
dDistance
=
EarthRadiusKm
*
c
;
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