Skip to content
Permalink
Browse files

GRASS raster support works with MSVC

- 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@7377 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 11, 2007
1 parent b336c7b commit 777467e4de936d691cd11aa0f04eaccb49e8693e
@@ -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();
@@ -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"

@@ -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
@@ -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)

@@ -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
@@ -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
@@ -462,5 +504,6 @@ INSTALL(TARGETS
grass_dbmibase
grass_linkm
grass_dbmiclient
grass_I
RUNTIME DESTINATION ${QGIS_BIN_DIR}
ARCHIVE DESTINATION lib)
@@ -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 */
@@ -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
@@ -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
@@ -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
@@ -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__ */
@@ -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 777467e

Please sign in to comment.
You can’t perform that action at this time.