-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: stamen basemap not working (#2451)
- Loading branch information
Showing
15 changed files
with
240 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ | |
#include <ogr_spatialref.h> | ||
|
||
#include <curl/curl.h> | ||
#include "../GdaConst.h" | ||
#include "../GeneralWxUtils.h" | ||
#include "../ShapeOperations/OGRDataAdapter.h" | ||
#include "Basemap.h" | ||
|
||
|
@@ -156,8 +158,6 @@ XYFraction::XYFraction(double _x, double _y) | |
yfrac = modf(_y, &yint); | ||
} | ||
|
||
const char *Basemap::USER_AGENT = "GeoDa 1.14 contact [email protected]"; | ||
|
||
Basemap::Basemap(BasemapItem& _basemap_item, | ||
Screen* _screen, | ||
MapLayer* _map, | ||
|
@@ -612,6 +612,21 @@ size_t curlCallback(void *ptr, size_t size, size_t nmemb, void* userdata) | |
return written; | ||
} | ||
|
||
wxString Basemap::GetUserAgent(const wxString& url) | ||
{ | ||
if (url.Find("openstreetmap") != wxNOT_FOUND) { | ||
return GdaConst::gda_basemap_osm_useragent; | ||
} | ||
if (GeneralWxUtils::isWindows()) { | ||
return GdaConst::gda_basemap_win_useragent; | ||
} else if (GeneralWxUtils::isMac()) { | ||
return GdaConst::gda_basemap_mac_useragent; | ||
} else { | ||
return GdaConst::gda_basemap_linux_useragent; | ||
} | ||
|
||
} | ||
|
||
wxString Basemap::GetContentType() | ||
{ | ||
wxString url = GetTileUrl(16, 11); // guerry | ||
|
@@ -621,7 +636,8 @@ wxString Basemap::GetContentType() | |
if(curl) { | ||
curl_easy_setopt(curl, CURLOPT_URL, url.ToUTF8().data()); | ||
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); | ||
curl_easy_setopt(curl, CURLOPT_USERAGENT, Basemap::USER_AGENT); | ||
curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent(url).ToUTF8().data()); | ||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); | ||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1L); | ||
|
@@ -670,10 +686,10 @@ void Basemap::DownloadTile(int x, int y) | |
if (fp) { | ||
curl_easy_setopt(image, CURLOPT_URL, url.ToUTF8().data()); | ||
curl_easy_setopt(image, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); | ||
curl_easy_setopt(image, CURLOPT_USERAGENT, Basemap::USER_AGENT); | ||
curl_easy_setopt(image, CURLOPT_USERAGENT, GetUserAgent(url).ToUTF8().data()); | ||
curl_easy_setopt(image, CURLOPT_WRITEFUNCTION, curlCallback); | ||
curl_easy_setopt(image, CURLOPT_WRITEDATA, fp); | ||
//curl_easy_setopt(image, CURLOPT_FOLLOWLOCATION, 1); | ||
curl_easy_setopt(image, CURLOPT_FOLLOWLOCATION, 1); | ||
curl_easy_setopt(image, CURLOPT_SSL_VERIFYHOST, 0); | ||
curl_easy_setopt(image, CURLOPT_SSL_VERIFYPEER, 0); | ||
curl_easy_setopt(image, CURLOPT_CONNECTTIMEOUT, 1L); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,6 +395,10 @@ wxString GdaConst::gda_basemap_sources = | |
"\nOther (China).GaoDe,http://webst{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}" | ||
"\nOther (China).GaoDe(Satellite),http://webst{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}" | ||
; | ||
const wxString GdaConst::gda_basemap_osm_useragent = "GeoDa 1.14 contact [email protected]"; | ||
const wxString GdaConst::gda_basemap_win_useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; | ||
const wxString GdaConst::gda_basemap_mac_useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; | ||
const wxString GdaConst::gda_basemap_linux_useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"; | ||
|
||
const wxString GdaConst::gda_lbl_not_sig = _("Not Significant"); | ||
const wxString GdaConst::gda_lbl_undefined = _("Undefined"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.