forked from nohal/libbsb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsb.h
132 lines (117 loc) · 3.76 KB
/
bsb.h
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
#ifndef BSB_INCLUDED
#define BSB_INCLUDED
/*
* bsb.h - libbsb types and functions
*
* Copyright (C) 2000 Stuart Cunningham <stuart_hc@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: bsb.h,v 1.14 2007/02/18 06:12:50 mikrom Exp $
*
*/
#include <stdio.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
// not ISO C99 - use best guess instead
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#endif
#define BSB_MAX_REFS 200
#define BSB_MAX_PLYS 20
#define BSB_MAX_AFTS 20
typedef struct BSBImage
{
char name[200];
char projection[50];
char datum[50];
char depth;
float version;
int width;
int height;
double xresolution;
double yresolution;
double scale;
/* usually 'scale given at latitude' with mercator projection */
double projectionparam;
uint8_t red[256];
uint8_t green[256];
uint8_t blue[256];
char num_colors;
/* geo reference points */
struct REF
{
int id;
int x;
int y;
double lon;
double lat;
} ref[BSB_MAX_REFS];
int num_refs;
/* chart border points */
struct PLY
{
int id;
double lat;
double lon;
} ply[BSB_MAX_PLYS];
int num_plys;
/* geotransforms from/to lat/lon & X,Y are polynomials */
/* wpx,wpy - world to pixel */
double wpx[BSB_MAX_AFTS];
int num_wpxs;
int wpx_level;
double wpy[BSB_MAX_AFTS];
int num_wpys;
int wpy_level;
/* pwx,pwy - pixel to world */
double pwx[BSB_MAX_AFTS];
int num_pwxs;
int pwx_level;
double pwy[BSB_MAX_AFTS];
int num_pwys;
int pwy_level;
/* phase change for charts crossing 180 longitude */
double cph;
/* private: */
FILE* pFile;
uint32_t* row_index;
unsigned char* rbuf;
} BSBImage;
#ifdef __cplusplus
extern "C" {
#endif
/* See comments in bsb_io.c for documentation on these functions */
extern int bsb_get_header_size(FILE *fp);
extern int bsb_open_header(char *filename, BSBImage *p);
inline int bsb_open_file(char *filename, BSBImage *p) { return bsb_open_header(filename, p); }
extern int bsb_open_fp(FILE *fp, BSBImage *p);
extern int bsb_seek_to_row(BSBImage *p, int row);
extern int bsb_read_row(BSBImage *p, uint8_t *buf);
extern int bsb_read_row_at(BSBImage *p, int row, uint8_t *buf);
extern int bsb_read_row_part(BSBImage *p, int row, uint8_t *buf, int xoffset, int len);
extern int bsb_LLtoXY(BSBImage *p, double lon, double lat, int* x, int* y);
extern int bsb_LLtoXY_ex(double lon, double lat, int *x, int *y, double cph, double wpx[], double wpy[], int nwp);
extern int bsb_XYtoLL(BSBImage *p, int x, int y, double* lon, double* lat);
extern int bsb_XYtoLL_ex(int x, int y, double *lon, double *lat, double cph, double pwx[], double pwy[], int npw);
extern int bsb_compress_row(BSBImage *p, int row, const uint8_t *pixel, uint8_t *buf);
extern int bsb_write_index(FILE *fp, int height, int index[]);
extern int bsb_close(BSBImage *p);
#ifdef __cplusplus
}
#endif
#endif /* BSB_INCLUDED */