Skip to content

Commit

Permalink
GRASS raster support works with MSVC
Browse files Browse the repository at this point in the history
- let user know when a grass raster layer could not be inserted
- some fixes for the GRASS DLL build
- add grass_I (needed by GDAL's GRASS driver)

builds with current GDAL + http://trac.osgeo.org/gdal/ticket/1983
and current GRASS CVS (one bug fix should be applied soon).




git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7377 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 11, 2007
1 parent f817fe7 commit a5c51c2
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/plugins/grass/qgsgrassplugin.cpp
Expand Up @@ -414,6 +414,10 @@ void QgsGrassPlugin::addRaster()

//qGisInterface->addRasterLayer( uri );
QgsRasterLayer *layer = new QgsRasterLayer( uri, sel->map );
if( !layer->isValid() ) {
// let the user know something went wrong - addRasterLayer cleans up
QMessageBox::warning( 0, tr("Warning"), tr("Could not add raster layer: " ) + uri);
}
qGisInterface->addRasterLayer(layer);

mCanvas->refresh();
Expand Down
9 changes: 0 additions & 9 deletions src/providers/grass/provider.cpp
Expand Up @@ -27,21 +27,12 @@
#include "qgsfield.h"
#include "qgsrect.h"

#ifdef _MSC_VER
// enables prototype in GRASS headers
#define __STDC__ 1
#endif

extern "C" {
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
}

#ifdef _MSC_VER
#undef __STDC__
#endif

#include "qgsgrass.h"
#include "qgsgrassprovider.h"

Expand Down
49 changes: 46 additions & 3 deletions src/providers/grass/vc/CMakeLists.txt
Expand Up @@ -6,8 +6,9 @@ ADD_DEFINITIONS(
-I${CMAKE_CURRENT_SOURCE_DIR}
-I${GRASS_PREFIX}/lib/db/dbmi_base
-I${ZLIB_INCLUDE_DIR}
-D__MINGW32__)

-D__MINGW32__
-Dpopen=G_popen
-Dpclose=G_pclose)

