1 /*
2 
3  rasterlite2_private -- hidden internals
4 
5  version 0.1, 2013 March 29
6 
7  Author: Sandro Furieri a.furieri@lqt.it
8 
9  -----------------------------------------------------------------------------
10 
11  Version: MPL 1.1/GPL 2.0/LGPL 2.1
12 
13  The contents of this file are subject to the Mozilla Public License Version
14  1.1 (the "License"); you may not use this file except in compliance with
15  the License. You may obtain a copy of the License at
16  http://www.mozilla.org/MPL/
17 
18 Software distributed under the License is distributed on an "AS IS" basis,
19 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20 for the specific language governing rights and limitations under the
21 License.
22 
23 The Original Code is the RasterLite2 library
24 
25 The Initial Developer of the Original Code is Alessandro Furieri
26 
27 Portions created by the Initial Developer are Copyright (C) 2013
28 the Initial Developer. All Rights Reserved.
29 
30 Alternatively, the contents of this file may be used under the terms of
31 either the GNU General Public License Version 2 or later (the "GPL"), or
32 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33 in which case the provisions of the GPL or the LGPL are applicable instead
34 of those above. If you wish to allow use of your version of this file only
35 under the terms of either the GPL or the LGPL, and not to allow others to
36 use your version of this file under the terms of the MPL, indicate your
37 decision by deleting the provisions above and replace them with the notice
38 and other provisions required by the GPL or the LGPL. If you do not delete
39 the provisions above, a recipient may use your version of this file under
40 the terms of any one of the MPL, the GPL or the LGPL.
41 
42 */
43 
44 /**
45  \file rasterlite2_private.h
46 
47  RasterLite2 private header file
48  */
49 
50 #include "config.h"
51 
52 /*
53 / the following patch supporting GeoTiff headers
54 / was kindly contributed by Brad Hards on 2011-09-02
55 / for libgaigraphics (the ancestor of librasterlite2)
56 */
57 #ifdef HAVE_GEOTIFF_GEOTIFF_H
58 #include <geotiff/geotiff.h>
59 #include <geotiff/xtiffio.h>
60 #include <geotiff/geo_tiffp.h>
61 #include <geotiff/geo_keyp.h>
62 #include <geotiff/geovalues.h>
63 #include <geotiff/geo_normalize.h>
64 #elif HAVE_LIBGEOTIFF_GEOTIFF_H
65 #include <libgeotiff/geotiff.h>
66 #include <libgeotiff/xtiffio.h>
67 #include <libgeotiff/geo_tiffp.h>
68 #include <libgeotiff/geo_keyp.h>
69 #include <libgeotiff/geovalues.h>
70 #include <libgeotiff/geo_normalize.h>
71 #else
72 #include <geotiff.h>
73 #include <xtiffio.h>
74 #include <geo_tiffp.h>
75 #include <geo_keyp.h>
76 #include <geovalues.h>
77 #include <geo_normalize.h>
78 #endif
79 
80 #ifndef DOXYGEN_SHOULD_SKIP_THIS
81 #ifdef _WIN32
82 #ifdef DLL_EXPORT
83 #define RL2_PRIVATE
84 #else
85 #define RL2_PRIVATE
86 #endif
87 #else
88 #define RL2_PRIVATE __attribute__ ((visibility("hidden")))
89 #endif
90 #endif
91 
92 #ifndef _RASTERLITE2_PRIVATE_H
93 #ifndef DOXYGEN_SHOULD_SKIP_THIS
94 #define _RASTERLITE2_PRIVATE_H
95 #endif
96 
97 #ifdef __cplusplus
98 extern "C"
99 {
100 #endif
101 
102 /* internal binary format markers */
103 #define RL2_ODD_BLOCK_START			0xfa
104 #define RL2_ODD_BLOCK_END			0xf0
105 #define RL2_EVEN_BLOCK_START			0xdb
106 #define RL2_EVEN_BLOCK_END			0xd0
107 #define RL2_LITTLE_ENDIAN			0x01
108 #define RL2_BIG_ENDIAN				0x00
109 #define RL2_PALETTE_START			0xa4
110 #define RL2_PALETTE_END				0xa5
111 #define RL2_DATA_START				0xc8
112 #define RL2_DATA_END				0xc9
113 #define RL2_MASK_START				0xb6
114 #define RL2_MASK_END				0xb7
115 #define RL2_STATS_START				0x27
116 #define RL2_STATS_END				0x2a
117 #define RL2_BAND_STATS_START			0x37
118 #define RL2_BAND_STATS_END			0x3a
119 #define RL2_HISTOGRAM_START			0x47
120 #define RL2_HISTOGRAM_END			0x4a
121 #define RL2_NO_DATA_START			0x03
122 #define RL2_NO_DATA_END				0x23
123 #define RL2_SAMPLE_START			0x06
124 #define RL2_SAMPLE_END				0x26
125 
126 /* internal ColorSpace forced conversions */
127 #define RL2_CONVERT_NO				0x00
128 #define RL2_CONVERT_MONOCHROME_TO_PALETTE	0x01
129 #define RL2_CONVERT_PALETTE_TO_MONOCHROME	0x02
130 #define RL2_CONVERT_RGB_TO_GRAYSCALE 		0x03
131 #define RL2_CONVERT_GRAYSCALE_TO_RGB 		0x04
132 #define RL2_CONVERT_PALETTE_TO_GRAYSCALE	0x05
133 #define RL2_CONVERT_GRAYSCALE_TO_PALETTE	0x06
134 #define RL2_CONVERT_PALETTE_TO_RGB		0x07
135 #define RL2_CONVERT_GRID_INT8_TO_UINT8		0x08
136 #define RL2_CONVERT_GRID_INT8_TO_INT16		0x09
137 #define RL2_CONVERT_GRID_INT8_TO_UINT16		0x0a
138 #define RL2_CONVERT_GRID_INT8_TO_INT32		0x0b
139 #define RL2_CONVERT_GRID_INT8_TO_UINT32		0x0c
140 #define RL2_CONVERT_GRID_INT8_TO_FLOAT		0x0d
141 #define RL2_CONVERT_GRID_INT8_TO_DOUBLE		0x0e
142 #define RL2_CONVERT_GRID_INT16_TO_INT8		0x0f
143 #define RL2_CONVERT_GRID_INT16_TO_UINT8		0x10
144 #define RL2_CONVERT_GRID_INT16_TO_UINT16	0x11
145 #define RL2_CONVERT_GRID_INT16_TO_INT32		0x12
146 #define RL2_CONVERT_GRID_INT16_TO_UINT32	0x13
147 #define RL2_CONVERT_GRID_INT16_TO_FLOAT		0x14
148 #define RL2_CONVERT_GRID_INT16_TO_DOUBLE	0x15
149 #define RL2_CONVERT_GRID_INT32_TO_UINT8		0x16
150 #define RL2_CONVERT_GRID_INT32_TO_INT8		0x17
151 #define RL2_CONVERT_GRID_INT32_TO_UINT16	0x18
152 #define RL2_CONVERT_GRID_INT32_TO_INT16		0x19
153 #define RL2_CONVERT_GRID_INT32_TO_UINT32	0x1a
154 #define RL2_CONVERT_GRID_INT32_TO_FLOAT		0x1b
155 #define RL2_CONVERT_GRID_INT32_TO_DOUBLE	0x1c
156 #define RL2_CONVERT_GRID_UINT8_TO_INT8		0x1d
157 #define RL2_CONVERT_GRID_UINT8_TO_INT16		0x1e
158 #define RL2_CONVERT_GRID_UINT8_TO_UINT16	0x1f
159 #define RL2_CONVERT_GRID_UINT8_TO_INT32		0x20
160 #define RL2_CONVERT_GRID_UINT8_TO_UINT32	0x21
161 #define RL2_CONVERT_GRID_UINT8_TO_FLOAT		0x22
162 #define RL2_CONVERT_GRID_UINT8_TO_DOUBLE	0x23
163 #define RL2_CONVERT_GRID_UINT16_TO_INT8		0x24
164 #define RL2_CONVERT_GRID_UINT16_TO_UINT8	0x25
165 #define RL2_CONVERT_GRID_UINT16_TO_INT16	0x26
166 #define RL2_CONVERT_GRID_UINT16_TO_INT32	0x27
167 #define RL2_CONVERT_GRID_UINT16_TO_UINT32	0x28
168 #define RL2_CONVERT_GRID_UINT16_TO_FLOAT	0x29
169 #define RL2_CONVERT_GRID_UINT16_TO_DOUBLE	0x2a
170 #define RL2_CONVERT_GRID_UINT32_TO_UINT8	0x2b
171 #define RL2_CONVERT_GRID_UINT32_TO_INT8		0x2c
172 #define RL2_CONVERT_GRID_UINT32_TO_UINT16	0x2d
173 #define RL2_CONVERT_GRID_UINT32_TO_INT16	0x2e
174 #define RL2_CONVERT_GRID_UINT32_TO_INT32	0x2f
175 #define RL2_CONVERT_GRID_UINT32_TO_FLOAT	0x30
176 #define RL2_CONVERT_GRID_UINT32_TO_DOUBLE	0x31
177 #define RL2_CONVERT_GRID_FLOAT_TO_UINT8		0x32
178 #define RL2_CONVERT_GRID_FLOAT_TO_INT8		0x33
179 #define RL2_CONVERT_GRID_FLOAT_TO_UINT16	0x34
180 #define RL2_CONVERT_GRID_FLOAT_TO_INT16		0x35
181 #define RL2_CONVERT_GRID_FLOAT_TO_UINT32	0x36
182 #define RL2_CONVERT_GRID_FLOAT_TO_INT32		0x37
183 #define RL2_CONVERT_GRID_FLOAT_TO_DOUBLE	0x38
184 #define RL2_CONVERT_GRID_DOUBLE_TO_UINT8	0x39
185 #define RL2_CONVERT_GRID_DOUBLE_TO_INT8		0x3a
186 #define RL2_CONVERT_GRID_DOUBLE_TO_UINT16	0x3b
187 #define RL2_CONVERT_GRID_DOUBLE_TO_INT16	0x3c
188 #define RL2_CONVERT_GRID_DOUBLE_TO_UINT32	0x3d
189 #define RL2_CONVERT_GRID_DOUBLE_TO_INT32	0x3e
190 #define RL2_CONVERT_GRID_DOUBLE_TO_FLOAT	0x3f
191 
192 /* internal RasterStyle constants */
193 #define RL2_BAND_SELECTION_TRIPLE		0xd1
194 #define RL2_BAND_SELECTION_MONO			0xd2
195 
196     typedef union rl2_priv_sample
197     {
198 	char int8;
199 	unsigned char uint8;
200 	short int16;
201 	unsigned short uint16;
202 	int int32;
203 	unsigned int uint32;
204 	float float32;
205 	double float64;
206     } rl2PrivSample;
207     typedef rl2PrivSample *rl2PrivSamplePtr;
208 
209     typedef struct rl2_priv_pixel
210     {
211 	unsigned char sampleType;
212 	unsigned char pixelType;
213 	unsigned char nBands;
214 	unsigned char isTransparent;
215 	rl2PrivSamplePtr Samples;
216     } rl2PrivPixel;
217     typedef rl2PrivPixel *rl2PrivPixelPtr;
218 
219     typedef struct rl2_priv_palette_entry
220     {
221 	unsigned char red;
222 	unsigned char green;
223 	unsigned char blue;
224     } rl2PrivPaletteEntry;
225     typedef rl2PrivPaletteEntry *rl2PrivPaletteEntryPtr;
226 
227     typedef struct rl2_priv_palette
228     {
229 	unsigned short nEntries;
230 	rl2PrivPaletteEntryPtr entries;
231     } rl2PrivPalette;
232     typedef rl2PrivPalette *rl2PrivPalettePtr;
233 
234     typedef struct rl2_priv_raster
235     {
236 	unsigned char sampleType;
237 	unsigned char pixelType;
238 	unsigned char nBands;
239 	unsigned int width;
240 	unsigned int height;
241 	double minX;
242 	double minY;
243 	double maxX;
244 	double maxY;
245 	int Srid;
246 	double hResolution;
247 	double vResolution;
248 	unsigned char *rasterBuffer;
249 	unsigned char *maskBuffer;
250 	rl2PrivPalettePtr Palette;
251 	rl2PrivPixelPtr noData;
252     } rl2PrivRaster;
253     typedef rl2PrivRaster *rl2PrivRasterPtr;
254 
255     typedef struct rl2_priv_tile
256     {
257 	unsigned short pyramidLevel;
258 	unsigned short sectionRow;
259 	unsigned short sectionColumn;
260 	rl2PrivRasterPtr Raster;
261     } rl2PrivTile;
262     typedef rl2PrivTile *rl2PrivTilePtr;
263 
264     typedef struct rl2_priv_section
265     {
266 	char *sectionName;
267 	unsigned char Compression;
268 	unsigned int tileWidth;
269 	unsigned int tileHeight;
270 	rl2PrivRasterPtr Raster;
271     } rl2PrivSection;
272     typedef rl2PrivSection *rl2PrivSectionPtr;
273 
274     typedef struct rl2_priv_coverage
275     {
276 	char *coverageName;
277 	unsigned char sampleType;
278 	unsigned char pixelType;
279 	unsigned char nBands;
280 	unsigned char Compression;
281 	int Quality;
282 	unsigned int tileWidth;
283 	unsigned int tileHeight;
284 	int Srid;
285 	double hResolution;
286 	double vResolution;
287 	rl2PrivPixelPtr noData;
288     } rl2PrivCoverage;
289     typedef rl2PrivCoverage *rl2PrivCoveragePtr;
290 
291     typedef struct rl2_priv_tiff_origin
292     {
293 	char *path;
294 	char *tfw_path;
295 	int isGeoTiff;
296 	TIFF *in;
297 	int isTiled;
298 	uint32 width;
299 	uint32 height;
300 	uint32 tileWidth;
301 	uint32 tileHeight;
302 	uint32 rowsPerStrip;
303 	uint16 bitsPerSample;
304 	uint16 samplesPerPixel;
305 	uint16 photometric;
306 	uint16 compression;
307 	uint16 sampleFormat;
308 	uint16 planarConfig;
309 	unsigned short maxPalette;
310 	unsigned char *red;
311 	unsigned char *green;
312 	unsigned char *blue;
313 	unsigned short remapMaxPalette;
314 	unsigned char *remapRed;
315 	unsigned char *remapGreen;
316 	unsigned char *remapBlue;
317 	int isGeoReferenced;
318 	int Srid;
319 	double hResolution;
320 	double vResolution;
321 	char *srsName;
322 	char *proj4text;
323 	double minX;
324 	double minY;
325 	double maxX;
326 	double maxY;
327 	unsigned char forced_sample_type;
328 	unsigned char forced_pixel_type;
329 	unsigned char forced_num_bands;
330 	unsigned char forced_conversion;
331     } rl2PrivTiffOrigin;
332     typedef rl2PrivTiffOrigin *rl2PrivTiffOriginPtr;
333 
334     typedef struct rl2_priv_tiff_destination
335     {
336 	char *path;
337 	char *tfw_path;
338 	int isGeoTiff;
339 	TIFF *out;
340 	GTIF *gtif;
341 	void *tiffBuffer;
342 	uint32 width;
343 	uint32 height;
344 	int isTiled;
345 	uint32 tileWidth;
346 	uint32 tileHeight;
347 	uint32 rowsPerStrip;
348 	uint16 bitsPerSample;
349 	uint16 samplesPerPixel;
350 	uint16 photometric;
351 	uint16 compression;
352 	uint16 sampleFormat;
353 	unsigned short maxPalette;
354 	unsigned char *red;
355 	unsigned char *green;
356 	unsigned char *blue;
357 	int isGeoReferenced;
358 	int Srid;
359 	double hResolution;
360 	double vResolution;
361 	char *srsName;
362 	char *proj4text;
363 	double minX;
364 	double minY;
365 	double maxX;
366 	double maxY;
367     } rl2PrivTiffDestination;
368     typedef rl2PrivTiffDestination *rl2PrivTiffDestinationPtr;
369 
370     typedef struct rl2_priv_ascii_origin
371     {
372 	char *path;
373 	FILE *tmp;
374 	unsigned int width;
375 	unsigned int height;
376 	int Srid;
377 	double hResolution;
378 	double vResolution;
379 	double minX;
380 	double minY;
381 	double maxX;
382 	double maxY;
383 	double noData;
384 	unsigned char sample_type;
385     } rl2PrivAsciiOrigin;
386     typedef rl2PrivAsciiOrigin *rl2PrivAsciiOriginPtr;
387 
388     typedef struct rl2_priv_ascii_destination
389     {
390 	char *path;
391 	FILE *out;
392 	unsigned int width;
393 	unsigned int height;
394 	double Resolution;
395 	double X;
396 	double Y;
397 	int isCentered;
398 	double noData;
399 	int decimalDigits;
400 	unsigned int nextLineNo;
401 	char headerDone;
402 	void *pixels;
403 	unsigned char sampleType;
404     } rl2PrivAsciiDestination;
405     typedef rl2PrivAsciiDestination *rl2PrivAsciiDestinationPtr;
406 
407     typedef struct rl2_pool_variance
408     {
409 	double variance;
410 	double count;
411 	struct rl2_pool_variance *next;
412     } rl2PoolVariance;
413     typedef rl2PoolVariance *rl2PoolVariancePtr;
414 
415     typedef struct rl2_priv_band_statistics
416     {
417 	double min;
418 	double max;
419 	double mean;
420 	double sum_sq_diff;
421 	unsigned short nHistogram;
422 	double *histogram;
423 	rl2PoolVariancePtr first;
424 	rl2PoolVariancePtr last;
425     } rl2PrivBandStatistics;
426     typedef rl2PrivBandStatistics *rl2PrivBandStatisticsPtr;
427 
428     typedef struct rl2_priv_raster_statistics
429     {
430 	double no_data;
431 	double count;
432 	unsigned char sampleType;
433 	unsigned char nBands;
434 	rl2PrivBandStatisticsPtr band_stats;
435     } rl2PrivRasterStatistics;
436     typedef rl2PrivRasterStatistics *rl2PrivRasterStatisticsPtr;
437 
438     typedef struct rl2_color_map_ref
439     {
440 	double min;
441 	double max;
442 	unsigned char red;
443 	unsigned char green;
444 	unsigned char blue;
445 	unsigned char maxRed;
446 	unsigned char maxGreen;
447 	unsigned char maxBlue;
448 	struct rl2_color_map_ref *next;
449     } rl2ColorMapRef;
450     typedef rl2ColorMapRef *rl2ColorMapRefPtr;
451 
452     typedef struct rl2_color_map_item
453     {
454 	rl2ColorMapRefPtr first;
455 	rl2ColorMapRefPtr last;
456     } rl2ColorMapItem;
457     typedef rl2ColorMapItem *rl2ColorMapItemPtr;
458 
459     typedef struct rl2_color_map_locator
460     {
461 	int interpolate;
462 	rl2ColorMapItem look_up[256];
463 	unsigned char red;
464 	unsigned char green;
465 	unsigned char blue;
466     } rl2ColorMapLocator;
467     typedef rl2ColorMapLocator *rl2ColorMapLocatorPtr;
468 
469     typedef struct rl2_band_handling
470     {
471 	unsigned char contrastEnhancement;
472 	unsigned char look_up[256];
473 	double minValue;
474 	double maxValue;
475 	double scaleFactor;
476 	rl2ColorMapLocatorPtr colorMap;
477     } rl2BandHandling;
478     typedef rl2BandHandling *rl2BandHandlingPtr;
479 
480     typedef struct rl2_priv_band_selection
481     {
482 	int selectionType;
483 	unsigned char redBand;
484 	unsigned char greenBand;
485 	unsigned char blueBand;
486 	unsigned char grayBand;
487 	unsigned char redContrast;
488 	double redGamma;
489 	unsigned char greenContrast;
490 	double greenGamma;
491 	unsigned char blueContrast;
492 	double blueGamma;
493 	unsigned char grayContrast;
494 	double grayGamma;
495     } rl2PrivBandSelection;
496     typedef rl2PrivBandSelection *rl2PrivBandSelectionPtr;
497 
498     typedef struct rl2_priv_color_map_point
499     {
500 	double value;
501 	unsigned char red;
502 	unsigned char green;
503 	unsigned char blue;
504 	struct rl2_priv_color_map_point *next;
505     } rl2PrivColorMapPoint;
506     typedef rl2PrivColorMapPoint *rl2PrivColorMapPointPtr;
507 
508     typedef struct rl2_priv_color_map_categorize
509     {
510 	unsigned char baseRed;
511 	unsigned char baseGreen;
512 	unsigned char baseBlue;
513 	rl2PrivColorMapPointPtr first;
514 	rl2PrivColorMapPointPtr last;
515 	unsigned char dfltRed;
516 	unsigned char dfltGreen;
517 	unsigned char dfltBlue;
518     } rl2PrivColorMapCategorize;
519     typedef rl2PrivColorMapCategorize *rl2PrivColorMapCategorizePtr;
520 
521     typedef struct rl2_priv_color_map_interpolate
522     {
523 	rl2PrivColorMapPointPtr first;
524 	rl2PrivColorMapPointPtr last;
525 	unsigned char dfltRed;
526 	unsigned char dfltGreen;
527 	unsigned char dfltBlue;
528     } rl2PrivColorMapInterpolate;
529     typedef rl2PrivColorMapInterpolate *rl2PrivColorMapInterpolatePtr;
530 
531     typedef struct rl2_priv_raster_style
532     {
533 	char *name;
534 	char *title;
535 	char *abstract;
536 	double opacity;
537 	unsigned char contrastEnhancement;
538 	double gammaValue;
539 	rl2PrivBandSelectionPtr bandSelection;
540 	rl2PrivColorMapCategorizePtr categorize;
541 	rl2PrivColorMapInterpolatePtr interpolate;
542 	int shadedRelief;
543 	int brightnessOnly;
544 	double reliefFactor;
545     } rl2PrivRasterStyle;
546     typedef rl2PrivRasterStyle *rl2PrivRasterStylePtr;
547 
548     typedef struct rl2_priv_child_style
549     {
550 	char *namedLayer;
551 	char *namedStyle;
552 	int validLayer;
553 	int validStyle;
554 	struct rl2_priv_child_style *next;
555     } rl2PrivChildStyle;
556     typedef rl2PrivChildStyle *rl2PrivChildStylePtr;
557 
558     typedef struct rl2_priv_group_style
559     {
560 	char *name;
561 	char *title;
562 	char *abstract;
563 	rl2PrivChildStylePtr first;
564 	rl2PrivChildStylePtr last;
565 	int valid;
566     } rl2PrivGroupStyle;
567     typedef rl2PrivGroupStyle *rl2PrivGroupStylePtr;
568 
569     typedef struct rl2_priv_group_renderer_layer
570     {
571 	int layer_type;
572 	char *layer_name;
573 	rl2CoveragePtr coverage;
574 	char *style_name;
575 	rl2PrivRasterStylePtr raster_symbolizer;
576 	rl2PrivRasterStatisticsPtr raster_stats;
577     } rl2PrivGroupRendererLayer;
578     typedef rl2PrivGroupRendererLayer *rl2PrivGroupRendererLayerPtr;
579 
580     typedef struct rl2_priv_group_renderer
581     {
582 	int count;
583 	rl2PrivGroupRendererLayerPtr layers;
584     } rl2PrivGroupRenderer;
585     typedef rl2PrivGroupRenderer *rl2PrivGroupRendererPtr;
586 
587     typedef struct wms_retry_item
588     {
589 	int done;
590 	int count;
591 	double minx;
592 	double miny;
593 	double maxx;
594 	double maxy;
595 	struct wms_retry_item *next;
596     } WmsRetryItem;
597     typedef WmsRetryItem *WmsRetryItemPtr;
598 
599     typedef struct wms_retry_list
600     {
601 	WmsRetryItemPtr first;
602 	WmsRetryItemPtr last;
603     } WmsRetryList;
604     typedef WmsRetryList *WmsRetryListPtr;
605 
606     typedef struct section_pyramid_tile_in
607     {
608 	sqlite3_int64 tile_id;
609 	double cx;
610 	double cy;
611 	struct section_pyramid_tile_in *next;
612     } SectionPyramidTileIn;
613     typedef SectionPyramidTileIn *SectionPyramidTileInPtr;
614 
615     typedef struct section_pyramid_tile_ref
616     {
617 	SectionPyramidTileInPtr child;
618 	struct section_pyramid_tile_ref *next;
619     } SectionPyramidTileRef;
620     typedef SectionPyramidTileRef *SectionPyramidTileRefPtr;
621 
622     typedef struct section_pyramid_tile_out
623     {
624 	unsigned int row;
625 	unsigned int col;
626 	double minx;
627 	double miny;
628 	double maxx;
629 	double maxy;
630 	SectionPyramidTileRefPtr first;
631 	SectionPyramidTileRefPtr last;
632 	struct section_pyramid_tile_out *next;
633     } SectionPyramidTileOut;
634     typedef SectionPyramidTileOut *SectionPyramidTileOutPtr;
635 
636     typedef struct section_pyramid
637     {
638 	sqlite3_int64 section_id;
639 	int scale;
640 	unsigned char sample_type;
641 	unsigned char pixel_type;
642 	unsigned char num_samples;
643 	unsigned char compression;
644 	int quality;
645 	int srid;
646 	unsigned int full_width;
647 	unsigned int full_height;
648 	double res_x;
649 	double res_y;
650 	unsigned int scaled_width;
651 	unsigned int scaled_height;
652 	double tile_width;
653 	double tile_height;
654 	double minx;
655 	double miny;
656 	double maxx;
657 	double maxy;
658 	SectionPyramidTileInPtr first_in;
659 	SectionPyramidTileInPtr last_in;
660 	SectionPyramidTileOutPtr first_out;
661 	SectionPyramidTileOutPtr last_out;
662     } SectionPyramid;
663     typedef SectionPyramid *SectionPyramidPtr;
664 
665     typedef struct resolution_level
666     {
667 	int level;
668 	int scale;
669 	int real_scale;
670 	double x_resolution;
671 	double y_resolution;
672 	struct resolution_level *prev;
673 	struct resolution_level *next;
674     } ResolutionLevel;
675     typedef ResolutionLevel *ResolutionLevelPtr;
676 
677     typedef struct resolutions_list
678     {
679 	ResolutionLevelPtr first;
680 	ResolutionLevelPtr last;
681     } ResolutionsList;
682     typedef ResolutionsList *ResolutionsListPtr;
683 
684     typedef struct insert_wms
685     {
686 	sqlite3 *sqlite;
687 	unsigned char *rgba_tile;
688 	rl2CoveragePtr coverage;
689 	const char *sect_name;
690 	double x;
691 	double y;
692 	int width;
693 	int height;
694 	double tilew;
695 	double tileh;
696 	int srid;
697 	double minx;
698 	double miny;
699 	double maxx;
700 	double maxy;
701 	unsigned char sample_type;
702 	unsigned char num_bands;
703 	unsigned char compression;
704 	double horz_res;
705 	double vert_res;
706 	unsigned int tile_width;
707 	unsigned int tile_height;
708 	rl2PixelPtr no_data;
709 	sqlite3_stmt *stmt_sect;
710 	sqlite3_stmt *stmt_levl;
711 	sqlite3_stmt *stmt_tils;
712 	sqlite3_stmt *stmt_data;
713     } InsertWms;
714     typedef InsertWms *InsertWmsPtr;
715 
716     typedef struct rl2_mem_pdf_target
717     {
718 	unsigned char *buffer;
719 	int write_offset;
720 	int size;
721     } rl2PrivMemPdf;
722     typedef rl2PrivMemPdf *rl2PrivMemPdfPtr;
723 
724     struct aux_renderer
725     {
726 	/* helper struct for passing arguments to aux_render_image */
727 	sqlite3 *sqlite;
728 	int width;
729 	int height;
730 	int base_width;
731 	int base_height;
732 	double minx;
733 	double miny;
734 	double maxx;
735 	double maxy;
736 	int srid;
737 	double xx_res;
738 	double yy_res;
739 	int transparent;
740 	double opacity;
741 	int quality;
742 	unsigned char format_id;
743 	unsigned char bg_red;
744 	unsigned char bg_green;
745 	unsigned char bg_blue;
746 	rl2CoveragePtr coverage;
747 	rl2RasterStylePtr symbolizer;
748 	rl2RasterStatisticsPtr stats;
749 	unsigned char *outbuf;
750 	rl2PalettePtr palette;
751 	unsigned char out_pixel;
752     };
753 
754     struct aux_group_renderer
755     {
756 	/* helper struct for passing arguments to aux_group_renderer */
757 	sqlite3_context *context;
758 	const char *group_name;
759 	double minx;
760 	double maxx;
761 	double miny;
762 	double maxy;
763 	int width;
764 	int height;
765 	const char *style;
766 	unsigned char format_id;
767 	unsigned char bg_red;
768 	unsigned char bg_green;
769 	unsigned char bg_blue;
770 	int transparent;
771 	int quality;
772 	int reaspect;
773     };
774 
775     RL2_PRIVATE int
776 	rl2_blob_from_file (const char *path, unsigned char **blob,
777 			    int *blob_size);
778 
779     RL2_PRIVATE int
780 	rl2_blob_to_file (const char *path, unsigned char *blob, int blob_size);
781 
782     RL2_PRIVATE int
783 	rl2_decode_jpeg_scaled (int scale, const unsigned char *jpeg,
784 				int jpeg_sz, unsigned int *width,
785 				unsigned int *height,
786 				unsigned char *pixel_type,
787 				unsigned char **pixels, int *pixels_sz);
788 
789     RL2_PRIVATE int
790 	rl2_decode_webp_scaled (int scale, const unsigned char *webp,
791 				int webp_sz, unsigned int *width,
792 				unsigned int *height,
793 				unsigned char pixel_type,
794 				unsigned char **pixels, int *pixels_sz,
795 				unsigned char **mask, int *mask_sz);
796 
797     RL2_PRIVATE int
798 	rl2_data_to_png (const unsigned char *pixels, const unsigned char *mask,
799 			 double opacity, rl2PalettePtr plt,
800 			 unsigned int width, unsigned int height,
801 			 unsigned char sample_type, unsigned char pixel_type,
802 			 unsigned char **compr_data, int *compressed_size);
803 
804     RL2_PRIVATE int
805 	rl2_decode_png (const unsigned char *png, int png_sz,
806 			unsigned int *width, unsigned int *height,
807 			unsigned char *sample_type, unsigned char *pixel_type,
808 			unsigned char *num_bands, unsigned char **pixels,
809 			int *pixels_sz, unsigned char **mask, int *mask_sz,
810 			rl2PalettePtr * palette);
811 
812     RL2_PRIVATE int
813 	rl2_data_to_gif (const unsigned char *pixels,
814 			 rl2PalettePtr plt, unsigned int width,
815 			 unsigned int height, unsigned char sample_type,
816 			 unsigned char pixel_type, unsigned char **compr_data,
817 			 int *compressed_size);
818 
819     RL2_PRIVATE int
820 	rl2_decode_gif (const unsigned char *gif, int gif_sz,
821 			unsigned int *width, unsigned int *height,
822 			unsigned char *sample_type, unsigned char *pixel_type,
823 			unsigned char **pixels, int *pixels_sz,
824 			rl2PalettePtr * palette);
825 
826     RL2_PRIVATE int
827 	rl2_data_to_jpeg (const unsigned char *pixels,
828 			  const unsigned char *mask, rl2PalettePtr plt,
829 			  unsigned int width, unsigned int height,
830 			  unsigned char sample_type, unsigned char pixel_type,
831 			  unsigned char **jpeg, int *jpeg_size, int quality);
832 
833     RL2_PRIVATE int
834 	rl2_decode_tiff_mono4 (const unsigned char *tiff, int tiff_sz,
835 			       unsigned int *width, unsigned int *height,
836 			       unsigned char **pixels, int *pixels_sz);
837 
838     RL2_PRIVATE char truncate_8 (double val);
839 
840     RL2_PRIVATE unsigned char truncate_u8 (double val);
841 
842     RL2_PRIVATE short truncate_16 (double val);
843 
844     RL2_PRIVATE unsigned short truncate_u16 (double val);
845 
846     RL2_PRIVATE int truncate_32 (double val);
847 
848     RL2_PRIVATE unsigned int truncate_u32 (double val);
849 
850     RL2_PRIVATE void void_raw_buffer_palette (unsigned char *buffer,
851 					      unsigned int width,
852 					      unsigned int height,
853 					      rl2PixelPtr no_data);
854 
855     RL2_PRIVATE void void_raw_buffer (unsigned char *buffer,
856 				      unsigned int width,
857 				      unsigned int height,
858 				      unsigned char sample_type,
859 				      unsigned char num_bands,
860 				      rl2PixelPtr no_data);
861 
862     RL2_PRIVATE int load_dbms_tiles (sqlite3 * handle,
863 				     sqlite3_stmt * stmt_tiles,
864 				     sqlite3_stmt * stmt_data,
865 				     unsigned char *outbuf,
866 				     unsigned int width,
867 				     unsigned int height,
868 				     unsigned char sample_type,
869 				     unsigned char num_bands, double x_res,
870 				     double y_res, double minx, double miny,
871 				     double maxx, double maxy, int level,
872 				     int scale, rl2PalettePtr palette,
873 				     rl2PixelPtr no_data,
874 				     rl2RasterStylePtr style,
875 				     rl2RasterStatisticsPtr stats);
876 
877     RL2_PRIVATE int load_dbms_tiles_section (sqlite3 * handle,
878 					     sqlite3_int64 section_id,
879 					     sqlite3_stmt * stmt_tiles,
880 					     sqlite3_stmt * stmt_data,
881 					     unsigned char *outbuf,
882 					     unsigned int width,
883 					     unsigned int height,
884 					     unsigned char sample_type,
885 					     unsigned char num_bands,
886 					     double x_res, double y_res,
887 					     double minx, double maxy,
888 					     int scale, rl2PalettePtr palette,
889 					     rl2PixelPtr no_data);
890 
891     RL2_PRIVATE void
892 	compute_aggregate_sq_diff (rl2RasterStatisticsPtr aggreg_stats);
893 
894     RL2_PRIVATE int get_coverage_sample_bands (sqlite3 * sqlite,
895 					       const char *coverage,
896 					       unsigned char *sample_type,
897 					       unsigned char *num_bands);
898 
899     RL2_PRIVATE int get_coverage_defs (sqlite3 * sqlite, const char *coverage,
900 				       unsigned int *tile_width,
901 				       unsigned int *tile_height,
902 				       unsigned char *sample_type,
903 				       unsigned char *pixel_type,
904 				       unsigned char *num_bands,
905 				       unsigned char *compression);
906 
907     RL2_PRIVATE rl2PixelPtr default_nodata (unsigned char sample,
908 					    unsigned char pixel,
909 					    unsigned char num_bands);
910 
911     RL2_PRIVATE WmsRetryListPtr alloc_retry_list ();
912 
913     RL2_PRIVATE void free_retry_list (WmsRetryListPtr lst);
914 
915     RL2_PRIVATE void add_retry (WmsRetryListPtr lst, double minx, double miny,
916 				double maxx, double maxy);
917 
918     RL2_PRIVATE gaiaGeomCollPtr build_extent (int srid, double minx,
919 					      double miny, double maxx,
920 					      double maxy);
921 
922     RL2_PRIVATE int do_insert_wms_tile (sqlite3 * handle,
923 					unsigned char *blob_odd,
924 					int blob_odd_sz,
925 					unsigned char *blob_even,
926 					int blob_even_sz,
927 					sqlite3_int64 section_id, int srid,
928 					double res_x, double res_y,
929 					unsigned int tile_w,
930 					unsigned int tile_h, double miny,
931 					double maxx, double tile_minx,
932 					double tile_miny, double tile_maxx,
933 					double tile_maxy,
934 					rl2PalettePtr aux_palette,
935 					rl2PixelPtr no_data,
936 					sqlite3_stmt * stmt_tils,
937 					sqlite3_stmt * stmt_data,
938 					rl2RasterStatisticsPtr section_stats);
939 
940     RL2_PRIVATE int do_insert_levels (sqlite3 * handle, double base_res_x,
941 				      double base_res_y, double factor,
942 				      unsigned char sample_type,
943 				      sqlite3_stmt * stmt_levl);
944 
945     RL2_PRIVATE int do_insert_stats (sqlite3 * handle,
946 				     rl2RasterStatisticsPtr section_stats,
947 				     sqlite3_int64 section_id,
948 				     sqlite3_stmt * stmt_upd_sect);
949 
950     RL2_PRIVATE int do_insert_section (sqlite3 * handle, const char *src_path,
951 				       const char *section, int srid,
952 				       unsigned int width,
953 				       unsigned int height, double minx,
954 				       double miny, double maxx, double maxy,
955 				       sqlite3_stmt * stmt_sect,
956 				       sqlite3_int64 * id);
957 
958     RL2_PRIVATE char *get_section_name (const char *src_path);
959 
960     RL2_PRIVATE rl2RasterPtr build_wms_tile (rl2CoveragePtr coverage,
961 					     const unsigned char *rgba_tile);
962 
963     RL2_PRIVATE int insert_wms_tile (InsertWmsPtr ptr, int *first,
964 				     rl2RasterStatisticsPtr * section_stats,
965 				     sqlite3_int64 * section_id);
966 
967     RL2_PRIVATE int is_point (gaiaGeomCollPtr geom);
968 
969     RL2_PRIVATE ResolutionsListPtr alloc_resolutions_list ();
970 
971     RL2_PRIVATE void destroy_resolutions_list (ResolutionsListPtr list);
972 
973     RL2_PRIVATE void add_base_resolution (ResolutionsListPtr list, int level,
974 					  int scale, double x_res,
975 					  double y_res);
976 
977     RL2_PRIVATE int find_best_resolution_level (sqlite3 * handle,
978 						const char *coverage,
979 						double x_res, double y_res,
980 						int *level_id, int *scale,
981 						int *real_scale, double *xx_res,
982 						double *yy_res);
983 
984     RL2_PRIVATE unsigned char get_palette_format (rl2PrivPalettePtr plt);
985 
986     RL2_PRIVATE int get_payload_from_monochrome_opaque (unsigned int width,
987 							unsigned int height,
988 							sqlite3 * handle,
989 							double minx,
990 							double miny,
991 							double maxx,
992 							double maxy, int srid,
993 							unsigned char *pixels,
994 							unsigned char format,
995 							int quality,
996 							unsigned char **image,
997 							int *image_sz);
998 
999     RL2_PRIVATE int get_payload_from_monochrome_transparent (unsigned int
1000 							     width,
1001 							     unsigned int
1002 							     height,
1003 							     unsigned char
1004 							     *pixels,
1005 							     unsigned char
1006 							     format,
1007 							     int quality,
1008 							     unsigned char
1009 							     **image,
1010 							     int *image_sz,
1011 							     double opacity);
1012 
1013     RL2_PRIVATE int get_payload_from_palette_opaque (unsigned int width,
1014 						     unsigned int height,
1015 						     sqlite3 * handle,
1016 						     double minx, double miny,
1017 						     double maxx, double maxy,
1018 						     int srid,
1019 						     unsigned char *pixels,
1020 						     rl2PalettePtr palette,
1021 						     unsigned char format,
1022 						     int quality,
1023 						     unsigned char **image,
1024 						     int *image_sz);
1025 
1026     RL2_PRIVATE int get_payload_from_palette_transparent (unsigned int width,
1027 							  unsigned int height,
1028 							  unsigned char *pixels,
1029 							  rl2PalettePtr palette,
1030 							  unsigned char format,
1031 							  int quality,
1032 							  unsigned char **image,
1033 							  int *image_sz,
1034 							  unsigned char bg_red,
1035 							  unsigned char
1036 							  bg_green,
1037 							  unsigned char
1038 							  bg_blue,
1039 							  double opacity);
1040 
1041     RL2_PRIVATE int get_payload_from_grayscale_opaque (unsigned int width,
1042 						       unsigned int height,
1043 						       sqlite3 * handle,
1044 						       double minx, double miny,
1045 						       double maxx, double maxy,
1046 						       int srid,
1047 						       unsigned char *pixels,
1048 						       unsigned char format,
1049 						       int quality,
1050 						       unsigned char **image,
1051 						       int *image_sz);
1052 
1053     RL2_PRIVATE int get_payload_from_grayscale_transparent (unsigned int
1054 							    width,
1055 							    unsigned int
1056 							    height,
1057 							    unsigned char
1058 							    *pixels,
1059 							    unsigned char
1060 							    format, int quality,
1061 							    unsigned char
1062 							    **image,
1063 							    int *image_sz,
1064 							    unsigned char
1065 							    bg_gray,
1066 							    double opacity);
1067 
1068     RL2_PRIVATE int get_payload_from_rgb_opaque (unsigned int width,
1069 						 unsigned int height,
1070 						 sqlite3 * handle, double minx,
1071 						 double miny, double maxx,
1072 						 double maxy, int srid,
1073 						 unsigned char *pixels,
1074 						 unsigned char format,
1075 						 int quality,
1076 						 unsigned char **image,
1077 						 int *image_sz);
1078 
1079     RL2_PRIVATE int get_payload_from_rgb_transparent (unsigned int width,
1080 						      unsigned int height,
1081 						      unsigned char *pixels,
1082 						      unsigned char format,
1083 						      int quality,
1084 						      unsigned char **image,
1085 						      int *image_sz,
1086 						      unsigned char bg_red,
1087 						      unsigned char bg_green,
1088 						      unsigned char bg_blue,
1089 						      double opacity);
1090 
1091     RL2_PRIVATE int get_rgba_from_monochrome_mask (unsigned int width,
1092 						   unsigned int height,
1093 						   unsigned char *pixels,
1094 						   unsigned char *mask,
1095 						   rl2PrivPixelPtr no_data,
1096 						   unsigned char *rgba);
1097 
1098     RL2_PRIVATE int get_rgba_from_monochrome_opaque (unsigned int width,
1099 						     unsigned int height,
1100 						     unsigned char *pixels,
1101 						     unsigned char *rgba);
1102 
1103     RL2_PRIVATE int get_rgba_from_monochrome_transparent (unsigned int width,
1104 							  unsigned int height,
1105 							  unsigned char *pixels,
1106 							  unsigned char *rgba);
1107 
1108     RL2_PRIVATE int get_rgba_from_palette_mask (unsigned int base_width,
1109 						unsigned int base_height,
1110 						unsigned char *pixels,
1111 						unsigned char *mask,
1112 						rl2PalettePtr palette,
1113 						rl2PrivPixelPtr no_data,
1114 						unsigned char *rgba);
1115 
1116     RL2_PRIVATE int get_rgba_from_palette_opaque (unsigned int base_width,
1117 						  unsigned int base_height,
1118 						  unsigned char *pixels,
1119 						  rl2PalettePtr palette,
1120 						  unsigned char *rgba);
1121 
1122     RL2_PRIVATE int get_rgba_from_palette_transparent (unsigned int width,
1123 						       unsigned int height,
1124 						       unsigned char *pixels,
1125 						       rl2PalettePtr palette,
1126 						       unsigned char *rgba,
1127 						       unsigned char bg_red,
1128 						       unsigned char bg_green,
1129 						       unsigned char bg_blue);
1130 
1131     RL2_PRIVATE int get_rgba_from_grayscale_mask (unsigned int width,
1132 						  unsigned int height,
1133 						  unsigned char *pixels,
1134 						  unsigned char *mask,
1135 						  rl2PrivPixelPtr no_data,
1136 						  unsigned char *rgba);
1137 
1138     RL2_PRIVATE int get_rgba_from_grayscale_opaque (unsigned int width,
1139 						    unsigned int height,
1140 						    unsigned char *pixels,
1141 						    unsigned char *rgba);
1142 
1143     RL2_PRIVATE int get_rgba_from_grayscale_transparent (unsigned int width,
1144 							 unsigned int height,
1145 							 unsigned char *pixels,
1146 							 unsigned char *rgba,
1147 							 unsigned char bg_gray);
1148 
1149     RL2_PRIVATE int get_rgba_from_rgb_mask (unsigned int width,
1150 					    unsigned int height,
1151 					    unsigned char *pixels,
1152 					    unsigned char *mask,
1153 					    rl2PrivPixelPtr no_data,
1154 					    unsigned char *rgba);
1155 
1156     RL2_PRIVATE int get_rgba_from_rgb_opaque (unsigned int width,
1157 					      unsigned int height,
1158 					      unsigned char *pixels,
1159 					      unsigned char *rgba);
1160 
1161     RL2_PRIVATE int get_rgba_from_rgb_transparent (unsigned int width,
1162 						   unsigned int height,
1163 						   unsigned char *pixels,
1164 						   unsigned char *rgba,
1165 						   unsigned char bg_red,
1166 						   unsigned char bg_green,
1167 						   unsigned char bg_blue);
1168 
1169     RL2_PRIVATE int get_rgba_from_datagrid_mask (unsigned int width,
1170 						 unsigned int height,
1171 						 unsigned char sample_type,
1172 						 void *pixels,
1173 						 unsigned char *mask,
1174 						 rl2PrivPixelPtr no_made,
1175 						 unsigned char *rgba);
1176 
1177     RL2_PRIVATE int get_payload_from_gray_rgba_opaque (unsigned int width,
1178 						       unsigned int height,
1179 						       sqlite3 * handle,
1180 						       double minx, double miny,
1181 						       double maxx, double maxy,
1182 						       int srid,
1183 						       unsigned char *rgb,
1184 						       unsigned char format,
1185 						       int quality,
1186 						       unsigned char **image,
1187 						       int *image_sz);
1188 
1189     RL2_PRIVATE int get_payload_from_gray_rgba_transparent (unsigned int
1190 							    width,
1191 							    unsigned int
1192 							    height,
1193 							    unsigned char *rgb,
1194 							    unsigned char
1195 							    *alpha,
1196 							    unsigned char
1197 							    format, int quality,
1198 							    unsigned char
1199 							    **image,
1200 							    int *image_sz,
1201 							    double opacity);
1202 
1203     RL2_PRIVATE int get_payload_from_rgb_rgba_opaque (unsigned int width,
1204 						      unsigned int height,
1205 						      sqlite3 * handle,
1206 						      double minx, double miny,
1207 						      double maxx, double maxy,
1208 						      int srid,
1209 						      unsigned char *rgb,
1210 						      unsigned char format,
1211 						      int quality,
1212 						      unsigned char **image,
1213 						      int *image_sz);
1214 
1215     RL2_PRIVATE int get_payload_from_rgb_rgba_transparent (unsigned int width,
1216 							   unsigned int
1217 							   height,
1218 							   unsigned char *rgb,
1219 							   unsigned char *alpha,
1220 							   unsigned char format,
1221 							   int quality,
1222 							   unsigned char
1223 							   **image,
1224 							   int *image_sz,
1225 							   double opacity);
1226 
1227     RL2_PRIVATE int build_rgb_alpha (unsigned int width,
1228 				     unsigned int height, unsigned char *rgba,
1229 				     unsigned char **rgb, unsigned char **alpha,
1230 				     unsigned char bg_red,
1231 				     unsigned char bg_green,
1232 				     unsigned char bg_blue);
1233 
1234     RL2_PRIVATE int get_rgba_from_multiband8 (unsigned int width,
1235 					      unsigned int height,
1236 					      unsigned char red_band,
1237 					      unsigned char green_band,
1238 					      unsigned char blue_band,
1239 					      unsigned char num_bands,
1240 					      unsigned char *pixels,
1241 					      unsigned char *mask,
1242 					      rl2PrivPixelPtr no_data,
1243 					      unsigned char *rgba);
1244 
1245     RL2_PRIVATE int get_rgba_from_multiband16 (unsigned int width,
1246 					       unsigned int height,
1247 					       unsigned char red_band,
1248 					       unsigned char green_band,
1249 					       unsigned char blue_band,
1250 					       unsigned char num_bands,
1251 					       unsigned short *pixels,
1252 					       unsigned char *mask,
1253 					       rl2PrivPixelPtr no_data,
1254 					       unsigned char *rgba);
1255     RL2_PRIVATE int parse_worldfile (FILE * in, double *px, double *py,
1256 				     double *pres_x, double *pres_y);
1257 
1258     RL2_PRIVATE rl2RasterStylePtr raster_style_from_sld_se_xml (char *name,
1259 								char *title,
1260 								char *abstract,
1261 								unsigned char
1262 								*xml);
1263 
1264     RL2_PRIVATE rl2GroupStylePtr group_style_from_sld_xml (char *name,
1265 							   char *title,
1266 							   char *abstract,
1267 							   unsigned char *xml);
1268 
1269     RL2_PRIVATE int get_raster_band_histogram (rl2PrivBandStatisticsPtr band,
1270 					       unsigned char **image,
1271 					       int *image_sz);
1272 
1273     RL2_PRIVATE int copy_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf,
1274 				     unsigned int width,
1275 				     unsigned int height,
1276 				     unsigned char sample_type,
1277 				     unsigned char num_bands, double x_res,
1278 				     double y_res, double minx, double maxy,
1279 				     double tile_minx, double tile_maxy,
1280 				     rl2PixelPtr no_data,
1281 				     rl2RasterStylePtr style,
1282 				     rl2RasterStatisticsPtr stats);
1283 
1284     RL2_PRIVATE int rl2_build_shaded_relief_mask (sqlite3 * handle,
1285 						  rl2CoveragePtr cvg,
1286 						  double relief_factor,
1287 						  double scale_factor,
1288 						  unsigned int width,
1289 						  unsigned int height,
1290 						  double minx, double miny,
1291 						  double maxx, double maxy,
1292 						  double x_res, double y_res,
1293 						  float **shaded_relief,
1294 						  int *shaded_relief_sz);
1295 
1296     RL2_PRIVATE int set_coverage_infos (sqlite3 * handle,
1297 					const char *coverage_name,
1298 					const char *title,
1299 					const char *abstract);
1300 
1301     RL2_PRIVATE int rl2_test_layer_group (sqlite3 * handle,
1302 					  const char *group_name);
1303 
1304     RL2_PRIVATE int rl2_rgba_raster_data (sqlite3 * handle,
1305 					  const char *coverage_name, void *ctx,
1306 					  int level, double minx, double miny,
1307 					  double maxx, double maxy,
1308 					  rl2PalettePtr palette,
1309 					  rl2PixelPtr no_data);
1310 
1311     RL2_PRIVATE int rl2_aux_render_image (struct aux_renderer *aux,
1312 					  unsigned char **ximage,
1313 					  int *ximage_size);
1314 
1315     RL2_PRIVATE void rl2_aux_group_renderer (struct aux_group_renderer *auxgrp);
1316 
1317     RL2_PRIVATE double rl2_get_shaded_relief_scale_factor (sqlite3 * handle,
1318 							   const char
1319 							   *coverage);
1320 
1321 #ifdef __cplusplus
1322 }
1323 #endif
1324 
1325 #endif				/* _RASTERLITE2_PRIVATE_H */
1326