12 unsigned char *tmp, *tmp2;
13 int dummy1, dummy2, indexLength, tileIndex;
16 indexLast = lseek(map->
data_fd, (
long)0, SEEK_END);
17 if (indexLast == -1) {
32 Rast3d_error(
"Rast3d_readIndex: error in Rast3d_malloc");
38 if (read(map->
data_fd, tmp, indexLength) != indexLength) {
50 if (indexLength > (
int)
sizeof(
long) * map->
nTiles) {
55 Rast3d_error(
"Rast3d_readIndex: error in Rast3d_malloc");
61 tmp2 = (
unsigned char *)map->
index;
63 if (read(map->
data_fd, tmp2, indexLength) != indexLength) {
74 if (indexLength > (
int)
sizeof(
long) * map->
nTiles)
80 for (tileIndex = 0; tileIndex < map->
nTiles; tileIndex++)
81 if (map->
index[tileIndex] == 0)
82 map->
index[tileIndex] = -1;
93 int indexLength, tileIndex;
111 Rast3d_error(
"Rast3d_flush_index: error in Rast3d_malloc");
115 for (tileIndex = 0; tileIndex < map->
nTiles; tileIndex++)
116 if (map->
index[tileIndex] == -1)
117 map->
index[tileIndex] = 0;
121 indexLength = map->
nTiles *
sizeof(long);
122 if (write(map->
data_fd, tmp, indexLength) != indexLength) {
129 if (!Rast3d_readIndex(map)) {
130 Rast3d_error(
"Rast3d_flush_index: error in Rast3d_readIndex");
139 static long *cmpIndex;
141 static int indexSortCompare(
const void *a,
const void *
b)
143 long offset1, offset2;
145 offset1 = cmpIndex[*((
const long *)a)];
146 offset2 = cmpIndex[*((
const long *)
b)];
148 if (offset1 > offset2)
150 if (offset1 < offset2)
160 int i0, i1, i2, i3, i4, i5, nofElts;
169 Rast3d_error(
"Rast3d_init_index: error in Rast3d_malloc");
174 for (tile = 0; tile < map->
nTiles; tile++)
175 map->
index[tile] = -1;
181 for (tile = 0; tile < map->
nTiles; tile++) {
184 map, tile, &i0, &i1, &i2, &i3, &i4, &i5);
191 if (!Rast3d_readIndex(map)) {
192 Rast3d_error(
"Rast3d_init_index: error in Rast3d_readIndex");
197 if (offsetP ==
NULL) {
198 Rast3d_error(
"Rast3d_init_index: error in Rast3d_malloc");
202 for (tile = 0; tile < map->
nTiles; tile++)
203 offsetP[tile] = tile;
204 cmpIndex = map->
index;
205 qsort(offsetP, map->
nTiles,
sizeof(
long), indexSortCompare);
207 for (tile = 0; tile < map->
nTiles - 1; tile++) {
208 if (map->
index[offsetP[tile]] == -1) {
214 map->
index[offsetP[tile + 1]] - map->
index[offsetP[tile]];
void Rast3d_free(void *)
Same as free (ptr).
void Rast3d_long_decode(unsigned char *, long *, int, int)
int Rast3d_compute_clipped_tile_dimensions(RASTER3D_Map *, int, int *, int *, int *, int *, int *, int *)
Computes the dimensions of the tile when clipped to fit the region of map. The clipped dimensions are...
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_long_encode(long *, unsigned char *, int)
void Rast3d_rle_decode(char *, char *, int, int, int *, int *)
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
int Rast3d_flush_index(RASTER3D_Map *map)
int Rast3d_init_index(RASTER3D_Map *map, int hasIndex)
#define RASTER3D_WRITE_DATA