Skip to content
Permalink
Browse files
More GRASS direct functions for Windows
  • Loading branch information
blazek committed Dec 12, 2012
1 parent c7fb230 commit 32f0dfdb51d00c200de18e0e3b496fdba81aa3f3
Showing with 93 additions and 47 deletions.
  1. +72 −44 src/providers/grass/CMakeLists.txt
  2. +21 −3 src/providers/grass/qgsgrassgislib.cpp
@@ -58,9 +58,17 @@ ENDIF (APPLE)
# Create list of functions to be mapped
SET ( FUNCTIONS
"G_add_color_rule"
"G_add_c_raster_color_rule"
"G_add_d_raster_color_rule"
"G_add_f_raster_color_rule"
"G_add_raster_color_rule"
"G_adjust_Cell_head"
"G_align_window"
"G_allocate_cell_buf"
"G_allocate_c_raster_buf"
"G_allocate_d_raster_buf"
"G_allocate_f_raster_buf"
"G_allocate_null_buf"
"G_allocate_raster_buf"
"G__calloc"
"G_col_to_easting"
@@ -71,17 +79,17 @@ SET ( FUNCTIONS
"G_define_standard_option"
"G_free"
"G_free_raster_cats"
"G__getenv"
"G_get_fp_range_min_max"
"G_get_range_min_max"
"G_get_window"
"G_get_set_window"
"G__init_null_patterns"
"G_gettext"
"G_get_window"
"G_incr_void_ptr"
"G_init_colors"
"G_init_fp_range"
"G_init_raster_cats"
"G__init_null_patterns"
"G_init_range"
"G_init_raster_cats"
"G_is_c_null_value"
"G_is_d_null_value"
"G_is_f_null_value"
@@ -93,19 +101,20 @@ SET ( FUNCTIONS
"G_quant_free"
"G_quant_get_limits"
"G_quant_init"
"G__realloc"
"G_raster_size"
"G__realloc"
"G_row_to_northing"
"G_set_c_null_value"
"G_set_d_null_value"
"G_set_f_null_value"
"G_set_d_raster_cat"
"G_setenv"
"G_set_f_null_value"
"G_set_gisrc_mode"
"G_set_null_value"
"G_set_raster_cat"
"G_set_raster_cats_title"
"G_set_raster_value_d"
"G_set_window"
"G_setenv"
"G_strip"
"G_suppress_masking"
"G_trim_decimal"
@@ -116,60 +125,79 @@ SET ( FUNCTIONS
"G_zero"
)

# If a function, say G_1 called in true GRASS gis lib (loaded by QLibrary)
# calls another function G_2 which does not have to be reimplemented in gis fake lib:
# - on Linux: G_2 is resolved in original GRASS true gis lib and it is not necessary
# to add it to functions mapped in fake lib
# - on Windows: it seems that dynamic linker is searching for G_2 in the first loaded
# module of the same name, i.e. in our fake library, not in the original
# true GRASS gis lib, so we have to add all functions called in true lib
# also to mapped functions in fake lib

IF(MSVC)
SET ( FUNCTIONS
${FUNCTIONS}
"G__getenv"
)
ENDIF(MSVC)

# List of functions which are implemented in qgsgrassgislib.cpp and
# thus we only need prototype
SET ( FUNCTION_PROTOTYPES
"G__gisinit"
"G_parser"
"G_set_error_routine"
"G_warning"
"G_fatal_error"
"G_done_msg"
"*G_find_cell2"
"*G_find_cell"
"G_open_cell_old"
"G_asprintf"
"G_begin_distance_calculations"
"G_check_input_output_name"
"G_close_cell"
"G_open_raster_new"
"G_open_cell_new"
"G_raster_map_is_fp"
"G_read_fp_range"
"G_read_range"
"G_command_history"
"G_database_units_to_meters_factor"
"G_debug"
"G_message"
"G_verbose_message"
"G_set_quant_rules"
"G_get_raster_row"
"G_get_raster_row_nomask"
"G_distance"
"G_done_msg"
"G_fatal_error"
"G_find_cell"
"G_find_cell2"
"G_get_cellhd"
"G_get_c_raster_row"
"G_get_c_raster_row_nomask"
"G_get_f_raster_row"
"G_get_f_raster_row_nomask"
"G_get_d_raster_row"
"G_get_d_raster_row_nomask"
"G_get_f_raster_row"
"G_get_f_raster_row_nomask"
"G_get_map_row"
"G_get_map_row_nomask"
"G_put_raster_row"
"G_check_input_output_name"
"G_get_cellhd"
"G_database_units_to_meters_factor"
"G_begin_distance_calculations"
"G_distance"
"G_get_raster_map_type"
"G_get_raster_row"
"G_get_raster_row_nomask"
"G__gisinit"
"G_legal_filename"
"G_tempfile"
"G_mapset"
"G_location"
"G_write_colors"
"G_make_aspect_fp_colors"
"G_mapset"
"G_maskfd"
"G_message"
"G_open_cell_new"
"G_open_cell_old"
"G_open_raster_new"
"G_parser"
"G_put_raster_row"
"G_quantize_fp_map_range"
"G_raster_map_is_fp"
"G_read_colors"
"G_read_fp_range"
"G_read_history"
"G_read_range"
"G_read_raster_cats"
"G_write_raster_cats"
"G_set_cats_title"
"G_set_error_routine"
"G_set_quant_rules"
"G_short_history"
"G_tempfile"
"G_vasprintf"
"G_verbose_message"
"G_warning"
"G_write_colors"
"G_write_history"
"G_maskfd"
"G_command_history"
"G_set_cats_title"
"G_read_history"
"G_read_colors"
"G_make_aspect_fp_colors"
"G_write_raster_cats"
)

SET ( FUNCTIONS_ALL
@@ -18,9 +18,9 @@
#include <stdarg.h>
#include <QtGlobal>

// If qgsgrassgislibfunctions.h is included on Linux, symbols defined here
// cannot be found (undefined symbol error) even if they are present in
// the library (in code section) - why?
// If qgsgrassgislibfunctions.h is included on Linux, symbols defined here
// cannot be found (undefined symbol error) even if they are present in
// the library (in code section) - why?
#ifdef Q_OS_WIN
#include "qgsgrassgislibfunctions.h"
#endif
@@ -975,6 +975,24 @@ RASTER_MAP_TYPE QgsGrassGisLib::grassRasterType( QgsRasterBlock::DataType qgisTy
}
}

typedef int G_vasprintf_type( char **, const char *, va_list );
int G_vasprintf( char **out, const char *fmt, va_list ap )
{
G_vasprintf_type* fn = ( G_vasprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_vasprintf_type" ) );
return fn( out, fmt, ap );
}

typedef int G_asprintf_type( char **, const char *, ... );
int G_asprintf( char **out, const char *fmt, ... )
{
G_asprintf_type* fn = ( G_asprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_asprintf_type" ) );
va_list ap;
va_start( ap, fmt );
int ret = fn( out, fmt, ap );
va_end( ap );
return ret;
}

char GRASS_LIB_EXPORT *G_tempfile( void )
{
QTemporaryFile file( "qgis-grass-temp.XXXXXX" );

0 comments on commit 32f0dfd

Please sign in to comment.