Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
working fix for #2670 and fix for GRASS 6.2 support (as found on debi…
…an lenny)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13489 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 15, 2010
1 parent 2b753a2 commit 2db0c19
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
1 change: 1 addition & 0 deletions cmake/FindPyQt.py
Expand Up @@ -6,6 +6,7 @@

pyqtcfg = PyQt4.pyqtconfig.Configuration()
print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
print("pyqt_version_num:%d" % pyqtcfg.pyqt_version)
print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)

pyqt_version_tag = ""
Expand Down
3 changes: 3 additions & 0 deletions cmake/FindPyQt4.cmake
Expand Up @@ -34,6 +34,7 @@ ELSE(EXISTS PYQT4_VERSION)
STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_num:([^\n]+).*$" "\\1" PYQT4_VERSION_NUM ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})

Expand All @@ -51,3 +52,5 @@ ELSE(EXISTS PYQT4_VERSION)
ENDIF(PYQT4_FOUND)

ENDIF(EXISTS PYQT4_VERSION)


4 changes: 2 additions & 2 deletions python/CMakeLists.txt
Expand Up @@ -35,9 +35,9 @@ IF(MSVC)
ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(MSVC)

IF(PYQT4_VERSION_TAG LESS 263680) # 0x040600
IF(PYQT4_VERSION_NUM LESS 263680) # 0x040600
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} PROXY_FACTORY)
ENDIF(PYQT4_VERSION_TAG LESS 263680)
ENDIF(PYQT4_VERSION_NUM LESS 263680)

