Skip to content

Commit 9e57e20

Browse files
committedApr 2, 2012
move grassprovider to grass library (might fix #3999)
1 parent 9e15906 commit 9e57e20

File tree

9 files changed

+244
-222
lines changed

9 files changed

+244
-222
lines changed
 

‎CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ IF (WIN32)
399399
SET(DLLIMPORT "__declspec(dllimport)")
400400
SET(DLLEXPORT "__declspec(dllexport)")
401401
ELSE (WIN32)
402+
IF(PEDANTIC)
403+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
404+
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
405+
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
406+
ENDIF(PEDANTIC)
407+
402408
SET(DLLIMPORT "")
403409
SET(DLLEXPORT "")
404410
ENDIF(WIN32)

‎cmake/FindProj.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
4545
)
4646
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h)
4747

48-
FIND_LIBRARY(PROJ_LIBRARY NAMES proj PATHS
48+
FIND_LIBRARY(PROJ_LIBRARY NAMES proj proj_i PATHS
4949
"$ENV{LIB_DIR}/lib"
5050
#mingw
5151
c:/msys/local/lib

‎src/plugins/grass/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,6 @@ TARGET_LINK_LIBRARIES(grassplugin
143143
${OPENPTY_LIBRARY}
144144
)
145145

146-
# provider must be built as module on OS X so it gets loaded,
147-
# lookup symbols dynamically instead of linking at compile time
148-
IF (APPLE)
149-
SET_TARGET_PROPERTIES(grassplugin PROPERTIES
150-
LINK_FLAGS "-undefined dynamic_lookup")
151-
ELSE (APPLE)
152-
TARGET_LINK_LIBRARIES(grassplugin
153-
grassprovider
154-
)
155-
ENDIF (APPLE)
156-
157146
# override default path where built files are put to allow running qgis without installing
158147
# the binary goes under libexec subdir
159148
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIBEXEC_SUBDIR}/grass/bin)

