Skip to content
Permalink
Browse files
Fix problem with analyzer test
  • Loading branch information
timlinux committed Nov 14, 2011
1 parent 2b8487b commit d13fb2586b843211830b15b78719f94b652d400a
@@ -149,12 +149,14 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
{
if ( !layer )
{
QgsDebugMsg( "No layer passed to centroids" );
return false;
}

QgsVectorDataProvider* dp = layer->dataProvider();
if ( !dp )
{
QgsDebugMsg( "No data provider for layer passed to centroids" );
return false;
}

@@ -34,7 +34,10 @@ class CORE_EXPORT QgsApplication: public QApplication
virtual ~QgsApplication();

/** This method initialises paths etc for QGIS. Called by the ctor or call it manually
when your app does not extend the QApplication class. */
when your app does not extend the QApplication class.
@note you will probably want to call initQgis too to load the providers in
the above case.
*/
static void init( QString customConfigPath = QString() );

//! Watch for QFileOpenEvent.
@@ -51,28 +51,30 @@ void TestQgsVectorAnalyzer::initTestCase()
//
// init QGIS's paths - true means that all path will be inited from prefix
QString qgisPath = QCoreApplication::applicationDirPath ();
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
QgsApplication::init( INSTALL_PREFIX );
QgsApplication::initQgis( );
QgsApplication::showSettings();
// Instantiate the plugin directory so that providers are loaded
QgsProviderRegistry::instance(QgsApplication::pluginPath());

//create some objects that will be used in all tests...
//create a map layer that will be used in all tests...
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
QString myBaseFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
QString myEndName = "lines.shp";
myFileName = myFileName + QDir::separator() + myEndName;
QString myFileName = myBaseFileName + QDir::separator() + myEndName;
qDebug() << myFileName;
QFileInfo myLineInfo ( myFileName );
mpLineLayer = new QgsVectorLayer ( myLineInfo.filePath(),
myLineInfo.completeBaseName(), "ogr" );

myEndName = "polys.shp";
myFileName = myFileName + QDir::separator() + myEndName;
myFileName = myBaseFileName + QDir::separator() + myEndName;
QFileInfo myPolyInfo ( myFileName );
mpPolyLayer = new QgsVectorLayer ( myPolyInfo.filePath(),
myPolyInfo.completeBaseName(), "ogr" );

myEndName = "points.shp";
myFileName = myFileName + QDir::separator() + myEndName;
myFileName = myBaseFileName + QDir::separator() + myEndName;
QFileInfo myPointInfo ( myFileName );
mpPointLayer = new QgsVectorLayer ( myPointInfo.filePath(),
myPointInfo.completeBaseName(), "ogr" );

0 comments on commit d13fb25

Please sign in to comment.