Pārlūkot izejas kodu

rasterlib: rename interpolation methods (bilinear->linear, bicubic->cubic)
update modules


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56327 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 12 gadi atpakaļ
vecāks
revīzija
cb6dced6a4

+ 4 - 6
include/raster.h

@@ -15,13 +15,11 @@
 /*! \brief Interpolation methods
 
   For G_get_raster_sample(), INTERP_TYPE
-
-  \todo Rename to use prefix INTERP_
 */
-#define UNKNOWN	  0
-#define NEAREST   1		/* nearest neighbor interpolation  */
-#define BILINEAR  2		/* bilinear interpolation          */
-#define CUBIC     3		/* cubic interpolation             */
+#define INTERP_UNKNOWN   0
+#define INTERP_NEAREST   1		/* nearest neighbor interpolation  */
+#define INTERP_LINEAR    2		/* linear interpolation            */
+#define INTERP_CUBIC     3		/* cubic interpolation             */
 
 /*** typedefs ***/
 typedef int RASTER_MAP_TYPE;

+ 4 - 4
lib/gis/parser_standard_options.c

@@ -308,12 +308,12 @@ struct Option *G_define_standard_option(int opt)
         Opt->type = TYPE_STRING;
         Opt->required = NO;
         Opt->description = _("Sampling interpolation method");
-        Opt->options = "nearest,bilinear,bicubic";
+        Opt->options = "nearest,linear,cubic";
         G_asprintf((char **) &(Opt->descriptions),
-                   "nearest;%s;bilinear;%s;bicubic;%s",
+                   "nearest;%s;linear;%s;cubic;%s",
                    _("Nearest-neighbor interpolation"),
-                   _("Bilinear interpolation"),
-                   _("Bicubic interpolation"));
+                   _("Linear interpolation"),
+                   _("Cubic interpolation"));
         break;
 
 	/*g3d maps */

+ 7 - 7
lib/raster/interp.c

