[Marble-commits] KDE/kdeedu/marble/src/plugins/runner/monav
Dennis Nienhüser
earthwings at gentoo.org
Sun Oct 10 13:57:24 CEST 2010
SVN commit 1184464 by nienhueser:
Change sort order of maps from hasBBox/name to hasBBox/area. This has the advantage that smaller maps are automatically preferred, which is useful for overlapping maps (e.g. baden-wurttemberg vs germany vs europe) to prefer the smaller map and only fall back to the larger (slower) one if really needed.
M +6 -4 MonavPlugin.cpp
--- trunk/KDE/kdeedu/marble/src/plugins/runner/monav/MonavPlugin.cpp #1184463:1184464
@@ -66,7 +66,7 @@
void loadMaps();
- static bool bordersFirst( const MonavMap &first, const MonavMap &second );
+ static bool areaLessThan( const MonavMap &first, const MonavMap &second );
private:
void loadMap( const QString &path );
@@ -200,7 +200,7 @@
loadMap( iter.filePath() );
}
// Prefer maps where bounding boxes are known
- qSort( m_maps.begin(), m_maps.end(), MonavPluginPrivate::bordersFirst );
+ qSort( m_maps.begin(), m_maps.end(), MonavPluginPrivate::areaLessThan );
}
void MonavPluginPrivate::loadMap( const QString &path )
@@ -214,7 +214,7 @@
}
}
-bool MonavPluginPrivate::bordersFirst( const MonavMap &first, const MonavMap &second )
+bool MonavPluginPrivate::areaLessThan( const MonavMap &first, const MonavMap &second )
{
if ( !first.m_tiles.isEmpty() && second.m_tiles.isEmpty() ) {
return true;
@@ -224,7 +224,9 @@
return false;
}
- return first.m_directory.absolutePath() < second.m_directory.absolutePath();
+ qreal const areaOne = first.m_boundingBox.width() * first.m_boundingBox.height();
+ qreal const areaTwo = second.m_boundingBox.width() * second.m_boundingBox.height();
+ return areaOne < areaTwo;
}
MonavPlugin::MonavPlugin( QObject *parent ) : RunnerPlugin( parent ), d( new MonavPluginPrivate )
More information about the Marble-commits
mailing list