35 #define INIT_MINMAX(p, nm, size, min, max, found) \
39 if (!BM_GET_BYOFFSET(nm, size)) { \
50 #define SET_MINMAX(p, nm, size, min, max) \
53 if (!BM_GET_BYOFFSET(nm, size)) { \
57 else if (*p > max) { \
66 #define NO_DATA_COL 0xffffff
88 return G_distance(from[0], from[1], to[0], to[1]);
110 float *buff,
struct BM *nullmap,
int *has_null)
114 int offset, row, col;
116 G_debug(3,
"Gs_loadmap_as_float(): name=%s", map_name);
120 G_warning(
_(
"Raster map <%s> not found"), map_name);
128 G_message(
_(
"Loading raster map <%s>..."), mname);
130 for (row = 0; row < wind->
rows; row++) {
131 offset = row * wind->
cols;
136 for (col = 0; col < wind->
cols; col++) {
139 BM_set(nullmap, col, row, 1);
146 G_debug(4,
" has_null=%d", *has_null);
175 struct BM *nullmap,
int *has_null)
179 int offset, row, col;
181 G_debug(3,
"Gs_loadmap_as_int");
185 G_warning(
_(
"Raster map <%s> not found"), map_name);
193 G_message(
_(
"Loading raster map <%s>..."), mname);
195 for (row = 0; row < wind->
rows; row++) {
196 offset = row * wind->
cols;
201 for (col = 0; col < wind->
cols; col++) {
204 BM_set(nullmap, col, row, 1);
232 int shortbits, charbits, bitplace;
233 static int max_short, max_char;
234 static int first = 1;
237 max_short = max_char = 1;
238 shortbits = 8 *
sizeof(short);
240 for (bitplace = 1; bitplace < shortbits; ++bitplace) {
248 charbits = 8 *
sizeof(
unsigned char);
250 for (bitplace = 0; bitplace < charbits; ++bitplace) {
261 G_warning(
_(
"Raster map <%s> not found"), filename);
266 G_debug(3,
"Gs_numtype(): fp map detected");
276 *negflag = (
min < 0);
278 if (max < max_char && min > 0) {
282 if (max < max_short && min > -max_short) {
310 short *buff,
struct BM *nullmap,
int *has_null)
315 int offset, row, col, val, max_short, overflow, shortsize, bitplace;
318 G_debug(3,
"Gs_loadmap_as_short");
321 shortsize = 8 *
sizeof(short);
325 for (max_short = bitplace = 1; bitplace < shortsize; ++bitplace) {
333 G_warning(
_(
"Raster map <%s> not found"), map_name);
346 G_message(
_(
"Loading raster map <%s>..."), mname);
348 for (row = 0; row < wind->
rows; row++) {
349 offset = row * wind->
cols;
354 ts = &(buff[offset]);
357 for (col = 0; col < wind->
cols; col++) {
360 BM_set(nullmap, col, row, 1);
364 if (abs(val) > max_short) {
368 *ts = (short)(max_short * val / abs(val));
386 return (overflow ? -2 : 1);
416 unsigned char *buff,
struct BM *nullmap,
int *has_null)
421 int offset, row, col, val, max_char, overflow, charsize, bitplace;
424 G_debug(3,
"Gs_loadmap_as_char");
427 charsize = 8 *
sizeof(
unsigned char);
432 for (bitplace = 0; bitplace < charsize; ++bitplace) {
440 G_warning(
_(
"Raster map <%s> not found"), map_name);
453 G_message(
_(
"Loading raster map <%s>..."), mname);
455 for (row = 0; row < wind->
rows; row++) {
456 offset = row * wind->
cols;
458 tc = (
unsigned char *)&(buff[offset]);
463 for (col = 0; col < wind->
cols; col++) {
466 BM_set(nullmap, col, row, 1);
470 if (val > max_char) {
472 *tc = (
unsigned char)max_char;
479 *tc = (
unsigned char)val;
494 return (overflow ? -2 : 1);
524 G_debug(3,
"Gs_loadmap_as_bitmap");
528 G_warning(
_(
"Raster map <%s> not found"), map_name);
540 G_message(
_(
"Loading raster map <%s>..."), mname);
542 for (row = 0; row < wind->
rows; row++) {
545 for (col = 0; col < wind->
cols; col++) {
548 BM_set(buff, col, row, 1);
551 BM_set(buff, col, row, 0);
582 unsigned char r[256],
g[256],
b[256], set[256];
584 G_debug(3,
"building color table");
588 G_warning(
_(
"Raster map <%s> not found"), filename);
595 if (min < 0 || max > 255) {
597 _(
"Color table range doesn't match data (mincol=%d, maxcol=%d"),
606 for (i =
min; i <=
max; i++) {
612 for (i = 0; i < 256; i++) {
616 (
r[i] & 0xff) | ((
g[i] & 0xff) << 8) | ((
b[i] & 0xff) << 16);
641 unsigned char *
r, *
g, *
b, *set;
646 G_warning(
_(
"Raster map <%s> not found"), filename);
653 set = (
unsigned char *)
G_malloc(cols);
660 G_message(
_(
"Translating colors from raster map <%s>..."), mname);
662 for (i = 0; i < rows; i++) {
666 for (j = 0; j < cols; j++) {
668 cur[j] = (
r[j] & 0xff) | ((
g[j] & 0xff) << 8) |
669 ((
b[j] & 0xff) << 16);
710 unsigned char *
r, *
g, *
b, *set;
716 G_warning(
_(
"Raster map <%s> not found"), filename);
723 set = (
unsigned char *)
G_malloc(cols);
731 G_message(
_(
"Translating colors from raster map <%s>..."), mname);
733 for (i = 0; i < rows; i++) {
737 for (j = 0; j < cols; j++) {
739 icur[j] = (
r[j] & 0xff) | ((
g[j] & 0xff) << 8) |
740 ((
b[j] & 0xff) << 16);
747 icur = &(icur[cols]);
748 fcur = &(fcur[cols]);
786 G_warning(
_(
"Raster map <%s> not found"), filename);
802 sprintf(catstr,
"(%d) %s", buf[dcol],
815 sprintf(catstr,
"(NULL) %s",
819 sprintf(catstr,
"(%g) %s", dbuf[dcol],
827 strcpy(catstr,
"no category label");
864 if (mapset !=
NULL) {
960 if (mapset !=
NULL) {
965 if (strcmp((v.
pgm_id),
"Nvision-ALPHA!")) {
967 "there may be some inconsistencies"));
1035 (
int)(v.
fov > 0 ? v.
fov * 10. + 0.5 : v.
fov * 10. - 0.5));
1115 size = (size_t)gs->
rows * gs->
cols;
1124 size = (size_t)gs->
rows * gs->
cols;
1131 size = (size_t)gs->
rows * gs->
cols;
1140 size = (size_t)gs->
rows * gs->
cols;
1147 size = (size_t)gs->
rows * gs->
cols;
1156 size = (size_t)gs->
rows * gs->
cols;
1163 size = (size_t)gs->
rows * gs->
cols;
1172 size = (size_t)gs->
rows * gs->
cols;
1192 G_debug(3,
"Gs_update_attrange(): min=%f max=%f", gs->
zmin, gs->
zmax);
int BM_set(struct BM *, int, int, int)
Sets bitmap value to 'val' at location 'x' 'y'.
void G_percent(long, long, int)
Print percent complete messages.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
const char * G_find_file2(const char *, const char *, const char *)
Searches for a file from the mapset search list or in a specified mapset. (look but don't touch)
void G_warning(const char *,...) __attribute__((format(printf
int G_get_3dview(const char *, const char *, struct G_3dview *)
Gets a 3D View.
const char * G_find_raster2(const char *, const char *)
Find a raster map (look but don't touch)
const char * G_mapset(void)
Get current mapset name.
int G_put_3dview(const char *, const struct G_3dview *, const struct Cell_head *)
Saves info to a 3d.view file in the current mapset.
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
double G_distance(double, double, double, double)
Returns distance in meters.
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int G_get_3dview_defaults(struct G_3dview *, struct Cell_head *)
Sets default for v based on w.
int int G_begin_distance_calculations(void)
Begin distance calculations.
void GS_v3mult(float *, float)
Multiple vectors.
void GS_set_fov(int)
Set field of view.
void GS_alldraw_wire(void)
Draw all wires.
typbuff * gsds_get_typbuff(int, IFLAG)
Get data buffer.
int GS_get_zrange(float *, float *, int)
Get z-extent for all loaded surfaces.
int GS_setall_drawmode(int)
Set all draw-modes.
int gs_get_att_src(geosurf *, int)
Get attribute source.
void GS_set_focus(float *)
Set focus.
void GS_set_twist(int)
Set viewpoint twist value.
void GS_v3eq(float *, float *)
Copy vector values.
int GS_setall_drawres(int, int, int, int)
Set all draw resolutions.
void GS_set_global_exag(float)
Set global z-exag value.
void GS_moveto_real(float *)
Move position to (real)
int gsds_get_changed(int)
ADD.
void gsd_model2real(Point3)
Convert model to real coordinates.
void Rast_free_cats(struct Categories *)
Free category structure memory.
int Rast_read_colors(const char *, const char *, struct Colors *)
Read color table of raster map.
int Rast_read_cats(const char *, const char *, struct Categories *)
Read raster category file.
#define Rast_is_f_null_value(fcellVal)
void Rast_lookup_f_colors(const FCELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
Lookup an array of colors (FCELL)
void Rast_close(int)
Close a raster map.
int Rast_open_old(const char *, const char *)
Open an existing integer raster map (cell)
void Rast_free_colors(struct Colors *)
Free color structure memory.
void Rast_get_c_row(int, CELL *, int)
Get raster row (CELL type)
CELL * Rast_allocate_c_buf(void)
Allocate memory for a CELL type raster map.
void Rast_get_f_row(int, FCELL *, int)
Get raster row (FCELL type)
void Rast_get_d_row(int, DCELL *, int)
Get raster row (DCELL type)
void Rast_get_c_color_range(CELL *, CELL *, const struct Colors *)
Get color range values (CELL)
void Rast_get_range_min_max(const struct Range *, CELL *, CELL *)
Get range min and max.
DCELL * Rast_allocate_d_buf(void)
Allocates memory for a raster map of type DCELL.
int Rast_read_range(const char *, const char *, struct Range *)
Read raster range (CELL)
char * Rast_get_c_cat(CELL *, struct Categories *)
Get a raster category label (CELL)
char * Rast_get_d_cat(DCELL *, struct Categories *)
Get a raster category label (DCELL)
int Rast_map_is_fp(const char *, const char *)
Check if raster map is floating-point.
#define Rast_is_d_null_value(dcellVal)
#define Rast_is_c_null_value(cellVal)
void Rast_lookup_c_colors(const CELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
Lookup an array of colors.
RASTER_MAP_TYPE Rast_get_map_type(int)
Determine raster type from descriptor.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int Gs_loadmap_as_short(struct Cell_head *wind, const char *map_name, short *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
int Gs_loadmap_as_bitmap(struct Cell_head *wind, const char *map_name, struct BM *buff)
Load raster map as integer map.
int Gs_save_3dview(const char *vname, geoview *gv, geodisplay *gd UNUSED, struct Cell_head *w, geosurf *defsurf)
Save 3dview.
int Gs_numtype(const char *filename, int *negflag)
Get map data type.
void Gs_pack_colors(const char *filename, int *buff, int rows, int cols)
Pack color table.
void Gs_pack_colors_float(const char *filename, float *fbuf, int *ibuf, int rows, int cols)
Pack color table (floating-point map)
#define INIT_MINMAX(p, nm, size, min, max, found)
Used in the function Gs_update_attrange()
int Gs_load_3dview(const char *vname, geoview *gv, geodisplay *gd UNUSED, struct Cell_head *w, const geosurf *defsurf)
Load 3dview.
int Gs_loadmap_as_char(struct Cell_head *wind, const char *map_name, unsigned char *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
int Gs_loadmap_as_float(struct Cell_head *wind, const char *map_name, float *buff, struct BM *nullmap, int *has_null)
Load raster map as floating point map.
int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
Get categories/labels.
#define SET_MINMAX(p, nm, size, min, max)
Used in the function Gs_update_attrange()
double Gs_distance(double *from, double *to)
Calculates distance in METERS between two points in current projection (2D)
int Gs_build_256lookup(const char *filename, int *buff)
Build color table (256)
int Gs_update_attrange(geosurf *gs, int desc)
Update no_zero ranges for attribute (actually no_null now)
int Gs_loadmap_as_int(struct Cell_head *wind, const char *map_name, int *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
2D/3D raster map header (used also for region)
double ew_res
Resolution - east to west cell size for 2D data.
double ns_res
Resolution - north to south cell size for 2D data.
int rows
Number of rows for 2D data.
int cols
Number of columns for 2D data.
double south
Extent coordinates (south)
double west
Extent coordinates (west)
struct lightdefs lights[MAX_LIGHTS]