@@ -194,20 +194,20 @@ int Rast_option_to_interp_type(const struct Option *option)
 {
     int interp_type;
     
-    interp_type = UNKNOWN;
+    interp_type = INTERP_UNKNOWN;
     if (option->answer) {
         if (strcmp(option->answer, "nearest") == 0) {
-            interp_type = NEAREST;
+            interp_type = INTERP_NEAREST;
         }
-        else if (strcmp(option->answer, "bilinear") == 0) {
-            interp_type = BILINEAR;
+        else if (strcmp(option->answer, "linear") == 0) {
+            interp_type = INTERP_LINEAR;
         }
-        else if (strcmp(option->answer, "bicubic") == 0) {
-            interp_type = CUBIC;
+        else if (strcmp(option->answer, "cubic") == 0) {
+            interp_type = INTERP_CUBIC;
         }
     }
 
-    if (interp_type == UNKNOWN)
+    if (interp_type == INTERP_UNKNOWN)
         G_fatal_error(_("Unknown interpolation method: %s"), option->answer);
 
     return interp_type;

+ 3 - 3
lib/raster/sample.c

@@ -54,15 +54,15 @@ DCELL Rast_get_sample(int fd,
     double retval;
 
     switch (itype) {
-    case NEAREST:
+    case INTERP_NEAREST:
 	retval =
 	    Rast_get_sample_nearest(fd, window, cats, north, east, usedesc);
 	break;
-    case BILINEAR:
+    case INTERP_LINEAR:
 	retval =
 	    Rast_get_sample_bilinear(fd, window, cats, north, east, usedesc);
 	break;
-    case CUBIC:
+    case INTERP_CUBIC:
 	retval =
 	    Rast_get_sample_cubic(fd, window, cats, north, east, usedesc);
 	break;

+ 4 - 7
raster/r.resamp.bspline/main.c

@@ -115,13 +115,10 @@ int main(int argc, char *argv[])
 	_("Length of each spline step in the north-south direction. Default: 1.5 * nsres.");
     stepN_opt->guisection = _("Settings");
 
-    method_opt = G_define_option();
-    method_opt->key = "method";
-    method_opt->type = TYPE_STRING;
-    method_opt->required = NO;
+    method_opt = G_define_standard_option(G_OPT_R_INTERP_TYPE);
     method_opt->description = _("Spline interpolation algorithm");
-    method_opt->options = "bilinear,bicubic";
-    method_opt->answer = "bicubic";
+    method_opt->options = "linear,cubic";
+    method_opt->answer = "cubic";
     method_opt->guisection = _("Settings");
 
     lambda_f_opt = G_define_option();
@@ -158,7 +155,7 @@ int main(int argc, char *argv[])
     inrast = in_opt->answer;
     outrast = out_opt->answer;
 
-    if (!strcmp(method_opt->answer, "bilinear"))
+    if (!strcmp(method_opt->answer, "linear"))
 	interp_method = P_BILINEAR;
     else
 	interp_method = P_BICUBIC;

+ 5 - 9
raster/r.resamp.interp/main.c

@@ -81,22 +81,18 @@ int main(int argc, char *argv[])
     rastin = G_define_standard_option(G_OPT_R_INPUT);
     rastout = G_define_standard_option(G_OPT_R_OUTPUT);
 
-    method = G_define_option();
-    method->key = "method";
-    method->type = TYPE_STRING;
-    method->required = NO;
-    method->description = _("Interpolation method");
-    method->options = "nearest,bilinear,bicubic,lanczos";
-    method->answer = "bilinear";
+    method = G_define_standard_option(G_OPT_R_INTERP_TYPE);
+    method->options = "nearest,linear,cubic,lanczos";
+    method->answer = "linear";
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
     if (G_strcasecmp(method->answer, "nearest") == 0)
 	neighbors = 1;
-    else if (G_strcasecmp(method->answer, "bilinear") == 0)
+    else if (G_strcasecmp(method->answer, "linear") == 0)
 	neighbors = 2;
-    else if (G_strcasecmp(method->answer, "bicubic") == 0)
+    else if (G_strcasecmp(method->answer, "cubic") == 0)
 	neighbors = 4;
     else if (G_strcasecmp(method->answer, "lanczos") == 0)
 	neighbors = 5;

+ 1 - 1
vector/v.sample/main.c

@@ -45,7 +45,7 @@
 int main(int argc, char **argv)
 {
     double scale, predicted, actual;
-    INTERP_TYPE method = UNKNOWN;
+    INTERP_TYPE method = INTERP_UNKNOWN;
     int fdrast;			/* file descriptor for raster map is int */
     struct Cell_head window;
     struct GModule *module;

+ 4 - 7
vector/v.surf.bspline/main.c

@@ -152,13 +152,10 @@ int main(int argc, char *argv[])
 	_("Length of each spline step in the north-south direction");
     stepN_opt->guisection = _("Settings");
 
-    type_opt = G_define_option();
-    type_opt->key = "method";
-    type_opt->type = TYPE_STRING;
-    type_opt->required = NO;
+    type_opt = G_define_standard_option(G_OPT_R_INTERP_TYPE);
     type_opt->description = _("Spline interpolation algorithm");
-    type_opt->options = "bilinear,bicubic";
-    type_opt->answer = "bilinear";
+    type_opt->options = "linear,cubic";
+    type_opt->answer = "linear";
     type_opt->guisection = _("Settings");
 
     lambda_f_opt = G_define_option();
@@ -206,7 +203,7 @@ int main(int argc, char *argv[])
     if (!vector && !map && !cross_corr_flag->answer)
 	G_fatal_error(_("No raster or vector or cross-validation output"));
 
-    if (!strcmp(type_opt->answer, "bilinear"))
+    if (!strcmp(type_opt->answer, "linear"))
 	bilin = P_BILINEAR;
     else
 	bilin = P_BICUBIC;