# core module
FILE(GLOB sip_files_core core/*.sip)
Expand Down
9 changes: 7 additions & 2 deletions src/providers/grass/qgis.g.info.c
Expand Up @@ -108,7 +108,12 @@ int main( int argc, char **argv )
void *ptr;
double val;

#if defined(GRASS_VERSION_MAJOR) && defined(GRASS_VERSION_MINOR) && \
( ( GRASS_VERSION_MAJOR == 6 && GRASS_VERSION_MINOR > 2 ) || GRASS_VERSION_MAJOR > 6 )
rast_type = G_get_raster_map_type( fd );
#else
rast_type = G_raster_map_type( rast_opt->answer, "" );
#endif
cell = G_allocate_c_raster_buf();
dcell = G_allocate_d_raster_buf();

Expand All @@ -120,7 +125,7 @@ int main( int argc, char **argv )
rast_opt->answer, row );
}
val = cell[col];
ptr = &(cell[col]);
ptr = &( cell[col] );
}
else
{
Expand All @@ -130,7 +135,7 @@ int main( int argc, char **argv )
rast_opt->answer, row );
}
val = dcell[col];
ptr = &(dcell[col]);
ptr = &( dcell[col] );
}
if ( G_is_null_value( ptr, rast_type ) )
{
Expand Down
43 changes: 25 additions & 18 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -40,6 +40,13 @@ extern "C"
#include <grass/version.h>
}

#if !defined(GRASS_VERSION_MAJOR) || \
!defined(GRASS_VERSION_MINOR) || \
GRASS_VERSION_MAJOR<6 || \
(GRASS_VERSION_MAJOR == 6 && GRASS_VERSION_MINOR <= 2)
#define G__setenv(name,value) G__setenv( ( char * ) (name), (char *) (value) )
#endif

#if defined(WIN32)
#include <windows.h>
QString GRASS_EXPORT QgsGrass::shortPath( const QString &path )
Expand Down Expand Up @@ -333,14 +340,14 @@ void QgsGrass::setLocation( QString gisdbase, QString location )

// Set principal GRASS variables (in memory)
#if defined(WIN32)
G__setenv(( char * ) "GISDBASE", shortPath( gisdbase ).toLocal8Bit().data() );
G__setenv( "GISDBASE", shortPath( gisdbase ).toLocal8Bit().data() );
#else
// This does not work for GISBAS with non ascii chars on Windows XP,
// This does not work for GISBASE with non ascii chars on Windows XP,
// gives error 'LOCATION ... not available':
G__setenv(( char * ) "GISDBASE", gisdbase.toUtf8().constData() );
G__setenv( "GISDBASE", gisdbase.toUtf8().constData() );
#endif
G__setenv(( char * ) "LOCATION_NAME", location.toUtf8().constData() );
G__setenv(( char * ) "MAPSET", ( char * ) "PERMANENT" ); // PERMANENT must always exist
G__setenv( "LOCATION_NAME", location.toUtf8().constData() );
G__setenv( "MAPSET", "PERMANENT" ); // PERMANENT must always exist

// Add all available mapsets to search path
char **ms = G_available_mapsets();
Expand All @@ -354,12 +361,12 @@ void QgsGrass::setMapset( QString gisdbase, QString location, QString mapset )

// Set principal GRASS variables (in memory)
#if defined(WIN32)
G__setenv(( char * ) "GISDBASE", shortPath( gisdbase ).toUtf8().data() );
G__setenv( "GISDBASE", shortPath( gisdbase ).toUtf8().data() );
#else
G__setenv(( char * ) "GISDBASE", gisdbase.toUtf8().data() );
G__setenv( "GISDBASE", gisdbase.toUtf8().data() );
#endif
G__setenv(( char * ) "LOCATION_NAME", location.toUtf8().data() );
G__setenv(( char * ) "MAPSET", mapset.toUtf8().data() );
G__setenv( "LOCATION_NAME", location.toUtf8().data() );
G__setenv( "MAPSET", mapset.toUtf8().data() );

// Add all available mapsets to search path
char **ms = G_available_mapsets();
Expand Down Expand Up @@ -560,14 +567,14 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q
putEnv( "GISRC", mGisrc );

// Reinitialize GRASS
G__setenv(( char * ) "GISRC", mGisrc.toUtf8().data() );
G__setenv( "GISRC", mGisrc.toUtf8().data() );
#if defined(WIN32)
G__setenv(( char * ) "GISDBASE", shortPath( gisdbase ).toLocal8Bit().data() );
G__setenv( "GISDBASE", shortPath( gisdbase ).toLocal8Bit().data() );
#else
G__setenv(( char * ) "GISDBASE", gisdbase.toUtf8().data() );
G__setenv( "GISDBASE", gisdbase.toUtf8().data() );
#endif
G__setenv(( char * ) "LOCATION_NAME", location.toLocal8Bit().data() );
G__setenv(( char * ) "MAPSET", mapset.toLocal8Bit().data() );
G__setenv( "LOCATION_NAME", location.toLocal8Bit().data() );
G__setenv( "MAPSET", mapset.toLocal8Bit().data() );
defaultGisdbase = gisdbase;
defaultLocation = location;
defaultMapset = mapset;
Expand Down Expand Up @@ -602,15 +609,15 @@ QString QgsGrass::closeMapset( )
putenv(( char * ) "GISRC" );

// Reinitialize GRASS
G__setenv(( char * ) "GISRC", ( char * ) "" );
G__setenv( "GISRC", ( char * ) "" );

// Temporarily commented because of
// http://trac.osgeo.org/qgis/ticket/1900
// http://trac.osgeo.org/gdal/ticket/3313
// it can be uncommented once GDAL with patch gets deployed (probably GDAL 1.8)
//G__setenv(( char * ) "GISDBASE", ( char * ) "" );
//G__setenv(( char * ) "LOCATION_NAME", ( char * ) "" );
//G__setenv(( char * ) "MAPSET", ( char * ) "" );
//G__setenv( "GISDBASE", ( char * ) "" );
//G__setenv( "LOCATION_NAME", ( char * ) "" );
//G__setenv( "MAPSET", ( char * ) "" );

defaultGisdbase = "";
defaultLocation = "";
Expand Down

0 comments on commit 2db0c19

Please sign in to comment.