35 #define INIT_MINMAX(p, nm, size, min, max, found) \ 40 if (!BM_GET_BYOFFSET(nm, size)) \ 52 #define SET_MINMAX(p, nm, size, min, max) \ 56 if (!BM_GET_BYOFFSET(nm, size)) \ 72 #define NO_DATA_COL 0xffffff 93 return G_distance(from[0], from[1], to[0], to[1]);
115 float *buff,
struct BM *nullmap,
int *has_null)
119 int offset, row, col;
121 G_debug(3,
"Gs_loadmap_as_float(): name=%s", map_name);
125 G_warning(
_(
"Raster map <%s> not found"), map_name);
135 for (row = 0; row < wind->
rows; row++) {
136 offset = row * wind->
cols;
141 for (col = 0; col < wind->
cols; col++) {
144 BM_set(nullmap, col, row, 1);
151 G_debug(4,
" has_null=%d", *has_null);
179 struct BM *nullmap,
int *has_null)
183 int offset, row, col;
185 G_debug(3,
"Gs_loadmap_as_int");
189 G_warning(
_(
"Raster map <%s> not found"), map_name);
199 for (row = 0; row < wind->
rows; row++) {
200 offset = row * wind->
cols;
205 for (col = 0; col < wind->
cols; col++) {
208 BM_set(nullmap, col, row, 1);
235 int shortbits, charbits, bitplace;
236 static int max_short, max_char;
237 static int first = 1;
240 max_short = max_char = 1;
241 shortbits = 8 *
sizeof(short);
243 for (bitplace = 1; bitplace < shortbits; ++bitplace) {
251 charbits = 8 *
sizeof(
unsigned char);
253 for (bitplace = 0; bitplace < charbits; ++bitplace) {
264 G_warning(
_(
"Raster map <%s> not found"), filename);
269 G_debug(3,
"Gs_numtype(): fp map detected");
279 *negflag = (
min < 0);
281 if (max < max_char && min > 0) {
285 if (max < max_short && min > -max_short) {
313 short *buff,
struct BM *nullmap,
int *has_null)
318 int offset, row, col, val, max_short, overflow, shortsize, bitplace;
321 G_debug(3,
"Gs_loadmap_as_short");
324 shortsize = 8 *
sizeof(short);
328 for (max_short = bitplace = 1; bitplace < shortsize; ++bitplace) {
336 G_warning(
_(
"Raster map <%s> not found"), map_name);
351 for (row = 0; row < wind->
rows; row++) {
352 offset = row * wind->
cols;
357 ts = &(buff[offset]);
360 for (col = 0; col < wind->
cols; col++) {
363 BM_set(nullmap, col, row, 1);
367 if (abs(val) > max_short) {
371 *ts = (short)(max_short * val / abs(val));
388 return (overflow ? -2 : 1);
418 unsigned char *buff,
struct BM *nullmap,
int *has_null)
423 int offset, row, col, val, max_char, overflow, charsize, bitplace;
426 G_debug(3,
"Gs_loadmap_as_char");
429 charsize = 8 *
sizeof(
unsigned char);
434 for (bitplace = 0; bitplace < charsize; ++bitplace) {
442 G_warning(
_(
"Raster map <%s> not found"), map_name);
457 for (row = 0; row < wind->
rows; row++) {
458 offset = row * wind->
cols;
460 tc = (
unsigned char *)&(buff[offset]);
465 for (col = 0; col < wind->
cols; col++) {
468 BM_set(nullmap, col, row, 1);
472 if (val > max_char) {
474 *tc = (
unsigned char)max_char;
481 *tc = (
unsigned char)val;
495 return (overflow ? -2 : 1);
525 G_debug(3,
"Gs_loadmap_as_bitmap");
529 G_warning(
_(
"Raster map <%s> not found"), map_name);
543 for (row = 0; row < wind->
rows; row++) {
546 for (col = 0; col < wind->
cols; col++) {
549 BM_set(buff, col, row, 1);
552 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) {
596 G_warning(
_(
"Color table range doesn't match data (mincol=%d, maxcol=%d"),
599 min = min < 0 ? 0 :
min;
600 max = max > 255 ? 255 :
max;
605 for (i = min; i <=
max; i++) {
611 for (i = 0; i < 256; i++) {
615 (r[i] & 0xff) | ((g[i] & 0xff) << 8) | ((b[i] & 0xff) << 16);
640 unsigned char *
r, *
g, *
b, *
set;
645 G_warning(
_(
"Raster map <%s> not found"), filename);
649 r = (
unsigned char *)
G_malloc(cols);
650 g = (
unsigned char *)
G_malloc(cols);
651 b = (
unsigned char *)
G_malloc(cols);
652 set = (
unsigned char *)
G_malloc(cols);
658 G_message(
_(
"Translating colors from raster map <%s>..."),
661 for (i = 0; i < rows; i++) {
665 for (j = 0; j < cols; j++) {
668 (r[j] & 0xff) | ((g[j] & 0xff) << 8) | ((b[j] & 0xff) <<
710 unsigned char *
r, *
g, *
b, *
set;
716 G_warning(
_(
"Raster map <%s> not found"), filename);
720 r = (
unsigned char *)
G_malloc(cols);
721 g = (
unsigned char *)
G_malloc(cols);
722 b = (
unsigned char *)
G_malloc(cols);
723 set = (
unsigned char *)
G_malloc(cols);
730 G_message(
_(
"Translating colors from raster map <%s>..."),
733 for (i = 0; i < rows; i++) {
737 for (j = 0; j < cols; j++) {
740 (r[j] & 0xff) | ((g[j] & 0xff) << 8) | ((b[j] & 0xff) <<
748 icur = &(icur[cols]);
749 fcur = &(fcur[cols]);
786 G_warning(
_(
"Raster map <%s> not found"), filename);
799 sprintf(catstr,
"(NULL) %s",
803 sprintf(catstr,
"(%d) %s", buf[dcol],
816 sprintf(catstr,
"(NULL) %s",
820 sprintf(catstr,
"(%g) %s", dbuf[dcol],
828 strcpy(catstr,
"no category label");
865 if (mapset !=
NULL) {
931 strcpy((v.
pgm_id),
"Nvision-ALPHA!");
960 if (mapset !=
NULL) {
965 if (strcmp((v.
pgm_id),
"Nvision-ALPHA!")) {
967 "there may be some inconsistancies"));
1034 (v.
fov > 0 ? v.
fov * 10. + 0.5 : v.
fov * 10. - 0.5));
1119 size = (size_t)gs->
rows * gs->
cols;
1128 size = (size_t)gs->
rows * gs->
cols;
1135 size = (size_t)gs->
rows * gs->
cols;
1144 size = (size_t)gs->
rows * gs->
cols;
1151 size = (size_t)gs->
rows * gs->
cols;
1160 size = (size_t)gs->
rows * gs->
cols;
1167 size = (size_t)gs->
rows * gs->
cols;
1176 size = (size_t)gs->
rows * gs->
cols;
1196 G_debug(3,
"Gs_update_attrange(): min=%f max=%f", gs->
zmin, gs->
zmax);
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) ...
typbuff * gsds_get_typbuff(int, IFLAG)
Get data buffer.
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 G_get_3dview(const char *, const char *, struct G_3dview *)
Gets a 3D View.
2D/3D raster map header (used also for region)
void GS_set_focus(float *)
Set focus.
#define Rast_is_d_null_value(dcellVal)
int BM_set(struct BM *, int, int, int)
Sets bitmap value to 'val' at location 'x' 'y'.
int Gs_update_attrange(geosurf *gs, int desc)
Update no_zero ranges for attribute (actually no_null now)
double west
Extent coordinates (west)
int gs_get_att_src(geosurf *, int)
Get attribute source.
int Gs_build_256lookup(const char *filename, int *buff)
Build color table (256)
int G_put_3dview(const char *, const char *, const struct G_3dview *, const struct Cell_head *)
Saves info to a 3d.view file.
void Rast_get_d_row(int, DCELL *, int)
Get raster row (DCELL type)
void G_free(void *)
Free allocated memory.
#define INIT_MINMAX(p, nm, size, min, max, found)
Used in the function Gs_update_attrange()
int GS_setall_drawres(int, int, int, int)
Set all draw resolutions.
int gsds_get_changed(int)
ADD.
#define Rast_is_f_null_value(fcellVal)
void Gs_pack_colors(const char *filename, int *buff, int rows, int cols)
Pack color table.
int Rast_read_range(const char *, const char *, struct Range *)
Read raster range (CELL)
int GS_setall_drawmode(int)
Set all draw-modes.
void GS_moveto_real(float *)
Move position to (real)
void GS_alldraw_wire(void)
Draw all wires.
void G_message(const char *,...) __attribute__((format(printf
void Rast_get_c_row(int, CELL *, int)
Get raster row (CELL type)
double Gs_distance(double *from, double *to)
Calculates distance in METERS between two points in current projection (2D)
char * Rast_get_c_cat(CELL *, struct Categories *)
Get a raster category label (CELL)
DCELL * Rast_allocate_d_buf(void)
Allocates memory for a raster map of type DCELL.
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
int Gs_loadmap_as_bitmap(struct Cell_head *wind, const char *map_name, struct BM *buff)
Load raster map as integer map.
char * Rast_get_d_cat(DCELL *, struct Categories *)
Get a raster category label (DCELL)
double south
Extent coordinates (south)
void GS_set_twist(int)
Set viewpoint twist value.
void Rast_free_colors(struct Colors *)
Free color structure memory.
void Gs_pack_colors_float(const char *filename, float *fbuf, int *ibuf, int rows, int cols)
Pack color table (floating-point map)
int Rast_open_old(const char *, const char *)
Open an existing integer raster map (cell)
int G_get_3dview_defaults(struct G_3dview *, struct Cell_head *)
Sets default for v based on w.
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.
int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
Get categories/labels.
void G_percent(long, long, int)
Print percent complete messages.
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 int G_begin_distance_calculations(void)
Begin distance calculations.
int cols
Number of columns for 2D data.
void GS_v3eq(float *, float *)
Copy vector values.
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 Rast_read_cats(const char *, const char *, struct Categories *)
Read raster category file.
double ns_res
Resolution - north to south cell size for 2D data.
const char * G_mapset(void)
Get current mapset name.
int Rast_read_colors(const char *, const char *, struct Colors *)
Read color table of raster map.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void Rast_get_c_color_range(CELL *, CELL *, const struct Colors *)
Get color range values (CELL)
void G_warning(const char *,...) __attribute__((format(printf
void Rast_free_cats(struct Categories *)
Free category structure memory.
RASTER_MAP_TYPE Rast_get_map_type(int)
Determine raster type from descriptor.
double G_distance(double, double, double, double)
Returns distance in meters.
const char * G_find_raster2(const char *, const char *)
Find a raster map (look but don't touch)
int Gs_numtype(const char *filename, int *negflag)
Get map data type.
int GS_get_zrange(float *, float *, int)
Get z-extent for all loaded surfaces.
int Gs_load_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, const geosurf *defsurf)
Load 3dview.
void gsd_model2real(Point3)
Convert model to real coordinates.
#define SET_MINMAX(p, nm, size, min, max)
Used in the function Gs_update_attrange()
int Gs_save_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Save 3dview.
void Rast_lookup_c_colors(const CELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
Lookup an array of colors.
double ew_res
Resolution - east to west cell size for 2D data.
void GS_set_global_exag(float)
Set global z-exag value.
int rows
Number of rows for 2D data.
#define Rast_is_c_null_value(cellVal)
int G_debug(int, const char *,...) __attribute__((format(printf
CELL * Rast_allocate_c_buf(void)
Allocate memory for a CELL type raster map.
void Rast_close(int)
Close a raster map.
int Rast_map_is_fp(const char *, const char *)
Check if raster map is floating-point.
void GS_v3mult(float *, float)
Multiple vectors.
void Rast_get_range_min_max(const struct Range *, CELL *, CELL *)
Get range min and max.
void Rast_get_f_row(int, FCELL *, int)
Get raster row (FCELL type)
void Rast_lookup_f_colors(const FCELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
Lookup an array of colors (FCELL)
struct lightdefs lights[MAX_LIGHTS]
void GS_set_fov(int)
Set field of view.