35 using namespace projections;
38 TLMaps* TLMaps::m_pInstance=
nullptr;
47 RetryLoadTile(2),useMemoryCache(true),lastZoom(0),quadCoordRight(0),quadCoordBottom(0)
82 qDebug()<<
"Entered GetImageFrom";
103 qDebug()<<
"Tile not in memory";
107 if(
accessmode != (AccessMode::ServerOnly) && type != MapType::UserImage)
110 qDebug()<<
"Try tile from DataBase";
119 qDebug()<<
"Tile found in Database";
124 qDebug()<<
"Add Tile to memory";
136 if (type == MapType::UserImage)
139 static QImage imMap(userImageFileName);
142 static double widthPx=imMap.width();
143 static double heightPx=imMap.height();
144 static double width=widthPx*hScale;
145 static double height=heightPx*vScale;
146 static double cornerLLA[3];
147 static bool once=
true;
153 double homeLLA[3]={0,0,0};
154 double cornerNED[3]={-height, width, 0};
159 int tileSize= projection->
TileSize().Width();
169 double top=90, bottom=-90, left=-180, right=180;
170 double lat=cornerLLA[0];
171 double lon=cornerLLA[1];
174 for (
int i=0;
i<zoom;
i++)
178 if ((left+right)/2<lon )
185 right=(right+left)/2;
188 if ((top+bottom)/2<lat)
190 bottom=(top+bottom)/2;
225 retImage=retImage.convertToFormat(QImage::Format_ARGB32);
226 QPainter painter(&retImage);
227 painter.setFont(QFont(
"Chicago", 7));
228 painter.setPen(QColor(233, 10, 150));
229 painter.drawText(20, 40, QString::number(pos.
X() , 2));
230 painter.drawText(20, 80, QString::number(pos.
Y() , 2));
236 buffer.open(QIODevice::WriteOnly);
237 retImage.save(&buffer,
"PNG");
240 QImage retImage(tileSize,tileSize, QImage::Format_ARGB32);
241 retImage.fill(Qt::black);
245 QPainter painter(&retImage);
246 painter.setFont(QFont(
"Chicago", 16));
247 painter.setPen(QColor(10, 233, 150));
248 painter.drawText(20, 40, QString::number(pos.
X() , 2));
249 painter.drawText(20, 80, QString::number(pos.
Y() , 2));
254 buffer.open(QIODevice::WriteOnly);
255 retImage.save(&buffer,
"PNG");
266 qDebug()<<
"Add Tile to memory cache";
275 qDebug()<<
"Add tile to DataBase";
285 qDebug()<<
"Entered GetImageFrom";
313 qDebug()<<
"Entered GetImageFrom";
334 qDebug()<<
"Tile not in memory";
338 if(
accessmode != (AccessMode::ServerOnly) && type != MapType::UserImage)
341 qDebug()<<
"Try tile from DataBase";
350 qDebug()<<
"Tile found in Database";
355 qDebug()<<
"Add Tile to memory";
368 QNetworkReply *reply;
369 QNetworkRequest qheader;
370 QNetworkAccessManager network;
372 tT.setSingleShot(
true);
373 connect(&network, SIGNAL(finished(QNetworkReply*)),
375 connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
376 network.setProxy(
Proxy);
378 qDebug()<<
"Try Tile from the Internet";
381 qDebug()<<
"opmaps before make image url"<<time.elapsed();
385 qDebug()<<
"opmaps after make image url"<<time.elapsed();
386 #endif //url "http://vec02.maps.yandex.ru/tiles?l=map&v=2.10.2&x=7&y=5&z=3" string
388 qheader.setUrl(QUrl(url));
389 qheader.setRawHeader(
"User-Agent",
UserAgent);
390 qheader.setRawHeader(
"Accept",
"*/*");
393 case MapType::GoogleMap:
394 case MapType::GoogleSatellite:
395 case MapType::GoogleLabels:
396 case MapType::GoogleTerrain:
397 case MapType::GoogleHybrid:
399 qheader.setRawHeader(
"Referrer",
"http://maps.google.com/");
403 case MapType::GoogleMapChina:
404 case MapType::GoogleSatelliteChina:
405 case MapType::GoogleLabelsChina:
406 case MapType::GoogleTerrainChina:
407 case MapType::GoogleHybridChina:
409 qheader.setRawHeader(
"Referrer",
"http://ditu.google.cn/");
413 case MapType::BingHybrid:
414 case MapType::BingMap:
415 case MapType::BingSatellite:
417 qheader.setRawHeader(
"Referrer",
"http://www.bing.com/maps/");
421 case MapType::YahooHybrid:
422 case MapType::YahooLabels:
423 case MapType::YahooMap:
424 case MapType::YahooSatellite:
426 qheader.setRawHeader(
"Referrer",
"http://maps.yahoo.com/");
430 case MapType::ArcGIS_MapsLT_Map_Labels:
431 case MapType::ArcGIS_MapsLT_Map:
432 case MapType::ArcGIS_MapsLT_OrtoFoto:
433 case MapType::ArcGIS_MapsLT_Map_Hybrid:
435 qheader.setRawHeader(
"Referrer",
"http://www.maps.lt/map_beta/");
439 case MapType::OpenStreetMapSurfer:
440 case MapType::OpenStreetMapSurferTerrain:
442 qheader.setRawHeader(
"Referrer",
"http://www.mapsurfer.net/");
446 case MapType::OpenStreetMap:
447 case MapType::OpenStreetOsm:
449 qheader.setRawHeader(
"Referrer",
"http://www.openstreetmap.org/");
453 case MapType::YandexMapRu:
455 qheader.setRawHeader(
"Referrer",
"http://maps.yandex.ru/");
462 qDebug() <<
"qheader: " << qheader.url();
464 reply=network.get(qheader);
475 if( (reply->error()!=QNetworkReply::NoError))
480 reply->deleteLater();
483 ret=reply->readAll();
484 reply->deleteLater();
488 qDebug()<<
"Invalid Tile";
496 qDebug()<<
"Received Tile from the Internet";
508 qDebug()<<
"Add Tile to memory cache";
517 qDebug()<<
"Add tile to DataBase";
527 qDebug()<<
"Entered GetImageFrom";
int NED2LLA_HomeLLA(double homeLLA[3], double NED[3], double LLA[3])