Skip to content

Commit 32f0dfd

Browse files
committed
More GRASS direct functions for Windows
1 parent c7fb230 commit 32f0dfd

File tree

2 files changed

+93
-47
lines changed

2 files changed

+93
-47
lines changed

src/providers/grass/CMakeLists.txt

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,17 @@ ENDIF (APPLE)
5858
# Create list of functions to be mapped
5959
SET ( FUNCTIONS
6060
"G_add_color_rule"
61+
"G_add_c_raster_color_rule"
62+
"G_add_d_raster_color_rule"
63+
"G_add_f_raster_color_rule"
64+
"G_add_raster_color_rule"
6165
"G_adjust_Cell_head"
6266
"G_align_window"
6367
"G_allocate_cell_buf"
68+
"G_allocate_c_raster_buf"
69+
"G_allocate_d_raster_buf"
70+
"G_allocate_f_raster_buf"
71+
"G_allocate_null_buf"
6472
"G_allocate_raster_buf"
6573
"G__calloc"
6674
"G_col_to_easting"
@@ -71,17 +79,17 @@ SET ( FUNCTIONS
7179
"G_define_standard_option"
7280
"G_free"
7381
"G_free_raster_cats"
74-
"G__getenv"
7582
"G_get_fp_range_min_max"
7683
"G_get_range_min_max"
77-
"G_get_window"
7884
"G_get_set_window"
79-
"G__init_null_patterns"
85+
"G_gettext"
86+
"G_get_window"
8087
"G_incr_void_ptr"
8188
"G_init_colors"
8289
"G_init_fp_range"
83-
"G_init_raster_cats"
90+
"G__init_null_patterns"
8491
"G_init_range"
92+
"G_init_raster_cats"
8593
"G_is_c_null_value"
8694
"G_is_d_null_value"
8795
"G_is_f_null_value"
@@ -93,19 +101,20 @@ SET ( FUNCTIONS
93101
"G_quant_free"
94102
"G_quant_get_limits"
95103
"G_quant_init"
96-
"G__realloc"
97104
"G_raster_size"
105+
"G__realloc"
98106
"G_row_to_northing"
99107
"G_set_c_null_value"
100108
"G_set_d_null_value"
101-
"G_set_f_null_value"
102109
"G_set_d_raster_cat"
110+
"G_setenv"
111+
"G_set_f_null_value"
103112
"G_set_gisrc_mode"
104113
"G_set_null_value"
114+
"G_set_raster_cat"
105115
"G_set_raster_cats_title"
106116
"G_set_raster_value_d"
107117
"G_set_window"
108-
"G_setenv"
109118
"G_strip"
110119
"G_suppress_masking"
111120
"G_trim_decimal"
@@ -116,60 +125,79 @@ SET ( FUNCTIONS
116125
"G_zero"
117126
)
118127

128+
# If a function, say G_1 called in true GRASS gis lib (loaded by QLibrary)
129+
# calls another function G_2 which does not have to be reimplemented in gis fake lib:
130+
# - on Linux: G_2 is resolved in original GRASS true gis lib and it is not necessary
131+
# to add it to functions mapped in fake lib
132+
# - on Windows: it seems that dynamic linker is searching for G_2 in the first loaded
133+
# module of the same name, i.e. in our fake library, not in the original
134+
# true GRASS gis lib, so we have to add all functions called in true lib
135+
# also to mapped functions in fake lib
136+
137+
IF(MSVC)
138+
SET ( FUNCTIONS
139+
${FUNCTIONS}
140+
"G__getenv"
141+
)
142+
ENDIF(MSVC)
143+
119144
# List of functions which are implemented in qgsgrassgislib.cpp and
120145
# thus we only need prototype
121146
SET ( FUNCTION_PROTOTYPES
122-
"G__gisinit"
123-
"G_parser"
124-
"G_set_error_routine"
125-
"G_warning"
126-
"G_fatal_error"
127-
"G_done_msg"
128-
"*G_find_cell2"
129-
"*G_find_cell"
130-
"G_open_cell_old"
147+
"G_asprintf"
148+
"G_begin_distance_calculations"
149+
"G_check_input_output_name"
131150
"G_close_cell"
132-
"G_open_raster_new"
133-
"G_open_cell_new"
134-
"G_raster_map_is_fp"
135-
"G_read_fp_range"
136-
"G_read_range"
151+
"G_command_history"
152+
"G_database_units_to_meters_factor"
137153
"G_debug"
138-
"G_message"
139-
"G_verbose_message"
140-
"G_set_quant_rules"
141-
"G_get_raster_row"
142-
"G_get_raster_row_nomask"
154+
"G_distance"
155+
"G_done_msg"
156+
"G_fatal_error"
157+
"G_find_cell"
158+
"G_find_cell2"
159+
"G_get_cellhd"
143160
"G_get_c_raster_row"
144161
"G_get_c_raster_row_nomask"
145-
"G_get_f_raster_row"
146-
"G_get_f_raster_row_nomask"
147162
"G_get_d_raster_row"
148163
"G_get_d_raster_row_nomask"
164+
"G_get_f_raster_row"
165+
"G_get_f_raster_row_nomask"
149166
"G_get_map_row"
150167
"G_get_map_row_nomask"
151-
"G_put_raster_row"
152-
"G_check_input_output_name"
153-
"G_get_cellhd"
154-
"G_database_units_to_meters_factor"
155-
"G_begin_distance_calculations"
156-
"G_distance"
168+
"G_get_raster_map_type"
169+
"G_get_raster_row"
170+
"G_get_raster_row_nomask"
171+
"G__gisinit"
157172
"G_legal_filename"
158-
"G_tempfile"
159-
"G_mapset"
160173
"G_location"
161-
"G_write_colors"
174+
"G_make_aspect_fp_colors"
175+
"G_mapset"
176+
"G_maskfd"
177+
"G_message"
178+
"G_open_cell_new"
179+
"G_open_cell_old"
180+
"G_open_raster_new"
181+
"G_parser"
182+
"G_put_raster_row"
162183
"G_quantize_fp_map_range"
184+
"G_raster_map_is_fp"
185+
"G_read_colors"
186+
"G_read_fp_range"
187+
"G_read_history"
188+
"G_read_range"
163189
"G_read_raster_cats"
164-
"G_write_raster_cats"
190+
"G_set_cats_title"
191+
"G_set_error_routine"
192+
"G_set_quant_rules"
165193
"G_short_history"
194+
"G_tempfile"
195+
"G_vasprintf"
196+
"G_verbose_message"
197+
"G_warning"
198+
"G_write_colors"
166199
"G_write_history"
167-
"G_maskfd"
168-
"G_command_history"
169-
"G_set_cats_title"
170-
"G_read_history"
171-
"G_read_colors"
172-
"G_make_aspect_fp_colors"
200+
"G_write_raster_cats"
173201
)
174202

175203
SET ( FUNCTIONS_ALL

src/providers/grass/qgsgrassgislib.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include <stdarg.h>
1919
#include <QtGlobal>
2020

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

978+
typedef int G_vasprintf_type( char **, const char *, va_list );
979+
int G_vasprintf( char **out, const char *fmt, va_list ap )
980+
{
981+
G_vasprintf_type* fn = ( G_vasprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_vasprintf_type" ) );
982+
return fn( out, fmt, ap );
983+
}
984+
985+
typedef int G_asprintf_type( char **, const char *, ... );
986+
int G_asprintf( char **out, const char *fmt, ... )
987+
{
988+
G_asprintf_type* fn = ( G_asprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_asprintf_type" ) );
989+
va_list ap;
990+
va_start( ap, fmt );
991+
int ret = fn( out, fmt, ap );
992+
va_end( ap );
993+
return ret;
994+
}
995+
978996
char GRASS_LIB_EXPORT *G_tempfile( void )
979997
{
980998
QTemporaryFile file( "qgis-grass-temp.XXXXXX" );

0 commit comments

Comments
 (0)