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
e968d6ca
Commit
e968d6ca
authored
Jun 26, 2014
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up Google maps URL building
parent
7e9c2bef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
39 deletions
+42
-39
urlfactory.cpp
libs/opmapcontrol/src/core/urlfactory.cpp
+41
-39
urlfactory.h
libs/opmapcontrol/src/core/urlfactory.h
+1
-0
No files found.
libs/opmapcontrol/src/core/urlfactory.cpp
View file @
e968d6ca
...
@@ -43,7 +43,7 @@ namespace core {
...
@@ -43,7 +43,7 @@ namespace core {
/// <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>
UserAgent
=
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"
;
UserAgent
=
QString
(
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:%1.0) Gecko/%2%3%4 Firefox/%5.0.%6"
).
arg
(
QString
::
number
(
Random
(
3
,
14
)),
QString
::
number
(
Random
(
QDate
().
currentDate
().
year
()
-
4
,
QDate
().
currentDate
().
year
())),
QString
::
number
(
Random
(
11
,
12
)),
QString
::
number
(
Random
(
10
,
30
)),
QString
::
number
(
Random
(
3
,
14
)),
QString
::
number
(
Random
(
1
,
10
))).
toLatin1
()
;
Timeout
=
5
*
1000
;
Timeout
=
5
*
1000
;
CorrectGoogleVersions
=
true
;
CorrectGoogleVersions
=
true
;
...
@@ -54,6 +54,10 @@ namespace core {
...
@@ -54,6 +54,10 @@ namespace core {
UrlFactory
::~
UrlFactory
()
UrlFactory
::~
UrlFactory
()
{
{
}
}
int
UrlFactory
::
Random
(
int
low
,
int
high
)
{
return
low
+
qrand
()
%
(
high
-
low
);
}
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
;
...
@@ -112,7 +116,7 @@ namespace core {
...
@@ -112,7 +116,7 @@ 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
=
"https://maps.google.com"
;
QString
url
=
"https://maps.google.com"
;
qheader
.
setUrl
(
QUrl
(
url
));
qheader
.
setUrl
(
QUrl
(
url
));
...
@@ -131,7 +135,7 @@ namespace core {
...
@@ -131,7 +135,7 @@ namespace core {
return
;
return
;
}
}
QString
html
=
QString
(
reply
->
readAll
());
QString
html
=
QString
(
reply
->
readAll
());
QRegExp
reg
(
"
\"
*https://mt
s
0.google.com/vt/lyrs=m@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
QRegExp
reg
(
"
\"
*https://mt0.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
();
...
@@ -143,7 +147,7 @@ namespace core {
...
@@ -143,7 +147,7 @@ namespace core {
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
}
}
reg
=
QRegExp
(
"
\"
*https://mts
0.google.com/vt/lyrs=h@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*https://mt
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
();
...
@@ -153,7 +157,7 @@ namespace core {
...
@@ -153,7 +157,7 @@ namespace core {
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleLabels: "
<<
VersionGoogleLabels
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleLabels: "
<<
VersionGoogleLabels
;
#endif //DEBUG_URLFACTORY
#endif //DEBUG_URLFACTORY
}
}
reg
=
QRegExp
(
"
\"
*https://khm
s0
.google.com/kh/v=(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*https://khm
\\
D?
\\
d
.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
();
...
@@ -163,7 +167,7 @@ namespace core {
...
@@ -163,7 +167,7 @@ namespace core {
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleSatellite: "
<<
VersionGoogleSatellite
;
qDebug
()
<<
"TryCorrectGoogleVersions, VersionGoogleSatellite: "
<<
VersionGoogleSatellite
;
}
}
reg
=
QRegExp
(
"
\"
*https://mt
s
0.google.com/vt/lyrs=t@(
\\
d*),r@(
\\
d*)"
,
Qt
::
CaseInsensitive
);
reg
=
QRegExp
(
"
\"
*https://mt0.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
();
...
@@ -206,7 +210,6 @@ namespace core {
...
@@ -206,7 +210,6 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
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
(
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
;
...
@@ -230,7 +233,6 @@ namespace core {
...
@@ -230,7 +233,6 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
TryCorrectGoogleVersions
();
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
);
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
;
break
;
...
@@ -244,7 +246,7 @@ namespace core {
...
@@ -244,7 +246,7 @@ namespace core {
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
// http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
// http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
return
QString
(
"http://%1%2.google.cn/%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
(
VersionGoogleMapChina
).
arg
(
"zh-CN"
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.cn/%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
(
VersionGoogleMapChina
).
arg
(
"zh-CN"
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleSatelliteChina
:
case
MapType
:
:
GoogleSatelliteChina
:
...
@@ -255,9 +257,9 @@ namespace core {
...
@@ -255,9 +257,9 @@ namespace core {
QString
sec2
=
""
;
// after &zoom=...
QString
sec2
=
""
;
// after &zoom=...
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
GetSecGoogleWords
(
pos
,
sec1
,
sec2
);
// TryCorrectGoogleVersions();
// TryCorrectGoogleVersions();
// http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga
// http
s
://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga
return
QString
(
"http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatelliteChina
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleSatelliteChina
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleLabelsChina
:
case
MapType
:
:
GoogleLabelsChina
:
...
@@ -270,7 +272,7 @@ namespace core {
...
@@ -270,7 +272,7 @@ namespace core {
TryCorrectGoogleVersions
();
TryCorrectGoogleVersions
();
// http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
// http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
return
QString
(
"http://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabelsChina
).
arg
(
"zh-CN"
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
return
QString
(
"http
s
://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10"
).
arg
(
server
).
arg
(
GetServerNum
(
pos
,
4
)).
arg
(
request
).
arg
(
VersionGoogleLabelsChina
).
arg
(
"zh-CN"
).
arg
(
pos
.
X
()).
arg
(
sec1
).
arg
(
pos
.
Y
()).
arg
(
zoom
).
arg
(
sec2
);
}
}
break
;
break
;
case
MapType
:
:
GoogleTerrainChina
:
case
MapType
:
:
GoogleTerrainChina
:
...
@@ -284,7 +286,7 @@ namespace core {
...
@@ -284,7 +286,7 @@ namespace core {
// http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
// 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
);
return
QString
(
"http
s
://%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
);
}
}
break
;
break
;
case
MapType
:
:
GoogleMapKorea
:
case
MapType
:
:
GoogleMapKorea
:
...
@@ -311,7 +313,7 @@ namespace core {
...
@@ -311,7 +313,7 @@ namespace core {
// 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
s
://%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
);
}
}
break
;
break
;
case
MapType
:
:
GoogleLabelsKorea
:
case
MapType
:
:
GoogleLabelsKorea
:
...
@@ -502,12 +504,12 @@ namespace core {
...
@@ -502,12 +504,12 @@ namespace core {
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
s
://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
)
{
{
return
QString
(
"http://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4"
).
arg
(
language
).
arg
(
QString
::
number
(
pt
.
Lat
())).
arg
(
QString
::
number
(
pt
.
Lng
())).
arg
(
GoogleMapsAPIKey
);
return
QString
(
"http
s
://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4"
).
arg
(
language
).
arg
(
QString
::
number
(
pt
.
Lat
())).
arg
(
QString
::
number
(
pt
.
Lng
())).
arg
(
GoogleMapsAPIKey
);
}
}
internals
::
PointLatLng
UrlFactory
::
GetLatLngFromGeodecoder
(
const
QString
&
keywords
,
GeoCoderStatusCode
::
Types
&
status
)
internals
::
PointLatLng
UrlFactory
::
GetLatLngFromGeodecoder
(
const
QString
&
keywords
,
GeoCoderStatusCode
::
Types
&
status
)
...
...
libs/opmapcontrol/src/core/urlfactory.h
View file @
e968d6ca
...
@@ -61,6 +61,7 @@ namespace core {
...
@@ -61,6 +61,7 @@ namespace core {
Placemark
GetPlacemarkFromGeocoder
(
internals
::
PointLatLng
location
);
Placemark
GetPlacemarkFromGeocoder
(
internals
::
PointLatLng
location
);
int
Timeout
;
int
Timeout
;
private:
private:
int
Random
(
int
low
,
int
high
);
void
GetSecGoogleWords
(
const
core
::
Point
&
pos
,
QString
&
sec1
,
QString
&
sec2
);
void
GetSecGoogleWords
(
const
core
::
Point
&
pos
,
QString
&
sec1
,
QString
&
sec2
);
int
GetServerNum
(
const
core
::
Point
&
pos
,
const
int
&
max
)
const
;
int
GetServerNum
(
const
core
::
Point
&
pos
,
const
int
&
max
)
const
;
void
TryCorrectGoogleVersions
();
void
TryCorrectGoogleVersions
();
...
...
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