‎src/providers/grass/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ INCLUDE_DIRECTORIES(
1616
# GRASS library
1717
#
1818

19-
ADD_LIBRARY(qgisgrass SHARED qgsgrass.cpp)
19+
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS qgsgrassprovider.h)
20+
ADD_LIBRARY(qgisgrass SHARED qgsgrass.cpp qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
2021

2122
SET_TARGET_PROPERTIES(qgisgrass PROPERTIES
2223
CLEAN_DIRECT_OUTPUT 1
@@ -52,14 +53,7 @@ ENDIF (APPLE)
5253
# GRASS vector provider
5354
#
5455

55-
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS qgsgrassprovider.h)
56-
# provider must be built as module on OS X so it gets loaded,
57-
# other modules that need provider symbols must dynamically lookup them
58-
IF (APPLE)
59-
ADD_LIBRARY(grassprovider MODULE qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
60-
ELSE (APPLE)
61-
ADD_LIBRARY(grassprovider SHARED qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
62-
ENDIF (APPLE)
56+
ADD_LIBRARY(grassprovider MODULE qgsgrassprovidermodule.cpp)
6357
SET_TARGET_PROPERTIES(grassprovider PROPERTIES COMPILE_FLAGS "\"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\"" )
6458
TARGET_LINK_LIBRARIES(grassprovider qgisgrass)
6559

‎src/providers/grass/qgsgrassprovider.cpp

Lines changed: 0 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
#include "qgsgrass.h"
3131
#include "qgsgrassprovider.h"
3232

33-
34-
#include "qgsgrassprovider.h"
35-
#include "qgsgrass.h"
36-
3733
#include "qgsapplication.h"
3834
#include "qgscoordinatereferencesystem.h"
3935
#include "qgsfield.h"
@@ -45,9 +41,6 @@
4541
#include <QFileInfo>
4642
#include <QMessageBox>
4743
#include <QTextCodec>
48-
//#include <QtGui/qwindowdefs.h>
49-
//#include <QtGui/qmacincludes_mac.h>
50-
//#include <ApplicationServices/ApplicationServices.h>
5144

5245
#ifdef _MSC_VER
5346
// enable grass prototypes
@@ -2421,179 +2414,13 @@ int QgsGrassProvider::cidxGetMaxCat( int idx )
24212414
return ( cat );
24222415
}
24232416

2424-
2425-
24262417
QString QgsGrassProvider::name() const
24272418
{
24282419
return GRASS_KEY;
24292420
} // QgsGrassProvider::name()
24302421

2431-
2432-
24332422
QString QgsGrassProvider::description() const
24342423
{
24352424
return GRASS_DESCRIPTION;
24362425
} // QgsGrassProvider::description()
24372426

2438-
2439-
QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString path )
2440-
: QgsDataCollectionItem( parent, "", path )
2441-
{
2442-
QFileInfo fi( path );
2443-
mName = fi.baseName();
2444-
mIcon = QIcon( getThemePixmap( "grass_location.png" ) );
2445-
}
2446-
QgsGrassLocationItem::~QgsGrassLocationItem() {}
2447-
2448-
bool QgsGrassLocationItem::isLocation( QString path )
2449-
{
2450-
//QgsDebugMsg( "path = " + path );
2451-
return QFile::exists( path + QDir::separator() + "PERMANENT" + QDir::separator() + "DEFAULT_WIND" );
2452-
}
2453-
2454-
QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
2455-
{
2456-
QVector<QgsDataItem*> mapsets;
2457-
2458-
QDir dir( mPath );
2459-
2460-
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
2461-
foreach( QString name, entries )
2462-
{
2463-
QString path = dir.absoluteFilePath( name );
2464-
2465-
if ( QgsGrassMapsetItem::isMapset( path ) )
2466-
{
2467-
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path );
2468-
mapsets.append( mapset );
2469-
}
2470-
}
2471-
return mapsets;
2472-
}
2473-
2474-
QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString path )
2475-
: QgsDataCollectionItem( parent, "", path )
2476-
{
2477-
QDir dir( path );
2478-
mName = dir.dirName();
2479-
dir.cdUp();
2480-
mLocation = dir.dirName();
2481-
dir.cdUp();
2482-
mGisdbase = dir.path();
2483-
2484-
mIcon = QIcon( getThemePixmap( "grass_mapset.png" ) );
2485-
}
2486-
2487-
QgsGrassMapsetItem::~QgsGrassMapsetItem() {}
2488-
2489-
bool QgsGrassMapsetItem::isMapset( QString path )
2490-
{
2491-
return QFile::exists( path + QDir::separator() + "WIND" );
2492-
}
2493-
2494-
QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
2495-
{
2496-
QVector<QgsDataItem*> items;
2497-
2498-
QStringList vectorNames = QgsGrass::vectors( mPath );
2499-
2500-
foreach( QString name, vectorNames )
2501-
{
2502-
QStringList layerNames = QgsGrass::vectorLayers( mGisdbase , mLocation, mName, name );
2503-
2504-
QString path = mPath + QDir::separator() + "vector" + QDir::separator() + name;
2505-
2506-
QgsDataCollectionItem *map = 0;
2507-
if ( layerNames.size() != 1 )
2508-
map = new QgsDataCollectionItem( this, name );
2509-
foreach( QString layerName, layerNames )
2510-
{
2511-
QString uri = mPath + QDir::separator() + name + QDir::separator() + layerName;
2512-
QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
2513-
QString typeName = layerName.split( "_" )[1];
2514-
QString baseLayerName = layerName.split( "_" )[0];
2515-
2516-
if ( typeName == "point" )
2517-
layerType = QgsLayerItem::Point;
2518-
else if ( typeName == "line" )
2519-
layerType = QgsLayerItem::Line;
2520-
else if ( typeName == "polygon" )
2521-
layerType = QgsLayerItem::Polygon;
2522-
2523-
if ( layerNames.size() == 1 )
2524-
{
2525-
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, path, uri, layerType, "grass" );
2526-
items.append( layer );
2527-
}
2528-
else
2529-
{
2530-
QgsLayerItem *layer = new QgsLayerItem( map, baseLayerName, path, uri, layerType, "grass" );
2531-
map->addChild( layer );
2532-
}
2533-
}
2534-
if ( layerNames.size() != 1 )
2535-
items.append( map );
2536-
}
2537-
2538-
QStringList rasterNames = QgsGrass::rasters( mPath );
2539-
2540-
foreach( QString name, rasterNames )
2541-
{
2542-
QString uri = mPath + QDir::separator() + "cellhd" + QDir::separator() + name;
2543-
QgsDebugMsg( "uri = " + uri );
2544-
2545-
QgsLayerItem *layer = new QgsLayerItem( this, name, uri, uri, QgsLayerItem::Raster, "grassraster" );
2546-
2547-
items.append( layer );
2548-
}
2549-
2550-
return items;
2551-
}
2552-
2553-
QGISEXTERN int dataCapabilities()
2554-
{
2555-
return QgsDataProvider::Dir;
2556-
}
2557-
2558-
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
2559-
{
2560-
if ( QgsGrassLocationItem::isLocation( thePath ) )
2561-
{
2562-
QgsGrassLocationItem * location = new QgsGrassLocationItem( parentItem, thePath );
2563-
return location;
2564-
}
2565-
return 0;
2566-
}
2567-
2568-
/**
2569-
* Class factory to return a pointer to a newly created
2570-
* QgsGrassProvider object
2571-
*/
2572-
QGISEXTERN QgsGrassProvider * classFactory( const QString *uri )
2573-
{
2574-
return new QgsGrassProvider( *uri );
2575-
}
2576-
2577-
/** Required key function (used to map the plugin to a data store type)
2578-
*/
2579-
QGISEXTERN QString providerKey()
2580-
{
2581-
return QString( "grass" );
2582-
}
2583-
2584-
/**
2585-
* Required description function
2586-
*/
2587-
QGISEXTERN QString description()
2588-
{
2589-
return QString( "GRASS data provider" );
2590-
}
2591-
2592-
/**
2593-
* Required isProvider function. Used to determine if this shared library
2594-
* is a data provider plugin
2595-
*/
2596-
QGISEXTERN bool isProvider()
2597-
{
2598-
return true;
2599-
}

