Skip to content

Commit

Permalink
rasterlib: raster-related fns moved from gislib to rasterlib (step 1)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38003 15284696-431f-4ddb-bdfa-cd5b030d7da7
  • Loading branch information
landam committed Jun 20, 2009
1 parent 2116dac commit 2f7a383
Show file tree
Hide file tree
Showing 877 changed files with 9,156 additions and 8,306 deletions.
14 changes: 7 additions & 7 deletions display/d.colors/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ int Write_cats(struct Categories *pcats, int current_cat)
CELL tmp = current_cat;
int start_cat, end_cat, at_cat, at_line;

if (G_is_c_null_value(&tmp))
if (Rast_is_c_null_value(&tmp))
current_cat = 0;
else
current_cat++;
G_set_c_null_value(&tmp, 1);
Rast_set_c_null_value(&tmp, 1);
start_cat = current_cat - 2;
start_cat = start_cat > 0 ? start_cat : 0;
end_cat = start_cat + 4;
Expand All @@ -85,18 +85,18 @@ int Write_cats(struct Categories *pcats, int current_cat)
if (at_cat == current_cat) {
if (!at_cat)
sprintf(buffer, "-> %3s %s", "N",
G_get_c_raster_cat(&tmp, pcats));
Rast_get_c_raster_cat(&tmp, pcats));
else
sprintf(buffer, "-> %3d %s", at_cat - 1,
G_get_cat(at_cat - 1, pcats));
Rast_get_cat(at_cat - 1, pcats));
}
else {
if (!at_cat)
sprintf(buffer, " %3s %s", "N",
G_get_c_raster_cat(&tmp, pcats));
Rast_get_c_raster_cat(&tmp, pcats));
else
sprintf(buffer, " %3d %s", at_cat - 1,
G_get_cat(at_cat - 1, pcats));
Rast_get_cat(at_cat - 1, pcats));
}
wmove(CAT_WIN, at_line++, 1);
waddstr(CAT_WIN, buffer);
Expand Down Expand Up @@ -155,7 +155,7 @@ Write_status(int red, int grn, int blu, int shift_incr, int at_cat,
if (hi_mode)
sprintf(buffer, "HIGHLIGHT COLOR");
else {
if (!G_is_c_null_value(&tmp))
if (!Rast_is_c_null_value(&tmp))
sprintf(buffer, "CATEGORY NUMBER: %d", at_cat);
else
sprintf(buffer, "CATEGORY NUMBER: N");
Expand Down
4 changes: 2 additions & 2 deletions display/d.colors/get_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ int get_map_info(char *name, char *mapset)
exit(0);

/* Reading color lookup table */
if (G_read_cats(name, mapset, &categories) == -1) {
if (Rast_read_cats(name, mapset, &categories) == -1) {
sprintf(buff, "category file for [%s] not available", name);
G_fatal_error(buff);
}

/* Reading color lookup table */
if (G_read_colors(name, mapset, &colors) == -1) {
if (Rast_read_colors(name, mapset, &colors) == -1) {
sprintf(buff, "color file for [%s] not available", name);
G_fatal_error(buff);
}
Expand Down
36 changes: 18 additions & 18 deletions display/d.colors/interact.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
hi_save_mode = 0;

colors_changed = 0;
G_set_c_null_value(&at_cat, 1);
G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
Rast_set_c_null_value(&at_cat, 1);
Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
shift_incr = 10;

Initialize_curses();
Expand Down Expand Up @@ -89,10 +89,10 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
case 'd':
case 'u':
if (hi_mode && !hi_save_mode) {
G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
}
/* tmark_category(at_cat, 0) ; */
if (G_is_c_null_value(&at_cat))
if (Rast_is_c_null_value(&at_cat))
tmp = 0;
else
tmp = at_cat + 1;
Expand All @@ -115,7 +115,7 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
}
tmp = tmp % (categories->num + 2); /* changed 11/99 M.N. */
if (!tmp)
G_set_c_null_value(&at_cat, 1);
Rast_set_c_null_value(&at_cat, 1);
else
at_cat = tmp - 1;

Expand All @@ -124,12 +124,12 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode) {
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
}
else {
G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
}

WRITE_CATS;
Expand Down Expand Up @@ -167,12 +167,12 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode) {
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
}
else {
G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
switch (cur_char) {
case 'r':
cur_red = shift_color(cur_red, -shift_incr);
Expand All @@ -193,7 +193,7 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
cur_blu = shift_color(cur_blu, shift_incr);
break;
}
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
WRITE_STATUS;
Expand All @@ -207,25 +207,25 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
WRITE_STATUS;
break;
case '+':
G_shift_colors(1, colors);
Rast_shift_colors(1, colors);
if (hi_mode) {
cur_red = red_hi;
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
WRITE_STATUS;
break;
case '-':
G_shift_colors(-1, colors);
Rast_shift_colors(-1, colors);
if (hi_mode) {
cur_red = red_hi;
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
WRITE_STATUS;
Expand All @@ -245,14 +245,14 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
break;
case 'h':
case 'H':
if (hi_mode) {
G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
hi_mode = 0;
hi_save_mode = 0;
}
Expand All @@ -262,7 +262,7 @@ interact(struct Categories *categories, struct Colors *colors, char *name,
cur_blu = blu_hi;
hi_mode = 1;
if (cur_char == 'H') {
G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
hi_save_mode = 1;
colors_changed = 1;
}
Expand Down Expand Up @@ -319,7 +319,7 @@ static int save_colors(char *name, char *mapset, struct Colors *colors)
Clear_message();
Write_message(2, "Writing color table ");

if (G_write_colors(name, mapset, colors) == -1) {
if (Rast_write_colors(name, mapset, colors) == -1) {
G_sleep(1);
Write_message(2, "Can't write color table ");
G_sleep(2);
Expand Down
2 changes: 1 addition & 1 deletion display/d.colors/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char **argv)
G_fatal_error(msg);
}

if (G_raster_map_is_fp(map->answer, mapset)) {
if (Rast_raster_map_is_fp(map->answer, mapset)) {
sprintf(buff,
"Raster file [%s] is floating point! \nd.colors only works with integer maps",
map->answer);
Expand Down
16 changes: 8 additions & 8 deletions display/d.colors/tbl_toggle.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ int table_toggle(char *name, char *mapset, struct Colors *colors)
char *msg = '\0';
char info[100];

G_get_color_range(&min, &max, colors);
G_free_colors(colors);
Rast_get_color_range(&min, &max, colors);
Rast_free_colors(colors);
sprintf(info, "Color range: %d to %d\n", min, max);

toggle_number++;
toggle_number &= 6;
switch (toggle_number) {
case 0:
msg = "Original colors";
G_read_colors(name, mapset, colors);
Rast_read_colors(name, mapset, colors);
break;
case 1:
msg = "Ramp colors";
G_make_ramp_colors(colors, min, max);
Rast_make_ramp_colors(colors, min, max);
break;
case 2:
msg = "Grey scale colors";
G_make_grey_scale_colors(colors, min, max);
Rast_make_grey_scale_colors(colors, min, max);
break;
case 3:
msg = "Random colors";
G_make_random_colors(colors, min, max);
Rast_make_random_colors(colors, min, max);
break;
case 4:
msg = "Wave colors";
G_make_wave_colors(colors, min, max);
Rast_make_wave_colors(colors, min, max);
break;
case 5:
msg = "Aspect colors";
G_make_aspect_colors(colors, min, max);
Rast_make_aspect_colors(colors, min, max);
break;
}
Write_message(2, msg);
Expand Down
15 changes: 8 additions & 7 deletions display/d.colortable/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <math.h>
#include <grass/display.h>
#include <grass/gis.h>
#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>

Expand Down Expand Up @@ -96,7 +97,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);

map_name = opt1->answer;
fp = G_raster_map_is_fp(map_name, "");
fp = Rast_raster_map_is_fp(map_name, "");

if (opt2->answer != NULL) {
new_colr = D_translate_color(opt2->answer);
Expand Down Expand Up @@ -128,18 +129,18 @@ int main(int argc, char **argv)
}

/* Make sure map is available */
if (G_read_colors(map_name, "", &colors) == -1)
if (Rast_read_colors(map_name, "", &colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), map_name);
if (G_read_fp_range(map_name, "", &fp_range) == -1)
if (Rast_read_fp_range(map_name, "", &fp_range) == -1)
G_fatal_error(_("Range file for <%s> not available"), map_name);
if (R_open_driver() != 0)
G_fatal_error(_("No graphics device selected"));

D_setup_unity(0);
D_get_src(&t, &b, &l, &r);

G_get_fp_range_min_max(&fp_range, &dmin, &dmax);
if (G_is_d_null_value(&dmin) || G_is_d_null_value(&dmax))
Rast_get_fp_range_min_max(&fp_range, &dmin, &dmax);
if (Rast_is_d_null_value(&dmin) || Rast_is_d_null_value(&dmax))
G_fatal_error("Data range is empty");
cats_num = (int)dmax - (int)dmin + 1;
if (lines <= 0 && cols <= 0) {
Expand Down Expand Up @@ -173,7 +174,7 @@ int main(int argc, char **argv)

white = D_translate_color("white");
black = D_translate_color("black");
G_set_c_null_value(&atcat, 1);
Rast_set_c_null_value(&atcat, 1);
if (!fp) {
for (atcol = 0; atcol < cols; atcol++) {
cur_dot_row = t;
Expand Down Expand Up @@ -250,7 +251,7 @@ int main(int argc, char **argv)
fprintf(stdout, "dots_per_line: %d\n", dots_per_line);
for (r = 0; r < dots_per_line - 6; r++) {
if (r <= 4)
G_set_d_null_value(&dval, 1);
Rast_set_d_null_value(&dval, 1);
else
dval =
dmin + (r - 1) * (dmax - dmin) / (dots_per_line - 6 - 5);
Expand Down
4 changes: 2 additions & 2 deletions display/d.extract/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ int main(int argc, char **argv)
G_fatal_error(_("No graphics device selected"));

color = G_standard_color_rgb(BLACK);
if (G_str_to_color(color_opt->answer, &r, &g, &b)) {
if (Rast_str_to_color(color_opt->answer, &r, &g, &b)) {
color.r = r;
color.g = g;
color.b = b;
}

hcolor = G_standard_color_rgb(RED);
if (G_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
if (Rast_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
hcolor.r = r;
hcolor.g = g;
hcolor.b = b;
Expand Down
7 changes: 4 additions & 3 deletions display/d.graph/do_graph.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/symbol.h>
Expand Down Expand Up @@ -99,7 +100,7 @@ int do_color(const char *str)
}

/* Parse and select color */
color = G_str_to_color(in_color, &R, &G, &B);
color = Rast_str_to_color(in_color, &R, &G, &B);
if (color == 0) {
G_warning(_("[%s]: No such color"), in_color);
/* store for backup */
Expand Down Expand Up @@ -339,7 +340,7 @@ int do_symbol(const char *str)
size *= yincr;

/* parse line color */
ret = G_str_to_color(line_color_str, &R, &G, &B);
ret = Rast_str_to_color(line_color_str, &R, &G, &B);
line_color->r = (unsigned char)R;
line_color->g = (unsigned char)G;
line_color->b = (unsigned char)B;
Expand All @@ -356,7 +357,7 @@ int do_symbol(const char *str)
}

/* parse fill color */
ret = G_str_to_color(fill_color_str, &R, &G, &B);
ret = Rast_str_to_color(fill_color_str, &R, &G, &B);
fill_color->r = (unsigned char)R;
fill_color->g = (unsigned char)G;
fill_color->b = (unsigned char)B;
Expand Down
1 change: 1 addition & 0 deletions display/d.graph/graphics.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
#include <grass/Rast.h>
#include <grass/glocale.h>

#include "local_proto.h"
Expand Down
3 changes: 2 additions & 1 deletion display/d.graph/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
Expand Down Expand Up @@ -100,7 +101,7 @@ int main(int argc, char **argv)

/* Parse and select color */
if (opt2->answer != NULL) {
color = G_str_to_color(opt2->answer, &R, &G, &B);
color = Rast_str_to_color(opt2->answer, &R, &G, &B);

if (color == 0)
G_fatal_error(_("[%s]: No such color"), opt2->answer);
Expand Down
Loading

0 comments on commit 2f7a383

Please sign in to comment.