Skip to content

Commit

Permalink
More GRASS direct functions
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 20, 2012
1 parent d58d347 commit d1795c0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/providers/grass/CMakeLists.txt
Expand Up @@ -102,6 +102,7 @@ SET ( FUNCTIONS
"G_format_easting"
"G_format_northing"
"G_format_resolution"
"G_format_timestamp"
"G__write_timestamp"
"G_free"
"G_free_cats"
Expand Down Expand Up @@ -202,6 +203,7 @@ SET ( FUNCTIONS
"G_quant_set_neg_infinite_rule"
"G_putenv"
"G_raster_cmp"
"G_raster_cpy"
"G_raster_size"
"G_read_key_value_file"
"G__realloc"
Expand All @@ -210,6 +212,8 @@ SET ( FUNCTIONS
"G_rewind_raster_cats"
"G_rindex"
"G_row_to_northing"
"G_row_update_fp_range"
"G_row_update_range"
"G_scan_easting"
"G_scan_northing"
"G_scan_timestamp"
Expand All @@ -231,6 +235,7 @@ SET ( FUNCTIONS
"G_set_raster_value_d"
"G_set_window"
"G_sleep"
"G_sleep_on_error"
"G_store"
"G_strcasecmp"
"G_strcat"
Expand Down Expand Up @@ -267,6 +272,7 @@ SET ( FUNCTIONS
"G_window_overlap"
"G_window_rows"
"G_write_key_value_file"
"G_yes"
"G_zero"
"G_zero_cell_buf"
"G_zero_raster_buf"
Expand Down Expand Up @@ -348,6 +354,7 @@ SET ( FUNCTION_PROTOTYPES
"G_open_fp_cell_new"
"G_open_new"
"G_open_raster_new"
"G_open_update"
"G_parser"
"G_put_cell_title"
"G_put_c_raster_row"
Expand Down Expand Up @@ -383,6 +390,7 @@ SET ( FUNCTION_PROTOTYPES
"G_verbose_message"
"G_warning"
"G_write_cats"
"G__write_colors"
"G_write_colors"
"G_write_fp_range"
"G_write_history"
Expand All @@ -405,10 +413,11 @@ FILE(READ "${GRASS_INCLUDE_DIR}/grass/gisdefs.h" HEADER_FILE)
STRING(REGEX REPLACE "(/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/)" "" HEADER_FILE "${HEADER_FILE}")
STRING(REGEX REPLACE "#[^\r\n]*" "" HEADER_FILE "${HEADER_FILE}")

# Add functions defined in glocale.h and spawn.h
# Add functions defined in glocale.h, colors.h and spawn.h
SET ( HEADER_FILE
${HEADER_FILE}
"char *G_gettext(const char *, const char *);"
"int G_num_standard_colors(void);"
"int G_spawn(const char *, ...);"
"int G_spawn_ex(const char *, ...);"
"int G_wait(int);"
Expand Down
35 changes: 32 additions & 3 deletions src/providers/grass/qgsgrassgislib.cpp
Expand Up @@ -24,6 +24,11 @@
// the library (in code section) - why?
#ifdef Q_OS_WIN
#include "qgsgrassgislibfunctions.h"
extern "C"
{
// defined here because too complex for parser in CMakeLists.txt
int GRASS_LIB_EXPORT G_cell_stats_histo_eq( struct Cell_stats *statf, CELL min1, CELL max1, CELL min2, CELL max2, int zero, void ( *func )( CELL, CELL, CELL ) );
}
#endif
#include "qgsgrassgislib.h"

Expand Down Expand Up @@ -1299,6 +1304,13 @@ int GRASS_LIB_EXPORT G_lookup_key_value_from_file( const char *file, const char
return fn( file, key, value, n );
}

typedef int G_cell_stats_histo_eq_type( struct Cell_stats *, CELL, CELL, CELL, CELL, int, void ( * )( CELL, CELL, CELL ) );

int GRASS_LIB_EXPORT G_cell_stats_histo_eq( struct Cell_stats *statf, CELL min1, CELL max1, CELL min2, CELL max2, int zero, void ( *func )( CELL, CELL, CELL ) )
{
G_cell_stats_histo_eq_type *fn = ( G_cell_stats_histo_eq_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_cell_stats_histo_eq_type" ) );
return fn( statf, min1, max1, min2, max2, zero, func );
}

int GRASS_LIB_EXPORT G__temp_element( char *element )
{
Expand All @@ -1324,6 +1336,13 @@ char GRASS_LIB_EXPORT *G_location( void )
return qstrdup( "qgis" );
}

int GRASS_LIB_EXPORT G__write_colors( FILE * fd, struct Colors *colors )
{
Q_UNUSED( fd );
Q_UNUSED( colors );
return 1; // OK
}

int GRASS_LIB_EXPORT G_write_colors( const char *name, const char *mapset, struct Colors *colors )
{
Q_UNUSED( name );
Expand Down Expand Up @@ -1599,23 +1618,33 @@ int GRASS_LIB_EXPORT G_read_quant( const char *name, const char *mapset, struct
return 0; // does not exist
}

int G_write_fp_range( const char *name, const struct FPRange *range )
int GRASS_LIB_EXPORT G_write_fp_range( const char *name, const struct FPRange *range )
{
Q_UNUSED( name );
Q_UNUSED( range );
return 0; // OK
}

int G_write_range( const char *name, const struct Range *range )
int GRASS_LIB_EXPORT G_write_range( const char *name, const struct Range *range )
{
Q_UNUSED( name );
Q_UNUSED( range );
return 0; // OK
}

int G_write_raster_units( const char *name, const char *str )
int GRASS_LIB_EXPORT G_write_raster_units( const char *name, const char *str )
{
Q_UNUSED( name );
Q_UNUSED( str );
return 0; // OK
}

int GRASS_LIB_EXPORT G_open_update( const char *element, const char *name )
{
// G_open_update is used in r.flow if parm.seg, but parm.seg doesnt seem
// to be set to 1
Q_UNUSED( element );
Q_UNUSED( name );
qFatal( "G_open_update not imlemented" );
return -1; // Cannot open
}

0 comments on commit d1795c0

Please sign in to comment.