‎src/providers/grass/qgsgrassprovider.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class QgsFeature;
2020
class QgsField;
2121
#include <QDateTime>
2222

23-
#include "qgsdataitem.h"
2423
#include "qgsvectordataprovider.h"
2524
#include <vector>
2625

@@ -110,7 +109,7 @@ struct GMAP
110109
\class QgsGrassProvider
111110
\brief Data provider for GRASS vectors
112111
*/
113-
class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
112+
class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
114113
{
115114
Q_OBJECT
116115

@@ -687,30 +686,4 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider
687686
static std::vector<GMAP> mMaps; // Map
688687
};
689688

690-
691-
class QgsGrassLocationItem : public QgsDataCollectionItem
692-
{
693-
public:
694-
QgsGrassLocationItem( QgsDataItem* parent, QString path );
695-
~QgsGrassLocationItem();
696-
697-
static bool isLocation( QString path );
698-
QVector<QgsDataItem*> createChildren();
699-
};
700-
701-
class QgsGrassMapsetItem : public QgsDataCollectionItem
702-
{
703-
public:
704-
QgsGrassMapsetItem( QgsDataItem* parent, QString path );
705-
~QgsGrassMapsetItem();
706-
707-
static bool isMapset( QString path );
708-
QVector<QgsDataItem*> createChildren();
709-
710-
QString mLocation;
711-
QString mGisdbase;
712-
};
713-
714-
715-
716689
#endif // QGSGRASSPROVIDER_H
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/***************************************************************************
2+
qgsgrassprovidermodule.cpp - Data provider for GRASS format
3+
-------------------
4+
begin : March, 2004
5+
copyright : (C) 2004 by Gary E.Sherman, Radim Blazek
6+
email : sherman@mrcc.com, blazek@itc.it
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#include "qgsgrassprovidermodule.h"
18+
#include "qgsgrassprovider.h"
19+
#include "qgsgrass.h"
20+
#include "qgslogger.h"
21+
22+
#include <QFileInfo>
23+
#include <QDir>
24+
25+
QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem* parent, QString path )
26+
: QgsDataCollectionItem( parent, "", path )
27+
{
28+
QFileInfo fi( path );
29+
mName = fi.baseName();
30+
mIcon = QIcon( getThemePixmap( "grass_location.png" ) );
31+
}
32+
QgsGrassLocationItem::~QgsGrassLocationItem() {}
33+
34+
bool QgsGrassLocationItem::isLocation( QString path )
35+
{
36+
//QgsDebugMsg( "path = " + path );
37+
return QFile::exists( path + QDir::separator() + "PERMANENT" + QDir::separator() + "DEFAULT_WIND" );
38+
}
39+
40+
QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
41+
{
42+
QVector<QgsDataItem*> mapsets;
43+
44+
QDir dir( mPath );
45+
46+
QStringList entries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
47+
foreach( QString name, entries )
48+
{
49+
QString path = dir.absoluteFilePath( name );
50+
51+
if ( QgsGrassMapsetItem::isMapset( path ) )
52+
{
53+
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path );
54+
mapsets.append( mapset );
55+
}
56+
}
57+
return mapsets;
58+
}
59+
60+
QgsGrassMapsetItem::QgsGrassMapsetItem( QgsDataItem* parent, QString path )
61+
: QgsDataCollectionItem( parent, "", path )
62+
{
63+
QDir dir( path );
64+
mName = dir.dirName();
65+
dir.cdUp();
66+
mLocation = dir.dirName();
67+
dir.cdUp();
68+
mGisdbase = dir.path();
69+
70+
mIcon = QIcon( getThemePixmap( "grass_mapset.png" ) );
71+
}
72+
73+
QgsGrassMapsetItem::~QgsGrassMapsetItem() {}
74+
75+
bool QgsGrassMapsetItem::isMapset( QString path )
76+
{
77+
return QFile::exists( path + QDir::separator() + "WIND" );
78+
}
79+
80+
QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
81+
{
82+
QVector<QgsDataItem*> items;
83+
84+
QStringList vectorNames = QgsGrass::vectors( mPath );
85+
86+
foreach( QString name, vectorNames )
87+
{
88+
QStringList layerNames = QgsGrass::vectorLayers( mGisdbase , mLocation, mName, name );
89+
90+
QString path = mPath + QDir::separator() + "vector" + QDir::separator() + name;
91+
92+
QgsDataCollectionItem *map = 0;
93+
if ( layerNames.size() != 1 )
94+
map = new QgsDataCollectionItem( this, name );
95+
foreach( QString layerName, layerNames )
96+
{
97+
QString uri = mPath + QDir::separator() + name + QDir::separator() + layerName;
98+
QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
99+
QString typeName = layerName.split( "_" )[1];
100+
QString baseLayerName = layerName.split( "_" )[0];
101+
102+
if ( typeName == "point" )
103+
layerType = QgsLayerItem::Point;
104+
else if ( typeName == "line" )
105+
layerType = QgsLayerItem::Line;
106+
else if ( typeName == "polygon" )
107+
layerType = QgsLayerItem::Polygon;
108+
109+
if ( layerNames.size() == 1 )
110+
{
111+
QgsLayerItem *layer = new QgsLayerItem( this, name + " " + baseLayerName, path, uri, layerType, "grass" );
112+
items.append( layer );
113+
}
114+
else
115+
{
116+
QgsLayerItem *layer = new QgsLayerItem( map, baseLayerName, path, uri, layerType, "grass" );
117+
map->addChild( layer );
118+
}
119+
}
120+
if ( layerNames.size() != 1 )
121+
items.append( map );
122+
}
123+
124+
QStringList rasterNames = QgsGrass::rasters( mPath );
125+
126+
foreach( QString name, rasterNames )
127+
{
128+
QString uri = mPath + QDir::separator() + "cellhd" + QDir::separator() + name;
129+
QgsDebugMsg( "uri = " + uri );
130+
131+
QgsLayerItem *layer = new QgsLayerItem( this, name, uri, uri, QgsLayerItem::Raster, "grassraster" );
132+
133+
items.append( layer );
134+
}
135+
136+
return items;
137+
}
138+
139+
QGISEXTERN int dataCapabilities()
140+
{
141+
return QgsDataProvider::Dir;
142+
}
143+
144+
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
145+
{
146+
if ( QgsGrassLocationItem::isLocation( thePath ) )
147+
{
148+
QgsGrassLocationItem * location = new QgsGrassLocationItem( parentItem, thePath );
149+
return location;
150+
}
151+
return 0;
152+
}
153+
154+
/**
155+
* Class factory to return a pointer to a newly created
156+
* QgsGrassProvider object
157+
*/
158+
QGISEXTERN QgsGrassProvider * classFactory( const QString *uri )
159+
{
160+
return new QgsGrassProvider( *uri );
161+
}
162+
163+
/** Required key function (used to map the plugin to a data store type)
164+
*/
165+
QGISEXTERN QString providerKey()
166+
{
167+
return QString( "grass" );
168+
}
169+
170+
/**
171+
* Required description function
172+
*/
173+
QGISEXTERN QString description()
174+
{
175+
return QString( "GRASS data provider" );
176+
}
177+
178+
/**
179+
* Required isProvider function. Used to determine if this shared library
180+
* is a data provider plugin
181+
*/
182+
QGISEXTERN bool isProvider()
183+
{
184+
return true;
185+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/***************************************************************************
2+
qgsgrassprovidermodule.h - Data provider for GRASS format
3+
-------------------
4+
begin : March, 2004
5+
copyright : (C) 2004 by Gary E.Sherman, Radim Blazek
6+
email : sherman@mrcc.com, blazek@itc.it
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
#ifndef QGSGRASSPROVIDERMODULE_H
17+
#define QGSGRASSPROVIDERMODULE_H
18+
19+
#include "qgsdataitem.h"
20+
21+
class QgsGrassLocationItem : public QgsDataCollectionItem
22+
{
23+
public:
24+
QgsGrassLocationItem( QgsDataItem* parent, QString path );
25+
~QgsGrassLocationItem();
26+
27+
static bool isLocation( QString path );
28+
QVector<QgsDataItem*> createChildren();
29+
};
30+
31+
class QgsGrassMapsetItem : public QgsDataCollectionItem
32+
{
33+
public:
34+
QgsGrassMapsetItem( QgsDataItem* parent, QString path );
35+
~QgsGrassMapsetItem();
36+
37+
static bool isMapset( QString path );
38+
QVector<QgsDataItem*> createChildren();
39+
40+
QString mLocation;
41+
QString mGisdbase;
42+
};
43+
44+
#endif // QGSGRASSPROVIDERMODULE_H

‎src/providers/sqlanywhere/sqlanyconnection/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ TARGET_LINK_LIBRARIES(qgissqlanyconnection
4747
qgis_core
4848
)
4949

50+
IF(UNIX AND NOT ANDROID)
51+
TARGET_LINK_LIBRARIES(qgissqlanyconnection ${CMAKE_DL_LIBS})
52+
ENDIF(UNIX AND NOT ANDROID)
53+
5054
IF (APPLE)
5155
SET_TARGET_PROPERTIES(qgissqlanyconnection PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE )
5256
ENDIF (APPLE)

0 commit comments

Comments
 (0)
Please sign in to comment.