GRASS Programmer's Manual  6.4.2(2012)
gsdiff.c
Go to the documentation of this file.
00001 
00030 #include <grass/gstypes.h>
00031 #include "gsget.h"
00032 
00033 static geosurf *Refsurf = NULL;
00034 static typbuff *Refbuff = NULL;
00035 static float Refscale = 1.0;
00036 
00042 void gsdiff_set_SDscale(float scale)
00043 {
00044     Refscale = scale;
00045 
00046     return;
00047 }
00048 
00054 float gsdiff_get_SDscale(void)
00055 {
00056     return (Refscale);
00057 }
00058 
00064 void gsdiff_set_SDref(geosurf * gsref)
00065 {
00066     Refsurf = gsref;
00067     Refbuff = gs_get_att_typbuff(gsref, ATT_TOPO, 0);
00068 
00069     return;
00070 }
00071 
00077 geosurf *gsdiff_get_SDref(void)
00078 {
00079     if (Refsurf && Refbuff) {
00080         return (Refsurf);
00081     }
00082 
00083     return (NULL);
00084 }
00085 
00094 float gsdiff_do_SD(float val, int offset)
00095 {
00096     float ref;
00097 
00098     if (Refbuff) {
00099         GET_MAPATT(Refbuff, offset, ref);
00100         return (ref + (val - ref) * Refscale);
00101     }
00102 
00103     return (val);
00104 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines