1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-37 GCS/MapPlugin cleaning and bug hunting

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@705 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-06-02 20:26:48 +00:00 committed by zedamota
parent f31cd81a8d
commit 570bbb4353
11 changed files with 242 additions and 220 deletions

View File

@ -28,6 +28,7 @@
#ifndef ACCESSMODE_H
#define ACCESSMODE_H
#include "debugheader.h"
namespace core {
struct AccessMode

View File

@ -29,7 +29,7 @@
#define CACHE_H
#include "pureimagecache.h"
#include "debugheader.h"
namespace core {
class Cache

View File

@ -33,4 +33,5 @@ HEADERS += opmaps.h \
geodecoderstatus.h \
placemark.h \
point.h \
kibertilecache.h
kibertilecache.h \
debugheader.h

View File

@ -0,0 +1,13 @@
#ifndef DEBUGHEADER_H
#define DEBUGHEADER_H
//#define DEBUG_MEMORY_CACHE
//#define DEBUG_CACHE
//#define DEBUG_GMAPS
//#define DEBUG_PUREIMAGECACHE
//#define DEBUG_TILECACHEQUEUE
//#define DEBUG_URLFACTORY
//#define DEBUG_MEMORY_CACHE
//#define DEBUG_GetGeocoderFromCache
#endif // DEBUGHEADER_H

View File

@ -51,14 +51,20 @@ int KiberTileCache::MemoryCacheCapacity()
void KiberTileCache::RemoveMemoryOverload()
{
while(memoryCacheSize>MemoryCacheCapacity())
while(MemoryCacheSize()>MemoryCacheCapacity())
{
if(cachequeue.count()>0 && list.count()>0)
{
#ifdef DEBUG_MEMORY_CACHE
qDebug()<<"Cleaning Memory cache="<<" started with "<<cachequeue.count()<<" tile "<<"ocupying "<<memoryCacheSize<<" bytes";
#endif
RawTile first=list.dequeue();
memoryCacheSize-=cachequeue.value(first).length();
memoryCacheSize-=cachequeue.value(first).size();
cachequeue.remove(first);
}
}
#ifdef DEBUG_MEMORY_CACHE
qDebug()<<"Cleaning Memory cache="<<" ended with "<<cachequeue.count()<<" tile "<<"ocupying "<<memoryCacheSize<<" bytes";
#endif
}
}

View File

@ -28,13 +28,12 @@
#ifndef KIBERTILECACHE_H
#define KIBERTILECACHE_H
#include <QPixmapCache>
#include "rawtile.h"
#include <QMutex>
#include <QReadWriteLock>
#include <QQueue>
#include <QDebug>
#include "debugheader.h"
namespace core {
class KiberTileCache
{
@ -52,9 +51,6 @@ public:
private:
int _MemoryCacheCapacity;
// QPixmapCache TilesInMemory;
};

View File

@ -48,7 +48,10 @@ void MemoryCache::AddTileToMemoryCache(const RawTile &tile, const QByteArray &pi
{
kiberCacheLock.lockForWrite();
// QPixmapCache::Key key=TilesInMemory.insert(pic);
TilesInMemory.memoryCacheSize +=pic.count();
TilesInMemory.memoryCacheSize +=pic.size();
#ifdef DEBUG_MEMORY_CACHE
qDebug()<<"Current memory="<<TilesInMemory.memoryCacheSize<<" in "<<TilesInMemory.cachequeue.count()<<" tiles";
#endif
TilesInMemory.cachequeue.insert(tile,pic);
TilesInMemory.list.enqueue(tile);

View File

@ -28,13 +28,13 @@
#ifndef MEMORYCACHE_H
#define MEMORYCACHE_H
#include <QPixmapCache>
#include "rawtile.h"
#include <QMutex>
#include <QReadWriteLock>
#include <QQueue>
#include "kibertilecache.h"
#include <QDebug>
#include "debugheader.h"
namespace core {
class MemoryCache
{
@ -45,7 +45,6 @@ public:
QByteArray GetTileFromMemoryCache(const RawTile &tile);
void AddTileToMemoryCache(const RawTile &tile, const QByteArray &pic);
QReadWriteLock kiberCacheLock;
};

View File

@ -56,6 +56,10 @@ OPMaps::~OPMaps()
QByteArray OPMaps::GetImageFrom(const MapType::Types &type,const Point &pos,const int &zoom)
{
#ifdef DEBUG_TIMINGS
QTime time;
time.restart();
#endif
#ifdef DEBUG_GMAPS
qDebug()<<"Entered GetImageFrom";
#endif //DEBUG_GMAPS
@ -104,7 +108,13 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type,const Point &pos,cons
#ifdef DEBUG_GMAPS
qDebug()<<"Try Tile from the Internet";
#endif //DEBUG_GMAPS
#ifdef DEBUG_TIMINGS
qDebug()<<"opmaps before make image url"<<time.elapsed();
#endif
QString url=MakeImageUrl(type,pos,zoom,LanguageStr);
#ifdef DEBUG_TIMINGS
qDebug()<<"opmaps after make image url"<<time.elapsed();
#endif
qheader.setUrl(QUrl(url));
qheader.setRawHeader("User-Agent",UserAgent);
qheader.setRawHeader("Accept","*/*");
@ -185,6 +195,9 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type,const Point &pos,cons
QTime time;
time.start();
while( !(reply->isFinished() | time.elapsed()>(6*Timeout)) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
#ifdef DEBUG_TIMINGS
qDebug()<<"Network time:"<<time.elapsed();
#endif
#ifdef DEBUG_GMAPS
qDebug()<<"Finished?"<<reply->error()<<" abort?"<<(time.elapsed()>Timeout*6);
#endif //DEBUG_GMAPS

View File

@ -28,12 +28,8 @@
#ifndef OPMaps_H
#define OPMaps_H
//#define DEBUG_CACHE
//#define DEBUG_GMAPS
//#define DEBUG_PUREIMAGECACHE
//#define DEBUG_TILECACHEQUEUE
//#define DEBUG_URLFACTORY
#include "debugheader.h"
#include "memorycache.h"
#include "rawtile.h"
#include "cache.h"
@ -66,22 +62,17 @@ public:
QByteArray GetImageFrom(const MapType::Types &type,const Point &pos,const int &zoom);
bool UseMemoryCache();//TODO
void setUseMemoryCache(const bool& value);//TODO
void setUseMemoryCache(const bool& value){useMemoryCache=value;}
void setLanguage(const LanguageType::Types& language);//TODO
LanguageType::Types GetLanguage();//TODO
AccessMode GetAccessMode();
void setAccessMode(const AccessMode& mode);
AccessMode::Types GetAccessMode()const{return accessmode;};
void setAccessMode(const AccessMode::Types& mode){accessmode=mode;};
int MaxZoom;
int RetryLoadTile;
private:
bool useMemoryCache;
LanguageType::Types Language;
AccessMode::Types accessmode;
// PureImageCache ImageCacheLocal;//TODO Criar acesso Get Set
TileCacheQueue TileDBcacheQueue;
OPMaps();

View File

@ -30,7 +30,6 @@
#include <QString>
//#include "size.h"
namespace core {
struct Size;