File: blx.h

package info (click to toggle)
gdal 1.10.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,320 kB
  • ctags: 74,726
  • sloc: cpp: 677,199; ansic: 162,820; python: 13,816; cs: 11,163; sh: 10,446; java: 5,279; perl: 4,429; php: 2,971; xml: 1,500; yacc: 934; makefile: 494; sql: 112
file content (147 lines) | stat: -rw-r--r-- 4,875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* libblx - Magellan BLX topo reader/writer library
 *
 * Copyright (c) 2008, Henrik Johansson <henrik@johome.net>
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef _BLX_H_INCLUDED
#define _BLX_H_INCLUDED

#include <stdio.h>

/* Constants */
#define BLX_UNDEF -32768
#define BLX_OVERVIEWLEVELS 4

/* Possible values of ctx.endian */
#define BIGENDIAN 1
#define LITTLEENDIAN 0

/* Data types */

typedef short int blxdata;

struct cellindex_s {
    int offset;	
    unsigned int datasize;       /* Uncompressed size */
    unsigned int compdatasize;   /* Compressed data size */
};

struct blxcontext_s {
    int xsize, ysize;
    int cell_xsize, cell_ysize;
    int cell_cols, cell_rows;
    double lon,lat;
    double pixelsize_lon, pixelsize_lat;

    int zscale;
    int maxchunksize;
    int minval, maxval;

    int endian;

    struct cellindex_s *cellindex;
    
    int debug;

    int fillundef;     /* If non-zero, fillundefval will be used instead of -32768 for undefined values in non-empty cells when
			a cell is written */ 
    int fillundefval; 

    FILE *fh;
    int write;
    int open;
};

typedef struct blxcontext_s blxcontext_t;

struct component_s {
    int n;
    blxdata *lut;
    int dlen;
    blxdata *data;
};

/* Included all functions in the global name space when testing */
#ifdef TEST
#define STATIC
#else
#define STATIC static
#endif

/* Define memory allocation and I/O function macros */
#ifdef GDALDRIVER
#include "cpl_conv.h"
#define BLXfopen VSIFOpen
#define BLXfclose VSIFClose
#define BLXfread VSIFRead
#define BLXfwrite VSIFWrite
#define BLXfseek VSIFSeek
#define BLXftell VSIFTell
#define BLXmalloc VSIMalloc
#define BLXfree CPLFree
#define BLXdebug0(text)              CPLDebug("BLX", text)
#define BLXdebug1(text, arg1)        CPLDebug("BLX", text, arg1)
#define BLXdebug2(text, arg1, arg2)  CPLDebug("BLX", text, arg1, arg2)
#define BLXerror0(text)              CPLError(CE_Failure, CPLE_AppDefined, text)
#define BLXnotice1(text, arg1)       CPLDebug("BLX", text, arg1)
#define BLXnotice2(text, arg1, arg2) CPLDebug("BLX", text, arg1, arg2)
#else
#define BLXfopen fopen
#define BLXfclose fclose
#define BLXfread fread
#define BLXfwrite fwrite
#define BLXfseek fseek
#define BLXftell ftell
#define BLXmalloc malloc
#define BLXfree free
#define BLXdebug0 printf
#define BLXdebug1 printf
#define BLXdebug2 printf
#define BLXerror0 printf
#define BLXnotice1 printf
#define BLXnotice2 printf
#endif

/* Function prototypes */
#ifdef TEST
STATIC int compress_chunk(unsigned char *inbuf, int inlen, unsigned char *outbuf, int outbuflen);
STATIC int uncompress_chunk(unsigned char *inbuf, int inlen, unsigned char *outbuf, int outbuflen);
STATIC blxdata *reconstruct_horiz(blxdata *base, blxdata *diff, unsigned rows, unsigned cols, blxdata *out);
STATIC blxdata *reconstruct_vert(blxdata *base, blxdata *diff, unsigned rows, unsigned cols, blxdata *out);
STATIC void decimate_horiz(blxdata *in, unsigned rows, unsigned cols, blxdata *base, blxdata *diff);
STATIC void decimate_vert(blxdata *in, unsigned int rows, unsigned int cols, blxdata *base, blxdata *diff);
STATIC blxdata *decode_celldata(blxcontext_t *blxcontext, unsigned char *inbuf, int len, int *side, blxdata *outbuf, int outbufsize, int overviewlevel);
#endif

blxcontext_t *blx_create_context(void);
void blx_free_context(blxcontext_t *ctx);
int blxopen(blxcontext_t *ctx, const char *filename, const char *rw);
int blxclose(blxcontext_t *ctx);
void blxprintinfo(blxcontext_t *ctx);
short *blx_readcell(blxcontext_t *ctx, int row, int col, short *buffer, int bufsize, int overviewlevel);
int blx_encode_celldata(blxcontext_t *ctx, blxdata *indata, int side, unsigned char *outbuf, int outbufsize);
int blx_checkheader(char *header);
int blx_writecell(blxcontext_t *ctx, blxdata *cell, int cellrow, int cellcol);

#endif