Commit dd5229fa authored by Pierre TILAK's avatar Pierre TILAK

Remove Airmap from MapReplyQGC

parent 9f48f6a4
......@@ -146,7 +146,7 @@ QString UrlFactory::getTypeFromId(int id) {
while (i.hasNext()) {
i.next();
if (abs(qHash(i.key())) == id) {
if ((int)(qHash(i.key())>>1) == id) {
return i.key();
}
}
......@@ -155,9 +155,9 @@ QString UrlFactory::getTypeFromId(int id) {
}
// Todo : qHash produce a uint bigger than max(int)
// There is still a low probability for abs to
// There is still a low probability for this to
// generate similar hash for different types
int UrlFactory::getIdFromType(QString type) { return abs(qHash(type)); }
int UrlFactory::getIdFromType(QString type) { return (int)(qHash(type)>>1); }
//-----------------------------------------------------------------------------
int
......@@ -178,19 +178,9 @@ UrlFactory::lat2tileY(QString mapType, double lat, int z)
QGCTileSet
UrlFactory::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, QString mapType)
{
//QGCTileSet set;
//if(mapType != "Airmap Elevation"){
// set.tileX0 = long2tileX(mapType, topleftLon, zoom);
// set.tileY0 = lat2tileY(mapType, topleftLat, zoom);
// set.tileX1 = long2tileX(mapType, bottomRightLon, zoom);
// set.tileY1 = lat2tileY(mapType, bottomRightLat, zoom);
//}else{
// set.tileX0 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, topleftLon, zoom);
// set.tileY0 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, bottomRightLat, zoom);
// set.tileX1 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, bottomRightLon, zoom);
// set.tileY1 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, topleftLat, zoom);
//}
//set.tileCount = (static_cast<quint64>(set.tileX1) - static_cast<quint64>(set.tileX0) + 1) * (static_cast<quint64>(set.tileY1) - static_cast<quint64>(set.tileY0) + 1);
//set.tileSize = getQGCMapEngine()->urlFactory()->averageSizeForType(mapType) * set.tileCount;
return _providersTable[mapType]->getTileCount(zoom, topleftLon, topleftLat, bottomRightLon, bottomRightLat);
}
bool UrlFactory::isElevation(int mapId){
return _providersTable[getTypeFromId(mapId)]->_isElevationProvider();
}
......@@ -53,6 +53,8 @@ public:
double bottomRightLon, double bottomRightLat,
QString mapType);
bool isElevation(int mapId);
private:
int _timeout;
QHash<QString, MapProvider*> _providersTable;
......
......@@ -124,12 +124,14 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
QByteArray a = _reply->readAll();
QString format = getQGCMapEngine()->urlFactory()->getImageFormat(tileSpec().mapId(), a);
//-- Test for a specialized, elevation data (not map tile)
int AirmapElevationId = getQGCMapEngine()->urlFactory()->getIdFromType("Airmap Elevation");
if (tileSpec().mapId() == AirmapElevationId) {
if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){
a = TerrainTile::serialize(a);
//-- Cache it if valid
if(!a.isEmpty()) {
getQGCMapEngine()->cacheTile("Airmap Elevation", tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
getQGCMapEngine()->cacheTile(
getQGCMapEngine()->urlFactory()->getTypeFromId(
tileSpec().mapId()),
tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
}
emit terrainDone(a, QNetworkReply::NoError);
} else {
......@@ -153,8 +155,7 @@ QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
return;
}
//-- Test for a specialized, elevation data (not map tile)
int AirmapElevationId = getQGCMapEngine()->urlFactory()->getIdFromType("Airmap Elevation");
if (tileSpec().mapId() == AirmapElevationId) {
if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){
emit terrainDone(QByteArray(), error);
} else {
//-- Regular map tile
......@@ -172,8 +173,7 @@ void
QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/)
{
if(!getQGCMapEngine()->isInternetActive()) {
int AirmapElevationId = getQGCMapEngine()->urlFactory()->getIdFromType("Airmap Elevation");
if (tileSpec().mapId() == AirmapElevationId) {
if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){
emit terrainDone(QByteArray(), QNetworkReply::NetworkSessionFailedError);
} else {
setError(QGeoTiledMapReply::CommunicationError, "Network not available");
......@@ -210,8 +210,7 @@ void
QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile)
{
//-- Test for a specialized, elevation data (not map tile)
int AirmapElevationId = getQGCMapEngine()->urlFactory()->getIdFromType("Airmap Elevation");
if (tileSpec().mapId() == AirmapElevationId) {
if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){
emit terrainDone(tile->img(), QNetworkReply::NoError);
} else {
//-- Regular map tile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment