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);
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);
174 struct BM *nullmap,
int *has_null)
178 int offset, row, col;
180 G_debug(3,
"Gs_loadmap_as_int");
184 G_warning(
_(
"Raster map <%s> not found"), map_name);
194 for (row = 0; row < wind->
rows; row++) {
195 offset = row * wind->
cols;
200 for (col = 0; col < wind->
cols; col++) {
203 BM_set(nullmap, col, row, 1);
230 int shortbits, charbits, bitplace;
231 static int max_short, max_char;
232 static int first = 1;
235 max_short = max_char = 1;
236 shortbits = 8 *
sizeof(short);
238 for (bitplace = 1; bitplace < shortbits; ++bitplace) {
246 charbits = 8 *
sizeof(
unsigned char);
248 for (bitplace = 0; bitplace < charbits; ++bitplace) {
259 G_warning(
_(
"Raster map <%s> not found"), filename);
264 G_debug(3,
"Gs_numtype(): fp map detected");
274 *negflag = (
min < 0);
276 if (max < max_char && min > 0) {
280 if (max < max_short && min > -max_short) {
308 short *buff,
struct BM *nullmap,
int *has_null)
313 int offset, row, col, val, max_short, overflow, shortsize, bitplace;
316 G_debug(3,
"Gs_loadmap_as_short");
319 shortsize = 8 *
sizeof(short);
323 for (max_short = bitplace = 1; bitplace < shortsize; ++bitplace) {
331 G_warning(
_(
"Raster map <%s> not found"), map_name);
346 for (row = 0; row < wind->
rows; row++) {
347 offset = row * wind->
cols;
352 ts = &(buff[offset]);
355 for (col = 0; col < wind->
cols; col++) {
358 BM_set(nullmap, col, row, 1);
362 if (abs(val) > max_short) {
366 *ts = (short)(max_short * val / abs(val));
383 return (overflow ? -2 : 1);
413 unsigned char *buff,
struct BM *nullmap,
int *has_null)
418 int offset, row, col, val, max_char, overflow, charsize, bitplace;
421 G_debug(3,
"Gs_loadmap_as_char");
424 charsize = 8 *
sizeof(
unsigned char);
429 for (bitplace = 0; bitplace < charsize; ++bitplace) {
437 G_warning(
_(
"Raster map <%s> not found"), map_name);
452 for (row = 0; row < wind->
rows; row++) {
453 offset = row * wind->
cols;
455 tc = (
unsigned char *)&(buff[offset]);
460 for (col = 0; col < wind->
cols; col++) {
463 BM_set(nullmap, col, row, 1);
467 if (val > max_char) {
469 *tc = (
unsigned char)max_char;
476 *tc = (
unsigned char)val;
490 return (overflow ? -2 : 1);
520 G_debug(3,
"Gs_loadmap_as_bitmap");
524 G_warning(
_(
"Raster map <%s> not found"), map_name);
538 for (row = 0; row < wind->
rows; row++) {
541 for (col = 0; col < wind->
cols; col++) {
544 BM_set(buff, col, row, 1);
547 BM_set(buff, col, row, 0);
577 unsigned char r[256],
g[256],
b[256], set[256];
579 G_debug(3,
"building color table");
583 G_warning(
_(
"Raster map <%s> not found"), filename);
590 if (min < 0 || max > 255) {
592 _(
"Color table range doesn't match data (mincol=%d, maxcol=%d"),
601 for (i =
min; i <=
max; i++) {
607 for (i = 0; i < 256; i++) {
611 (
r[i] & 0xff) | ((
g[i] & 0xff) << 8) | ((
b[i] & 0xff) << 16);
636 unsigned char *
r, *
g, *
b, *set;
641 G_warning(
_(
"Raster map <%s> not found"), filename);
648 set = (
unsigned char *)
G_malloc(cols);
654 G_message(
_(
"Translating colors from raster map <%s>..."),
657 for (i = 0; i < rows; i++) {
661 for (j = 0; j < cols; j++) {
663 cur[j] = (
r[j] & 0xff) | ((
g[j] & 0xff) << 8) |
664 ((
b[j] & 0xff) << 16);
705 unsigned char *
r, *
g, *
b, *set;
711 G_warning(
_(
"Raster map <%s> not found"), filename);
718 set = (
unsigned char *)
G_malloc(cols);
725 G_message(
_(
"Translating colors from raster map <%s>..."),
728 for (i = 0; i < rows; i++) {
732 for (j = 0; j < cols; j++) {
734 icur[j] = (
r[j] & 0xff) | ((
g[j] & 0xff) << 8) |
735 ((
b[j] & 0xff) << 16);
742 icur = &(icur[cols]);
743 fcur = &(fcur[cols]);
780 G_warning(
_(
"Raster map <%s> not found"), filename);
796 sprintf(catstr,
"(%d) %s", buf[dcol],
809 sprintf(catstr,
"(NULL) %s",
813 sprintf(catstr,
"(%g) %s", dbuf[dcol],
821 strcpy(catstr,
"no category label");
858 if (mapset !=
NULL) {
954 if (mapset !=
NULL) {
959 if (strcmp((v.
pgm_id),
"Nvision-ALPHA!")) {
961 "there may be some inconsistancies"));
1029 (
int)(v.
fov > 0 ? v.
fov * 10. + 0.5 : v.
fov * 10. - 0.5));
1109 size = (size_t)gs->
rows * gs->
cols;
1118 size = (size_t)gs->
rows * gs->
cols;
1125 size = (size_t)gs->
rows * gs->
cols;
1134 size = (size_t)gs->
rows * gs->
cols;
1141 size = (size_t)gs->
rows * gs->
cols;
1150 size = (size_t)gs->
rows * gs->
cols;
1157 size = (size_t)gs->
rows * gs->
cols;
1166 size = (size_t)gs->
rows * gs->
cols;
1186 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]