mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP37/GCS MapLib - Various fixes to improve stability, created diagnostics screen available from maps context menu.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2674 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
12cdec0ae7
commit
8c5fe506b3
@ -15,7 +15,8 @@ SOURCES += opmaps.cpp \
|
|||||||
placemark.cpp \
|
placemark.cpp \
|
||||||
point.cpp \
|
point.cpp \
|
||||||
size.cpp \
|
size.cpp \
|
||||||
kibertilecache.cpp
|
kibertilecache.cpp \
|
||||||
|
diagnostics.cpp
|
||||||
HEADERS += opmaps.h \
|
HEADERS += opmaps.h \
|
||||||
size.h \
|
size.h \
|
||||||
maptype.h \
|
maptype.h \
|
||||||
@ -35,4 +36,5 @@ HEADERS += opmaps.h \
|
|||||||
placemark.h \
|
placemark.h \
|
||||||
point.h \
|
point.h \
|
||||||
kibertilecache.h \
|
kibertilecache.h \
|
||||||
debugheader.h
|
debugheader.h \
|
||||||
|
diagnostics.h
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file diagnostics.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "diagnostics.h"
|
||||||
|
|
||||||
|
diagnostics::diagnostics():networkerrors(0),emptytiles(0),timeouts(0),runningThreads(0)
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file diagnostics.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef DIAGNOSTICS_H
|
||||||
|
#define DIAGNOSTICS_H
|
||||||
|
#include <QString>
|
||||||
|
struct diagnostics
|
||||||
|
{
|
||||||
|
diagnostics();
|
||||||
|
int networkerrors;
|
||||||
|
int emptytiles;
|
||||||
|
int timeouts;
|
||||||
|
int runningThreads;
|
||||||
|
QString toString()
|
||||||
|
{
|
||||||
|
return QString("Network errors:%1\nEmpty Tiles:%2\nTimeOuts:%3\nRunningThreads:%4").arg(networkerrors).arg(emptytiles).arg(timeouts).arg(runningThreads);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIAGNOSTICS_H
|
@ -107,7 +107,7 @@ namespace core {
|
|||||||
QTimer tT;
|
QTimer tT;
|
||||||
tT.setSingleShot(true);
|
tT.setSingleShot(true);
|
||||||
connect(&network, SIGNAL(finished(QNetworkReply*)),
|
connect(&network, SIGNAL(finished(QNetworkReply*)),
|
||||||
&q, SLOT(quit()));
|
&q, SLOT(quit()));
|
||||||
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
|
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
|
||||||
network.setProxy(Proxy);
|
network.setProxy(Proxy);
|
||||||
#ifdef DEBUG_GMAPS
|
#ifdef DEBUG_GMAPS
|
||||||
@ -120,7 +120,7 @@ namespace core {
|
|||||||
#ifdef DEBUG_TIMINGS
|
#ifdef DEBUG_TIMINGS
|
||||||
qDebug()<<"opmaps after make image url"<<time.elapsed();
|
qDebug()<<"opmaps after make image url"<<time.elapsed();
|
||||||
#endif //url "http://vec02.maps.yandex.ru/tiles?l=map&v=2.10.2&x=7&y=5&z=3" string
|
#endif //url "http://vec02.maps.yandex.ru/tiles?l=map&v=2.10.2&x=7&y=5&z=3" string
|
||||||
//"http://map3.pergo.com.tr/tile/02/000/000/007/000/000/002.png"
|
//"http://map3.pergo.com.tr/tile/02/000/000/007/000/000/002.png"
|
||||||
qheader.setUrl(QUrl(url));
|
qheader.setUrl(QUrl(url));
|
||||||
qheader.setRawHeader("User-Agent",UserAgent);
|
qheader.setRawHeader("User-Agent",UserAgent);
|
||||||
qheader.setRawHeader("Accept","*/*");
|
qheader.setRawHeader("Accept","*/*");
|
||||||
@ -199,9 +199,20 @@ namespace core {
|
|||||||
q.exec();
|
q.exec();
|
||||||
|
|
||||||
if(!tT.isActive()){
|
if(!tT.isActive()){
|
||||||
|
errorvars.lock();
|
||||||
|
++diag.timeouts;
|
||||||
|
errorvars.unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
tT.stop();
|
tT.stop();
|
||||||
|
if( (reply->error()!=QNetworkReply::NoError))
|
||||||
|
{
|
||||||
|
errorvars.lock();
|
||||||
|
++diag.networkerrors;
|
||||||
|
errorvars.unlock();
|
||||||
|
reply->deleteLater();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
ret=reply->readAll();
|
ret=reply->readAll();
|
||||||
reply->deleteLater();//TODO can't this be global??
|
reply->deleteLater();//TODO can't this be global??
|
||||||
if(ret.isEmpty())
|
if(ret.isEmpty())
|
||||||
@ -209,6 +220,9 @@ namespace core {
|
|||||||
#ifdef DEBUG_GMAPS
|
#ifdef DEBUG_GMAPS
|
||||||
qDebug()<<"Invalid Tile";
|
qDebug()<<"Invalid Tile";
|
||||||
#endif //DEBUG_GMAPS
|
#endif //DEBUG_GMAPS
|
||||||
|
errorvars.lock();
|
||||||
|
++diag.emptytiles;
|
||||||
|
errorvars.unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_GMAPS
|
#ifdef DEBUG_GMAPS
|
||||||
@ -247,4 +261,14 @@ namespace core {
|
|||||||
{
|
{
|
||||||
return Cache::Instance()->ImageCache.ExportMapDataToDB(file,Cache::Instance()->ImageCache.GtileCache()+QDir::separator()+"Data.qmdb");
|
return Cache::Instance()->ImageCache.ExportMapDataToDB(file,Cache::Instance()->ImageCache.GtileCache()+QDir::separator()+"Data.qmdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diagnostics OPMaps::GetDiagnostics()
|
||||||
|
{
|
||||||
|
diagnostics i;
|
||||||
|
errorvars.lock();
|
||||||
|
i=diag;
|
||||||
|
errorvars.unlock();
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "pureimagecache.h"
|
#include "pureimagecache.h"
|
||||||
#include "alllayersoftype.h"
|
#include "alllayersoftype.h"
|
||||||
#include "urlfactory.h"
|
#include "urlfactory.h"
|
||||||
|
#include "diagnostics.h"
|
||||||
|
|
||||||
//#include "point.h"
|
//#include "point.h"
|
||||||
|
|
||||||
@ -68,6 +69,8 @@ namespace core {
|
|||||||
AccessMode::Types GetAccessMode()const{return accessmode;}
|
AccessMode::Types GetAccessMode()const{return accessmode;}
|
||||||
void setAccessMode(const AccessMode::Types& mode){accessmode=mode;}
|
void setAccessMode(const AccessMode::Types& mode){accessmode=mode;}
|
||||||
int RetryLoadTile;
|
int RetryLoadTile;
|
||||||
|
diagnostics GetDiagnostics();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool useMemoryCache;
|
bool useMemoryCache;
|
||||||
LanguageType::Types Language;
|
LanguageType::Types Language;
|
||||||
@ -75,12 +78,11 @@ namespace core {
|
|||||||
// PureImageCache ImageCacheLocal;//TODO Criar acesso Get Set
|
// PureImageCache ImageCacheLocal;//TODO Criar acesso Get Set
|
||||||
TileCacheQueue TileDBcacheQueue;
|
TileCacheQueue TileDBcacheQueue;
|
||||||
OPMaps();
|
OPMaps();
|
||||||
|
|
||||||
OPMaps(OPMaps const&){}
|
OPMaps(OPMaps const&){}
|
||||||
OPMaps& operator=(OPMaps const&){ return *this; }
|
OPMaps& operator=(OPMaps const&){ return *this; }
|
||||||
static OPMaps* m_pInstance;
|
static OPMaps* m_pInstance;
|
||||||
|
diagnostics diag;
|
||||||
|
QMutex errorvars;
|
||||||
protected:
|
protected:
|
||||||
// MemoryCache TilesInMemory;
|
// MemoryCache TilesInMemory;
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ namespace core {
|
|||||||
qlonglong id=++ConnCounter;
|
qlonglong id=++ConnCounter;
|
||||||
Mcounter.unlock();
|
Mcounter.unlock();
|
||||||
{
|
{
|
||||||
|
Mcounter.lock();
|
||||||
QSqlDatabase cn;
|
QSqlDatabase cn;
|
||||||
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
|
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
|
||||||
QString db=gtilecache+"Data.qmdb";
|
QString db=gtilecache+"Data.qmdb";
|
||||||
@ -219,30 +220,30 @@ namespace core {
|
|||||||
}
|
}
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
|
Mcounter.unlock();
|
||||||
}
|
}
|
||||||
QSqlDatabase::removeDatabase(QString::number(id));
|
QSqlDatabase::removeDatabase(QString::number(id));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QByteArray PureImageCache::GetImageFromCache(MapType::Types type, Point pos, int zoom)
|
QByteArray PureImageCache::GetImageFromCache(MapType::Types type, Point pos, int zoom)
|
||||||
{
|
{
|
||||||
bool ret=true;
|
|
||||||
QByteArray ar;
|
QByteArray ar;
|
||||||
QString dir=gtilecache;
|
QString dir=gtilecache;
|
||||||
Mcounter.lock();
|
Mcounter.lock();
|
||||||
qlonglong id=++ConnCounter;
|
qlonglong id=++ConnCounter;
|
||||||
Mcounter.unlock();
|
Mcounter.unlock();
|
||||||
#ifdef DEBUG_PUREIMAGECACHE
|
#ifdef DEBUG_PUREIMAGECACHE
|
||||||
// qDebug()<<"Cache dir="<<dir<<" Try to GET:"<<pos.X()+","+pos.Y();
|
qDebug()<<"Cache dir="<<dir<<" Try to GET:"<<pos.X()+","+pos.Y();
|
||||||
#endif //DEBUG_PUREIMAGECACHE
|
#endif //DEBUG_PUREIMAGECACHE
|
||||||
|
|
||||||
{
|
{
|
||||||
QString db=dir+"Data.qmdb";
|
QString db=dir+"Data.qmdb";
|
||||||
ret=QFileInfo(db).exists();
|
|
||||||
if(ret)
|
|
||||||
{
|
{
|
||||||
|
Mcounter.lock();
|
||||||
QSqlDatabase cn;
|
QSqlDatabase cn;
|
||||||
|
|
||||||
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
|
cn = QSqlDatabase::addDatabase("QSQLITE",QString::number(id));
|
||||||
|
|
||||||
cn.setDatabaseName(db);
|
cn.setDatabaseName(db);
|
||||||
if(cn.open())
|
if(cn.open())
|
||||||
{
|
{
|
||||||
@ -252,15 +253,12 @@ namespace core {
|
|||||||
query.next();
|
query.next();
|
||||||
if(query.isValid())
|
if(query.isValid())
|
||||||
{
|
{
|
||||||
|
|
||||||
ar=query.value(0).toByteArray();
|
ar=query.value(0).toByteArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cn.close();
|
cn.close();
|
||||||
}
|
}
|
||||||
|
Mcounter.unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QSqlDatabase::removeDatabase(QString::number(id));
|
QSqlDatabase::removeDatabase(QString::number(id));
|
||||||
|
@ -29,102 +29,100 @@
|
|||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84
|
const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84
|
||||||
|
|
||||||
UrlFactory::UrlFactory()
|
UrlFactory::UrlFactory()
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// timeout for map connections
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
Proxy.setType(QNetworkProxy::NoProxy);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the User-agent HTTP header.
|
|
||||||
/// </summary>
|
|
||||||
UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7";
|
|
||||||
|
|
||||||
Timeout = 5 * 1000;
|
|
||||||
CorrectGoogleVersions=true;
|
|
||||||
isCorrectedGoogleVersions = false;
|
|
||||||
UseGeocoderCache=true;
|
|
||||||
UsePlacemarkCache=true;
|
|
||||||
// timer.setSingleShot(true);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
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';
|
/// <summary>
|
||||||
int mask = 1 << (i - 1);
|
/// timeout for map connections
|
||||||
if((tileX & mask) != 0)
|
/// </summary>
|
||||||
{
|
|
||||||
digit++;
|
Proxy.setType(QNetworkProxy::NoProxy);
|
||||||
}
|
|
||||||
if((tileY & mask) != 0)
|
/// <summary>
|
||||||
{
|
/// Gets or sets the value of the User-agent HTTP header.
|
||||||
digit++;
|
/// </summary>
|
||||||
digit++;
|
UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7";
|
||||||
}
|
|
||||||
quadKey.append(digit);
|
Timeout = 5 * 1000;
|
||||||
|
CorrectGoogleVersions=true;
|
||||||
|
isCorrectedGoogleVersions = false;
|
||||||
|
UseGeocoderCache=true;
|
||||||
|
UsePlacemarkCache=true;
|
||||||
}
|
}
|
||||||
return quadKey;
|
UrlFactory::~UrlFactory()
|
||||||
}
|
|
||||||
int UrlFactory::GetServerNum(const Point &pos,const int &max) const
|
|
||||||
{
|
|
||||||
return (pos.X() + 2 * pos.Y()) % max;
|
|
||||||
}
|
|
||||||
void UrlFactory::setIsCorrectGoogleVersions(bool value)
|
|
||||||
{
|
|
||||||
isCorrectedGoogleVersions=value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UrlFactory::IsCorrectGoogleVersions()
|
|
||||||
{
|
|
||||||
return isCorrectedGoogleVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UrlFactory::TryCorrectGoogleVersions()
|
|
||||||
{
|
|
||||||
if(CorrectGoogleVersions && !IsCorrectGoogleVersions())
|
|
||||||
{
|
{
|
||||||
QNetworkReply *reply;
|
}
|
||||||
QNetworkRequest qheader;
|
QString UrlFactory::TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const
|
||||||
QNetworkAccessManager network;
|
{
|
||||||
network.setProxy(Proxy);
|
QString quadKey;
|
||||||
#ifdef DEBUG_URLFACTORY
|
for(int i = levelOfDetail; i > 0; i--)
|
||||||
qDebug()<<"Correct GoogleVersion";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
setIsCorrectGoogleVersions(true);
|
|
||||||
QString url = "http://maps.google.com";
|
|
||||||
|
|
||||||
qheader.setUrl(QUrl(url));
|
|
||||||
qheader.setRawHeader("User-Agent",UserAgent);
|
|
||||||
reply=network.get(qheader);
|
|
||||||
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
|
|
||||||
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_URLFACTORY
|
char digit = '0';
|
||||||
qDebug()<<"Try corrected version network error:";
|
int mask = 1 << (i - 1);
|
||||||
#endif //DEBUG_URLFACTORY
|
if((tileX & mask) != 0)
|
||||||
return;
|
{
|
||||||
|
digit++;
|
||||||
|
}
|
||||||
|
if((tileY & mask) != 0)
|
||||||
|
{
|
||||||
|
digit++;
|
||||||
|
digit++;
|
||||||
|
}
|
||||||
|
quadKey.append(digit);
|
||||||
}
|
}
|
||||||
|
return quadKey;
|
||||||
|
}
|
||||||
|
int UrlFactory::GetServerNum(const Point &pos,const int &max) const
|
||||||
|
{
|
||||||
|
return (pos.X() + 2 * pos.Y()) % max;
|
||||||
|
}
|
||||||
|
void UrlFactory::setIsCorrectGoogleVersions(bool value)
|
||||||
|
{
|
||||||
|
isCorrectedGoogleVersions=value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UrlFactory::IsCorrectGoogleVersions()
|
||||||
|
{
|
||||||
|
return isCorrectedGoogleVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UrlFactory::TryCorrectGoogleVersions()
|
||||||
|
{
|
||||||
|
if(CorrectGoogleVersions && !IsCorrectGoogleVersions())
|
||||||
{
|
{
|
||||||
|
QNetworkReply *reply;
|
||||||
|
QNetworkRequest qheader;
|
||||||
|
QNetworkAccessManager network;
|
||||||
|
QEventLoop q;
|
||||||
|
QTimer tT;
|
||||||
|
tT.setSingleShot(true);
|
||||||
|
connect(&network, SIGNAL(finished(QNetworkReply*)),
|
||||||
|
&q, SLOT(quit()));
|
||||||
|
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
|
||||||
|
network.setProxy(Proxy);
|
||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
qDebug()<<"Try corrected version withou abort or error:"<<reply->errorString();
|
qDebug()<<"Correct GoogleVersion";
|
||||||
#endif //DEBUG_URLFACTORY
|
#endif //DEBUG_URLFACTORY
|
||||||
|
setIsCorrectGoogleVersions(true);
|
||||||
|
QString url = "http://maps.google.com";
|
||||||
|
|
||||||
|
qheader.setUrl(QUrl(url));
|
||||||
|
qheader.setRawHeader("User-Agent",UserAgent);
|
||||||
|
reply=network.get(qheader);
|
||||||
|
tT.start(Timeout);
|
||||||
|
q.exec();
|
||||||
|
if(!tT.isActive())
|
||||||
|
return;
|
||||||
|
tT.stop();
|
||||||
|
if( (reply->error()!=QNetworkReply::NoError))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"Try corrected version withou abort or error:"<<reply->errorString();
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
return;
|
||||||
|
}
|
||||||
QString html=QString(reply->readAll());
|
QString html=QString(reply->readAll());
|
||||||
QRegExp reg("\"*http://mt0.google.com/vt/lyrs=m@(\\d*)",Qt::CaseInsensitive);
|
QRegExp reg("\"*http://mt0.google.com/vt/lyrs=m@(\\d*)",Qt::CaseInsensitive);
|
||||||
if(reg.indexIn(html)!=-1)
|
if(reg.indexIn(html)!=-1)
|
||||||
@ -133,7 +131,7 @@ void UrlFactory::TryCorrectGoogleVersions()
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +142,7 @@ void UrlFactory::TryCorrectGoogleVersions()
|
|||||||
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://khm0.google.com/kh/v=(\\d*)",Qt::CaseInsensitive);
|
reg=QRegExp("\"*http://khm0.google.com/kh/v=(\\d*)",Qt::CaseInsensitive);
|
||||||
@ -154,9 +152,9 @@ void UrlFactory::TryCorrectGoogleVersions()
|
|||||||
VersionGoogleSatellite = gc[1];
|
VersionGoogleSatellite = gc[1];
|
||||||
VersionGoogleSatelliteKorea = VersionGoogleSatellite;
|
VersionGoogleSatelliteKorea = VersionGoogleSatellite;
|
||||||
VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite;
|
VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite;
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleSatellite: "<<VersionGoogleSatellite;
|
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleSatellite: "<<VersionGoogleSatellite;
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
}
|
}
|
||||||
reg=QRegExp("\"*http://mt0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)",Qt::CaseInsensitive);
|
reg=QRegExp("\"*http://mt0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)",Qt::CaseInsensitive);
|
||||||
if(reg.indexIn(html)!=-1)
|
if(reg.indexIn(html)!=-1)
|
||||||
@ -165,531 +163,532 @@ void UrlFactory::TryCorrectGoogleVersions()
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString UrlFactory::MakeImageUrl(const MapType::Types &type,const Point &pos,const int &zoom,const QString &language)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"Entered MakeImageUrl";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case MapType::GoogleMap:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleSatellite:
|
|
||||||
{
|
|
||||||
QString server = "khm";
|
|
||||||
QString request = "kh";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleLabels:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleTerrain:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleMapChina:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
TryCorrectGoogleVersions();
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleSatelliteChina:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
// TryCorrectGoogleVersions();
|
|
||||||
// http://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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleLabelsChina:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
QString sec2 = ""; // after &zoom=...
|
|
||||||
GetSecGoogleWords(pos, sec1, sec2);
|
|
||||||
TryCorrectGoogleVersions();
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleTerrainChina:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "vt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleMapKorea:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "mt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
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("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);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleSatelliteKorea:
|
|
||||||
{
|
|
||||||
QString server = "khm";
|
|
||||||
QString request = "kh";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::GoogleLabelsKorea:
|
|
||||||
{
|
|
||||||
QString server = "mt";
|
|
||||||
QString request = "mt";
|
|
||||||
QString sec1 = ""; // after &x=...
|
|
||||||
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("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);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::YahooMap:
|
|
||||||
{
|
|
||||||
return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((GetServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.X()).arg((((1 << zoom) >> 1) - 1 - pos.Y())).arg((zoom + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
case MapType::YahooSatellite:
|
|
||||||
{
|
|
||||||
return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::YahooLabels:
|
|
||||||
{
|
|
||||||
return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::OpenStreetMap:
|
|
||||||
{
|
|
||||||
char letter= "abc"[GetServerNum(pos, 3)];
|
|
||||||
return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::OpenStreetOsm:
|
|
||||||
{
|
|
||||||
char letter = "abc"[GetServerNum(pos, 3)];
|
|
||||||
return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::OpenStreetMapSurfer:
|
|
||||||
{
|
|
||||||
// http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16
|
|
||||||
|
|
||||||
return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::OpenStreetMapSurferTerrain:
|
|
||||||
{
|
|
||||||
// http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14
|
|
||||||
|
|
||||||
return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::BingMap:
|
|
||||||
{
|
|
||||||
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
|
||||||
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::BingSatellite:
|
|
||||||
{
|
|
||||||
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
|
||||||
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::BingHybrid:
|
|
||||||
{
|
|
||||||
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
|
||||||
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
case MapType::ArcGIS_Map:
|
|
||||||
{
|
|
||||||
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/0/0/0.jpg
|
|
||||||
|
|
||||||
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_Satellite:
|
|
||||||
{
|
|
||||||
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/1/0/1.jpg
|
|
||||||
|
|
||||||
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_ShadedRelief:
|
|
||||||
{
|
|
||||||
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg
|
|
||||||
|
|
||||||
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_Terrain:
|
|
||||||
{
|
|
||||||
// http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15
|
|
||||||
|
|
||||||
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_MapsLT_OrtoFoto:
|
|
||||||
{
|
|
||||||
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
|
|
||||||
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
|
|
||||||
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
|
|
||||||
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg
|
|
||||||
// return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
|
|
||||||
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg
|
|
||||||
//TODO verificar
|
|
||||||
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_MapsLT_Map:
|
|
||||||
{
|
|
||||||
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
|
|
||||||
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
|
|
||||||
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
|
|
||||||
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png
|
|
||||||
// http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png
|
|
||||||
//TODO verificar
|
|
||||||
// http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png
|
|
||||||
return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::ArcGIS_MapsLT_Map_Labels:
|
|
||||||
{
|
|
||||||
//http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13
|
|
||||||
//return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
|
|
||||||
//http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png
|
|
||||||
//TODO verificar
|
|
||||||
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::PergoTurkeyMap:
|
|
||||||
{
|
|
||||||
// http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png
|
|
||||||
|
|
||||||
// http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png
|
|
||||||
// That means: Zoom Level: 0 TileX: 1 TileY: 0
|
|
||||||
|
|
||||||
// http://domain/tile/14/000/019/371/000/011/825.png
|
|
||||||
// That means: Zoom Level: 14 TileX: 19371 TileY:11825
|
|
||||||
|
|
||||||
// string x = pos.X().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
|
|
||||||
// string y = pos.Y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
|
|
||||||
QString x=QString("%1").arg(QString::number(pos.X()),9,(QChar)'0');
|
|
||||||
x.insert(3,"/").insert(7,"/");
|
|
||||||
QString y=QString("%1").arg(QString::number(pos.Y()),9,(QChar)'0');
|
|
||||||
y.insert(3,"/").insert(7,"/");
|
|
||||||
//"http://map03.pergo.com.tr/tile/2/000/000/003/000/000/002.png"
|
|
||||||
return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(GetServerNum(pos, 4)).arg(zoom,2,10,(QChar)'0').arg(x).arg(y);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MapType::SigPacSpainMap:
|
|
||||||
{
|
|
||||||
return QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MapType::YandexMapRu:
|
|
||||||
{
|
|
||||||
QString server = "vec";
|
|
||||||
|
|
||||||
//http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
|
|
||||||
|
|
||||||
return QString("http://%1").arg(server)+QString("0%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(GetServerNum(pos, 4)+1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString::null;
|
QString UrlFactory::MakeImageUrl(const MapType::Types &type,const Point &pos,const int &zoom,const QString &language)
|
||||||
}
|
|
||||||
void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec2)
|
|
||||||
{
|
|
||||||
sec1 = ""; // after &x=...
|
|
||||||
sec2 = ""; // after &zoom=...
|
|
||||||
int seclen = ((pos.X() * 3) + pos.Y()) % 8;
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status)
|
|
||||||
{
|
|
||||||
return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords),UseGeocoderCache,status);
|
|
||||||
}
|
|
||||||
internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"Entered GetLatLngFromGeocoderUrl:";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
status = GeoCoderStatusCode::Unknow;
|
|
||||||
internals::PointLatLng ret(0,0);
|
|
||||||
QString urlEnd = url.mid(url.indexOf("geo?q=")+6);
|
|
||||||
urlEnd.replace( QRegExp(
|
|
||||||
"[^"
|
|
||||||
"A-Z,a-z,0-9,"
|
|
||||||
"\\^,\\&,\\',\\@,"
|
|
||||||
"\\{,\\},\\[,\\],"
|
|
||||||
"\\,,\\$,\\=,\\!,"
|
|
||||||
"\\-,\\#,\\(,\\),"
|
|
||||||
"\\%,\\.,\\+,\\~,\\_"
|
|
||||||
"]"), "_" );
|
|
||||||
|
|
||||||
QString geo = useCache ? Cache::Instance()->GetGeocoderFromCache(urlEnd) : "";
|
|
||||||
|
|
||||||
if(geo.isNull()|geo.isEmpty())
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
|
qDebug()<<"Entered MakeImageUrl";
|
||||||
#endif //DEBUG_URLFACTORY
|
#endif //DEBUG_URLFACTORY
|
||||||
QNetworkReply *reply;
|
switch(type)
|
||||||
QNetworkRequest qheader;
|
|
||||||
QNetworkAccessManager network;
|
|
||||||
network.setProxy(Proxy);
|
|
||||||
qheader.setUrl(QUrl(url));
|
|
||||||
qheader.setRawHeader("User-Agent",UserAgent);
|
|
||||||
reply=network.get(qheader);
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
|
|
||||||
#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
|
|
||||||
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_URLFACTORY
|
case MapType::GoogleMap:
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
return internals::PointLatLng(0,0);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
geo=reply->readAll();
|
|
||||||
|
|
||||||
|
|
||||||
// cache geocoding
|
|
||||||
if(useCache && geo.startsWith("200"))
|
|
||||||
{
|
{
|
||||||
Cache::Instance()->CacheGeocoder(urlEnd, geo);
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
reply->deleteLater();
|
case MapType::GoogleSatellite:
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// parse values
|
|
||||||
// true : 200,4,56.1451640,22.0681787
|
|
||||||
// false: 602,0,0,0
|
|
||||||
{
|
|
||||||
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();
|
QString server = "khm";
|
||||||
double lng = QString(values[3]).toDouble();
|
QString request = "kh";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
ret = internals::PointLatLng(lat, lng);
|
QString sec2 = ""; // after &zoom=...
|
||||||
#ifdef DEBUG_URLFACTORY
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
qDebug()<<"Lat="<<lat<<" Lng="<<lng;
|
TryCorrectGoogleVersions();
|
||||||
#endif //DEBUG_URLFACTORY
|
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);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
case MapType::GoogleLabels:
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Placemark UrlFactory::GetPlacemarkFromGeocoder(internals::PointLatLng location)
|
|
||||||
{
|
|
||||||
return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location, LanguageStr), UsePlacemarkCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
Placemark UrlFactory::GetPlacemarkFromReverseGeocoderUrl(const QString &url, const bool &useCache)
|
|
||||||
{
|
|
||||||
|
|
||||||
Placemark ret("");
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"Entered GetPlacemarkFromReverseGeocoderUrl:";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
// status = GeoCoderStatusCode::Unknow;
|
|
||||||
QString urlEnd = url.right(url.indexOf("geo?hl="));
|
|
||||||
urlEnd.replace( QRegExp(
|
|
||||||
"[^"
|
|
||||||
"A-Z,a-z,0-9,"
|
|
||||||
"\\^,\\&,\\',\\@,"
|
|
||||||
"\\{,\\},\\[,\\],"
|
|
||||||
"\\,,\\$,\\=,\\!,"
|
|
||||||
"\\-,\\#,\\(,\\),"
|
|
||||||
"\\%,\\.,\\+,\\~,\\_"
|
|
||||||
"]"), "_" );
|
|
||||||
|
|
||||||
QString reverse = useCache ? Cache::Instance()->GetPlacemarkFromCache(urlEnd) : "";
|
|
||||||
|
|
||||||
if(reverse.isNull()|reverse.isEmpty())
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
QNetworkReply *reply;
|
|
||||||
QNetworkRequest qheader;
|
|
||||||
QNetworkAccessManager network;
|
|
||||||
network.setProxy(Proxy);
|
|
||||||
qheader.setUrl(QUrl(url));
|
|
||||||
qheader.setRawHeader("User-Agent",UserAgent);
|
|
||||||
reply=network.get(qheader);
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
|
|
||||||
#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
|
|
||||||
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
QByteArray a=(reply->readAll());
|
|
||||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
|
||||||
reverse = codec->toUnicode(a);
|
|
||||||
#ifdef DEBUG_URLFACTORY
|
|
||||||
qDebug()<<reverse;
|
|
||||||
#endif //DEBUG_URLFACTORY
|
|
||||||
// cache geocoding
|
|
||||||
if(useCache && reverse.startsWith("200"))
|
|
||||||
{
|
{
|
||||||
Cache::Instance()->CachePlacemark(urlEnd, reverse);
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleTerrain:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleMapChina:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
TryCorrectGoogleVersions();
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleSatelliteChina:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
// TryCorrectGoogleVersions();
|
||||||
|
// http://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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleLabelsChina:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
QString sec2 = ""; // after &zoom=...
|
||||||
|
GetSecGoogleWords(pos, sec1, sec2);
|
||||||
|
TryCorrectGoogleVersions();
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleTerrainChina:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "vt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleMapKorea:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "mt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
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("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);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleSatelliteKorea:
|
||||||
|
{
|
||||||
|
QString server = "khm";
|
||||||
|
QString request = "kh";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::GoogleLabelsKorea:
|
||||||
|
{
|
||||||
|
QString server = "mt";
|
||||||
|
QString request = "mt";
|
||||||
|
QString sec1 = ""; // after &x=...
|
||||||
|
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("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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::YahooMap:
|
||||||
|
{
|
||||||
|
return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((GetServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.X()).arg((((1 << zoom) >> 1) - 1 - pos.Y())).arg((zoom + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
case MapType::YahooSatellite:
|
||||||
|
{
|
||||||
|
return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::YahooLabels:
|
||||||
|
{
|
||||||
|
return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::OpenStreetMap:
|
||||||
|
{
|
||||||
|
char letter= "abc"[GetServerNum(pos, 3)];
|
||||||
|
return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::OpenStreetOsm:
|
||||||
|
{
|
||||||
|
char letter = "abc"[GetServerNum(pos, 3)];
|
||||||
|
return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::OpenStreetMapSurfer:
|
||||||
|
{
|
||||||
|
// http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16
|
||||||
|
|
||||||
|
return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::OpenStreetMapSurferTerrain:
|
||||||
|
{
|
||||||
|
// http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14
|
||||||
|
|
||||||
|
return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::BingMap:
|
||||||
|
{
|
||||||
|
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
||||||
|
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::BingSatellite:
|
||||||
|
{
|
||||||
|
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
||||||
|
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::BingHybrid:
|
||||||
|
{
|
||||||
|
QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
|
||||||
|
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
case MapType::ArcGIS_Map:
|
||||||
|
{
|
||||||
|
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/0/0/0.jpg
|
||||||
|
|
||||||
|
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_Satellite:
|
||||||
|
{
|
||||||
|
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/1/0/1.jpg
|
||||||
|
|
||||||
|
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_ShadedRelief:
|
||||||
|
{
|
||||||
|
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg
|
||||||
|
|
||||||
|
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_Terrain:
|
||||||
|
{
|
||||||
|
// http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15
|
||||||
|
|
||||||
|
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_MapsLT_OrtoFoto:
|
||||||
|
{
|
||||||
|
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
|
||||||
|
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
|
||||||
|
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
|
||||||
|
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg
|
||||||
|
// return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
|
||||||
|
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg
|
||||||
|
//TODO verificar
|
||||||
|
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_MapsLT_Map:
|
||||||
|
{
|
||||||
|
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
|
||||||
|
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
|
||||||
|
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
|
||||||
|
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png
|
||||||
|
// http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png
|
||||||
|
//TODO verificar
|
||||||
|
// http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png
|
||||||
|
return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::ArcGIS_MapsLT_Map_Labels:
|
||||||
|
{
|
||||||
|
//http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13
|
||||||
|
//return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
|
||||||
|
//http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png
|
||||||
|
//TODO verificar
|
||||||
|
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::PergoTurkeyMap:
|
||||||
|
{
|
||||||
|
// http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png
|
||||||
|
|
||||||
|
// http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png
|
||||||
|
// That means: Zoom Level: 0 TileX: 1 TileY: 0
|
||||||
|
|
||||||
|
// http://domain/tile/14/000/019/371/000/011/825.png
|
||||||
|
// That means: Zoom Level: 14 TileX: 19371 TileY:11825
|
||||||
|
|
||||||
|
// string x = pos.X().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
|
||||||
|
// string y = pos.Y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
|
||||||
|
QString x=QString("%1").arg(QString::number(pos.X()),9,(QChar)'0');
|
||||||
|
x.insert(3,"/").insert(7,"/");
|
||||||
|
QString y=QString("%1").arg(QString::number(pos.Y()),9,(QChar)'0');
|
||||||
|
y.insert(3,"/").insert(7,"/");
|
||||||
|
//"http://map03.pergo.com.tr/tile/2/000/000/003/000/000/002.png"
|
||||||
|
return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(GetServerNum(pos, 4)).arg(zoom,2,10,(QChar)'0').arg(x).arg(y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MapType::SigPacSpainMap:
|
||||||
|
{
|
||||||
|
return QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MapType::YandexMapRu:
|
||||||
|
{
|
||||||
|
QString server = "vec";
|
||||||
|
|
||||||
|
//http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
|
||||||
|
|
||||||
|
return QString("http://%1").arg(server)+QString("0%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(GetServerNum(pos, 4)+1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString::null;
|
||||||
|
}
|
||||||
|
void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec2)
|
||||||
|
{
|
||||||
|
sec1 = ""; // after &x=...
|
||||||
|
sec2 = ""; // after &zoom=...
|
||||||
|
int seclen = ((pos.X() * 3) + pos.Y()) % 8;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status)
|
||||||
|
{
|
||||||
|
return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords),UseGeocoderCache,status);
|
||||||
|
}
|
||||||
|
internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"Entered GetLatLngFromGeocoderUrl:";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
status = GeoCoderStatusCode::Unknow;
|
||||||
|
internals::PointLatLng ret(0,0);
|
||||||
|
QString urlEnd = url.mid(url.indexOf("geo?q=")+6);
|
||||||
|
urlEnd.replace( QRegExp(
|
||||||
|
"[^"
|
||||||
|
"A-Z,a-z,0-9,"
|
||||||
|
"\\^,\\&,\\',\\@,"
|
||||||
|
"\\{,\\},\\[,\\],"
|
||||||
|
"\\,,\\$,\\=,\\!,"
|
||||||
|
"\\-,\\#,\\(,\\),"
|
||||||
|
"\\%,\\.,\\+,\\~,\\_"
|
||||||
|
"]"), "_" );
|
||||||
|
|
||||||
|
QString geo = useCache ? Cache::Instance()->GetGeocoderFromCache(urlEnd) : "";
|
||||||
|
|
||||||
|
if(geo.isNull()|geo.isEmpty())
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
QNetworkReply *reply;
|
||||||
|
QNetworkRequest qheader;
|
||||||
|
QNetworkAccessManager network;
|
||||||
|
network.setProxy(Proxy);
|
||||||
|
qheader.setUrl(QUrl(url));
|
||||||
|
qheader.setRawHeader("User-Agent",UserAgent);
|
||||||
|
reply=network.get(qheader);
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
|
||||||
|
#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
|
||||||
|
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
return internals::PointLatLng(0,0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
geo=reply->readAll();
|
||||||
|
|
||||||
|
|
||||||
|
// cache geocoding
|
||||||
|
if(useCache && geo.startsWith("200"))
|
||||||
|
{
|
||||||
|
Cache::Instance()->CacheGeocoder(urlEnd, geo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse values
|
||||||
|
// true : 200,4,56.1451640,22.0681787
|
||||||
|
// false: 602,0,0,0
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
ret = internals::PointLatLng(lat, lng);
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"Lat="<<lat<<" Lng="<<lng;
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reply->deleteLater();
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Placemark UrlFactory::GetPlacemarkFromGeocoder(internals::PointLatLng location)
|
||||||
// parse values
|
|
||||||
// true : 200,4,56.1451640,22.0681787
|
|
||||||
// false: 602,0,0,0
|
|
||||||
if(reverse.startsWith("200"))
|
|
||||||
{
|
{
|
||||||
QString acc = reverse.left(reverse.indexOf('\"'));
|
return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location, LanguageStr), UsePlacemarkCache);
|
||||||
ret = Placemark(reverse.remove(reverse.indexOf('\"')));
|
}
|
||||||
ret.SetAccuracy ((int) (( (QString) acc.split(',')[1]).toInt()) );
|
|
||||||
|
Placemark UrlFactory::GetPlacemarkFromReverseGeocoderUrl(const QString &url, const bool &useCache)
|
||||||
|
{
|
||||||
|
|
||||||
|
Placemark ret("");
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"Entered GetPlacemarkFromReverseGeocoderUrl:";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
// status = GeoCoderStatusCode::Unknow;
|
||||||
|
QString urlEnd = url.right(url.indexOf("geo?hl="));
|
||||||
|
urlEnd.replace( QRegExp(
|
||||||
|
"[^"
|
||||||
|
"A-Z,a-z,0-9,"
|
||||||
|
"\\^,\\&,\\',\\@,"
|
||||||
|
"\\{,\\},\\[,\\],"
|
||||||
|
"\\,,\\$,\\=,\\!,"
|
||||||
|
"\\-,\\#,\\(,\\),"
|
||||||
|
"\\%,\\.,\\+,\\~,\\_"
|
||||||
|
"]"), "_" );
|
||||||
|
|
||||||
|
QString reverse = useCache ? Cache::Instance()->GetPlacemarkFromCache(urlEnd) : "";
|
||||||
|
|
||||||
|
if(reverse.isNull()|reverse.isEmpty())
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
QNetworkReply *reply;
|
||||||
|
QNetworkRequest qheader;
|
||||||
|
QNetworkAccessManager network;
|
||||||
|
network.setProxy(Proxy);
|
||||||
|
qheader.setUrl(QUrl(url));
|
||||||
|
qheader.setRawHeader("User-Agent",UserAgent);
|
||||||
|
reply=network.get(qheader);
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
|
||||||
|
#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
|
||||||
|
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
QByteArray a=(reply->readAll());
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||||
|
reverse = codec->toUnicode(a);
|
||||||
|
#ifdef DEBUG_URLFACTORY
|
||||||
|
qDebug()<<reverse;
|
||||||
|
#endif //DEBUG_URLFACTORY
|
||||||
|
// cache geocoding
|
||||||
|
if(useCache && reverse.startsWith("200"))
|
||||||
|
{
|
||||||
|
Cache::Instance()->CachePlacemark(urlEnd, reverse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse values
|
||||||
|
// true : 200,4,56.1451640,22.0681787
|
||||||
|
// 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()) );
|
||||||
|
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
double UrlFactory::GetDistance(internals::PointLatLng p1, internals::PointLatLng p2)
|
||||||
|
{
|
||||||
|
double dLat1InRad = p1.Lat() * (M_PI / 180);
|
||||||
|
double dLong1InRad = p1.Lng() * (M_PI / 180);
|
||||||
|
double dLat2InRad = p2.Lat() * (M_PI / 180);
|
||||||
|
double dLong2InRad = p2.Lng() * (M_PI / 180);
|
||||||
|
double dLongitude = dLong2InRad - dLong1InRad;
|
||||||
|
double dLatitude = dLat2InRad - dLat1InRad;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
double UrlFactory::GetDistance(internals::PointLatLng p1, internals::PointLatLng p2)
|
|
||||||
{
|
|
||||||
double dLat1InRad = p1.Lat() * (M_PI / 180);
|
|
||||||
double dLong1InRad = p1.Lng() * (M_PI / 180);
|
|
||||||
double dLat2InRad = p2.Lat() * (M_PI / 180);
|
|
||||||
double dLong2InRad = p2.Lng() * (M_PI / 180);
|
|
||||||
double dLongitude = dLong2InRad - dLong1InRad;
|
|
||||||
double dLatitude = dLat2InRad - dLat1InRad;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ using namespace projections;
|
|||||||
|
|
||||||
namespace internals {
|
namespace internals {
|
||||||
Core::Core():MouseWheelZooming(false),currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
|
Core::Core():MouseWheelZooming(false),currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
|
||||||
,minOfTiles(0,0),maxOfTiles(0,0),zoom(0),isDragging(false),TooltipTextPadding(10,10),loaderLimit(5),maxzoom(21),started(false)
|
,minOfTiles(0,0),maxOfTiles(0,0),zoom(0),isDragging(false),TooltipTextPadding(10,10),loaderLimit(5),maxzoom(21),started(false),runningThreads(0)
|
||||||
{
|
{
|
||||||
mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
|
mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
|
||||||
SetProjection(new MercatorProjection());
|
SetProjection(new MercatorProjection());
|
||||||
@ -53,6 +53,9 @@ namespace internals {
|
|||||||
|
|
||||||
void Core::run()
|
void Core::run()
|
||||||
{
|
{
|
||||||
|
MrunningThreads.lock();
|
||||||
|
++runningThreads;
|
||||||
|
MrunningThreads.unlock();
|
||||||
#ifdef DEBUG_CORE
|
#ifdef DEBUG_CORE
|
||||||
qlonglong debug;
|
qlonglong debug;
|
||||||
Mdebug.lock();
|
Mdebug.lock();
|
||||||
@ -81,8 +84,8 @@ namespace internals {
|
|||||||
MtileLoadQueue.unlock();
|
MtileLoadQueue.unlock();
|
||||||
|
|
||||||
if(task.HasValue())
|
if(task.HasValue())
|
||||||
if(loaderLimit.tryAcquire(1,OPMaps::Instance()->Timeout))
|
if(loaderLimit.tryAcquire(1,OPMaps::Instance()->Timeout))
|
||||||
{
|
{
|
||||||
MtileToload.lock();
|
MtileToload.lock();
|
||||||
--tilesToload;
|
--tilesToload;
|
||||||
MtileToload.unlock();
|
MtileToload.unlock();
|
||||||
@ -172,7 +175,7 @@ namespace internals {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// emit OnTilesStillToLoad(tilesToload);
|
// emit OnTilesStillToLoad(tilesToload);
|
||||||
|
|
||||||
delete t;
|
delete t;
|
||||||
t = 0;
|
t = 0;
|
||||||
@ -216,7 +219,19 @@ namespace internals {
|
|||||||
emit OnTilesStillToLoad(tilesToload<0? 0:tilesToload);
|
emit OnTilesStillToLoad(tilesToload<0? 0:tilesToload);
|
||||||
loaderLimit.release();
|
loaderLimit.release();
|
||||||
}
|
}
|
||||||
|
MrunningThreads.lock();
|
||||||
|
--runningThreads;
|
||||||
|
MrunningThreads.unlock();
|
||||||
}
|
}
|
||||||
|
diagnostics Core::GetDiagnostics()
|
||||||
|
{
|
||||||
|
MrunningThreads.lock();
|
||||||
|
diag=OPMaps::Instance()->GetDiagnostics();
|
||||||
|
diag.runningThreads=runningThreads;
|
||||||
|
MrunningThreads.unlock();
|
||||||
|
return diag;
|
||||||
|
}
|
||||||
|
|
||||||
void Core::SetZoom(const int &value)
|
void Core::SetZoom(const int &value)
|
||||||
{
|
{
|
||||||
if (!isDragging)
|
if (!isDragging)
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
#include "../internals/projections/platecarreeprojectionpergo.h"
|
#include "../internals/projections/platecarreeprojectionpergo.h"
|
||||||
#include "../core/geodecoderstatus.h"
|
#include "../core/geodecoderstatus.h"
|
||||||
#include "../core/opmaps.h"
|
#include "../core/opmaps.h"
|
||||||
|
#include "../core/diagnostics.h"
|
||||||
|
|
||||||
#include <QSemaphore>
|
#include <QSemaphore>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -63,216 +65,219 @@ namespace mapcontrol
|
|||||||
|
|
||||||
namespace internals {
|
namespace internals {
|
||||||
|
|
||||||
class Core:public QObject,public QRunnable
|
class Core:public QObject,public QRunnable
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
friend class mapcontrol::OPMapControl;
|
|
||||||
friend class mapcontrol::MapGraphicItem;
|
|
||||||
public:
|
|
||||||
Core();
|
|
||||||
~Core();
|
|
||||||
void run();
|
|
||||||
PointLatLng CurrentPosition()const{return currentPosition;}
|
|
||||||
|
|
||||||
void SetCurrentPosition(const PointLatLng &value);
|
|
||||||
|
|
||||||
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;}
|
|
||||||
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;}
|
|
||||||
|
|
||||||
core::Point GetrenderOffset(){return renderOffset;}
|
|
||||||
void SetrenderOffset(const core::Point &value){renderOffset=value;}
|
|
||||||
|
|
||||||
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;}
|
|
||||||
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;}
|
|
||||||
|
|
||||||
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;}
|
|
||||||
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;}
|
|
||||||
|
|
||||||
core::Point GetdragPoint(){return dragPoint;}
|
|
||||||
void SetdragPoint(const core::Point &value){dragPoint=value;}
|
|
||||||
|
|
||||||
core::Point GetmouseDown(){return mouseDown;}
|
|
||||||
void SetmouseDown(const core::Point &value){mouseDown=value;}
|
|
||||||
|
|
||||||
core::Point GetmouseCurrent(){return mouseCurrent;}
|
|
||||||
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;}
|
|
||||||
|
|
||||||
core::Point GetmouseLastZoom(){return mouseLastZoom;}
|
|
||||||
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;}
|
|
||||||
|
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;}
|
|
||||||
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;}
|
|
||||||
|
|
||||||
PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
|
|
||||||
void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
|
|
||||||
|
|
||||||
Size GetsizeOfMapArea(){return sizeOfMapArea;}
|
|
||||||
void SetsizeOfMapArea(const Size &value){sizeOfMapArea=value;}
|
|
||||||
|
|
||||||
Size GetminOfTiles(){return minOfTiles;}
|
|
||||||
void SetminOfTiles(const Size &value){minOfTiles=value;}
|
|
||||||
|
|
||||||
Size GetmaxOfTiles(){return maxOfTiles;}
|
|
||||||
void SetmaxOfTiles(const Size &value){maxOfTiles=value;}
|
|
||||||
|
|
||||||
Rectangle GettileRect(){return tileRect;}
|
|
||||||
void SettileRect(const Rectangle &value){tileRect=value;}
|
|
||||||
|
|
||||||
core::Point GettilePoint(){return tilePoint;}
|
|
||||||
void SettilePoint(const core::Point &value){tilePoint=value;}
|
|
||||||
|
|
||||||
Rectangle GetCurrentRegion(){return CurrentRegion;}
|
|
||||||
void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
|
|
||||||
|
|
||||||
QList<core::Point> tileDrawingList;
|
|
||||||
|
|
||||||
PureProjection* Projection()
|
|
||||||
{
|
{
|
||||||
return projection;
|
Q_OBJECT
|
||||||
}
|
|
||||||
void SetProjection(PureProjection* value)
|
|
||||||
{
|
|
||||||
projection=value;
|
|
||||||
tileRect=Rectangle(core::Point(0,0),value->TileSize());
|
|
||||||
}
|
|
||||||
bool IsDragging()const{return isDragging;}
|
|
||||||
|
|
||||||
int Zoom()const{return zoom;}
|
friend class mapcontrol::OPMapControl;
|
||||||
void SetZoom(int const& value);
|
friend class mapcontrol::MapGraphicItem;
|
||||||
|
public:
|
||||||
|
Core();
|
||||||
|
~Core();
|
||||||
|
void run();
|
||||||
|
PointLatLng CurrentPosition()const{return currentPosition;}
|
||||||
|
|
||||||
int MaxZoom()const{return maxzoom;}
|
void SetCurrentPosition(const PointLatLng &value);
|
||||||
|
|
||||||
void UpdateBounds();
|
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;}
|
||||||
|
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;}
|
||||||
|
|
||||||
MapType::Types GetMapType(){return mapType;}
|
core::Point GetrenderOffset(){return renderOffset;}
|
||||||
void SetMapType(MapType::Types const& value);
|
void SetrenderOffset(const core::Point &value){renderOffset=value;}
|
||||||
|
|
||||||
void StartSystem();
|
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;}
|
||||||
|
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;}
|
||||||
|
|
||||||
void UpdateCenterTileXYLocation();
|
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;}
|
||||||
|
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;}
|
||||||
|
|
||||||
void OnMapSizeChanged(int const& width, int const& height);//TODO had as slot
|
core::Point GetdragPoint(){return dragPoint;}
|
||||||
|
void SetdragPoint(const core::Point &value){dragPoint=value;}
|
||||||
|
|
||||||
void OnMapClose();//TODO had as slot
|
core::Point GetmouseDown(){return mouseDown;}
|
||||||
|
void SetmouseDown(const core::Point &value){mouseDown=value;}
|
||||||
|
|
||||||
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys);
|
core::Point GetmouseCurrent(){return mouseCurrent;}
|
||||||
|
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;}
|
||||||
|
|
||||||
RectLatLng CurrentViewArea();
|
core::Point GetmouseLastZoom(){return mouseLastZoom;}
|
||||||
|
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;}
|
||||||
|
|
||||||
PointLatLng FromLocalToLatLng(int const& x, int const& y);
|
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;}
|
||||||
|
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;}
|
||||||
|
|
||||||
Point FromLatLngToLocal(PointLatLng const& latlng);
|
PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
|
||||||
|
void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
|
||||||
|
|
||||||
int GetMaxZoomToFitRect(RectLatLng const& rect);
|
Size GetsizeOfMapArea(){return sizeOfMapArea;}
|
||||||
|
void SetsizeOfMapArea(const Size &value){sizeOfMapArea=value;}
|
||||||
|
|
||||||
void BeginDrag(core::Point const& pt);
|
Size GetminOfTiles(){return minOfTiles;}
|
||||||
|
void SetminOfTiles(const Size &value){minOfTiles=value;}
|
||||||
|
|
||||||
void EndDrag();
|
Size GetmaxOfTiles(){return maxOfTiles;}
|
||||||
|
void SetmaxOfTiles(const Size &value){maxOfTiles=value;}
|
||||||
|
|
||||||
void ReloadMap();
|
Rectangle GettileRect(){return tileRect;}
|
||||||
|
void SettileRect(const Rectangle &value){tileRect=value;}
|
||||||
|
|
||||||
void GoToCurrentPosition();
|
core::Point GettilePoint(){return tilePoint;}
|
||||||
|
void SettilePoint(const core::Point &value){tilePoint=value;}
|
||||||
|
|
||||||
bool MouseWheelZooming;
|
Rectangle GetCurrentRegion(){return CurrentRegion;}
|
||||||
|
void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
|
||||||
|
|
||||||
void DragOffset(core::Point const& offset);
|
QList<core::Point> tileDrawingList;
|
||||||
|
|
||||||
void Drag(core::Point const& pt);
|
PureProjection* Projection()
|
||||||
|
{
|
||||||
|
return projection;
|
||||||
|
}
|
||||||
|
void SetProjection(PureProjection* value)
|
||||||
|
{
|
||||||
|
projection=value;
|
||||||
|
tileRect=Rectangle(core::Point(0,0),value->TileSize());
|
||||||
|
}
|
||||||
|
bool IsDragging()const{return isDragging;}
|
||||||
|
|
||||||
void CancelAsyncTasks();
|
int Zoom()const{return zoom;}
|
||||||
|
void SetZoom(int const& value);
|
||||||
|
|
||||||
void FindTilesAround(QList<core::Point> &list);
|
int MaxZoom()const{return maxzoom;}
|
||||||
|
|
||||||
void UpdateGroundResolution();
|
void UpdateBounds();
|
||||||
|
|
||||||
TileMatrix Matrix;
|
MapType::Types GetMapType(){return mapType;}
|
||||||
|
void SetMapType(MapType::Types const& value);
|
||||||
|
|
||||||
bool isStarted(){return started;}
|
void StartSystem();
|
||||||
|
|
||||||
|
void UpdateCenterTileXYLocation();
|
||||||
|
|
||||||
|
void OnMapSizeChanged(int const& width, int const& height);//TODO had as slot
|
||||||
|
|
||||||
|
void OnMapClose();//TODO had as slot
|
||||||
|
|
||||||
|
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys);
|
||||||
|
|
||||||
|
RectLatLng CurrentViewArea();
|
||||||
|
|
||||||
|
PointLatLng FromLocalToLatLng(int const& x, int const& y);
|
||||||
|
|
||||||
|
Point FromLatLngToLocal(PointLatLng const& latlng);
|
||||||
|
|
||||||
|
int GetMaxZoomToFitRect(RectLatLng const& rect);
|
||||||
|
|
||||||
|
void BeginDrag(core::Point const& pt);
|
||||||
|
|
||||||
|
void EndDrag();
|
||||||
|
|
||||||
|
void ReloadMap();
|
||||||
|
|
||||||
|
void GoToCurrentPosition();
|
||||||
|
|
||||||
|
bool MouseWheelZooming;
|
||||||
|
|
||||||
|
void DragOffset(core::Point const& offset);
|
||||||
|
|
||||||
|
void Drag(core::Point const& pt);
|
||||||
|
|
||||||
|
void CancelAsyncTasks();
|
||||||
|
|
||||||
|
void FindTilesAround(QList<core::Point> &list);
|
||||||
|
|
||||||
|
void UpdateGroundResolution();
|
||||||
|
|
||||||
|
TileMatrix Matrix;
|
||||||
|
|
||||||
|
bool isStarted(){return started;}
|
||||||
|
|
||||||
|
diagnostics GetDiagnostics();
|
||||||
|
signals:
|
||||||
|
void OnCurrentPositionChanged(internals::PointLatLng point);
|
||||||
|
void OnTileLoadComplete();
|
||||||
|
void OnTilesStillToLoad(int number);
|
||||||
|
void OnTileLoadStart();
|
||||||
|
void OnMapDrag();
|
||||||
|
void OnMapZoomChanged();
|
||||||
|
void OnMapTypeChanged(MapType::Types type);
|
||||||
|
void OnEmptyTileError(int zoom, core::Point pos);
|
||||||
|
void OnNeedInvalidation();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
signals:
|
PointLatLng currentPosition;
|
||||||
void OnCurrentPositionChanged(internals::PointLatLng point);
|
core::Point currentPositionPixel;
|
||||||
void OnTileLoadComplete();
|
core::Point renderOffset;
|
||||||
void OnTilesStillToLoad(int number);
|
core::Point centerTileXYLocation;
|
||||||
void OnTileLoadStart();
|
core::Point centerTileXYLocationLast;
|
||||||
void OnMapDrag();
|
core::Point dragPoint;
|
||||||
void OnMapZoomChanged();
|
Rectangle tileRect;
|
||||||
void OnMapTypeChanged(MapType::Types type);
|
core::Point mouseDown;
|
||||||
void OnEmptyTileError(int zoom, core::Point pos);
|
bool CanDragMap;
|
||||||
void OnNeedInvalidation();
|
core::Point mouseCurrent;
|
||||||
|
PointLatLng LastLocationInBounds;
|
||||||
|
core::Point mouseLastZoom;
|
||||||
|
|
||||||
private:
|
MouseWheelZoomType::Types mousewheelzoomtype;
|
||||||
|
|
||||||
|
|
||||||
PointLatLng currentPosition;
|
Size sizeOfMapArea;
|
||||||
core::Point currentPositionPixel;
|
Size minOfTiles;
|
||||||
core::Point renderOffset;
|
Size maxOfTiles;
|
||||||
core::Point centerTileXYLocation;
|
|
||||||
core::Point centerTileXYLocationLast;
|
|
||||||
core::Point dragPoint;
|
|
||||||
Rectangle tileRect;
|
|
||||||
core::Point mouseDown;
|
|
||||||
bool CanDragMap;
|
|
||||||
core::Point mouseCurrent;
|
|
||||||
PointLatLng LastLocationInBounds;
|
|
||||||
core::Point mouseLastZoom;
|
|
||||||
|
|
||||||
MouseWheelZoomType::Types mousewheelzoomtype;
|
core::Point tilePoint;
|
||||||
|
|
||||||
|
Rectangle CurrentRegion;
|
||||||
|
|
||||||
Size sizeOfMapArea;
|
QQueue<LoadTask> tileLoadQueue;
|
||||||
Size minOfTiles;
|
|
||||||
Size maxOfTiles;
|
|
||||||
|
|
||||||
core::Point tilePoint;
|
int zoom;
|
||||||
|
|
||||||
Rectangle CurrentRegion;
|
PureProjection* projection;
|
||||||
|
|
||||||
QQueue<LoadTask> tileLoadQueue;
|
bool isDragging;
|
||||||
|
|
||||||
int zoom;
|
QMutex MtileLoadQueue;
|
||||||
|
|
||||||
PureProjection* projection;
|
QMutex Moverlays;
|
||||||
|
|
||||||
bool isDragging;
|
QMutex MtileDrawingList;
|
||||||
|
|
||||||
QMutex MtileLoadQueue;
|
|
||||||
|
|
||||||
QMutex Moverlays;
|
|
||||||
|
|
||||||
QMutex MtileDrawingList;
|
|
||||||
#ifdef DEBUG_CORE
|
#ifdef DEBUG_CORE
|
||||||
QMutex Mdebug;
|
QMutex Mdebug;
|
||||||
static qlonglong debugcounter;
|
static qlonglong debugcounter;
|
||||||
#endif
|
#endif
|
||||||
Size TooltipTextPadding;
|
Size TooltipTextPadding;
|
||||||
|
|
||||||
MapType::Types mapType;
|
MapType::Types mapType;
|
||||||
|
|
||||||
QSemaphore loaderLimit;
|
QSemaphore loaderLimit;
|
||||||
|
|
||||||
QThreadPool ProcessLoadTaskCallback;
|
QThreadPool ProcessLoadTaskCallback;
|
||||||
QMutex MtileToload;
|
QMutex MtileToload;
|
||||||
int tilesToload;
|
int tilesToload;
|
||||||
|
|
||||||
int maxzoom;
|
int maxzoom;
|
||||||
|
QMutex MrunningThreads;
|
||||||
|
int runningThreads;
|
||||||
|
diagnostics diag;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
int Width;
|
int Width;
|
||||||
int Height;
|
int Height;
|
||||||
int pxRes100m; // 100 meters
|
int pxRes100m; // 100 meters
|
||||||
int pxRes1000m; // 1km
|
int pxRes1000m; // 1km
|
||||||
int pxRes10km; // 10km
|
int pxRes10km; // 10km
|
||||||
int pxRes100km; // 100km
|
int pxRes100km; // 100km
|
||||||
int pxRes1000km; // 1000km
|
int pxRes1000km; // 1000km
|
||||||
int pxRes5000km; // 5000km
|
int pxRes5000km; // 5000km
|
||||||
void SetCurrentPositionGPixel(core::Point const& value){currentPositionPixel = value;}
|
void SetCurrentPositionGPixel(core::Point const& value){currentPositionPixel = value;}
|
||||||
void GoToCurrentPositionOnZoom();
|
void GoToCurrentPositionOnZoom();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // CORE_H
|
#endif // CORE_H
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include "../internals/core.h"
|
#include "../internals/core.h"
|
||||||
//#include "../internals/point.h"
|
//#include "../internals/point.h"
|
||||||
|
#include "../core/diagnostics.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
@ -19,8 +19,8 @@ LIBS += -L../build \
|
|||||||
-linternals \
|
-linternals \
|
||||||
-lcore
|
-lcore
|
||||||
|
|
||||||
TARGETDEPS += ../build/libcore.a
|
POST_TARGETDEPS += ../build/libcore.a
|
||||||
TARGETDEPS += ../build/libinternals.a
|
POST_TARGETDEPS += ../build/libinternals.a
|
||||||
|
|
||||||
HEADERS += mapgraphicitem.h \
|
HEADERS += mapgraphicitem.h \
|
||||||
opmapwidget.h \
|
opmapwidget.h \
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
|
||||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),GPS(0),Home(0),followmouse(true),compass(0),showuav(false),showhome(false)
|
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),GPS(0),Home(0),followmouse(true),compass(0),showuav(false),showhome(false),showDiag(false),diagGraphItem(0),diagTimer(0)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
core=new internals::Core;
|
core=new internals::Core;
|
||||||
@ -50,11 +50,35 @@ namespace mapcontrol
|
|||||||
connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete()));
|
connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete()));
|
||||||
connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart()));
|
connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart()));
|
||||||
connect(map->core,SIGNAL(OnTilesStillToLoad(int)),this,SIGNAL(OnTilesStillToLoad(int)));
|
connect(map->core,SIGNAL(OnTilesStillToLoad(int)),this,SIGNAL(OnTilesStillToLoad(int)));
|
||||||
|
SetShowDiagnostics(showDiag);
|
||||||
this->setMouseTracking(followmouse);
|
this->setMouseTracking(followmouse);
|
||||||
SetShowCompass(true);
|
SetShowCompass(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void OPMapWidget::SetShowDiagnostics(bool const& value)
|
||||||
|
{
|
||||||
|
showDiag=value;
|
||||||
|
if(!showDiag)
|
||||||
|
{
|
||||||
|
if(diagGraphItem!=0)
|
||||||
|
{
|
||||||
|
delete diagGraphItem;
|
||||||
|
diagGraphItem=0;
|
||||||
|
}
|
||||||
|
if(diagTimer!=0)
|
||||||
|
{
|
||||||
|
delete diagTimer;
|
||||||
|
diagTimer=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diagTimer=new QTimer();
|
||||||
|
connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh()));
|
||||||
|
diagTimer->start(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
void OPMapWidget::SetShowUAV(const bool &value)
|
void OPMapWidget::SetShowUAV(const bool &value)
|
||||||
{
|
{
|
||||||
if(value && UAV==0)
|
if(value && UAV==0)
|
||||||
@ -118,7 +142,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
QSize OPMapWidget::sizeHint() const
|
QSize OPMapWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
return map->sizeHint();
|
return map->sizeHint();
|
||||||
}
|
}
|
||||||
void OPMapWidget::showEvent(QShowEvent *event)
|
void OPMapWidget::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
@ -135,7 +159,7 @@ namespace mapcontrol
|
|||||||
delete configuration;
|
delete configuration;
|
||||||
foreach(QGraphicsItem* i,this->items())
|
foreach(QGraphicsItem* i,this->items())
|
||||||
{
|
{
|
||||||
delete i;
|
delete i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::closeEvent(QCloseEvent *event)
|
void OPMapWidget::closeEvent(QCloseEvent *event)
|
||||||
@ -264,6 +288,28 @@ namespace mapcontrol
|
|||||||
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)));
|
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)));
|
||||||
connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int)));
|
connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int)));
|
||||||
}
|
}
|
||||||
|
void OPMapWidget::diagRefresh()
|
||||||
|
{
|
||||||
|
if(showDiag)
|
||||||
|
{
|
||||||
|
if(diagGraphItem==0)
|
||||||
|
{
|
||||||
|
diagGraphItem=new QGraphicsTextItem();
|
||||||
|
mscene.addItem(diagGraphItem);
|
||||||
|
diagGraphItem->setPos(10,100);
|
||||||
|
diagGraphItem->setZValue(3);
|
||||||
|
diagGraphItem->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
diagGraphItem->setDefaultTextColor(Qt::yellow);
|
||||||
|
}
|
||||||
|
diagGraphItem->setPlainText(core->GetDiagnostics().toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(diagGraphItem!=0)
|
||||||
|
{
|
||||||
|
delete diagGraphItem;
|
||||||
|
diagGraphItem=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
void OPMapWidget::SetShowCompass(const bool &value)
|
void OPMapWidget::SetShowCompass(const bool &value)
|
||||||
@ -272,7 +318,7 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
compass=new QGraphicsSvgItem(QString::fromUtf8(":/markers/images/compas.svg"));
|
compass=new QGraphicsSvgItem(QString::fromUtf8(":/markers/images/compas.svg"));
|
||||||
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
||||||
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
||||||
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
mscene.addItem(compass);
|
mscene.addItem(compass);
|
||||||
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
||||||
@ -287,15 +333,15 @@ namespace mapcontrol
|
|||||||
compass=0;
|
compass=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::SetRotate(qreal const& value)
|
void OPMapWidget::SetRotate(qreal const& value)
|
||||||
{
|
{
|
||||||
map->mapRotate(value);
|
map->mapRotate(value);
|
||||||
if(compass && (compass->rotation() != value)) {
|
if(compass && (compass->rotation() != value)) {
|
||||||
compass->setRotation(value);
|
compass->setRotation(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::RipMap()
|
void OPMapWidget::RipMap()
|
||||||
{
|
{
|
||||||
new MapRipper(core,map->SelectedArea());
|
new MapRipper(core,map->SelectedArea());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "../core/geodecoderstatus.h"
|
#include "../core/geodecoderstatus.h"
|
||||||
#include "../core/maptype.h"
|
#include "../core/maptype.h"
|
||||||
#include "../core/languagetype.h"
|
#include "../core/languagetype.h"
|
||||||
|
#include "../core/diagnostics.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtOpenGL/QGLWidget>
|
#include <QtOpenGL/QGLWidget>
|
||||||
@ -120,7 +121,7 @@ namespace mapcontrol
|
|||||||
*/
|
*/
|
||||||
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
|
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Converts from String to Type
|
* @brief Converts from String to Type
|
||||||
*/
|
*/
|
||||||
static UAVMapFollowType::Types UAVMapFollowFromString(QString const& value){return UAVMapFollowType::TypeByStr(value);}
|
static UAVMapFollowType::Types UAVMapFollowFromString(QString const& value){return UAVMapFollowType::TypeByStr(value);}
|
||||||
@ -135,31 +136,31 @@ namespace mapcontrol
|
|||||||
/**
|
/**
|
||||||
* @brief Converts from String to Type
|
* @brief Converts from String to Type
|
||||||
*/
|
*/
|
||||||
static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);}
|
static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);}
|
||||||
/**
|
/**
|
||||||
* @brief Converts from Type to String
|
* @brief Converts from Type to String
|
||||||
*/
|
*/
|
||||||
static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);}
|
static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);}
|
||||||
/**
|
/**
|
||||||
* @brief Returns QStringList with string representing all the enum values
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
*/
|
*/
|
||||||
static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();}
|
static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OPMapWidget:public QGraphicsView
|
class OPMapWidget:public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
||||||
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
||||||
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
||||||
Q_PROPERTY(double Zoom READ ZoomTotal WRITE SetZoom)
|
Q_PROPERTY(double Zoom READ ZoomTotal WRITE SetZoom)
|
||||||
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
|
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
|
||||||
Q_ENUMS(internals::MouseWheelZoomType::Types)
|
Q_ENUMS(internals::MouseWheelZoomType::Types)
|
||||||
Q_ENUMS(internals::GeoCoderStatusCode::Types)
|
Q_ENUMS(internals::GeoCoderStatusCode::Types)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
@ -191,7 +192,7 @@ namespace mapcontrol
|
|||||||
*/
|
*/
|
||||||
int MaxZoom()const{return map->MaxZoom();}
|
int MaxZoom()const{return map->MaxZoom();}
|
||||||
|
|
||||||
// void SetMaxZoom(int const& value){map->maxZoom = value;}
|
// void SetMaxZoom(int const& value){map->maxZoom = value;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -346,6 +347,7 @@ namespace mapcontrol
|
|||||||
bool ShowUAV()const{return showuav;}
|
bool ShowUAV()const{return showuav;}
|
||||||
void SetShowHome(bool const& value);
|
void SetShowHome(bool const& value);
|
||||||
bool ShowHome()const{return showhome;}
|
bool ShowHome()const{return showhome;}
|
||||||
|
void SetShowDiagnostics(bool const& value);
|
||||||
private:
|
private:
|
||||||
internals::Core *core;
|
internals::Core *core;
|
||||||
MapGraphicItem *map;
|
MapGraphicItem *map;
|
||||||
@ -360,7 +362,12 @@ namespace mapcontrol
|
|||||||
QGraphicsSvgItem *compass;
|
QGraphicsSvgItem *compass;
|
||||||
bool showuav;
|
bool showuav;
|
||||||
bool showhome;
|
bool showhome;
|
||||||
// WayPointItem* item;//apagar
|
QTimer * diagTimer;
|
||||||
|
QGraphicsTextItem * diagGraphItem;
|
||||||
|
bool showDiag;
|
||||||
|
private slots:
|
||||||
|
void diagRefresh();
|
||||||
|
// WayPointItem* item;//apagar
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void showEvent ( QShowEvent * event );
|
void showEvent ( QShowEvent * event );
|
||||||
@ -383,14 +390,14 @@ namespace mapcontrol
|
|||||||
* @param waypoint a pointer to the WayPoint
|
* @param waypoint a pointer to the WayPoint
|
||||||
*/
|
*/
|
||||||
void WPValuesChanged(WayPointItem* waypoint);
|
void WPValuesChanged(WayPointItem* waypoint);
|
||||||
/**
|
/**
|
||||||
* @brief Fires when a new WayPoint is inserted
|
* @brief Fires when a new WayPoint is inserted
|
||||||
*
|
*
|
||||||
* @param number new WayPoint number
|
* @param number new WayPoint number
|
||||||
* @param waypoint WayPoint inserted
|
* @param waypoint WayPoint inserted
|
||||||
*/
|
*/
|
||||||
void WPReached(WayPointItem* waypoint);
|
void WPReached(WayPointItem* waypoint);
|
||||||
/**
|
/**
|
||||||
* @brief Fires when a new WayPoint is inserted
|
* @brief Fires when a new WayPoint is inserted
|
||||||
*
|
*
|
||||||
* @param number new WayPoint number
|
* @param number new WayPoint number
|
||||||
|
@ -463,6 +463,8 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
menu.addAction(showCompassAct);
|
menu.addAction(showCompassAct);
|
||||||
|
|
||||||
|
menu.addAction(showDiagnostics);
|
||||||
|
|
||||||
menu.addSeparator()->setText(tr("Zoom"));
|
menu.addSeparator()->setText(tr("Zoom"));
|
||||||
|
|
||||||
menu.addAction(zoomInAct);
|
menu.addAction(zoomInAct);
|
||||||
@ -1373,6 +1375,12 @@ void OPMapGadgetWidget::createActions()
|
|||||||
showCompassAct->setChecked(true);
|
showCompassAct->setChecked(true);
|
||||||
connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool)));
|
connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool)));
|
||||||
|
|
||||||
|
showDiagnostics = new QAction(tr("Show Diagnostics"), this);
|
||||||
|
showDiagnostics->setStatusTip(tr("Show/Hide the diagnostics"));
|
||||||
|
showDiagnostics->setCheckable(true);
|
||||||
|
showDiagnostics->setChecked(false);
|
||||||
|
connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool)));
|
||||||
|
|
||||||
showHomeAct = new QAction(tr("Show Home"), this);
|
showHomeAct = new QAction(tr("Show Home"), this);
|
||||||
showHomeAct->setStatusTip(tr("Show/Hide the Home location"));
|
showHomeAct->setStatusTip(tr("Show/Hide the Home location"));
|
||||||
showHomeAct->setCheckable(true);
|
showHomeAct->setCheckable(true);
|
||||||
@ -1614,6 +1622,14 @@ void OPMapGadgetWidget::onShowCompassAct_toggled(bool show)
|
|||||||
m_map->SetShowCompass(show);
|
m_map->SetShowCompass(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show)
|
||||||
|
{
|
||||||
|
if (!m_widget || !m_map)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_map->SetShowDiagnostics(show);
|
||||||
|
}
|
||||||
|
|
||||||
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)
|
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)
|
||||||
{
|
{
|
||||||
if (!m_widget || !m_map)
|
if (!m_widget || !m_map)
|
||||||
|
@ -185,6 +185,7 @@ private slots:
|
|||||||
void onCopyMouseLonToClipAct_triggered();
|
void onCopyMouseLonToClipAct_triggered();
|
||||||
// void onFindPlaceAct_triggered();
|
// void onFindPlaceAct_triggered();
|
||||||
void onShowCompassAct_toggled(bool show);
|
void onShowCompassAct_toggled(bool show);
|
||||||
|
void onShowDiagnostics_toggled(bool show);
|
||||||
void onShowUAVAct_toggled(bool show);
|
void onShowUAVAct_toggled(bool show);
|
||||||
void onShowHomeAct_toggled(bool show);
|
void onShowHomeAct_toggled(bool show);
|
||||||
void onGoZoomInAct_triggered();
|
void onGoZoomInAct_triggered();
|
||||||
@ -265,6 +266,7 @@ private:
|
|||||||
QAction *copyMouseLonToClipAct;
|
QAction *copyMouseLonToClipAct;
|
||||||
QAction *findPlaceAct;
|
QAction *findPlaceAct;
|
||||||
QAction *showCompassAct;
|
QAction *showCompassAct;
|
||||||
|
QAction *showDiagnostics;
|
||||||
QAction *showHomeAct;
|
QAction *showHomeAct;
|
||||||
QAction *showUAVAct;
|
QAction *showUAVAct;
|
||||||
QAction *zoomInAct;
|
QAction *zoomInAct;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user