ADD_LIBRARY (xdr STATIC
xdr.c
Expand Down Expand Up @@ -396,6 +397,7 @@ ADD_LIBRARY (grass_dbmibase SHARED
${GRASS_PREFIX}/lib/db/dbmi_base/xdrvalue.c
${GRASS_PREFIX}/lib/db/dbmi_base/zero.c
)
SET_SOURCE_FILES_PROPERTIES(${GRASS_PREFIX}/lib/db/dbmi_base/xdr.c PROPERTIES COMPILE_FLAGS -U__MINGW32__)
SET_TARGET_PROPERTIES(grass_dbmibase PROPERTIES LINK_FLAGS "/def:${CMAKE_CURRENT_SOURCE_DIR}/grass_dbmibase.def")
TARGET_LINK_LIBRARIES(grass_dbmibase grass_gis)

Expand All @@ -408,7 +410,7 @@ ADD_LIBRARY (grass_linkm SHARED
${GRASS_PREFIX}/lib/linkm/oom.c
)
SET_TARGET_PROPERTIES(grass_linkm PROPERTIES LINK_FLAGS "/def:${CMAKE_CURRENT_SOURCE_DIR}/grass_linkm.def")

ADD_LIBRARY (grass_dbmiclient SHARED
${GRASS_PREFIX}/lib/db/dbmi_client/column.c
${GRASS_PREFIX}/lib/db/dbmi_client/copy_tab.c
Expand Down Expand Up @@ -451,6 +453,46 @@ ADD_LIBRARY (grass_dbmiclient SHARED
)
SET_TARGET_PROPERTIES(grass_dbmiclient PROPERTIES LINK_FLAGS "/def:${CMAKE_CURRENT_SOURCE_DIR}/grass_dbmiclient.def")
TARGET_LINK_LIBRARIES(grass_dbmiclient grass_dbmibase)

ADD_LIBRARY (grass_I SHARED
${GRASS_PREFIX}/lib/imagery/alloc.c
${GRASS_PREFIX}/lib/imagery/ask_group.c
${GRASS_PREFIX}/lib/imagery/c_assign.c
${GRASS_PREFIX}/lib/imagery/c_begin.c
${GRASS_PREFIX}/lib/imagery/c_clear.c
${GRASS_PREFIX}/lib/imagery/c_distinct.c
${GRASS_PREFIX}/lib/imagery/c_exec.c
${GRASS_PREFIX}/lib/imagery/c_execmem.c
${GRASS_PREFIX}/lib/imagery/c_means.c
${GRASS_PREFIX}/lib/imagery/c_merge.c
${GRASS_PREFIX}/lib/imagery/c_nclasses.c
${GRASS_PREFIX}/lib/imagery/c_point.c
${GRASS_PREFIX}/lib/imagery/c_reassign.c
${GRASS_PREFIX}/lib/imagery/c_reclass.c
${GRASS_PREFIX}/lib/imagery/c_sep.c
${GRASS_PREFIX}/lib/imagery/c_sig.c
${GRASS_PREFIX}/lib/imagery/c_sum2.c
${GRASS_PREFIX}/lib/imagery/eol.c
${GRASS_PREFIX}/lib/imagery/find.c
${GRASS_PREFIX}/lib/imagery/fopen.c
${GRASS_PREFIX}/lib/imagery/georef.c
${GRASS_PREFIX}/lib/imagery/group.c
${GRASS_PREFIX}/lib/imagery/list_gp.c
${GRASS_PREFIX}/lib/imagery/list_subgp.c
${GRASS_PREFIX}/lib/imagery/loc_info.c
${GRASS_PREFIX}/lib/imagery/ls_groups.c
${GRASS_PREFIX}/lib/imagery/points.c
${GRASS_PREFIX}/lib/imagery/ref.c
${GRASS_PREFIX}/lib/imagery/sig.c
${GRASS_PREFIX}/lib/imagery/sigfile.c
${GRASS_PREFIX}/lib/imagery/sigset.c
${GRASS_PREFIX}/lib/imagery/sigsetfile.c
${GRASS_PREFIX}/lib/imagery/target.c
${GRASS_PREFIX}/lib/imagery/title.c
${GRASS_PREFIX}/lib/imagery/var.c
)
SET_TARGET_PROPERTIES(grass_I PROPERTIES LINK_FLAGS "/def:${CMAKE_CURRENT_SOURCE_DIR}/grass_I.def")
TARGET_LINK_LIBRARIES(grass_I grass_gis)

INSTALL(TARGETS
grass_gis
Expand All @@ -462,5 +504,6 @@ INSTALL(TARGETS
grass_dbmibase
grass_linkm
grass_dbmiclient
grass_I
RUNTIME DESTINATION ${QGIS_BIN_DIR}
ARCHIVE DESTINATION lib)
26 changes: 26 additions & 0 deletions src/providers/grass/vc/dirent.h
Expand Up @@ -83,6 +83,7 @@ typedef struct DIR {
static DIR *opendir (const char *dirname);
static struct dirent *readdir (DIR *dirp);
static int closedir (DIR *dirp);
static void rewinddir (DIR *dirp);


/* use the new safe string functions introduced in Visual Studio 2005 */
Expand Down Expand Up @@ -222,6 +223,31 @@ readdir(
return &dirp->current;
}

/*
* Rewind the directory
*
*/
static void
rewinddir(
DIR *dirp)
{
assert (dirp != NULL);

/* release search handle */
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->search_handle);
dirp->search_handle = INVALID_HANDLE_VALUE;
}

/* open stream and retrieve first file */
dirp->search_handle = FindFirstFile (dirp->patt, &dirp->current.data);
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
return;
}

/* there is an un-processed directory entry in memory now */
dirp->cached = 1;
}

/*
* Close directory stream opened by opendir() function. Close of the
Expand Down
5 changes: 1 addition & 4 deletions src/providers/grass/vc/grass_gis.def
@@ -1,8 +1,5 @@
LIBRARY grass_gis.dll
EXPORTS
; xdrmem_create @ 1
; DllMainCRTStartup@12 @ 2
; FindAtomA@4 @ 3 DATA
G_3dview_warning @ 4
G__ @ 5 DATA
G__allocate_null_bits @ 6
Expand Down Expand Up @@ -178,7 +175,7 @@ EXPORTS
G_color_name @ 175
G_color_values @ 176
G_colors_count @ 177
G_command_history @ 178
; G_command_history @ 178
G_compare_projections @ 179
G_construct_default_range @ 180
G_convert_dirseps_from_host @ 181
Expand Down
5 changes: 5 additions & 0 deletions src/providers/grass/vc/rpc/types.h
Expand Up @@ -96,4 +96,9 @@ typedef unsigned long u_long;
typedef unsigned short u_short;
#endif

#ifdef _MSC_VER
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif //_MSC_VER

#endif /* ndef __TYPES_RPC_HEADER__ */
13 changes: 12 additions & 1 deletion src/providers/grass/vc/unistd.h
@@ -1 +1,12 @@
#include <io.h>
#include <io.h>
#include <windows.h>
#include <process.h>
#include <direct.h>

#define getpid() GetCurrentProcessId()
#define chmod(f,m)
#define rmdir _rmdir

#ifndef S_ISDIR
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
#endif

0 comments on commit a5c51c2

Please sign in to comment.