mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
move grassprovider to grass library (might fix #3999)
This commit is contained in:
parent
9e15906f06
commit
9e57e20f61
@ -399,6 +399,12 @@ IF (WIN32)
|
|||||||
SET(DLLIMPORT "__declspec(dllimport)")
|
SET(DLLIMPORT "__declspec(dllimport)")
|
||||||
SET(DLLEXPORT "__declspec(dllexport)")
|
SET(DLLEXPORT "__declspec(dllexport)")
|
||||||
ELSE (WIN32)
|
ELSE (WIN32)
|
||||||
|
IF(PEDANTIC)
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
|
||||||
|
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
|
||||||
|
ENDIF(PEDANTIC)
|
||||||
|
|
||||||
SET(DLLIMPORT "")
|
SET(DLLIMPORT "")
|
||||||
SET(DLLEXPORT "")
|
SET(DLLEXPORT "")
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
@ -45,7 +45,7 @@ FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
|
|||||||
)
|
)
|
||||||
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h)
|
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h)
|
||||||
|
|
||||||
FIND_LIBRARY(PROJ_LIBRARY NAMES proj PATHS
|
FIND_LIBRARY(PROJ_LIBRARY NAMES proj proj_i PATHS
|
||||||
"$ENV{LIB_DIR}/lib"
|
"$ENV{LIB_DIR}/lib"
|
||||||
#mingw
|
#mingw
|
||||||
c:/msys/local/lib
|
c:/msys/local/lib
|
||||||
|
@ -143,17 +143,6 @@ TARGET_LINK_LIBRARIES(grassplugin
|
|||||||
${OPENPTY_LIBRARY}
|
${OPENPTY_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
# provider must be built as module on OS X so it gets loaded,
|
|
||||||
# lookup symbols dynamically instead of linking at compile time
|
|
||||||
IF (APPLE)
|
|
||||||
SET_TARGET_PROPERTIES(grassplugin PROPERTIES
|
|
||||||
LINK_FLAGS "-undefined dynamic_lookup")
|
|
||||||
ELSE (APPLE)
|
|
||||||
TARGET_LINK_LIBRARIES(grassplugin
|
|
||||||
grassprovider
|
|
||||||
)
|
|
||||||
ENDIF (APPLE)
|
|
||||||
|
|
||||||
# override default path where built files are put to allow running qgis without installing
|
# override default path where built files are put to allow running qgis without installing
|
||||||
# the binary goes under libexec subdir
|
# the binary goes under libexec subdir
|
||||||
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIBEXEC_SUBDIR}/grass/bin)
|
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIBEXEC_SUBDIR}/grass/bin)
|
||||||
|
@ -16,7 +16,8 @@ INCLUDE_DIRECTORIES(
|
|||||||
# GRASS library
|
# GRASS library
|
||||||
#
|
#
|
||||||
|
|
||||||
ADD_LIBRARY(qgisgrass SHARED qgsgrass.cpp)
|
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS qgsgrassprovider.h)
|
||||||
|
ADD_LIBRARY(qgisgrass SHARED qgsgrass.cpp qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES
|
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES
|
||||||
CLEAN_DIRECT_OUTPUT 1
|
CLEAN_DIRECT_OUTPUT 1
|
||||||
@ -52,14 +53,7 @@ ENDIF (APPLE)
|
|||||||
# GRASS vector provider
|
# GRASS vector provider
|
||||||
#
|
#
|
||||||
|
|
||||||
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS qgsgrassprovider.h)
|
ADD_LIBRARY(grassprovider MODULE qgsgrassprovidermodule.cpp)
|
||||||
# provider must be built as module on OS X so it gets loaded,
|
|
||||||
# other modules that need provider symbols must dynamically lookup them
|
|
||||||
IF (APPLE)
|
|
||||||
ADD_LIBRARY(grassprovider MODULE qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
|
|
||||||
ELSE (APPLE)
|
|
||||||
ADD_LIBRARY(grassprovider SHARED qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
|
|
||||||
ENDIF (APPLE)
|
|
||||||
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\"" )
|
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\"" )
|
||||||
TARGET_LINK_LIBRARIES(grassprovider qgisgrass)
|
TARGET_LINK_LIBRARIES(grassprovider qgisgrass)
|
||||||
|
|
||||||
|
@ -30,10 +30,6 @@
|
|||||||
#include "qgsgrass.h"
|
#include "qgsgrass.h"
|
||||||
#include "qgsgrassprovider.h"
|
#include "qgsgrassprovider.h"
|
||||||
|
|
||||||
|
|
||||||
#include "qgsgrassprovider.h"
|
|
||||||
#include "qgsgrass.h"
|
|
||||||
|
|
||||||
#include "qgsapplication.h"
|
#include "qgsapplication.h"
|
||||||
#include "qgscoordinatereferencesystem.h"
|
#include "qgscoordinatereferencesystem.h"
|
||||||
#include "qgsfield.h"
|
#include "qgsfield.h"
|
||||||
@ -45,9 +41,6 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
//#include <QtGui/qwindowdefs.h>
|
|
||||||
//#include <QtGui/qmacincludes_mac.h>
|
|
||||||
//#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// enable grass prototypes
|
// enable grass prototypes
|
||||||
@ -2421,179 +2414,13 @@ int QgsGrassProvider::cidxGetMaxCat( int idx )
|
|||||||
return ( cat );
|
return ( cat );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString QgsGrassProvider::name() const
|
QString QgsGrassProvider::name() const
|
||||||
{
|
{
|
||||||
return GRASS_KEY;
|
return GRASS_KEY;
|
||||||
} // QgsGrassProvider::name()
|
} // QgsGrassProvider::name()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString QgsGrassProvider::description() const
|
QString QgsGrassProvider::description() const
|
||||||
{
|
{
|
||||||
return GRASS_DESCRIPTION;
|
return GRASS_DESCRIPTION;
|
||||||
} // QgsGrassProvider::description()
|
} // QgsGrassProvider::description()
|
||||||
|
|
||||||
|
|
||||||
QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString path )
|
|
||||||
: QgsDataCollectionItem( parent, "", path )
|
|
||||||
{
|
|
||||||
QFileInfo fi( path );
|
|
||||||
mName = fi.baseName();
|
|
||||||
mIcon = QIcon( getThemePixmap( "grass_location.png" ) );
|
|
||||||
}
|
|
||||||
QgsGrassLocationItem::~QgsGrassLocationItem() {}
|
|
||||||
|
|
||||||
bool QgsGrassLocationItem::isLocation( QString path )
|
|
||||||
{
|
|
||||||
//QgsDebugMsg( "path = " + path );
|
|
||||||
return QFile::exists( path + QDir::separator() + "PERMANENT" + QDir::separator() + "DEFAULT_WIND" );
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
|
|
||||||
{
|
|
||||||
QVector<QgsDataItem*> mapsets;
|
|
||||||
|
|
||||||
QDir dir( mPath );
|
|
||||||
|
|
||||||
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
|
|
||||||
foreach( QString name, entries )
|
|
||||||
{
|
|
||||||
QString path = dir.absoluteFilePath( name );
|
|
||||||
|
|
||||||
if ( QgsGrassMapsetItem::isMapset( path ) )
|
|
||||||
{
|
|
||||||
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path );
|
|
||||||
mapsets.append( mapset );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mapsets;
|
|
||||||
}
|
|
||||||
|
|
||||||
QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString path )
|
|
||||||
: QgsDataCollectionItem( parent, "", path )
|
|
||||||
{
|
|
||||||
QDir dir( path );
|
|
||||||
mName = dir.dirName();
|
|
||||||
dir.cdUp();
|
|
||||||
mLocation = dir.dirName();
|
|
||||||
dir.cdUp();
|
|
||||||
mGisdbase = dir.path();
|
|
||||||
|
|
||||||
mIcon = QIcon( getThemePixmap( "grass_mapset.png" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
QgsGrassMapsetItem::~QgsGrassMapsetItem() {}
|
|
||||||
|
|
||||||
bool QgsGrassMapsetItem::isMapset( QString path )
|
|
||||||
{
|
|
||||||
return QFile::exists( path + QDir::separator() + "WIND" );
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
|
|
||||||
{
|
|
||||||
QVector<QgsDataItem*> items;
|
|
||||||
|
|
||||||
QStringList vectorNames = QgsGrass::vectors( mPath );
|
|
||||||
|
|
||||||
foreach( QString name, vectorNames )
|
|
||||||
{
|
|
||||||
QStringList layerNames = QgsGrass::vectorLayers( mGisdbase , mLocation, mName, name );
|
|
||||||
|
|
||||||
QString path = mPath + QDir::separator() + "vector" + QDir::separator() + name;
|
|
||||||
|
|
||||||
QgsDataCollectionItem *map = 0;
|
|
||||||
if ( layerNames.size() != 1 )
|
|
||||||
map = new QgsDataCollectionItem( this, name );
|
|
||||||
foreach( QString layerName, layerNames )
|
|
||||||
{
|
|
||||||
QString uri = mPath + QDir::separator() + name + QDir::separator() + layerName;
|
|
||||||
QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
|
|
||||||
QString typeName = layerName.split( "_" )[1];
|
|
||||||
QString baseLayerName = layerName.split( "_" )[0];
|
|
||||||
|
|
||||||
if ( typeName == "point" )
|
|
||||||
layerType = QgsLayerItem::Point;
|
|
||||||
else if ( typeName == "line" )
|
|
||||||
layerType = QgsLayerItem::Line;
|
|
||||||
else if ( typeName == "polygon" )
|
|
||||||
layerType = QgsLayerItem::Polygon;
|
|
||||||
|
|
||||||
if ( layerNames.size() == 1 )
|
|
||||||
{
|
|
||||||
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, path, uri, layerType, "grass" );
|
|
||||||
items.append( layer );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QgsLayerItem *layer = new QgsLayerItem( map, baseLayerName, path, uri, layerType, "grass" );
|
|
||||||
map->addChild( layer );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( layerNames.size() != 1 )
|
|
||||||
items.append( map );
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList rasterNames = QgsGrass::rasters( mPath );
|
|
||||||
|
|
||||||
foreach( QString name, rasterNames )
|
|
||||||
{
|
|
||||||
QString uri = mPath + QDir::separator() + "cellhd" + QDir::separator() + name;
|
|
||||||
QgsDebugMsg( "uri = " + uri );
|
|
||||||
|
|
||||||
QgsLayerItem *layer = new QgsLayerItem( this, name, uri, uri, QgsLayerItem::Raster, "grassraster" );
|
|
||||||
|
|
||||||
items.append( layer );
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
QGISEXTERN int dataCapabilities()
|
|
||||||
{
|
|
||||||
return QgsDataProvider::Dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
|
|
||||||
{
|
|
||||||
if ( QgsGrassLocationItem::isLocation( thePath ) )
|
|
||||||
{
|
|
||||||
QgsGrassLocationItem * location = new QgsGrassLocationItem( parentItem, thePath );
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class factory to return a pointer to a newly created
|
|
||||||
* QgsGrassProvider object
|
|
||||||
*/
|
|
||||||
QGISEXTERN QgsGrassProvider * classFactory( const QString *uri )
|
|
||||||
{
|
|
||||||
return new QgsGrassProvider( *uri );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Required key function (used to map the plugin to a data store type)
|
|
||||||
*/
|
|
||||||
QGISEXTERN QString providerKey()
|
|
||||||
{
|
|
||||||
return QString( "grass" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required description function
|
|
||||||
*/
|
|
||||||
QGISEXTERN QString description()
|
|
||||||
{
|
|
||||||
return QString( "GRASS data provider" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required isProvider function. Used to determine if this shared library
|
|
||||||
* is a data provider plugin
|
|
||||||
*/
|
|
||||||
QGISEXTERN bool isProvider()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -20,7 +20,6 @@ class QgsFeature;
|
|||||||
class QgsField;
|
class QgsField;
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "qgsdataitem.h"
|
|
||||||
#include "qgsvectordataprovider.h"
|
#include "qgsvectordataprovider.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -110,7 +109,7 @@ struct GMAP
|
|||||||
\class QgsGrassProvider
|
\class QgsGrassProvider
|
||||||
\brief Data provider for GRASS vectors
|
\brief Data provider for GRASS vectors
|
||||||
*/
|
*/
|
||||||
class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
|
class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -687,30 +686,4 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
|
|||||||
static std::vector<GMAP> mMaps; // Map
|
static std::vector<GMAP> mMaps; // Map
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class QgsGrassLocationItem : public QgsDataCollectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QgsGrassLocationItem( QgsDataItem* parent, QString path );
|
|
||||||
~QgsGrassLocationItem();
|
|
||||||
|
|
||||||
static bool isLocation( QString path );
|
|
||||||
QVector<QgsDataItem*> createChildren();
|
|
||||||
};
|
|
||||||
|
|
||||||
class QgsGrassMapsetItem : public QgsDataCollectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QgsGrassMapsetItem( QgsDataItem* parent, QString path );
|
|
||||||
~QgsGrassMapsetItem();
|
|
||||||
|
|
||||||
static bool isMapset( QString path );
|
|
||||||
QVector<QgsDataItem*> createChildren();
|
|
||||||
|
|
||||||
QString mLocation;
|
|
||||||
QString mGisdbase;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // QGSGRASSPROVIDER_H
|
#endif // QGSGRASSPROVIDER_H
|
||||||
|
185
src/providers/grass/qgsgrassprovidermodule.cpp
Normal file
185
src/providers/grass/qgsgrassprovidermodule.cpp
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qgsgrassprovidermodule.cpp - Data provider for GRASS format
|
||||||
|
-------------------
|
||||||
|
begin : March, 2004
|
||||||
|
copyright : (C) 2004 by Gary E.Sherman, Radim Blazek
|
||||||
|
email : sherman@mrcc.com, blazek@itc.it
|
||||||
|
***************************************************************************/
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgsgrassprovidermodule.h"
|
||||||
|
#include "qgsgrassprovider.h"
|
||||||
|
#include "qgsgrass.h"
|
||||||
|
#include "qgslogger.h"
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString path )
|
||||||
|
: QgsDataCollectionItem( parent, "", path )
|
||||||
|
{
|
||||||
|
QFileInfo fi( path );
|
||||||
|
mName = fi.baseName();
|
||||||
|
mIcon = QIcon( getThemePixmap( "grass_location.png" ) );
|
||||||
|
}
|
||||||
|
QgsGrassLocationItem::~QgsGrassLocationItem() {}
|
||||||
|
|
||||||
|
bool QgsGrassLocationItem::isLocation( QString path )
|
||||||
|
{
|
||||||
|
//QgsDebugMsg( "path = " + path );
|
||||||
|
return QFile::exists( path + QDir::separator() + "PERMANENT" + QDir::separator() + "DEFAULT_WIND" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
|
||||||
|
{
|
||||||
|
QVector<QgsDataItem*> mapsets;
|
||||||
|
|
||||||
|
QDir dir( mPath );
|
||||||
|
|
||||||
|
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
|
||||||
|
foreach( QString name, entries )
|
||||||
|
{
|
||||||
|
QString path = dir.absoluteFilePath( name );
|
||||||
|
|
||||||
|
if ( QgsGrassMapsetItem::isMapset( path ) )
|
||||||
|
{
|
||||||
|
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path );
|
||||||
|
mapsets.append( mapset );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mapsets;
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString path )
|
||||||
|
: QgsDataCollectionItem( parent, "", path )
|
||||||
|
{
|
||||||
|
QDir dir( path );
|
||||||
|
mName = dir.dirName();
|
||||||
|
dir.cdUp();
|
||||||
|
mLocation = dir.dirName();
|
||||||
|
dir.cdUp();
|
||||||
|
mGisdbase = dir.path();
|
||||||
|
|
||||||
|
mIcon = QIcon( getThemePixmap( "grass_mapset.png" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsGrassMapsetItem::~QgsGrassMapsetItem() {}
|
||||||
|
|
||||||
|
bool QgsGrassMapsetItem::isMapset( QString path )
|
||||||
|
{
|
||||||
|
return QFile::exists( path + QDir::separator() + "WIND" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
|
||||||
|
{
|
||||||
|
QVector<QgsDataItem*> items;
|
||||||
|
|
||||||
|
QStringList vectorNames = QgsGrass::vectors( mPath );
|
||||||
|
|
||||||
|
foreach( QString name, vectorNames )
|
||||||
|
{
|
||||||
|
QStringList layerNames = QgsGrass::vectorLayers( mGisdbase , mLocation, mName, name );
|
||||||
|
|
||||||
|
QString path = mPath + QDir::separator() + "vector" + QDir::separator() + name;
|
||||||
|
|
||||||
|
QgsDataCollectionItem *map = 0;
|
||||||
|
if ( layerNames.size() != 1 )
|
||||||
|
map = new QgsDataCollectionItem( this, name );
|
||||||
|
foreach( QString layerName, layerNames )
|
||||||
|
{
|
||||||
|
QString uri = mPath + QDir::separator() + name + QDir::separator() + layerName;
|
||||||
|
QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
|
||||||
|
QString typeName = layerName.split( "_" )[1];
|
||||||
|
QString baseLayerName = layerName.split( "_" )[0];
|
||||||
|
|
||||||
|
if ( typeName == "point" )
|
||||||
|
layerType = QgsLayerItem::Point;
|
||||||
|
else if ( typeName == "line" )
|
||||||
|
layerType = QgsLayerItem::Line;
|
||||||
|
else if ( typeName == "polygon" )
|
||||||
|
layerType = QgsLayerItem::Polygon;
|
||||||
|
|
||||||
|
if ( layerNames.size() == 1 )
|
||||||
|
{
|
||||||
|
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, path, uri, layerType, "grass" );
|
||||||
|
items.append( layer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QgsLayerItem *layer = new QgsLayerItem( map, baseLayerName, path, uri, layerType, "grass" );
|
||||||
|
map->addChild( layer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( layerNames.size() != 1 )
|
||||||
|
items.append( map );
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList rasterNames = QgsGrass::rasters( mPath );
|
||||||
|
|
||||||
|
foreach( QString name, rasterNames )
|
||||||
|
{
|
||||||
|
QString uri = mPath + QDir::separator() + "cellhd" + QDir::separator() + name;
|
||||||
|
QgsDebugMsg( "uri = " + uri );
|
||||||
|
|
||||||
|
QgsLayerItem *layer = new QgsLayerItem( this, name, uri, uri, QgsLayerItem::Raster, "grassraster" );
|
||||||
|
|
||||||
|
items.append( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGISEXTERN int dataCapabilities()
|
||||||
|
{
|
||||||
|
return QgsDataProvider::Dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
|
||||||
|
{
|
||||||
|
if ( QgsGrassLocationItem::isLocation( thePath ) )
|
||||||
|
{
|
||||||
|
QgsGrassLocationItem * location = new QgsGrassLocationItem( parentItem, thePath );
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class factory to return a pointer to a newly created
|
||||||
|
* QgsGrassProvider object
|
||||||
|
*/
|
||||||
|
QGISEXTERN QgsGrassProvider * classFactory( const QString *uri )
|
||||||
|
{
|
||||||
|
return new QgsGrassProvider( *uri );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Required key function (used to map the plugin to a data store type)
|
||||||
|
*/
|
||||||
|
QGISEXTERN QString providerKey()
|
||||||
|
{
|
||||||
|
return QString( "grass" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required description function
|
||||||
|
*/
|
||||||
|
QGISEXTERN QString description()
|
||||||
|
{
|
||||||
|
return QString( "GRASS data provider" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required isProvider function. Used to determine if this shared library
|
||||||
|
* is a data provider plugin
|
||||||
|
*/
|
||||||
|
QGISEXTERN bool isProvider()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
44
src/providers/grass/qgsgrassprovidermodule.h
Normal file
44
src/providers/grass/qgsgrassprovidermodule.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qgsgrassprovidermodule.h - Data provider for GRASS format
|
||||||
|
-------------------
|
||||||
|
begin : March, 2004
|
||||||
|
copyright : (C) 2004 by Gary E.Sherman, Radim Blazek
|
||||||
|
email : sherman@mrcc.com, blazek@itc.it
|
||||||
|
***************************************************************************/
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
#ifndef QGSGRASSPROVIDERMODULE_H
|
||||||
|
#define QGSGRASSPROVIDERMODULE_H
|
||||||
|
|
||||||
|
#include "qgsdataitem.h"
|
||||||
|
|
||||||
|
class QgsGrassLocationItem : public QgsDataCollectionItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QgsGrassLocationItem( QgsDataItem* parent, QString path );
|
||||||
|
~QgsGrassLocationItem();
|
||||||
|
|
||||||
|
static bool isLocation( QString path );
|
||||||
|
QVector<QgsDataItem*> createChildren();
|
||||||
|
};
|
||||||
|
|
||||||
|
class QgsGrassMapsetItem : public QgsDataCollectionItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QgsGrassMapsetItem( QgsDataItem* parent, QString path );
|
||||||
|
~QgsGrassMapsetItem();
|
||||||
|
|
||||||
|
static bool isMapset( QString path );
|
||||||
|
QVector<QgsDataItem*> createChildren();
|
||||||
|
|
||||||
|
QString mLocation;
|
||||||
|
QString mGisdbase;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QGSGRASSPROVIDERMODULE_H
|
@ -47,6 +47,10 @@ TARGET_LINK_LIBRARIES(qgissqlanyconnection
|
|||||||
qgis_core
|
qgis_core
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(UNIX AND NOT ANDROID)
|
||||||
|
TARGET_LINK_LIBRARIES(qgissqlanyconnection ${CMAKE_DL_LIBS})
|
||||||
|
ENDIF(UNIX AND NOT ANDROID)
|
||||||
|
|
||||||
IF (APPLE)
|
IF (APPLE)
|
||||||
SET_TARGET_PROPERTIES(qgissqlanyconnection PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE )
|
SET_TARGET_PROPERTIES(qgissqlanyconnection PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE )
|
||||||
ENDIF (APPLE)
|
ENDIF (APPLE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user