mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP37/GCS Hot new way of zooming, no more Empty tiles.
Fixes to some provider strings. Changes to static libs needs rebuild. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@979 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
760fc69cba
commit
89ae1831ab
@ -49,7 +49,7 @@ namespace core {
|
||||
|
||||
OPMaps::~OPMaps()
|
||||
{
|
||||
//delete Proxy;
|
||||
TileDBcacheQueue.wait();
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,8 @@ namespace core {
|
||||
QString url=MakeImageUrl(type,pos,zoom,LanguageStr);
|
||||
#ifdef DEBUG_TIMINGS
|
||||
qDebug()<<"opmaps after make image url"<<time.elapsed();
|
||||
#endif
|
||||
#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"
|
||||
qheader.setUrl(QUrl(url));
|
||||
qheader.setRawHeader("User-Agent",UserAgent);
|
||||
qheader.setRawHeader("Accept","*/*");
|
||||
|
@ -39,21 +39,21 @@ namespace core {
|
||||
ProviderStrings::ProviderStrings()
|
||||
{
|
||||
// Google version strings
|
||||
VersionGoogleMap = "m@123";
|
||||
VersionGoogleSatellite = "59";
|
||||
VersionGoogleLabels = "h@123";
|
||||
VersionGoogleTerrain = "t@108,r@123";
|
||||
VersionGoogleMap = "m@126";
|
||||
VersionGoogleSatellite = "61";
|
||||
VersionGoogleLabels = "h@126";
|
||||
VersionGoogleTerrain = "t@125,r@126";
|
||||
SecGoogleWord = "Galileo";
|
||||
|
||||
// Google (China) version strings
|
||||
VersionGoogleMapChina = "m@123";
|
||||
VersionGoogleSatelliteChina = "s@59";
|
||||
VersionGoogleLabelsChina = "h@123";
|
||||
VersionGoogleTerrainChina = "t@108,r@123";
|
||||
VersionGoogleMapChina = "m@126";
|
||||
VersionGoogleSatelliteChina = "s@61";
|
||||
VersionGoogleLabelsChina = "h@126";
|
||||
VersionGoogleTerrainChina = "t@125,r@126";
|
||||
|
||||
// Google (Korea) version strings
|
||||
VersionGoogleMapKorea = "kr1.12";
|
||||
VersionGoogleSatelliteKorea = "59";
|
||||
VersionGoogleSatelliteKorea = "61";
|
||||
VersionGoogleLabelsKorea = "kr1t.12";
|
||||
|
||||
/// <summary>
|
||||
@ -68,7 +68,7 @@ namespace core {
|
||||
VersionYahooLabels = "4.3";
|
||||
|
||||
// BingMaps
|
||||
VersionBingMaps = "452";
|
||||
VersionBingMaps = "470";
|
||||
|
||||
// YandexMap
|
||||
VersionYandexMap = "2.10.2";
|
||||
|
@ -35,6 +35,10 @@ TileCacheQueue::TileCacheQueue()
|
||||
{
|
||||
|
||||
}
|
||||
TileCacheQueue::~TileCacheQueue()
|
||||
{
|
||||
// QThread::wait(10000);
|
||||
}
|
||||
|
||||
void TileCacheQueue::EnqueueCacheTask(CacheItemQueue *task)
|
||||
{
|
||||
@ -54,7 +58,7 @@ void TileCacheQueue::EnqueueCacheTask(CacheItemQueue *task)
|
||||
#ifdef DEBUG_TILECACHEQUEUE
|
||||
qDebug()<<"Wake Thread";
|
||||
#endif //DEBUG_TILECACHEQUEUE
|
||||
wait.wakeOne();
|
||||
waitc.wakeOne();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -93,7 +97,7 @@ void TileCacheQueue::run()
|
||||
else
|
||||
{
|
||||
waitmutex.lock();
|
||||
if(!wait.wait(&waitmutex,4444))
|
||||
if(!waitc.wait(&waitmutex,4444))
|
||||
|
||||
{
|
||||
#ifdef DEBUG_TILECACHEQUEUE
|
||||
|
@ -45,7 +45,7 @@ namespace core {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TileCacheQueue();
|
||||
|
||||
~TileCacheQueue();
|
||||
void EnqueueCacheTask(CacheItemQueue *task);
|
||||
|
||||
protected:
|
||||
@ -54,7 +54,7 @@ namespace core {
|
||||
void run();
|
||||
QMutex mutex;
|
||||
QMutex waitmutex;
|
||||
QWaitCondition wait;
|
||||
QWaitCondition waitc;
|
||||
};
|
||||
}
|
||||
#endif // TILECACHEQUEUE_H
|
||||
|
@ -515,12 +515,12 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type,const Point &pos,con
|
||||
|
||||
// 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(pos.X(),9,(QChar)'0');
|
||||
QString x=QString("%1").arg(QString::number(pos.X()),9,(QChar)'0');
|
||||
x.insert(3,"/").insert(7,"/");
|
||||
QString y=QString("%1").arg(pos.X(),9,(QChar)'0');
|
||||
QString y=QString("%1").arg(QString::number(pos.Y()),9,(QChar)'0');
|
||||
y.insert(3,"/").insert(7,"/");
|
||||
|
||||
return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(GetServerNum(pos, 4),2,10,(QChar)'0').arg(zoom).arg(x).arg(y);
|
||||
//"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:
|
||||
@ -535,7 +535,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type,const Point &pos,con
|
||||
|
||||
//http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
|
||||
|
||||
return QString("http://%10%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(server).arg(GetServerNum(pos, 4)+1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
|
||||
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:
|
||||
|
@ -46,6 +46,11 @@ namespace internals {
|
||||
CanDragMap=true;
|
||||
tilesToload=0;
|
||||
}
|
||||
Core::~Core()
|
||||
{
|
||||
ProcessLoadTaskCallback.waitForDone();
|
||||
}
|
||||
|
||||
void Core::run()
|
||||
{
|
||||
#ifdef DEBUG_CORE
|
||||
@ -214,6 +219,7 @@ namespace internals {
|
||||
}
|
||||
void Core::SetZoom(const int &value)
|
||||
{
|
||||
bool grow=false;
|
||||
if (zoom!=value && !isDragging)
|
||||
{
|
||||
zoom=value;
|
||||
|
@ -72,6 +72,7 @@ class Core:public QObject,public QRunnable
|
||||
friend class mapcontrol::MapGraphicItem;
|
||||
public:
|
||||
Core();
|
||||
~Core();
|
||||
void run();
|
||||
PointLatLng CurrentPosition()const{return currentPosition;};
|
||||
void SetCurrentPosition(const PointLatLng &value);
|
||||
|
@ -43,6 +43,60 @@ void TileMatrix::Clear()
|
||||
matrix.clear();
|
||||
mutex.unlock();
|
||||
}
|
||||
//void TileMatrix::RebuildToUpperZoom()
|
||||
//{
|
||||
// mutex.lock();
|
||||
// QList<Tile*> newtiles;
|
||||
// foreach(Tile* t,matrix.values())
|
||||
// {
|
||||
// Point point=Point(t->GetPos().X()*2,t->GetPos().Y()*2);
|
||||
// Tile* tile1=new Tile(t->GetZoom()+1,point);
|
||||
// Tile* tile2=new Tile(t->GetZoom()+1,Point(point.X()+1,point.Y()+0));
|
||||
// Tile* tile3=new Tile(t->GetZoom()+1,Point(point.X()+0,point.Y()+1));
|
||||
// Tile* tile4=new Tile(t->GetZoom()+1,Point(point.X()+1,point.Y()+1));
|
||||
//
|
||||
// foreach(QByteArray arr, t->Overlays)
|
||||
// {
|
||||
// QImage ima=QImage::fromData(arr);
|
||||
// QImage ima1=ima.copy(0,0,ima.width()/2,ima.height()/2);
|
||||
// QImage ima2=ima.copy(ima.width()/2,0,ima.width()/2,ima.height()/2);
|
||||
// QImage ima3=ima.copy(0,ima.height()/2,ima.width()/2,ima.height()/2);
|
||||
// QImage ima4=ima.copy(ima.width()/2,ima.height()/2,ima.width()/2,ima.height()/2);
|
||||
// QByteArray ba;
|
||||
// QBuffer buf(&ba);
|
||||
// ima1.scaled(QSize(ima.width(),ima.height())).save(&buf,"PNG");
|
||||
// tile1->Overlays.append(ba);
|
||||
// QByteArray ba1;
|
||||
// QBuffer buf1(&ba1);
|
||||
// ima2.scaled(QSize(ima.width(),ima.height())).save(&buf1,"PNG");
|
||||
// tile2->Overlays.append(ba1);
|
||||
// QByteArray ba2;
|
||||
// QBuffer buf2(&ba2);
|
||||
// ima3.scaled(QSize(ima.width(),ima.height())).save(&buf2,"PNG");
|
||||
// tile3->Overlays.append(ba2);
|
||||
// QByteArray ba3;
|
||||
// QBuffer buf3(&ba3);
|
||||
// ima4.scaled(QSize(ima.width(),ima.height())).save(&buf3,"PNG");
|
||||
// tile4->Overlays.append(ba3);
|
||||
// newtiles.append(tile1);
|
||||
// newtiles.append(tile2);
|
||||
// newtiles.append(tile3);
|
||||
// newtiles.append(tile4);
|
||||
// }
|
||||
// }
|
||||
// foreach(Tile* t,matrix.values())
|
||||
// {
|
||||
// delete t;
|
||||
// t=0;
|
||||
// }
|
||||
// matrix.clear();
|
||||
// foreach(Tile* t,newtiles)
|
||||
// {
|
||||
// matrix.insert(t->GetPos(),t);
|
||||
// }
|
||||
//
|
||||
// mutex.unlock();
|
||||
//}
|
||||
|
||||
void TileMatrix::ClearPointsNotIn(QList<Point>list)
|
||||
{
|
||||
@ -86,6 +140,9 @@ Tile* TileMatrix::TileAt(const Point &p)
|
||||
void TileMatrix::SetTileAt(const Point &p, Tile* tile)
|
||||
{
|
||||
mutex.lock();
|
||||
Tile* t=matrix.value(p,0);
|
||||
if(t!=0)
|
||||
delete t;
|
||||
matrix.insert(p,tile);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QList>
|
||||
#include "../core/point.h"
|
||||
#include "debugheader.h"
|
||||
#include <QBuffer>
|
||||
namespace internals {
|
||||
class TileMatrix
|
||||
{
|
||||
@ -43,6 +44,7 @@ public:
|
||||
Tile* TileAt(const core::Point &p);
|
||||
void SetTileAt(const core::Point &p,Tile* tile);
|
||||
int count()const{return matrix.count();}
|
||||
// void RebuildToUpperZoom();
|
||||
protected:
|
||||
QHash<core::Point,Tile*> matrix;
|
||||
QList<core::Point> removals;
|
||||
|
@ -80,6 +80,40 @@ namespace mapcontrol
|
||||
w->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ConstructLastImage()
|
||||
{
|
||||
QSize size=boundingRect().size().toSize();
|
||||
size.setWidth(size.width()*2);
|
||||
size.setHeight(size.height()*2);
|
||||
lastimage=QImage(size,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
lastimage.fill(0);
|
||||
QPainter* imagePainter=new QPainter(&lastimage);
|
||||
imagePainter->translate(-boundingRect().topLeft());
|
||||
imagePainter->scale(2,2);
|
||||
paintImage(imagePainter);
|
||||
imagePainter->end();
|
||||
lastimagepoint=Point(core->GetrenderOffset().X()*2,core->GetrenderOffset().Y()*2);
|
||||
}
|
||||
void MapGraphicItem::paintImage(QPainter *painter)
|
||||
{
|
||||
|
||||
if(MapRenderTransform!=1)
|
||||
{
|
||||
QTransform transform;
|
||||
transform.scale(MapRenderTransform,MapRenderTransform);
|
||||
painter->setWorldTransform(transform);
|
||||
{
|
||||
DrawMap2D(painter,true);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter,true);
|
||||
}
|
||||
//painter->drawRect(maprect);
|
||||
}
|
||||
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
||||
@ -89,15 +123,15 @@ namespace mapcontrol
|
||||
transform.scale(MapRenderTransform,MapRenderTransform);
|
||||
painter->setWorldTransform(transform);
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
DrawMap2D(painter,false);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
DrawMap2D(painter,false);
|
||||
}
|
||||
painter->drawRect(maprect);
|
||||
// painter->drawRect(maprect);
|
||||
}
|
||||
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
@ -217,10 +251,14 @@ namespace mapcontrol
|
||||
core->MouseWheelZooming = false;
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::DrawMap2D(QPainter *painter)
|
||||
void MapGraphicItem::DrawMap2D(QPainter *painter,bool ToImage)
|
||||
{
|
||||
// qDebug()<<core->Matrix.count();
|
||||
// painter.drawText(10,10,"TESTE");
|
||||
//painter->drawImage(0,0,lastimage);
|
||||
if(!ToImage && !lastimage.isNull())
|
||||
painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage);
|
||||
|
||||
for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
|
||||
{
|
||||
for(int j = -core->GetsizeOfMapArea().Height(); j <= core->GetsizeOfMapArea().Height(); j++)
|
||||
@ -240,6 +278,7 @@ namespace mapcontrol
|
||||
core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width());
|
||||
core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height());
|
||||
core->tileRect.Offset(core->GetrenderOffset());
|
||||
qDebug()<<core->GetrenderOffset().ToString();
|
||||
|
||||
if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
|
||||
{
|
||||
@ -276,7 +315,7 @@ namespace mapcontrol
|
||||
}
|
||||
|
||||
// add text if tile is missing
|
||||
if(!found)
|
||||
if(false)
|
||||
{
|
||||
|
||||
painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptytileBrush);
|
||||
@ -296,6 +335,7 @@ namespace mapcontrol
|
||||
}
|
||||
}
|
||||
}
|
||||
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
|
||||
}
|
||||
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
||||
{
|
||||
@ -369,6 +409,10 @@ namespace mapcontrol
|
||||
}
|
||||
void MapGraphicItem::SetZoomStep(int const& value)
|
||||
{
|
||||
if(value-core->Zoom()==1 && value<= MaxZoom())
|
||||
ConstructLastImage();
|
||||
else
|
||||
lastimage=QImage();
|
||||
if(value > MaxZoom())
|
||||
{
|
||||
core->SetZoom(MaxZoom());
|
||||
|
@ -91,6 +91,10 @@ namespace mapcontrol
|
||||
*/
|
||||
bool IsDragging()const{return core->IsDragging();}
|
||||
|
||||
QImage lastimage;
|
||||
core::Point lastimagepoint;
|
||||
void paintImage(QPainter* painter);
|
||||
void ConstructLastImage();
|
||||
protected:
|
||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
@ -111,13 +115,15 @@ namespace mapcontrol
|
||||
*/
|
||||
void SetZoomStep(int const& value);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
internals::Core *core;
|
||||
Configuration *config;
|
||||
bool showTileGridLines;
|
||||
qreal MapRenderTransform;
|
||||
void DrawMap2D(QPainter *painter);
|
||||
void DrawMap2D(QPainter *painter,bool ToImage);
|
||||
|
||||
/**
|
||||
* @brief Maximum possible zoom
|
||||
|
@ -202,7 +202,7 @@ namespace mapcontrol
|
||||
void SetUseOpenGL(bool const& value);
|
||||
|
||||
MapType::Types GetMapType(){return map->core->GetMapType();}
|
||||
void SetMapType(MapType::Types const& value){map->core->SetMapType(value);}
|
||||
void SetMapType(MapType::Types const& value){map->lastimage=QImage(); map->core->SetMapType(value);}
|
||||
|
||||
bool isStarted(){return map->core->isStarted();}
|
||||
|
||||
@ -304,6 +304,8 @@ namespace mapcontrol
|
||||
|
||||
void SetShowCompass(bool const& value);
|
||||
|
||||
QImage X(){map->ConstructLastImage(); return map->lastimage;}
|
||||
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
|
Loading…
Reference in New Issue
Block a user