Check-in Differences
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Difference From 0da08dfd33708d89 To c5692a3458233cdd

2016-12-29
15:48
rl2_load_raw_tiles: supporting 1-BIT, 2-BIT, 4-BIT MONOCHROME and PALETTE check-in: 6618242a60 user: sandro tags: trunk
11:37
rl2_load_raw_tiles: initial implementation check-in: 0da08dfd33 user: sandro tags: trunk
2016-12-28
12:40
bugfix: importing DATAGRID from TIFF (by strip / setting the initial palette only after importing the first Section check-in: 77db64b78e user: sandro tags: trunk
2015-06-05
12:03
updating to automake 1.15 check-in: 7574f54ee8 user: sandro tags: trunk
2015-06-04
21:50
implementing RL2_CopyRasterCoverage() check-in: c5692a3458 user: sandro tags: trunk
2015-05-31
10:02
wmslite micro-server: supporting WMS vector layers in GetCapabilities check-in: 6b8e213297 user: sandro tags: trunk

Added Android_R4.2.0.mk.

            1  +# -------------------
            2  +# Android_R4.2.0.mk
            3  +# ndk-build clean
            4  +# ndk-build
            5  +# -------------------
            6  +LOCAL_PATH := $(call my-dir)
            7  +JSQLITE_PATH := javasqlite-20120209
            8  +SPATIALITE_PATH := libspatialite-4.2.0-rc1
            9  +GEOS_PATH := geos-3.4.2
           10  +PROJ4_PATH := proj-4.8.0
           11  +SQLITE_PATH := sqlite-amalgamation-3080403
           12  +ICONV_PATH := libiconv-1.13.1
           13  +RASTERLITE2_PATH := librasterlite2-4.2.0
           14  +GEOTIFF_PATH := libgeotiff-1.4.0
           15  +TIFF_PATH := tiff-4.0.3/libtiff
           16  +JPEG_PATH := jpeg-8d
           17  +GIF_PATH := giflib-5.0.6/lib
           18  +CAIRO_PATH := cairo-1.12.14/src
           19  +FREETYPE_PATH := freetype-2.5.3
           20  +FONTCONFIG_PATH := fontconfig-2.11.1
           21  +EXPAT_PATH := expat-2.1.0
           22  +PIXMAN_PATH := pixman-0.32.4
           23  +PNG_PATH := libpng-1.6.10
           24  +WEBP_PATH := libwebp-0.4.0
           25  +XML2_PATH := libxml2-2.9.1
           26  +CURL_PATH := curl-7.36.0
           27  +LZMA_PATH := xz-5.1.3alpha
           28  +
           29  +include $(LOCAL_PATH)/jsqlite-R4.2.0.mk
           30  +include $(LOCAL_PATH)/iconv-1.13.1.mk
           31  +include $(LOCAL_PATH)/sqlite-3080403.mk
           32  +include $(LOCAL_PATH)/proj4-4.8.0.mk
           33  +include $(LOCAL_PATH)/geos-3.4.2.mk
           34  +include $(LOCAL_PATH)/spatialite-4.2.0.mk
           35  +include $(LOCAL_PATH)/libjpeg-8d.mk
           36  +include $(LOCAL_PATH)/giflib-5.0.6.mk
           37  +include $(LOCAL_PATH)/libpng-1.6.10.mk
           38  +include $(LOCAL_PATH)/libtiff-4.0.3.mk
           39  +include $(LOCAL_PATH)/libwebp-0.4.0.mk
           40  +include $(LOCAL_PATH)/pixman-0.32.4.mk
           41  +include $(LOCAL_PATH)/freetype-2.5.3.mk
           42  +include $(LOCAL_PATH)/fontconfig-2.11.1.mk
           43  +include $(LOCAL_PATH)/expat-2.1.0.mk
           44  +include $(LOCAL_PATH)/cairo-1.12.14.mk
           45  +include $(LOCAL_PATH)/libgeotiff-1.4.0.mk
           46  +include $(LOCAL_PATH)/libxml2-2.9.1.mk
           47  +include $(LOCAL_PATH)/libcurl-7.36.0.mk
           48  +include $(LOCAL_PATH)/lzma-xz-5.1.3a.mk
           49  +include $(LOCAL_PATH)/rasterlite2-4.2.0.mk
           50  +$(call import-module,android/cpufeatures)

Deleted Android_R4.3.0.mk.

     1         -# -------------------
     2         -# Android_R4.3.0.mk
     3         -# ndk-build clean
     4         -# ndk-build
     5         -# -------------------
     6         -LOCAL_PATH := $(call my-dir)
     7         -JSQLITE_PATH := javasqlite-20120209
     8         -SPATIALITE_PATH := libspatialite-4.3.0
     9         -GEOS_PATH := geos-3.4.2
    10         -PROJ4_PATH := proj-4.9.1
    11         -SQLITE_PATH := sqlite-amalgamation-3081002
    12         -ICONV_PATH := libiconv-1.13.1
    13         -RASTERLITE2_PATH := librasterlite2-4.3.0
    14         -GEOTIFF_PATH := libgeotiff-1.4.0
    15         -TIFF_PATH := tiff-4.0.3/libtiff
    16         -JPEG_PATH := jpeg-8d
    17         -GIF_PATH := giflib-5.0.6/lib
    18         -CAIRO_PATH := cairo-1.12.14/src
    19         -FREETYPE_PATH := freetype-2.5.3
    20         -FONTCONFIG_PATH := fontconfig-2.11.1
    21         -EXPAT_PATH := expat-2.1.0
    22         -PIXMAN_PATH := pixman-0.32.4
    23         -PNG_PATH := libpng-1.6.10
    24         -WEBP_PATH := libwebp-0.4.0
    25         -XML2_PATH := libxml2-2.9.1
    26         -CURL_PATH := curl-7.36.0
    27         -LZMA_PATH := xz-5.1.3alpha
    28         -CHARLS_PATH := charls-1.0
    29         -OPENJPEG_PATH := openjpeg-2.0.0
    30         -
    31         -include $(LOCAL_PATH)/charls-1.0.mk
    32         -include $(LOCAL_PATH)/jsqlite-R4.2.0.mk
    33         -include $(LOCAL_PATH)/iconv-1.13.1.mk
    34         -include $(LOCAL_PATH)/sqlite-3081002.mk
    35         -include $(LOCAL_PATH)/proj4-4.9.1.mk
    36         -include $(LOCAL_PATH)/geos-3.4.2.mk
    37         -include $(LOCAL_PATH)/spatialite-4.3.0.mk
    38         -include $(LOCAL_PATH)/libjpeg-8d.mk
    39         -include $(LOCAL_PATH)/openjpeg-2.0.0.mk
    40         -include $(LOCAL_PATH)/giflib-5.0.6.mk
    41         -include $(LOCAL_PATH)/libpng-1.6.10.mk
    42         -include $(LOCAL_PATH)/libtiff-4.0.3.mk
    43         -include $(LOCAL_PATH)/libwebp-0.4.0.mk
    44         -include $(LOCAL_PATH)/pixman-0.32.4.mk
    45         -include $(LOCAL_PATH)/freetype-2.5.3.mk
    46         -include $(LOCAL_PATH)/fontconfig-2.11.1.mk
    47         -include $(LOCAL_PATH)/expat-2.1.0.mk
    48         -include $(LOCAL_PATH)/cairo-1.12.14.mk
    49         -include $(LOCAL_PATH)/libgeotiff-1.4.0.mk
    50         -include $(LOCAL_PATH)/libxml2-2.9.1.mk
    51         -include $(LOCAL_PATH)/libcurl-7.36.0.mk
    52         -include $(LOCAL_PATH)/lzma-xz-5.1.3a.mk
    53         -include $(LOCAL_PATH)/rasterlite2-4.3.0.mk
    54         -$(call import-module,android/cpufeatures)

Changes to Makefile-static-MinGW.

     9      9   	./static_bin/wmslite.exe
    10     10   
    11     11   ./static_bin/rl2sniff.exe: ./tools/rl2sniff.o 
    12     12   	$(GG) ./tools/rl2sniff.o -o ./static_bin/rl2sniff.exe \
    13     13   	/usr/local/lib/librasterlite2.a \
    14     14   	/usr/local/lib/libspatialite.a \
    15     15   	/usr/local/lib/libsqlite3.a \
    16         -	/usr/local/lib/librttopo.a \
           16  +	/usr/local/lib/liblwgeom.a \
    17     17   	/usr/local/lib/libproj.a \
    18     18   	/usr/local/lib/libgeos_c.a \
    19     19   	/usr/local/lib/libgeos.a \
    20     20   	/usr/local/lib/libfreexl.a \
    21     21   	/usr/local/lib/libcairo.a \
    22     22   	/usr/local/lib/libpixman-1.a \
    23     23   	/usr/local/lib/libfontconfig.a \
................................................................................
    42     42   	strip --strip-all ./static_bin/rl2sniff.exe
    43     43   	
    44     44   ./static_bin/rl2tool.exe: ./tools/rl2tool.o 
    45     45   	$(GG) ./tools/rl2tool.o -o ./static_bin/rl2tool.exe \
    46     46   	/usr/local/lib/librasterlite2.a \
    47     47   	/usr/local/lib/libspatialite.a \
    48     48   	/usr/local/lib/libsqlite3.a \
    49         -	/usr/local/lib/librttopo.a \
           49  +	/usr/local/lib/liblwgeom.a \
    50     50   	/usr/local/lib/libproj.a \
    51     51   	/usr/local/lib/libgeos_c.a \
    52     52   	/usr/local/lib/libgeos.a \
    53     53   	/usr/local/lib/libfreexl.a \
    54     54   	/usr/local/lib/libcairo.a \
    55     55   	/usr/local/lib/libpixman-1.a \
    56     56   	/usr/local/lib/libfontconfig.a \
................................................................................
    75     75   	strip --strip-all ./static_bin/rl2tool.exe
    76     76   
    77     77   ./static_bin/wmslite.exe: ./tools/wmslite.o 
    78     78   	$(GG) ./tools/wmslite.o -o ./static_bin/wmslite.exe \
    79     79   	/usr/local/lib/librasterlite2.a \
    80     80   	/usr/local/lib/libspatialite.a \
    81     81   	/usr/local/lib/libsqlite3.a \
    82         -	/usr/local/lib/librttopo.a \
           82  +	/usr/local/lib/liblwgeom.a \
    83     83   	/usr/local/lib/libproj.a \
    84     84   	/usr/local/lib/libgeos_c.a \
    85     85   	/usr/local/lib/libgeos.a \
    86     86   	/usr/local/lib/libfreexl.a \
    87     87   	/usr/local/lib/libcairo.a \
    88     88   	/usr/local/lib/libpixman-1.a \
    89     89   	/usr/local/lib/libfontconfig.a \

Changes to Makefile.am.

     1      1   ACLOCAL_AMFLAGS = -I m4
     2      2   
     3      3   SUBDIRS = headers src test tools
     4      4   
     5         -EXTRA_DIST = mainpage.doxy Android_R4.3.0.mk rasterlite2-4.3.0.mk \
            5  +EXTRA_DIST = mainpage.doxy Android_R4.2.0.mk rasterlite2-4.2.0.mk \
     6      6   	Makefile-static-MinGW
     7      7   
     8         -AUTOMAKE_OPTIONS = dist-zip foreign
            8  +AUTOMAKE_OPTIONS = dist-zip
     9      9   
    10     10   pkgconfigdir = $(libdir)/pkgconfig
    11     11   pkgconfig_DATA = rasterlite2.pc
    12     12   
    13     13   coverage-init:
    14     14   	lcov --directory src --capture --initial --output-file rasterlite2_cov.info
    15     15   
    16     16   coverage::
    17     17   	lcov --rc lcov_branch_coverage=1 --directory src --output-file rasterlite2_cov.info --capture
    18         -	lcov --rc lcov_branch_coverage=1 --remove rasterlite2_cov.info "*include/*" --output-file rasterlite2_cov.info
    19     18   	genhtml --rc lcov_branch_coverage=1 -o covresults rasterlite2_cov.info
    20     19   
    21     20   MOSTLYCLEANFILES = rasterlite2_cov.info 

Changes to Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   
    17     17   VPATH = @srcdir@
    18         -am__is_gnu_make = { \
    19         -  if test -z '$(MAKELEVEL)'; then \
    20         -    false; \
    21         -  elif test -n '$(MAKE_HOST)'; then \
    22         -    true; \
    23         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    24         -    true; \
    25         -  else \
    26         -    false; \
    27         -  fi; \
    28         -}
           18  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    29     19   am__make_running_with_option = \
    30     20     case $${target_option-} in \
    31     21         ?) ;; \
    32     22         *) echo "am__make_running_with_option: internal error: invalid" \
    33     23                 "target option '$${target_option-}' specified" >&2; \
    34     24            exit 1;; \
    35     25     esac; \
................................................................................
    85     75   POST_INSTALL = :
    86     76   NORMAL_UNINSTALL = :
    87     77   PRE_UNINSTALL = :
    88     78   POST_UNINSTALL = :
    89     79   build_triplet = @build@
    90     80   host_triplet = @host@
    91     81   subdir = .
           82  +DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
           83  +	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
           84  +	$(top_srcdir)/configure $(am__configure_deps) \
           85  +	$(srcdir)/config.h.in $(srcdir)/Doxyfile.in \
           86  +	$(srcdir)/rasterlite2.pc.in COPYING compile config.guess \
           87  +	config.sub depcomp install-sh missing ltmain.sh
    92     88   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    93     89   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    94     90   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    95     91   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    96     92   	$(top_srcdir)/configure.ac
    97     93   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    98     94   	$(ACLOCAL_M4)
    99         -DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
   100         -	$(am__configure_deps) $(am__DIST_COMMON)
   101     95   am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
   102     96    configure.lineno config.status.lineno
   103     97   mkinstalldirs = $(install_sh) -d
   104     98   CONFIG_HEADER = config.h
   105     99   CONFIG_CLEAN_FILES = Doxyfile rasterlite2.pc
   106    100   CONFIG_CLEAN_VPATH_FILES =
   107    101   AM_V_P = $(am__v_P_@AM_V@)
................................................................................
   186    180     unique=`for i in $$list; do \
   187    181       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   188    182     done | $(am__uniquify_input)`
   189    183   ETAGS = etags
   190    184   CTAGS = ctags
   191    185   CSCOPE = cscope
   192    186   DIST_SUBDIRS = $(SUBDIRS)
   193         -am__DIST_COMMON = $(srcdir)/Doxyfile.in $(srcdir)/Makefile.in \
   194         -	$(srcdir)/config.h.in $(srcdir)/rasterlite2.pc.in AUTHORS \
   195         -	COPYING ChangeLog INSTALL NEWS README compile config.guess \
   196         -	config.sub depcomp install-sh ltmain.sh missing
   197    187   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   198    188   distdir = $(PACKAGE)-$(VERSION)
   199    189   top_distdir = $(distdir)
   200    190   am__remove_distdir = \
   201    191     if test -d "$(distdir)"; then \
   202    192       find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
   203    193         && rm -rf "$(distdir)" \
................................................................................
   376    366   sysconfdir = @sysconfdir@
   377    367   target_alias = @target_alias@
   378    368   top_build_prefix = @top_build_prefix@
   379    369   top_builddir = @top_builddir@
   380    370   top_srcdir = @top_srcdir@
   381    371   ACLOCAL_AMFLAGS = -I m4
   382    372   SUBDIRS = headers src test tools
   383         -EXTRA_DIST = mainpage.doxy Android_R4.3.0.mk rasterlite2-4.3.0.mk \
          373  +EXTRA_DIST = mainpage.doxy Android_R4.2.0.mk rasterlite2-4.2.0.mk \
   384    374   	Makefile-static-MinGW
   385    375   
   386         -AUTOMAKE_OPTIONS = dist-zip foreign
          376  +AUTOMAKE_OPTIONS = dist-zip
   387    377   pkgconfigdir = $(libdir)/pkgconfig
   388    378   pkgconfig_DATA = rasterlite2.pc
   389    379   MOSTLYCLEANFILES = rasterlite2_cov.info 
   390    380   all: config.h
   391    381   	$(MAKE) $(AM_MAKEFLAGS) all-recursive
   392    382   
   393    383   .SUFFIXES:
   394    384   am--refresh: Makefile
   395    385   	@:
   396    386   $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
   397    387   	@for dep in $?; do \
   398    388   	  case '$(am__configure_deps)' in \
   399    389   	    *$$dep*) \
   400         -	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
   401         -	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
          390  +	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
          391  +	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
   402    392   		&& exit 0; \
   403    393   	      exit 1;; \
   404    394   	  esac; \
   405    395   	done; \
   406         -	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
          396  +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
   407    397   	$(am__cd) $(top_srcdir) && \
   408         -	  $(AUTOMAKE) --foreign Makefile
          398  +	  $(AUTOMAKE) --gnu Makefile
          399  +.PRECIOUS: Makefile
   409    400   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   410    401   	@case '$?' in \
   411    402   	  *config.status*) \
   412    403   	    echo ' $(SHELL) ./config.status'; \
   413    404   	    $(SHELL) ./config.status;; \
   414    405   	  *) \
   415    406   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
................................................................................
   657    648   	$(am__post_remove_distdir)
   658    649   
   659    650   dist-xz: distdir
   660    651   	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
   661    652   	$(am__post_remove_distdir)
   662    653   
   663    654   dist-tarZ: distdir
   664         -	@echo WARNING: "Support for distribution archives compressed with" \
   665         -		       "legacy program 'compress' is deprecated." >&2
          655  +	@echo WARNING: "Support for shar distribution archives is" \
          656  +	               "deprecated." >&2
   666    657   	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
   667    658   	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
   668    659   	$(am__post_remove_distdir)
   669    660   
   670    661   dist-shar: distdir
   671         -	@echo WARNING: "Support for shar distribution archives is" \
   672         -	               "deprecated." >&2
          662  +	@echo WARNING: "Support for distribution archives compressed with" \
          663  +		       "legacy program 'compress' is deprecated." >&2
   673    664   	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
   674    665   	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
   675    666   	$(am__post_remove_distdir)
   676    667   dist-zip: distdir
   677    668   	-rm -f $(distdir).zip
   678    669   	zip -rq $(distdir).zip $(distdir)
   679    670   	$(am__post_remove_distdir)
................................................................................
   700    691   	*.shar.gz*) \
   701    692   	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
   702    693   	*.zip*) \
   703    694   	  unzip $(distdir).zip ;;\
   704    695   	esac
   705    696   	chmod -R a-w $(distdir)
   706    697   	chmod u+w $(distdir)
   707         -	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
          698  +	mkdir $(distdir)/_build $(distdir)/_inst
   708    699   	chmod a-w $(distdir)
   709    700   	test -d $(distdir)/_build || exit 0; \
   710    701   	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
   711    702   	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
   712    703   	  && am__cwd=`pwd` \
   713         -	  && $(am__cd) $(distdir)/_build/sub \
   714         -	  && ../../configure \
          704  +	  && $(am__cd) $(distdir)/_build \
          705  +	  && ../configure \
   715    706   	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
   716    707   	    $(DISTCHECK_CONFIGURE_FLAGS) \
   717         -	    --srcdir=../.. --prefix="$$dc_install_base" \
          708  +	    --srcdir=.. --prefix="$$dc_install_base" \
   718    709   	  && $(MAKE) $(AM_MAKEFLAGS) \
   719    710   	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
   720    711   	  && $(MAKE) $(AM_MAKEFLAGS) check \
   721    712   	  && $(MAKE) $(AM_MAKEFLAGS) install \
   722    713   	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
   723    714   	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
   724    715   	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
................................................................................
   891    882   	install-man install-pdf install-pdf-am install-pkgconfigDATA \
   892    883   	install-ps install-ps-am install-strip installcheck \
   893    884   	installcheck-am installdirs installdirs-am maintainer-clean \
   894    885   	maintainer-clean-generic mostlyclean mostlyclean-generic \
   895    886   	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
   896    887   	uninstall-am uninstall-pkgconfigDATA
   897    888   
   898         -.PRECIOUS: Makefile
   899         -
   900    889   
   901    890   coverage-init:
   902    891   	lcov --directory src --capture --initial --output-file rasterlite2_cov.info
   903    892   
   904    893   coverage::
   905    894   	lcov --rc lcov_branch_coverage=1 --directory src --output-file rasterlite2_cov.info --capture
   906         -	lcov --rc lcov_branch_coverage=1 --remove rasterlite2_cov.info "*include/*" --output-file rasterlite2_cov.info
   907    895   	genhtml --rc lcov_branch_coverage=1 -o covresults rasterlite2_cov.info
   908    896   
   909    897   # Tell versions [3.59,3.63) of GNU make to not export all variables.
   910    898   # Otherwise a system limit (for SysV at least) may be exceeded.
   911    899   .NOEXPORT:

Changes to aclocal.m4.

     1         -# generated automatically by aclocal 1.15 -*- Autoconf -*-
            1  +# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
     2      2   
     3         -# Copyright (C) 1996-2014 Free Software Foundation, Inc.
            3  +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
     4      4   
     5      5   # This file is free software; the Free Software Foundation
     6      6   # gives unlimited permission to copy and/or distribute it,
     7      7   # with or without modifications, as long as this notice is preserved.
     8      8   
     9      9   # This program is distributed in the hope that it will be useful,
    10     10   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
................................................................................
   231    231   
   232    232   _PKG_CONFIG([$1], [variable="][$3]["], [$2])
   233    233   AS_VAR_COPY([$1], [pkg_cv_][$1])
   234    234   
   235    235   AS_VAR_IF([$1], [""], [$5], [$4])dnl
   236    236   ])# PKG_CHECK_VAR
   237    237   
   238         -# Copyright (C) 2002-2014 Free Software Foundation, Inc.
          238  +# Copyright (C) 2002-2013 Free Software Foundation, Inc.
   239    239   #
   240    240   # This file is free software; the Free Software Foundation
   241    241   # gives unlimited permission to copy and/or distribute it,
   242    242   # with or without modifications, as long as this notice is preserved.
   243    243   
   244    244   # AM_AUTOMAKE_VERSION(VERSION)
   245    245   # ----------------------------
   246    246   # Automake X.Y traces this macro to ensure aclocal.m4 has been
   247    247   # generated from the m4 files accompanying Automake X.Y.
   248    248   # (This private macro should not be called outside this file.)
   249    249   AC_DEFUN([AM_AUTOMAKE_VERSION],
   250         -[am__api_version='1.15'
          250  +[am__api_version='1.14'
   251    251   dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
   252    252   dnl require some minimum version.  Point them to the right macro.
   253         -m4_if([$1], [1.15], [],
          253  +m4_if([$1], [1.14.1], [],
   254    254         [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
   255    255   ])
   256    256   
   257    257   # _AM_AUTOCONF_VERSION(VERSION)
   258    258   # -----------------------------
   259    259   # aclocal traces this macro to find the Autoconf version.
   260    260   # This is a private macro too.  Using m4_define simplifies
................................................................................
   262    262   m4_define([_AM_AUTOCONF_VERSION], [])
   263    263   
   264    264   # AM_SET_CURRENT_AUTOMAKE_VERSION
   265    265   # -------------------------------
   266    266   # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
   267    267   # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
   268    268   AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
   269         -[AM_AUTOMAKE_VERSION([1.15])dnl
          269  +[AM_AUTOMAKE_VERSION([1.14.1])dnl
   270    270   m4_ifndef([AC_AUTOCONF_VERSION],
   271    271     [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
   272    272   _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
   273    273   
   274    274   # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
   275    275   
   276         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
          276  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
   277    277   #
   278    278   # This file is free software; the Free Software Foundation
   279    279   # gives unlimited permission to copy and/or distribute it,
   280    280   # with or without modifications, as long as this notice is preserved.
   281    281   
   282    282   # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
   283    283   # $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
................................................................................
   314    314   # configure, and could therefore not use this "fixed" $ac_aux_dir.
   315    315   #
   316    316   # Another solution, used here, is to always expand $ac_aux_dir to an
   317    317   # absolute PATH.  The drawback is that using absolute paths prevent a
   318    318   # configured tree to be moved without reconfiguration.
   319    319   
   320    320   AC_DEFUN([AM_AUX_DIR_EXPAND],
   321         -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
   322         -# Expand $ac_aux_dir to an absolute path.
   323         -am_aux_dir=`cd "$ac_aux_dir" && pwd`
          321  +[dnl Rely on autoconf to set up CDPATH properly.
          322  +AC_PREREQ([2.50])dnl
          323  +# expand $ac_aux_dir to an absolute path
          324  +am_aux_dir=`cd $ac_aux_dir && pwd`
   324    325   ])
   325    326   
   326    327   # AM_CONDITIONAL                                            -*- Autoconf -*-
   327    328   
   328         -# Copyright (C) 1997-2014 Free Software Foundation, Inc.
          329  +# Copyright (C) 1997-2013 Free Software Foundation, Inc.
   329    330   #
   330    331   # This file is free software; the Free Software Foundation
   331    332   # gives unlimited permission to copy and/or distribute it,
   332    333   # with or without modifications, as long as this notice is preserved.
   333    334   
   334    335   # AM_CONDITIONAL(NAME, SHELL-CONDITION)
   335    336   # -------------------------------------
................................................................................
   352    353   fi
   353    354   AC_CONFIG_COMMANDS_PRE(
   354    355   [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
   355    356     AC_MSG_ERROR([[conditional "$1" was never defined.
   356    357   Usually this means the macro was only invoked conditionally.]])
   357    358   fi])])
   358    359   
   359         -# Copyright (C) 1999-2014 Free Software Foundation, Inc.
          360  +# Copyright (C) 1999-2013 Free Software Foundation, Inc.
   360    361   #
   361    362   # This file is free software; the Free Software Foundation
   362    363   # gives unlimited permission to copy and/or distribute it,
   363    364   # with or without modifications, as long as this notice is preserved.
   364    365   
   365    366   
   366    367   # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
................................................................................
   543    544   _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
   544    545   AC_SUBST([am__nodep])dnl
   545    546   _AM_SUBST_NOTMAKE([am__nodep])dnl
   546    547   ])
   547    548   
   548    549   # Generate code to set up dependency tracking.              -*- Autoconf -*-
   549    550   
   550         -# Copyright (C) 1999-2014 Free Software Foundation, Inc.
          551  +# Copyright (C) 1999-2013 Free Software Foundation, Inc.
   551    552   #
   552    553   # This file is free software; the Free Software Foundation
   553    554   # gives unlimited permission to copy and/or distribute it,
   554    555   # with or without modifications, as long as this notice is preserved.
   555    556   
   556    557   
   557    558   # _AM_OUTPUT_DEPENDENCY_COMMANDS
................................................................................
   619    620   [AC_CONFIG_COMMANDS([depfiles],
   620    621        [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
   621    622        [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
   622    623   ])
   623    624   
   624    625   # Do all the work for Automake.                             -*- Autoconf -*-
   625    626   
   626         -# Copyright (C) 1996-2014 Free Software Foundation, Inc.
          627  +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
   627    628   #
   628    629   # This file is free software; the Free Software Foundation
   629    630   # gives unlimited permission to copy and/or distribute it,
   630    631   # with or without modifications, as long as this notice is preserved.
   631    632   
   632    633   # This macro actually does too much.  Some checks are only needed if
   633    634   # your package does certain things.  But this isn't really a big deal.
................................................................................
   709    710   AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
   710    711   AC_REQUIRE([AC_PROG_MKDIR_P])dnl
   711    712   # For better backward compatibility.  To be removed once Automake 1.9.x
   712    713   # dies out for good.  For more background, see:
   713    714   # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
   714    715   # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
   715    716   AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
   716         -# We need awk for the "check" target (and possibly the TAP driver).  The
   717         -# system "awk" is bad on some platforms.
          717  +# We need awk for the "check" target.  The system "awk" is bad on
          718  +# some platforms.
   718    719   AC_REQUIRE([AC_PROG_AWK])dnl
   719    720   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
   720    721   AC_REQUIRE([AM_SET_LEADING_DOT])dnl
   721    722   _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
   722    723   	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
   723    724   			     [_AM_PROG_TAR([v7])])])
   724    725   _AM_IF_OPTION([no-dependencies],,
................................................................................
   783    784   If you want to complete the configuration process using your problematic
   784    785   'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
   785    786   to "yes", and re-run configure.
   786    787   
   787    788   END
   788    789       AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   789    790     fi
   790         -fi
   791         -dnl The trailing newline in this macro's definition is deliberate, for
   792         -dnl backward compatibility and to allow trailing 'dnl'-style comments
   793         -dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
   794         -])
          791  +fi])
   795    792   
   796    793   dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
   797    794   dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
   798    795   dnl mangled by Autoconf and run in a shell conditional statement.
   799    796   m4_define([_AC_COMPILER_EXEEXT],
   800    797   m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
   801    798   
................................................................................
   816    813         break ;;
   817    814       * )
   818    815         _am_stamp_count=`expr $_am_stamp_count + 1` ;;
   819    816     esac
   820    817   done
   821    818   echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
   822    819   
   823         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
          820  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
   824    821   #
   825    822   # This file is free software; the Free Software Foundation
   826    823   # gives unlimited permission to copy and/or distribute it,
   827    824   # with or without modifications, as long as this notice is preserved.
   828    825   
   829    826   # AM_PROG_INSTALL_SH
   830    827   # ------------------
   831    828   # Define $install_sh.
   832    829   AC_DEFUN([AM_PROG_INSTALL_SH],
   833    830   [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
   834         -if test x"${install_sh+set}" != xset; then
          831  +if test x"${install_sh}" != xset; then
   835    832     case $am_aux_dir in
   836    833     *\ * | *\	*)
   837    834       install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
   838    835     *)
   839    836       install_sh="\${SHELL} $am_aux_dir/install-sh"
   840    837     esac
   841    838   fi
   842    839   AC_SUBST([install_sh])])
   843    840   
   844         -# Copyright (C) 2003-2014 Free Software Foundation, Inc.
          841  +# Copyright (C) 2003-2013 Free Software Foundation, Inc.
   845    842   #
   846    843   # This file is free software; the Free Software Foundation
   847    844   # gives unlimited permission to copy and/or distribute it,
   848    845   # with or without modifications, as long as this notice is preserved.
   849    846   
   850    847   # Check whether the underlying file-system supports filenames
   851    848   # with a leading dot.  For instance MS-DOS doesn't.
................................................................................
   859    856   fi
   860    857   rmdir .tst 2>/dev/null
   861    858   AC_SUBST([am__leading_dot])])
   862    859   
   863    860   # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
   864    861   # From Jim Meyering
   865    862   
   866         -# Copyright (C) 1996-2014 Free Software Foundation, Inc.
          863  +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
   867    864   #
   868    865   # This file is free software; the Free Software Foundation
   869    866   # gives unlimited permission to copy and/or distribute it,
   870    867   # with or without modifications, as long as this notice is preserved.
   871    868   
   872    869   # AM_MAINTAINER_MODE([DEFAULT-MODE])
   873    870   # ----------------------------------
................................................................................
   894    891     MAINT=$MAINTAINER_MODE_TRUE
   895    892     AC_SUBST([MAINT])dnl
   896    893   ]
   897    894   )
   898    895   
   899    896   # Check to see how 'make' treats includes.	            -*- Autoconf -*-
   900    897   
   901         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
          898  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
   902    899   #
   903    900   # This file is free software; the Free Software Foundation
   904    901   # gives unlimited permission to copy and/or distribute it,
   905    902   # with or without modifications, as long as this notice is preserved.
   906    903   
   907    904   # AM_MAKE_INCLUDE()
   908    905   # -----------------
................................................................................
   944    941   AC_SUBST([am__quote])
   945    942   AC_MSG_RESULT([$_am_result])
   946    943   rm -f confinc confmf
   947    944   ])
   948    945   
   949    946   # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
   950    947   
   951         -# Copyright (C) 1997-2014 Free Software Foundation, Inc.
          948  +# Copyright (C) 1997-2013 Free Software Foundation, Inc.
   952    949   #
   953    950   # This file is free software; the Free Software Foundation
   954    951   # gives unlimited permission to copy and/or distribute it,
   955    952   # with or without modifications, as long as this notice is preserved.
   956    953   
   957    954   # AM_MISSING_PROG(NAME, PROGRAM)
   958    955   # ------------------------------
................................................................................
   985    982   fi
   986    983   ])
   987    984   
   988    985   #  -*- Autoconf -*-
   989    986   # Obsolete and "removed" macros, that must however still report explicit
   990    987   # error messages when used, to smooth transition.
   991    988   #
   992         -# Copyright (C) 1996-2014 Free Software Foundation, Inc.
          989  +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
   993    990   #
   994    991   # This file is free software; the Free Software Foundation
   995    992   # gives unlimited permission to copy and/or distribute it,
   996    993   # with or without modifications, as long as this notice is preserved.
   997    994   
   998    995   AC_DEFUN([AM_CONFIG_HEADER],
   999    996   [AC_DIAGNOSE([obsolete],
................................................................................
  1012   1009   
  1013   1010   AC_DEFUN([AM_C_PROTOTYPES],
  1014   1011            [AC_FATAL([automatic de-ANSI-fication support has been removed])])
  1015   1012   AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
  1016   1013   
  1017   1014   # Helper functions for option handling.                     -*- Autoconf -*-
  1018   1015   
  1019         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
         1016  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
  1020   1017   #
  1021   1018   # This file is free software; the Free Software Foundation
  1022   1019   # gives unlimited permission to copy and/or distribute it,
  1023   1020   # with or without modifications, as long as this notice is preserved.
  1024   1021   
  1025   1022   # _AM_MANGLE_OPTION(NAME)
  1026   1023   # -----------------------
................................................................................
  1041   1038   
  1042   1039   # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
  1043   1040   # -------------------------------------------
  1044   1041   # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
  1045   1042   AC_DEFUN([_AM_IF_OPTION],
  1046   1043   [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
  1047   1044   
  1048         -# Copyright (C) 1999-2014 Free Software Foundation, Inc.
         1045  +# Copyright (C) 1999-2013 Free Software Foundation, Inc.
  1049   1046   #
  1050   1047   # This file is free software; the Free Software Foundation
  1051   1048   # gives unlimited permission to copy and/or distribute it,
  1052   1049   # with or without modifications, as long as this notice is preserved.
  1053   1050   
  1054   1051   # _AM_PROG_CC_C_O
  1055   1052   # ---------------
................................................................................
  1088   1085      CC="$am_aux_dir/compile $CC"
  1089   1086   fi
  1090   1087   AC_LANG_POP([C])])
  1091   1088   
  1092   1089   # For backward compatibility.
  1093   1090   AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
  1094   1091   
  1095         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
         1092  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
  1096   1093   #
  1097   1094   # This file is free software; the Free Software Foundation
  1098   1095   # gives unlimited permission to copy and/or distribute it,
  1099   1096   # with or without modifications, as long as this notice is preserved.
  1100   1097   
  1101   1098   # AM_RUN_LOG(COMMAND)
  1102   1099   # -------------------
................................................................................
  1107   1104      ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
  1108   1105      ac_status=$?
  1109   1106      echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
  1110   1107      (exit $ac_status); }])
  1111   1108   
  1112   1109   # Check to make sure that the build environment is sane.    -*- Autoconf -*-
  1113   1110   
  1114         -# Copyright (C) 1996-2014 Free Software Foundation, Inc.
         1111  +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
  1115   1112   #
  1116   1113   # This file is free software; the Free Software Foundation
  1117   1114   # gives unlimited permission to copy and/or distribute it,
  1118   1115   # with or without modifications, as long as this notice is preserved.
  1119   1116   
  1120   1117   # AM_SANITY_CHECK
  1121   1118   # ---------------
................................................................................
  1188   1185        # Hide warnings about reused PIDs.
  1189   1186        wait $am_sleep_pid 2>/dev/null
  1190   1187      fi
  1191   1188      AC_MSG_RESULT([done])])
  1192   1189   rm -f conftest.file
  1193   1190   ])
  1194   1191   
  1195         -# Copyright (C) 2009-2014 Free Software Foundation, Inc.
         1192  +# Copyright (C) 2009-2013 Free Software Foundation, Inc.
  1196   1193   #
  1197   1194   # This file is free software; the Free Software Foundation
  1198   1195   # gives unlimited permission to copy and/or distribute it,
  1199   1196   # with or without modifications, as long as this notice is preserved.
  1200   1197   
  1201   1198   # AM_SILENT_RULES([DEFAULT])
  1202   1199   # --------------------------
................................................................................
  1248   1245   AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
  1249   1246   AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
  1250   1247   AM_BACKSLASH='\'
  1251   1248   AC_SUBST([AM_BACKSLASH])dnl
  1252   1249   _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
  1253   1250   ])
  1254   1251   
  1255         -# Copyright (C) 2001-2014 Free Software Foundation, Inc.
         1252  +# Copyright (C) 2001-2013 Free Software Foundation, Inc.
  1256   1253   #
  1257   1254   # This file is free software; the Free Software Foundation
  1258   1255   # gives unlimited permission to copy and/or distribute it,
  1259   1256   # with or without modifications, as long as this notice is preserved.
  1260   1257   
  1261   1258   # AM_PROG_INSTALL_STRIP
  1262   1259   # ---------------------
................................................................................
  1276   1273   dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
  1277   1274   if test "$cross_compiling" != no; then
  1278   1275     AC_CHECK_TOOL([STRIP], [strip], :)
  1279   1276   fi
  1280   1277   INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
  1281   1278   AC_SUBST([INSTALL_STRIP_PROGRAM])])
  1282   1279   
  1283         -# Copyright (C) 2006-2014 Free Software Foundation, Inc.
         1280  +# Copyright (C) 2006-2013 Free Software Foundation, Inc.
  1284   1281   #
  1285   1282   # This file is free software; the Free Software Foundation
  1286   1283   # gives unlimited permission to copy and/or distribute it,
  1287   1284   # with or without modifications, as long as this notice is preserved.
  1288   1285   
  1289   1286   # _AM_SUBST_NOTMAKE(VARIABLE)
  1290   1287   # ---------------------------
................................................................................
  1295   1292   # AM_SUBST_NOTMAKE(VARIABLE)
  1296   1293   # --------------------------
  1297   1294   # Public sister of _AM_SUBST_NOTMAKE.
  1298   1295   AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
  1299   1296   
  1300   1297   # Check how to create a tarball.                            -*- Autoconf -*-
  1301   1298   
  1302         -# Copyright (C) 2004-2014 Free Software Foundation, Inc.
         1299  +# Copyright (C) 2004-2013 Free Software Foundation, Inc.
  1303   1300   #
  1304   1301   # This file is free software; the Free Software Foundation
  1305   1302   # gives unlimited permission to copy and/or distribute it,
  1306   1303   # with or without modifications, as long as this notice is preserved.
  1307   1304   
  1308   1305   # _AM_PROG_TAR(FORMAT)
  1309   1306   # --------------------

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.69 for librasterlite2 1.0.0-devel.
            3  +# Generated by GNU Autoconf 2.69 for librasterlite2 1.0.0-rc1.
     4      4   #
     5      5   # Report bugs to <a.furieri@lqt.it>.
     6      6   #
     7      7   #
     8      8   # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
     9      9   #
    10     10   #
................................................................................
   586    586   subdirs=
   587    587   MFLAGS=
   588    588   MAKEFLAGS=
   589    589   
   590    590   # Identity of this package.
   591    591   PACKAGE_NAME='librasterlite2'
   592    592   PACKAGE_TARNAME='librasterlite2'
   593         -PACKAGE_VERSION='1.0.0-devel'
   594         -PACKAGE_STRING='librasterlite2 1.0.0-devel'
          593  +PACKAGE_VERSION='1.0.0-rc1'
          594  +PACKAGE_STRING='librasterlite2 1.0.0-rc1'
   595    595   PACKAGE_BUGREPORT='a.furieri@lqt.it'
   596    596   PACKAGE_URL=''
   597    597   
   598    598   # Factoring default headers for most tests.
   599    599   ac_includes_default="\
   600    600   #include <stdio.h>
   601    601   #ifdef HAVE_SYS_TYPES_H
................................................................................
  1368   1368   #
  1369   1369   # Report the --help message.
  1370   1370   #
  1371   1371   if test "$ac_init_help" = "long"; then
  1372   1372     # Omit some internal or obsolete options to make the list less imposing.
  1373   1373     # This message is too long to be a string in the A/UX 3.1 sh.
  1374   1374     cat <<_ACEOF
  1375         -\`configure' configures librasterlite2 1.0.0-devel to adapt to many kinds of systems.
         1375  +\`configure' configures librasterlite2 1.0.0-rc1 to adapt to many kinds of systems.
  1376   1376   
  1377   1377   Usage: $0 [OPTION]... [VAR=VALUE]...
  1378   1378   
  1379   1379   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1380   1380   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1381   1381   
  1382   1382   Defaults for the options are specified in brackets.
................................................................................
  1438   1438     --build=BUILD     configure for building on BUILD [guessed]
  1439   1439     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1440   1440   _ACEOF
  1441   1441   fi
  1442   1442   
  1443   1443   if test -n "$ac_init_help"; then
  1444   1444     case $ac_init_help in
  1445         -     short | recursive ) echo "Configuration of librasterlite2 1.0.0-devel:";;
         1445  +     short | recursive ) echo "Configuration of librasterlite2 1.0.0-rc1:";;
  1446   1446      esac
  1447   1447     cat <<\_ACEOF
  1448   1448   
  1449   1449   Optional Features:
  1450   1450     --disable-option-checking  ignore unrecognized --enable/--with options
  1451   1451     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1452   1452     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1590   1590       cd "$ac_pwd" || { ac_status=$?; break; }
  1591   1591     done
  1592   1592   fi
  1593   1593   
  1594   1594   test -n "$ac_init_help" && exit $ac_status
  1595   1595   if $ac_init_version; then
  1596   1596     cat <<\_ACEOF
  1597         -librasterlite2 configure 1.0.0-devel
         1597  +librasterlite2 configure 1.0.0-rc1
  1598   1598   generated by GNU Autoconf 2.69
  1599   1599   
  1600   1600   Copyright (C) 2012 Free Software Foundation, Inc.
  1601   1601   This configure script is free software; the Free Software Foundation
  1602   1602   gives unlimited permission to copy, distribute and modify it.
  1603   1603   _ACEOF
  1604   1604     exit
................................................................................
  2134   2134     eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  2135   2135   
  2136   2136   } # ac_fn_c_check_type
  2137   2137   cat >config.log <<_ACEOF
  2138   2138   This file contains any messages produced by compilers while
  2139   2139   running configure, to aid debugging if configure makes a mistake.
  2140   2140   
  2141         -It was created by librasterlite2 $as_me 1.0.0-devel, which was
         2141  +It was created by librasterlite2 $as_me 1.0.0-rc1, which was
  2142   2142   generated by GNU Autoconf 2.69.  Invocation command line was
  2143   2143   
  2144   2144     $ $0 $@
  2145   2145   
  2146   2146   _ACEOF
  2147   2147   exec 5>>config.log
  2148   2148   {
................................................................................
  2519   2519   ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
  2520   2520   ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
  2521   2521   ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
  2522   2522   
  2523   2523   
  2524   2524   
  2525   2525   
  2526         -am__api_version='1.15'
         2526  +am__api_version='1.14'
  2527   2527   
  2528   2528   # Find a good install program.  We prefer a C program (faster),
  2529   2529   # so one script is as good as another.  But avoid the broken or
  2530   2530   # incompatible versions:
  2531   2531   # SysV /etc/install, /usr/sbin/install
  2532   2532   # SunOS /usr/etc/install
  2533   2533   # IRIX /sbin/install
................................................................................
  2691   2691   test "$program_suffix" != NONE &&
  2692   2692     program_transform_name="s&\$&$program_suffix&;$program_transform_name"
  2693   2693   # Double any \ or $.
  2694   2694   # By default was `s,x,x', remove it if useless.
  2695   2695   ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
  2696   2696   program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
  2697   2697   
  2698         -# Expand $ac_aux_dir to an absolute path.
  2699         -am_aux_dir=`cd "$ac_aux_dir" && pwd`
         2698  +# expand $ac_aux_dir to an absolute path
         2699  +am_aux_dir=`cd $ac_aux_dir && pwd`
  2700   2700   
  2701   2701   if test x"${MISSING+set}" != xset; then
  2702   2702     case $am_aux_dir in
  2703   2703     *\ * | *\	*)
  2704   2704       MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
  2705   2705     *)
  2706   2706       MISSING="\${SHELL} $am_aux_dir/missing" ;;
................................................................................
  2711   2711     am_missing_run="$MISSING "
  2712   2712   else
  2713   2713     am_missing_run=
  2714   2714     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
  2715   2715   $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
  2716   2716   fi
  2717   2717   
  2718         -if test x"${install_sh+set}" != xset; then
         2718  +if test x"${install_sh}" != xset; then
  2719   2719     case $am_aux_dir in
  2720   2720     *\ * | *\	*)
  2721   2721       install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
  2722   2722     *)
  2723   2723       install_sh="\${SHELL} $am_aux_dir/install-sh"
  2724   2724     esac
  2725   2725   fi
................................................................................
  3005   3005       CYGPATH_W=echo
  3006   3006     fi
  3007   3007   fi
  3008   3008   
  3009   3009   
  3010   3010   # Define the identity of the package.
  3011   3011    PACKAGE='librasterlite2'
  3012         - VERSION='1.0.0-devel'
         3012  + VERSION='1.0.0-rc1'
  3013   3013   
  3014   3014   
  3015   3015   cat >>confdefs.h <<_ACEOF
  3016   3016   #define PACKAGE "$PACKAGE"
  3017   3017   _ACEOF
  3018   3018   
  3019   3019   
................................................................................
  3039   3039   
  3040   3040   # For better backward compatibility.  To be removed once Automake 1.9.x
  3041   3041   # dies out for good.  For more background, see:
  3042   3042   # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
  3043   3043   # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
  3044   3044   mkdir_p='$(MKDIR_P)'
  3045   3045   
  3046         -# We need awk for the "check" target (and possibly the TAP driver).  The
  3047         -# system "awk" is bad on some platforms.
         3046  +# We need awk for the "check" target.  The system "awk" is bad on
         3047  +# some platforms.
  3048   3048   # Always define AMTAR for backward compatibility.  Yes, it's still used
  3049   3049   # in the wild :-(  We should find a proper way to deprecate it ...
  3050   3050   AMTAR='$${TAR-tar}'
  3051   3051   
  3052   3052   
  3053   3053   # We'll loop over all known methods to create a tar archive until one works.
  3054   3054   _am_tools='gnutar  pax cpio none'
................................................................................
  3097   3097   'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
  3098   3098   to "yes", and re-run configure.
  3099   3099   
  3100   3100   END
  3101   3101       as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
  3102   3102     fi
  3103   3103   fi
  3104         -
  3105   3104   
  3106   3105   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
  3107   3106   $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
  3108   3107       # Check whether --enable-maintainer-mode was given.
  3109   3108   if test "${enable_maintainer_mode+set}" = set; then :
  3110   3109     enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
  3111   3110   else
................................................................................
 19157  19156   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 19158  19157   
 19159  19158   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 19160  19159   # Save the log message, to keep $0 and so on meaningful, and to
 19161  19160   # report actual input values of CONFIG_FILES etc. instead of their
 19162  19161   # values after options handling.
 19163  19162   ac_log="
 19164         -This file was extended by librasterlite2 $as_me 1.0.0-devel, which was
        19163  +This file was extended by librasterlite2 $as_me 1.0.0-rc1, which was
 19165  19164   generated by GNU Autoconf 2.69.  Invocation command line was
 19166  19165   
 19167  19166     CONFIG_FILES    = $CONFIG_FILES
 19168  19167     CONFIG_HEADERS  = $CONFIG_HEADERS
 19169  19168     CONFIG_LINKS    = $CONFIG_LINKS
 19170  19169     CONFIG_COMMANDS = $CONFIG_COMMANDS
 19171  19170     $ $0 $@
................................................................................
 19223  19222   
 19224  19223   Report bugs to <a.furieri@lqt.it>."
 19225  19224   
 19226  19225   _ACEOF
 19227  19226   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 19228  19227   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 19229  19228   ac_cs_version="\\
 19230         -librasterlite2 config.status 1.0.0-devel
        19229  +librasterlite2 config.status 1.0.0-rc1
 19231  19230   configured by $0, generated by GNU Autoconf 2.69,
 19232  19231     with options \\"\$ac_cs_config\\"
 19233  19232   
 19234  19233   Copyright (C) 2012 Free Software Foundation, Inc.
 19235  19234   This config.status script is free software; the Free Software Foundation
 19236  19235   gives unlimited permission to copy, distribute and modify it."
 19237  19236   

Changes to configure.ac.

     1      1   #                                               -*- Autoconf -*-
     2      2   # Process this file with autoconf to produce a configure script.
     3      3   
     4      4   AC_PREREQ(2.61)
     5         -AC_INIT(librasterlite2, 1.0.0-devel, a.furieri@lqt.it)
            5  +AC_INIT(librasterlite2, 1.0.0-rc1, a.furieri@lqt.it)
     6      6   AC_LANG(C)
     7      7   AC_CONFIG_AUX_DIR([.])
     8      8   AC_CONFIG_MACRO_DIR([m4])
     9      9   
    10     10   AM_INIT_AUTOMAKE
    11     11   AM_MAINTAINER_MODE
    12     12   AM_CONFIG_HEADER(config.h)

Changes to headers/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   
    17     17   VPATH = @srcdir@
    18         -am__is_gnu_make = { \
    19         -  if test -z '$(MAKELEVEL)'; then \
    20         -    false; \
    21         -  elif test -n '$(MAKE_HOST)'; then \
    22         -    true; \
    23         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    24         -    true; \
    25         -  else \
    26         -    false; \
    27         -  fi; \
    28         -}
           18  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    29     19   am__make_running_with_option = \
    30     20     case $${target_option-} in \
    31     21         ?) ;; \
    32     22         *) echo "am__make_running_with_option: internal error: invalid" \
    33     23                 "target option '$${target_option-}' specified" >&2; \
    34     24            exit 1;; \
    35     25     esac; \
................................................................................
    85     75   POST_INSTALL = :
    86     76   NORMAL_UNINSTALL = :
    87     77   PRE_UNINSTALL = :
    88     78   POST_UNINSTALL = :
    89     79   build_triplet = @build@
    90     80   host_triplet = @host@
    91     81   subdir = headers
           82  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
           83  +	$(nobase_include_HEADERS) $(noinst_HEADERS)
    92     84   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    93     85   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    94     86   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    95     87   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    96     88   	$(top_srcdir)/configure.ac
    97     89   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    98     90   	$(ACLOCAL_M4)
    99         -DIST_COMMON = $(srcdir)/Makefile.am $(nobase_include_HEADERS) \
   100         -	$(noinst_HEADERS) $(am__DIST_COMMON)
   101     91   mkinstalldirs = $(install_sh) -d
   102     92   CONFIG_HEADER = $(top_builddir)/config.h
   103     93   CONFIG_CLEAN_FILES =
   104     94   CONFIG_CLEAN_VPATH_FILES =
   105     95   AM_V_P = $(am__v_P_@AM_V@)
   106     96   am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
   107     97   am__v_P_0 = false
................................................................................
   165    155   am__define_uniq_tagged_files = \
   166    156     list='$(am__tagged_files)'; \
   167    157     unique=`for i in $$list; do \
   168    158       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   169    159     done | $(am__uniquify_input)`
   170    160   ETAGS = etags
   171    161   CTAGS = ctags
   172         -am__DIST_COMMON = $(srcdir)/Makefile.in
   173    162   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   174    163   ACLOCAL = @ACLOCAL@
   175    164   AMTAR = @AMTAR@
   176    165   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   177    166   AR = @AR@
   178    167   AS = @AS@
   179    168   AUTOCONF = @AUTOCONF@
................................................................................
   332    321   	        && { if test -f $@; then exit 0; else break; fi; }; \
   333    322   	      exit 1;; \
   334    323   	  esac; \
   335    324   	done; \
   336    325   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu headers/Makefile'; \
   337    326   	$(am__cd) $(top_srcdir) && \
   338    327   	  $(AUTOMAKE) --gnu headers/Makefile
          328  +.PRECIOUS: Makefile
   339    329   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   340    330   	@case '$?' in \
   341    331   	  *config.status*) \
   342    332   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   343    333   	  *) \
   344    334   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   345    335   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
   581    571   	install-nobase_includeHEADERS install-pdf install-pdf-am \
   582    572   	install-ps install-ps-am install-strip installcheck \
   583    573   	installcheck-am installdirs maintainer-clean \
   584    574   	maintainer-clean-generic mostlyclean mostlyclean-generic \
   585    575   	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
   586    576   	uninstall-am uninstall-nobase_includeHEADERS
   587    577   
   588         -.PRECIOUS: Makefile
   589         -
   590    578   
   591    579   # Tell versions [3.59,3.63) of GNU make to not export all variables.
   592    580   # Otherwise a system limit (for SysV at least) may be exceeded.
   593    581   .NOEXPORT:

Changes to headers/rasterlite2/rasterlite2.h.

  3465   3465       RL2_DECLARE int rl2_load_raw_raster_into_dbms (sqlite3 * sqlite,
  3466   3466   						   int max_threads,
  3467   3467   						   rl2CoveragePtr cvg,
  3468   3468   						   const char *sctn_name,
  3469   3469   						   rl2RasterPtr rst,
  3470   3470   						   int pyramidize);
  3471   3471   
  3472         -    RL2_DECLARE int rl2_load_raw_tiles_into_dbms (sqlite3 * sqlite,
  3473         -						  rl2CoveragePtr cvg,
  3474         -						  const char *sctn_name,
  3475         -						  unsigned int sctn_width,
  3476         -						  unsigned int sctn_height,
  3477         -						  int sctn_srid,
  3478         -						  double sctn_minx,
  3479         -						  double sctn_miny,
  3480         -						  double sctn_maxx,
  3481         -						  double sctn_maxy,
  3482         -						  int (*getTile) (void *data,
  3483         -								  double
  3484         -								  tile_minx,
  3485         -								  double
  3486         -								  tile_miny,
  3487         -								  double
  3488         -								  tile_maxx,
  3489         -								  double
  3490         -								  tile_maxy,
  3491         -								  unsigned char
  3492         -								  *bufpix,
  3493         -								  rl2PalettePtr
  3494         -								  * palette),
  3495         -						  void *data, int pyramidize);
  3496         -
  3497   3472       RL2_DECLARE int
  3498   3473   	rl2_get_raw_raster_data (sqlite3 * handle, int max_threads,
  3499   3474   				 rl2CoveragePtr cvg, unsigned int width,
  3500   3475   				 unsigned int height, double minx, double miny,
  3501   3476   				 double maxx, double maxy, double x_res,
  3502   3477   				 double y_res, unsigned char **buffer,
  3503   3478   				 int *buf_size, rl2PalettePtr * palette,
  3504   3479   				 unsigned char out_pixel);
  3505   3480   
  3506         -    RL2_DECLARE int
  3507         -	rl2_get_raw_raster_mask (sqlite3 * handle, int max_threads,
  3508         -				 rl2CoveragePtr cvg, unsigned int width,
  3509         -				 unsigned int height, double minx, double miny,
  3510         -				 double maxx, double maxy, double x_res,
  3511         -				 double y_res, unsigned char **mask,
  3512         -				 int *mask_size);
  3513         -
  3514   3481       RL2_DECLARE int
  3515   3482   	rl2_get_section_raw_raster_data (sqlite3 * handle, int max_threads,
  3516   3483   					 rl2CoveragePtr cvg,
  3517   3484   					 sqlite3_int64 section_id,
  3518   3485   					 unsigned int width,
  3519   3486   					 unsigned int height, double minx,
  3520   3487   					 double miny, double maxx, double maxy,
  3521   3488   					 double x_res, double y_res,
  3522   3489   					 unsigned char **buffer, int *buf_size,
  3523   3490   					 rl2PalettePtr * palette,
  3524   3491   					 unsigned char out_pixel);
  3525   3492   
  3526         -    RL2_DECLARE int
  3527         -	rl2_get_section_raw_raster_mask (sqlite3 * handle, int max_threads,
  3528         -					 rl2CoveragePtr cvg,
  3529         -					 sqlite3_int64 section_id,
  3530         -					 unsigned int width,
  3531         -					 unsigned int height, double minx,
  3532         -					 double miny, double maxx, double maxy,
  3533         -					 double x_res, double y_res,
  3534         -					 unsigned char **mask, int *mask_size);
  3535         -
  3536   3493       RL2_DECLARE int
  3537   3494   	rl2_get_triple_band_raw_raster_data (sqlite3 * handle,
  3538   3495   					     rl2CoveragePtr cvg,
  3539   3496   					     unsigned int width,
  3540   3497   					     unsigned int height,
  3541   3498   					     double minx, double miny,
  3542   3499   					     double maxx, double maxy,
................................................................................
  3716   3673       RL2_DECLARE int
  3717   3674   	rl2_compare_palettes (rl2PalettePtr palette_1, rl2PalettePtr palette_2);
  3718   3675   
  3719   3676       RL2_DECLARE int
  3720   3677   	rl2_check_dbms_palette (sqlite3 * handle, rl2CoveragePtr cvg,
  3721   3678   				rl2TiffOriginPtr tiff);
  3722   3679   
  3723         -    RL2_DECLARE int
  3724         -	rl2_install_dbms_palette_from_tiff (sqlite3 * handle,
  3725         -					    rl2CoveragePtr cvg,
  3726         -					    rl2TiffOriginPtr tiff);
  3727         -
  3728   3680       RL2_DECLARE int
  3729   3681   	rl2_serialize_dbms_pixel (rl2PixelPtr pixel, unsigned char **blob,
  3730   3682   				  int *blob_size);
  3731   3683   
  3732   3684       RL2_DECLARE int
  3733   3685   	rl2_is_valid_dbms_pixel (const unsigned char *blob, int blob_size,
  3734   3686   				 unsigned char sample_type,

Changes to headers/rasterlite2/rl2graphics.h.

  1339   1339       RL2_DECLARE int rl2_graph_draw_rescaled_bitmap (rl2GraphicsContextPtr
  1340   1340   						    context,
  1341   1341   						    rl2GraphicsBitmapPtr bitmap,
  1342   1342   						    double scale_x,
  1343   1343   						    double scale_y, double x,
  1344   1344   						    double y);
  1345   1345   
  1346         -/**
  1347         - Rescales a raw pixbuf (RGB or GRAYSCALE)
  1348         -
  1349         - \param inbuf pointer to the input pixbuf.
  1350         - \param inwidth the width (measured in pixels) of the input pixbuf.
  1351         - \param inheight the height (measured in pixels) of the input pixbuf.
  1352         - \param pixtype either RL2_PIXEL_RGB or RL2_PIXEL_GRAYSCALE.
  1353         - \param outbuf pointer to the input pixbuf.
  1354         - \param outwidth the width (measured in pixels) of the output pixbuf.
  1355         - \param outheight the height (measured in pixels) of the output pixbuf.
  1356         -
  1357         - \return 0 (false) on error, any other value on success.
  1358         - */
  1359         -    RL2_DECLARE int rl2_rescale_pixbuf (const unsigned char *inbuf,
  1360         -					unsigned int inwidth,
  1361         -					unsigned int inheight,
  1362         -					unsigned char pixtype,
  1363         -					const unsigned char *outbuf,
  1364         -					unsigned int outwidth,
  1365         -					unsigned int outheight);
  1366         -
  1367   1346   /**
  1368   1347    Creates an RGB Array corresponding to the current Canvass
  1369   1348   
  1370   1349    \param context the pointer to a valid Graphics Context (aka Canvass).
  1371   1350   
  1372   1351    \return the pointer to the RGB Array: NULL on failure.
  1373   1352    

Changes to headers/rasterlite2/sqlite.h.

    48     48   #ifdef LOADABLE_EXTENSION	/* loadable-extension only */
    49     49   #include <sqlite3ext.h>
    50     50   extern const sqlite3_api_routines *sqlite3_api;
    51     51   #else /* ordinary lib */
    52     52   #include <sqlite3.h>
    53     53   #endif
    54     54   
    55         -#ifndef SQLITE_DETERMINISTIC
    56         -/* probably SQLite < 3.8.3 - attempting to fix */
    57         -#define SQLITE_DETERMINISTIC	SQLITE_UTF8
    58         -#endif
    59         -
    60     55   #endif

Changes to headers/rasterlite2_private.h.

  1097   1097       } rl2Point;
  1098   1098       typedef rl2Point *rl2PointPtr;
  1099   1099   
  1100   1100       typedef struct rl2_linestring
  1101   1101       {
  1102   1102   	int points;
  1103   1103   	double *coords;
  1104         -	double minx;
  1105         -	double miny;
  1106         -	double maxx;
  1107         -	double maxy;
  1108   1104   	struct rl2_linestring *next;
  1109   1105       } rl2Linestring;
  1110   1106       typedef rl2Linestring *rl2LinestringPtr;
  1111   1107   
  1112   1108       typedef struct rl2_ring
  1113   1109       {
  1114   1110   	int points;
  1115   1111   	double *coords;
  1116         -	double minx;
  1117         -	double miny;
  1118         -	double maxx;
  1119         -	double maxy;
  1120   1112   	struct rl2_ring *next;
  1121   1113       } rl2Ring;
  1122   1114       typedef rl2Ring *rl2RingPtr;
  1123   1115   
  1124   1116       typedef struct rl2_polygon
  1125   1117       {
  1126   1118   	rl2RingPtr exterior;
................................................................................
  1210   1202   	rl2PrivRasterStatisticsPtr stats;
  1211   1203   	rl2PrivRasterPtr raster;
  1212   1204   	rl2PrivPalettePtr palette;
  1213   1205   	int retcode;
  1214   1206       } rl2AuxDecoder;
  1215   1207       typedef rl2AuxDecoder *rl2AuxDecoderPtr;
  1216   1208   
  1217         -    typedef struct rl2_aux_mask_decoder
  1218         -    {
  1219         -	void *opaque_thread_id;
  1220         -	sqlite3_int64 tile_id;
  1221         -	unsigned char *blob_odd;
  1222         -	int blob_odd_sz;
  1223         -	unsigned char *maskbuf;
  1224         -	unsigned int width;
  1225         -	unsigned int height;
  1226         -	double x_res;
  1227         -	double y_res;
  1228         -	int scale;
  1229         -	double minx;
  1230         -	double maxy;
  1231         -	double tile_minx;
  1232         -	double tile_maxy;
  1233         -	rl2PrivRasterPtr raster;
  1234         -	int retcode;
  1235         -    } rl2AuxMaskDecoder;
  1236         -    typedef rl2AuxMaskDecoder *rl2AuxMaskDecoderPtr;
  1237         -
  1238   1209       typedef struct rl2_aux_shadower
  1239   1210       {
  1240   1211   	void *opaque_thread_id;
  1241   1212   	unsigned int width;
  1242   1213   	unsigned int height;
  1243   1214   	double relief_factor;
  1244   1215   	double scale_factor;
................................................................................
  1282   1253   				    unsigned int *height,
  1283   1254   				    unsigned char sample_type,
  1284   1255   				    unsigned char pixel_type,
  1285   1256   				    unsigned char num_bands,
  1286   1257   				    unsigned char **pixels, int *pixels_sz);
  1287   1258   
  1288   1259       RL2_PRIVATE int
  1289         -	rl2_data_to_png (const unsigned char *pixels,
  1290         -			 const unsigned char *mask, double opacity,
  1291         -			 rl2PalettePtr plt, unsigned int width,
  1292         -			 unsigned int height, unsigned char sample_type,
  1293         -			 unsigned char pixel_type, unsigned char num_bands,
  1294         -			 unsigned char **compr_data, int *compressed_size);
         1260  +	rl2_data_to_png (const unsigned char *pixels, const unsigned char *mask,
         1261  +			 double opacity, rl2PalettePtr plt,
         1262  +			 unsigned int width, unsigned int height,
         1263  +			 unsigned char sample_type, unsigned char pixel_type,
         1264  +			 unsigned char num_bands, unsigned char **compr_data,
         1265  +			 int *compressed_size);
  1295   1266   
  1296   1267       RL2_PRIVATE int
  1297   1268   	rl2_decode_png (const unsigned char *png, int png_sz,
  1298   1269   			unsigned int *width, unsigned int *height,
  1299   1270   			unsigned char *sample_type, unsigned char *pixel_type,
  1300   1271   			unsigned char *num_bands, unsigned char **pixels,
  1301   1272   			int *pixels_sz, unsigned char **mask, int *mask_sz,
................................................................................
  1307   1278   			    unsigned char pixel_type, unsigned char num_bands,
  1308   1279   			    unsigned char **compr_data, int *compressed_size);
  1309   1280   
  1310   1281       RL2_PRIVATE int
  1311   1282   	rl2_decode_charls (const unsigned char *charls, int charls_sz,
  1312   1283   			   unsigned int *width, unsigned int *height,
  1313   1284   			   unsigned char *sample_type,
  1314         -			   unsigned char *pixel_type,
  1315         -			   unsigned char *num_bands, unsigned char **pixels,
  1316         -			   int *pixels_sz);
         1285  +			   unsigned char *pixel_type, unsigned char *num_bands,
         1286  +			   unsigned char **pixels, int *pixels_sz);
  1317   1287   
  1318   1288       RL2_PRIVATE int
  1319   1289   	rl2_data_to_gif (const unsigned char *pixels,
  1320   1290   			 rl2PalettePtr plt, unsigned int width,
  1321   1291   			 unsigned int height, unsigned char sample_type,
  1322   1292   			 unsigned char pixel_type, unsigned char **compr_data,
  1323   1293   			 int *compressed_size);
................................................................................
  1373   1343   					 unsigned int height,
  1374   1344   					 unsigned char sample_type,
  1375   1345   					 unsigned char num_bands,
  1376   1346   					 unsigned char auto_ndvi,
  1377   1347   					 unsigned char red_band_index,
  1378   1348   					 unsigned char nir_band_index,
  1379   1349   					 double x_res, double y_res,
  1380         -					 double minx, double miny,
  1381         -					 double maxx, double maxy, int level,
  1382         -					 int scale, rl2PalettePtr palette,
         1350  +					 double minx, double miny, double maxx,
         1351  +					 double maxy, int level, int scale,
         1352  +					 rl2PalettePtr palette,
  1383   1353   					 rl2PixelPtr no_data,
  1384   1354   					 rl2RasterSymbolizerPtr style,
  1385   1355   					 rl2RasterStatisticsPtr stats);
  1386   1356   
  1387   1357       RL2_PRIVATE int rl2_load_dbms_tiles_section (sqlite3 * handle,
  1388   1358   						 int max_threads,
  1389   1359   						 sqlite3_int64 section_id,
................................................................................
  1394   1364   						 unsigned int height,
  1395   1365   						 unsigned char sample_type,
  1396   1366   						 unsigned char num_bands,
  1397   1367   						 unsigned char auto_ndvi,
  1398   1368   						 unsigned char red_band_index,
  1399   1369   						 unsigned char nir_band_index,
  1400   1370   						 double x_res, double y_res,
  1401         -						 double minx, double miny,
  1402         -						 double maxx, double maxy,
  1403         -						 int level, int scale,
         1371  +						 double minx, double maxy,
         1372  +						 int scale,
  1404   1373   						 rl2PalettePtr palette,
  1405   1374   						 rl2PixelPtr no_data);
  1406   1375   
  1407   1376       RL2_PRIVATE void
  1408   1377   	compute_aggregate_sq_diff (rl2RasterStatisticsPtr aggreg_stats);
  1409   1378   
  1410   1379       RL2_PRIVATE int get_coverage_sample_bands (sqlite3 * sqlite,
................................................................................
  1420   1389   				       unsigned char *num_bands,
  1421   1390   				       unsigned char *compression);
  1422   1391   
  1423   1392       RL2_PRIVATE rl2PixelPtr default_nodata (unsigned char sample,
  1424   1393   					    unsigned char pixel,
  1425   1394   					    unsigned char num_bands);
  1426   1395   
  1427         -    RL2_PRIVATE int
  1428         -	do_check_initial_palette (sqlite3 * handle, rl2CoveragePtr cvg);
  1429         -
  1430   1396       RL2_PRIVATE WmsRetryListPtr alloc_retry_list ();
  1431   1397   
  1432   1398       RL2_PRIVATE void free_retry_list (WmsRetryListPtr lst);
  1433   1399   
  1434   1400       RL2_PRIVATE void add_retry (WmsRetryListPtr lst, double minx, double miny,
  1435   1401   				double maxx, double maxy);
  1436   1402   
................................................................................
  1481   1447   					  int scale, double x_res,
  1482   1448   					  double y_res);
  1483   1449   
  1484   1450       RL2_PRIVATE int rl2_find_best_resolution_level (sqlite3 * handle,
  1485   1451   						    const char *coverage,
  1486   1452   						    int by_section,
  1487   1453   						    sqlite3_int64 section_id,
  1488         -						    double x_res,
  1489         -						    double y_res,
         1454  +						    double x_res, double y_res,
  1490   1455   						    int *level_id, int *scale,
  1491   1456   						    int *real_scale,
  1492   1457   						    double *xx_res,
  1493   1458   						    double *yy_res);
  1494   1459   
  1495   1460       RL2_PRIVATE unsigned char get_palette_format (rl2PrivPalettePtr plt);
  1496   1461   
................................................................................
  1532   1497   						     unsigned char format,
  1533   1498   						     int quality,
  1534   1499   						     unsigned char **image,
  1535   1500   						     int *image_sz);
  1536   1501   
  1537   1502       RL2_PRIVATE int get_payload_from_palette_transparent (unsigned int width,
  1538   1503   							  unsigned int height,
  1539         -							  unsigned char
  1540         -							  *pixels,
  1541         -							  rl2PalettePtr
  1542         -							  palette,
  1543         -							  unsigned char
  1544         -							  format, int quality,
  1545         -							  unsigned char
  1546         -							  **image,
         1504  +							  unsigned char *pixels,
         1505  +							  rl2PalettePtr palette,
         1506  +							  unsigned char format,
         1507  +							  int quality,
         1508  +							  unsigned char **image,
  1547   1509   							  int *image_sz,
  1548         -							  unsigned char
  1549         -							  bg_red,
         1510  +							  unsigned char bg_red,
  1550   1511   							  unsigned char
  1551   1512   							  bg_green,
  1552   1513   							  unsigned char
  1553   1514   							  bg_blue,
  1554   1515   							  double opacity);
  1555   1516   
  1556   1517       RL2_PRIVATE int get_payload_from_grayscale_opaque (unsigned int width,
  1557   1518   						       unsigned int height,
  1558   1519   						       sqlite3 * handle,
  1559         -						       double minx,
  1560         -						       double miny,
  1561         -						       double maxx,
  1562         -						       double maxy, int srid,
         1520  +						       double minx, double miny,
         1521  +						       double maxx, double maxy,
         1522  +						       int srid,
  1563   1523   						       unsigned char *pixels,
  1564   1524   						       unsigned char format,
  1565   1525   						       int quality,
  1566   1526   						       unsigned char **image,
  1567   1527   						       int *image_sz);
  1568   1528   
  1569   1529       RL2_PRIVATE int get_payload_from_grayscale_transparent (unsigned int
  1570   1530   							    width,
  1571   1531   							    unsigned int
  1572   1532   							    height,
  1573   1533   							    unsigned char
  1574   1534   							    *pixels,
  1575   1535   							    unsigned char
  1576         -							    format,
  1577         -							    int quality,
         1536  +							    format, int quality,
  1578   1537   							    unsigned char
  1579   1538   							    **image,
  1580   1539   							    int *image_sz,
  1581   1540   							    unsigned char
  1582   1541   							    bg_gray,
  1583   1542   							    double opacity);
  1584   1543   
  1585   1544       RL2_PRIVATE int get_payload_from_rgb_opaque (unsigned int width,
  1586   1545   						 unsigned int height,
  1587         -						 sqlite3 * handle,
  1588         -						 double minx, double miny,
  1589         -						 double maxx, double maxy,
  1590         -						 int srid,
         1546  +						 sqlite3 * handle, double minx,
         1547  +						 double miny, double maxx,
         1548  +						 double maxy, int srid,
  1591   1549   						 unsigned char *pixels,
  1592   1550   						 unsigned char format,
  1593   1551   						 int quality,
  1594   1552   						 unsigned char **image,
  1595   1553   						 int *image_sz);
  1596   1554   
  1597   1555       RL2_PRIVATE int get_payload_from_rgb_transparent (unsigned int width,
................................................................................
  1616   1574       RL2_PRIVATE int get_rgba_from_monochrome_opaque (unsigned int width,
  1617   1575   						     unsigned int height,
  1618   1576   						     unsigned char *pixels,
  1619   1577   						     unsigned char *rgba);
  1620   1578   
  1621   1579       RL2_PRIVATE int get_rgba_from_monochrome_transparent (unsigned int width,
  1622   1580   							  unsigned int height,
  1623         -							  unsigned char
  1624         -							  *pixels,
         1581  +							  unsigned char *pixels,
  1625   1582   							  unsigned char *rgba);
  1626   1583   
  1627   1584       RL2_PRIVATE int get_rgba_from_palette_mask (unsigned int base_width,
  1628   1585   						unsigned int base_height,
  1629   1586   						unsigned char *pixels,
  1630   1587   						unsigned char *mask,
  1631   1588   						rl2PalettePtr palette,
................................................................................
  1657   1614       RL2_PRIVATE int get_rgba_from_grayscale_opaque (unsigned int width,
  1658   1615   						    unsigned int height,
  1659   1616   						    unsigned char *pixels,
  1660   1617   						    unsigned char *rgba);
  1661   1618   
  1662   1619       RL2_PRIVATE int get_rgba_from_grayscale_transparent (unsigned int width,
  1663   1620   							 unsigned int height,
  1664         -							 unsigned char
  1665         -							 *pixels,
         1621  +							 unsigned char *pixels,
  1666   1622   							 unsigned char *rgba,
  1667   1623   							 unsigned char bg_gray);
  1668   1624   
  1669   1625       RL2_PRIVATE int get_rgba_from_rgb_mask (unsigned int width,
  1670   1626   					    unsigned int height,
  1671   1627   					    unsigned char *pixels,
  1672   1628   					    unsigned char *mask,
................................................................................
  1702   1658   						  unsigned char *mask,
  1703   1659   						  rl2PrivPixelPtr no_made,
  1704   1660   						  unsigned char *rgba);
  1705   1661   
  1706   1662       RL2_PRIVATE int get_payload_from_gray_rgba_opaque (unsigned int width,
  1707   1663   						       unsigned int height,
  1708   1664   						       sqlite3 * handle,
  1709         -						       double minx,
  1710         -						       double miny,
  1711         -						       double maxx,
  1712         -						       double maxy, int srid,
         1665  +						       double minx, double miny,
         1666  +						       double maxx, double maxy,
         1667  +						       int srid,
  1713   1668   						       unsigned char *rgb,
  1714   1669   						       unsigned char format,
  1715   1670   						       int quality,
  1716   1671   						       unsigned char **image,
  1717   1672   						       int *image_sz);
  1718   1673   
  1719   1674       RL2_PRIVATE int get_payload_from_gray_rgba_transparent (unsigned int
  1720   1675   							    width,
  1721   1676   							    unsigned int
  1722   1677   							    height,
  1723         -							    unsigned char
  1724         -							    *rgb,
         1678  +							    unsigned char *rgb,
  1725   1679   							    unsigned char
  1726   1680   							    *alpha,
  1727   1681   							    unsigned char
  1728         -							    format,
  1729         -							    int quality,
         1682  +							    format, int quality,
  1730   1683   							    unsigned char
  1731   1684   							    **image,
  1732   1685   							    int *image_sz,
  1733   1686   							    double opacity);
  1734   1687   
  1735   1688       RL2_PRIVATE int get_payload_from_rgb_rgba_opaque (unsigned int width,
  1736   1689   						      unsigned int height,
  1737   1690   						      sqlite3 * handle,
  1738         -						      double minx,
  1739         -						      double miny,
  1740         -						      double maxx,
  1741         -						      double maxy, int srid,
         1691  +						      double minx, double miny,
         1692  +						      double maxx, double maxy,
         1693  +						      int srid,
  1742   1694   						      unsigned char *rgb,
  1743   1695   						      unsigned char format,
  1744   1696   						      int quality,
  1745   1697   						      unsigned char **image,
  1746   1698   						      int *image_sz);
  1747   1699   
  1748   1700       RL2_PRIVATE int get_payload_from_rgb_rgba_transparent (unsigned int width,
  1749   1701   							   unsigned int
  1750   1702   							   height,
  1751   1703   							   unsigned char *rgb,
  1752         -							   unsigned char
  1753         -							   *alpha,
  1754         -							   unsigned char
  1755         -							   format,
         1704  +							   unsigned char *alpha,
         1705  +							   unsigned char format,
  1756   1706   							   int quality,
  1757   1707   							   unsigned char
  1758   1708   							   **image,
  1759   1709   							   int *image_sz,
  1760   1710   							   double opacity,
  1761   1711   							   int
  1762   1712   							   half_transparent);
  1763   1713   
  1764   1714       RL2_PRIVATE int build_rgb_alpha (unsigned int width,
  1765   1715   				     unsigned int height, unsigned char *rgba,
  1766         -				     unsigned char **rgb,
  1767         -				     unsigned char **alpha,
         1716  +				     unsigned char **rgb, unsigned char **alpha,
  1768   1717   				     unsigned char bg_red,
  1769   1718   				     unsigned char bg_green,
  1770   1719   				     unsigned char bg_blue);
  1771   1720   
  1772   1721       RL2_PRIVATE int get_rgba_from_multiband8 (unsigned int width,
  1773   1722   					      unsigned int height,
  1774   1723   					      unsigned char red_band,
................................................................................
  1793   1742       RL2_PRIVATE int parse_worldfile (FILE * in, double *px, double *py,
  1794   1743   				     double *pres_x, double *pres_y);
  1795   1744   
  1796   1745       RL2_PRIVATE rl2CoverageStylePtr coverage_style_from_xml (char *name,
  1797   1746   							     unsigned char
  1798   1747   							     *xml);
  1799   1748   
  1800         -    RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char
  1801         -								    *name,
         1749  +    RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char *name,
  1802   1750   								    unsigned
  1803   1751   								    char *xml);
  1804   1752   
  1805   1753       RL2_PRIVATE rl2GroupStylePtr group_style_from_sld_xml (char *name,
  1806   1754   							   unsigned char *xml);
  1807   1755   
  1808   1756       RL2_PRIVATE rl2PrivCoverageStylePtr
................................................................................
  1883   1831   
  1884   1832       RL2_PRIVATE void rl2_destroy_point_symbolizer (rl2PrivPointSymbolizerPtr
  1885   1833   						   symbolizer);
  1886   1834   
  1887   1835       RL2_PRIVATE void rl2_destroy_line_symbolizer (rl2PrivLineSymbolizerPtr
  1888   1836   						  symbolizer);
  1889   1837   
  1890         -    RL2_PRIVATE void
  1891         -	rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr symbolizer);
         1838  +    RL2_PRIVATE void rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr
         1839  +						     symbolizer);
  1892   1840   
  1893   1841       RL2_PRIVATE void rl2_destroy_text_symbolizer (rl2PrivTextSymbolizerPtr
  1894   1842   						  symbolizer);
  1895   1843   
  1896   1844       RL2_PRIVATE rl2PrivRuleSingleArgPtr
  1897   1845   	rl2_create_default_rule_single_arg (void);
  1898   1846   
................................................................................
  1929   1877   					 double x_res, double y_res,
  1930   1878   					 double minx, double maxy,
  1931   1879   					 double tile_minx, double tile_maxy,
  1932   1880   					 rl2PixelPtr no_data,
  1933   1881   					 rl2RasterSymbolizerPtr style,
  1934   1882   					 rl2RasterStatisticsPtr stats);
  1935   1883   
  1936         -    RL2_PRIVATE int rl2_copy_raw_mask (rl2RasterPtr raster,
  1937         -				       unsigned char *maskbuf,
  1938         -				       unsigned int width,
  1939         -				       unsigned int height,
  1940         -				       double x_res, double y_res,
  1941         -				       double minx, double maxy,
  1942         -				       double tile_minx, double tile_maxy);
  1943         -
  1944   1884       RL2_PRIVATE unsigned char *rl2_copy_endian_raw_pixels (const unsigned char
  1945   1885   							   *pixels,
  1946   1886   							   int pixels_sz,
  1947   1887   							   unsigned int width,
  1948         -							   unsigned int
  1949         -							   height,
         1888  +							   unsigned int height,
  1950   1889   							   unsigned char
  1951   1890   							   sample_type,
  1952   1891   							   unsigned char
  1953   1892   							   num_bands,
  1954   1893   							   int big_endian);
  1955   1894   
  1956   1895       RL2_PRIVATE int rl2_build_shaded_relief_mask (sqlite3 * handle,
  1957   1896   						  int max_threads,
  1958   1897   						  rl2CoveragePtr cvg,
  1959         -						  int by_section,
  1960         -						  sqlite3_int64 section_id,
  1961   1898   						  double relief_factor,
  1962   1899   						  double scale_factor,
  1963   1900   						  unsigned int width,
  1964   1901   						  unsigned int height,
  1965   1902   						  double minx, double miny,
  1966   1903   						  double maxx, double maxy,
  1967   1904   						  double x_res, double y_res,
................................................................................
  1973   1910   					const char *title,
  1974   1911   					const char *abstract);
  1975   1912   
  1976   1913       RL2_PRIVATE int rl2_test_layer_group (sqlite3 * handle,
  1977   1914   					  const char *group_name);
  1978   1915   
  1979   1916       RL2_PRIVATE int rl2_rgba_raster_data (sqlite3 * handle,
  1980         -					  const char *coverage_name,
  1981         -					  void *ctx, int level, double minx,
  1982         -					  double miny, double maxx,
  1983         -					  double maxy, rl2PalettePtr palette,
         1917  +					  const char *coverage_name, void *ctx,
         1918  +					  int level, double minx, double miny,
         1919  +					  double maxx, double maxy,
         1920  +					  rl2PalettePtr palette,
  1984   1921   					  rl2PixelPtr no_data);
  1985   1922   
  1986   1923       RL2_PRIVATE int rl2_aux_render_image (struct aux_renderer *aux,
  1987   1924   					  unsigned char **ximage,
  1988   1925   					  int *ximage_size);
  1989   1926   
  1990         -    RL2_PRIVATE int rl2_aux_default_image (unsigned int width,
  1991         -					   unsigned int height,
  1992         -					   unsigned char red,
  1993         -					   unsigned char green,
  1994         -					   unsigned char blue, int format_id,
  1995         -					   int transparent, int quality,
  1996         -					   unsigned char **ximage,
  1997         -					   int *ximage_size);
  1998         -
  1999   1927       RL2_PRIVATE void rl2_aux_group_renderer (struct aux_group_renderer *auxgrp);
  2000   1928   
  2001   1929       RL2_PRIVATE double rl2_get_shaded_relief_scale_factor (sqlite3 * handle,
  2002   1930   							   const char
  2003   1931   							   *coverage);
  2004   1932   
  2005   1933       RL2_PRIVATE void *rl2_CreateMD5Checksum (void);
................................................................................
  2022   1950   						    rl2CoveragePtr cvg,
  2023   1951   						    int by_section,
  2024   1952   						    sqlite3_int64 section_id,
  2025   1953   						    unsigned int width,
  2026   1954   						    unsigned int height,
  2027   1955   						    double minx, double miny,
  2028   1956   						    double maxx, double maxy,
  2029         -						    double x_res,
  2030         -						    double y_res,
         1957  +						    double x_res, double y_res,
  2031   1958   						    unsigned char **buffer,
  2032   1959   						    int *buf_size,
  2033   1960   						    rl2PalettePtr * palette,
  2034   1961   						    unsigned char out_pixel,
  2035   1962   						    rl2PixelPtr bgcolor,
  2036   1963   						    rl2RasterSymbolizerPtr
  2037   1964   						    style,
  2038   1965   						    rl2RasterStatisticsPtr
  2039   1966   						    stats);
  2040   1967   
  2041         -    RL2_PRIVATE int rl2_get_raw_raster_mask_common (sqlite3 * handle,
  2042         -						    int max_threads,
  2043         -						    rl2CoveragePtr cvg,
  2044         -						    int by_section,
  2045         -						    sqlite3_int64 section_id,
  2046         -						    unsigned int width,
  2047         -						    unsigned int height,
  2048         -						    double minx, double miny,
  2049         -						    double maxx, double maxy,
  2050         -						    double x_res, double y_res,
  2051         -						    unsigned char **mask,
  2052         -						    int *mask_size);
  2053         -
  2054         -    RL2_PRIVATE rl2RasterPtr
  2055         -	rl2_raster_decode_mask (int scale, const unsigned char *blob_odd,
  2056         -				int blob_odd_sz, int *status);
  2057         -
  2058   1968       RL2_PRIVATE char *rl2_double_quoted_sql (const char *value);
  2059   1969   
  2060   1970       RL2_PRIVATE int rl2_parse_point (sqlite3 * sqlite,
  2061   1971   				     const unsigned char *blob, int blob_sz,
  2062   1972   				     double *x, double *y);
  2063   1973   
  2064   1974       RL2_PRIVATE int rl2_parse_point_generic (sqlite3 * sqlite,
  2065   1975   					     const unsigned char *blob,
  2066   1976   					     int blob_sz, double *x, double *y);
  2067   1977   
  2068   1978       RL2_PRIVATE int rl2_parse_bbox_srid (sqlite3 * sqlite,
  2069         -					 const unsigned char *blob,
  2070         -					 int blob_sz, int *srid, double *minx,
  2071         -					 double *miny, double *maxx,
  2072         -					 double *maxy);
         1979  +					 const unsigned char *blob, int blob_sz,
         1980  +					 int *srid, double *minx, double *miny,
         1981  +					 double *maxx, double *maxy);
  2073   1982   
  2074         -    RL2_PRIVATE int rl2_parse_bbox (sqlite3 * sqlite,
  2075         -				    const unsigned char *blob, int blob_sz,
  2076         -				    double *minx, double *miny, double *maxx,
  2077         -				    double *maxy);
         1983  +    RL2_PRIVATE int rl2_parse_bbox (sqlite3 * sqlite, const unsigned char *blob,
         1984  +				    int blob_sz, double *minx, double *miny,
         1985  +				    double *maxx, double *maxy);
  2078   1986   
  2079   1987       RL2_PRIVATE int rl2_build_bbox (sqlite3 * sqlite, int srid, double minx,
  2080   1988   				    double miny, double maxx, double maxy,
  2081   1989   				    unsigned char **blob, int *blob_sz);
  2082   1990   
  2083   1991       RL2_PRIVATE int rl2_delta_encode (unsigned char *buffer, int size,
  2084   1992   				      int distance);
  2085   1993   
  2086   1994       RL2_PRIVATE int rl2_delta_decode (unsigned char *buffer, int size,
  2087   1995   				      int distance);
  2088   1996   
  2089         -    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char
  2090         -							       *name,
         1997  +    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char *name,
  2091   1998   							       sqlite3_int64
  2092   1999   							       value);
  2093   2000   
  2094   2001       RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_double (const char
  2095   2002   								  *name,
  2096   2003   								  double value);
  2097   2004   
................................................................................
  2105   2012   
  2106   2013       RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_null (const char
  2107   2014   								*name);
  2108   2015   
  2109   2016       RL2_PRIVATE void rl2_destroy_variant_value (rl2PrivVariantValuePtr value);
  2110   2017   
  2111   2018       RL2_PRIVATE void rl2_draw_vector_feature (void *ctx, sqlite3 * handle,
  2112         -					      const void *priv_data,
  2113         -					      rl2VectorSymbolizerPtr
  2114         -					      symbolizer, int height,
  2115         -					      double minx, double miny,
  2116         -					      double maxx, double maxy,
  2117         -					      double x_res, double y_res,
         2019  +					      rl2VectorSymbolizerPtr symbolizer,
         2020  +					      int height, double minx,
         2021  +					      double miny, double x_res,
         2022  +					      double y_res,
  2118   2023   					      rl2GeometryPtr geom,
  2119   2024   					      rl2VariantArrayPtr variant);
  2120   2025   
  2121   2026       RL2_PRIVATE rl2GeometryPtr
  2122   2027   	rl2_geometry_from_blob (const unsigned char *blob, int blob_sz);
  2123   2028   
  2124   2029       RL2_PRIVATE rl2GeometryPtr
................................................................................
  2129   2034       RL2_PRIVATE int rl2_serialize_linestring (rl2LinestringPtr line,
  2130   2035   					      unsigned char **blob,
  2131   2036   					      int *blob_sz);
  2132   2037   
  2133   2038       RL2_PRIVATE int rl2_serialize_ring (rl2RingPtr ring, unsigned char **blob,
  2134   2039   					int *blob_sz);
  2135   2040   
  2136         -    RL2_PRIVATE int rl2_serialize_ring_as_linestring (rl2RingPtr ring,
  2137         -						      unsigned char **blob,
  2138         -						      int *blob_sz);
  2139         -
  2140   2041       RL2_PRIVATE double rl2_compute_curve_length (rl2GeometryPtr geom);
  2141   2042   
  2142   2043       RL2_PRIVATE rl2GeometryPtr
  2143         -	rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom,
  2144         -			     double from, double to);
         2044  +	rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom, double from,
         2045  +			     double to);
  2145   2046   
  2146   2047       RL2_PRIVATE rl2GeometryPtr rl2_clone_curve (rl2GeometryPtr in);
  2147   2048   
  2148   2049       RL2_PRIVATE rl2GeometryPtr rl2_clone_linestring (rl2LinestringPtr in);
  2149   2050   
  2150   2051       RL2_PRIVATE rl2GeometryPtr
  2151   2052   	rl2_build_circle (double x, double y, double radius);
................................................................................
  2153   2054       RL2_PRIVATE int rl2_load_font_into_dbms (sqlite3 * handle,
  2154   2055   					     unsigned char *blob, int blob_sz);
  2155   2056   
  2156   2057       RL2_PRIVATE int rl2_get_font_from_dbms (sqlite3 * handle,
  2157   2058   					    const char *facename,
  2158   2059   					    unsigned char **font, int *font_sz);
  2159   2060   
  2160         -    RL2_PRIVATE rl2LinestringPtr rl2_linestring_to_image (rl2LinestringPtr line,
  2161         -							  int height,
  2162         -							  double minx,
  2163         -							  double miny,
  2164         -							  double x_res,
  2165         -							  double y_res);
  2166         -
  2167         -    RL2_PRIVATE rl2RingPtr rl2_ring_to_image (rl2RingPtr ring, int height,
  2168         -					      double minx, double miny,
  2169         -					      double x_res, double y_res);
  2170         -
  2171         -    RL2_PRIVATE void rl2DestroyLinestring (rl2LinestringPtr ptr);
  2172         -
  2173         -    RL2_PRIVATE void rl2DestroyRing (rl2RingPtr ptr);
  2174         -
  2175   2061   #ifdef __cplusplus
  2176   2062   }
  2177   2063   #endif
  2178   2064   
  2179   2065   #endif				/* _RASTERLITE2_PRIVATE_H */

Changes to headers/rl2svg_private.h.

   502    502   							in);
   503    503   
   504    504       RL2_PRIVATE rl2PrivSvgLinePtr svg_alloc_line (double x1, double y1,
   505    505   						  double x2, double y2);
   506    506   
   507    507       RL2_PRIVATE rl2PrivSvgLinePtr svg_clone_line (rl2PrivSvgLinePtr in);
   508    508   
   509         -    RL2_PRIVATE rl2PrivSvgPolylinePtr svg_alloc_polyline (int points,
   510         -							  double *x, double *y);
          509  +    RL2_PRIVATE rl2PrivSvgPolylinePtr svg_alloc_polyline (int points, double *x,
          510  +							  double *y);
   511    511   
   512         -    RL2_PRIVATE rl2PrivSvgPolylinePtr
   513         -	svg_clone_polyline (rl2PrivSvgPolylinePtr in);
          512  +    RL2_PRIVATE rl2PrivSvgPolylinePtr svg_clone_polyline (rl2PrivSvgPolylinePtr
          513  +							  in);
   514    514   
   515    515       RL2_PRIVATE rl2PrivSvgPolygonPtr svg_alloc_polygon (int points, double *x,
   516    516   							double *y);
   517    517   
   518    518       RL2_PRIVATE rl2PrivSvgPolygonPtr svg_clone_polygon (rl2PrivSvgPolygonPtr
   519    519   							in);
   520    520   
   521    521       RL2_PRIVATE rl2PrivSvgPathMovePtr svg_alloc_path_move (double x, double y);
   522    522   
   523         -    RL2_PRIVATE rl2PrivSvgPathMovePtr
   524         -	svg_clone_path_move (rl2PrivSvgPathMovePtr in);
          523  +    RL2_PRIVATE rl2PrivSvgPathMovePtr svg_clone_path_move (rl2PrivSvgPathMovePtr
          524  +							   in);
   525    525   
   526    526       RL2_PRIVATE rl2PrivSvgPathBezierPtr svg_alloc_path_bezier (double x1,
   527    527   							       double y1,
   528    528   							       double x2,
   529    529   							       double y2,
   530    530   							       double x,
   531    531   							       double y);
................................................................................
   606    606   
   607    607       RL2_PRIVATE void svg_set_group_parent (rl2PrivSvgItemPtr item,
   608    608   					   rl2PrivSvgGroupPtr grp);
   609    609   
   610    610       RL2_PRIVATE rl2PrivSvgGradientStopPtr svg_alloc_gradient_stop (double
   611    611   								   offset,
   612    612   								   double red,
   613         -								   double
   614         -								   green,
   615         -								   double
   616         -								   blue,
          613  +								   double green,
          614  +								   double blue,
   617    615   								   double
   618    616   								   opacity);
   619    617   
   620    618       RL2_PRIVATE rl2PrivSvgGradientStopPtr
   621    619   	svg_clone_gradient_stop (rl2PrivSvgGradientStopPtr in);
   622    620   
   623    621       RL2_PRIVATE rl2PrivSvgGradientPtr svg_alloc_gradient (void);
   624    622   
   625         -    RL2_PRIVATE rl2PrivSvgGradientPtr
   626         -	svg_clone_gradient (rl2PrivSvgGradientPtr in,
   627         -			    rl2PrivSvgGradientPtr old);
          623  +    RL2_PRIVATE rl2PrivSvgGradientPtr svg_clone_gradient (rl2PrivSvgGradientPtr
          624  +							  in,
          625  +							  rl2PrivSvgGradientPtr
          626  +							  old);
   628    627   
   629    628       RL2_PRIVATE rl2PrivSvgDocumentPtr svg_alloc_document (void);
   630    629   
   631    630       RL2_PRIVATE void svg_close_group (rl2PrivSvgDocumentPtr svg_doc);
   632    631   
   633    632       RL2_PRIVATE void svg_insert_group (rl2PrivSvgDocumentPtr svg_doc);
   634    633   
   635    634       RL2_PRIVATE void svg_close_clip (rl2PrivSvgDocumentPtr svg_doc);
   636    635   
   637    636       RL2_PRIVATE void svg_insert_clip (rl2PrivSvgDocumentPtr svg_doc);
   638    637   
   639         -    RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr
   640         -						 svg_doc,
          638  +    RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr svg_doc,
   641    639   						 const char *xlink_href,
   642    640   						 double x, double y,
   643    641   						 double width, double height);
   644    642   
   645         -    RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc,
   646         -				       int type, void *data);
          643  +    RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc, int type,
          644  +				       void *data);
   647    645   
   648    646       RL2_PRIVATE void svg_insert_gradient_stop (rl2PrivSvgGradientPtr gradient,
   649    647   					       double offset, double red,
   650    648   					       double green, double blue,
   651    649   					       double opacity);
   652    650   
   653    651       RL2_PRIVATE rl2PrivSvgGradientPtr
   654    652   	svg_insert_linear_gradient (rl2PrivSvgDocumentPtr svg_doc,
   655    653   				    const char *id, const char *xlink_href,
   656         -				    double x1, double y1, double x2,
   657         -				    double y2, int units);
          654  +				    double x1, double y1, double x2, double y2,
          655  +				    int units);
   658    656   
   659    657       RL2_PRIVATE rl2PrivSvgGradientPtr
   660    658   	svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc,
   661    659   				    const char *id, const char *xlink_href,
   662         -				    double cx, double cy, double fx,
   663         -				    double fy, double r, int units);
          660  +				    double cx, double cy, double fx, double fy,
          661  +				    double r, int units);
   664    662   
   665    663       RL2_PRIVATE rl2PrivSvgGradientPtr
   666    664   	svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc,
   667    665   				    const char *id, const char *xlink_href,
   668         -				    double cx, double cy, double fx,
   669         -				    double fy, double r, int units);
          666  +				    double cx, double cy, double fx, double fy,
          667  +				    double r, int units);
   670    668   
   671    669       RL2_PRIVATE void svg_init_style (rl2PrivSvgStylePtr style);
   672    670   
   673    671       RL2_PRIVATE void svg_style_cleanup (rl2PrivSvgStylePtr style);
   674    672   
   675    673   
   676    674   #ifdef __cplusplus
   677    675   }
   678    676   #endif
   679    677   
   680    678   #endif				/* _RL2SVG_PRIVATE_H */

Added rasterlite2-4.2.0.mk.

            1  +include $(CLEAR_VARS)
            2  +# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
            3  +LOCAL_MODULE    := rasterlite2
            4  +
            5  +# SQLite flags copied from ASOP [may not be needed for rasterlite2]
            6  +common_sqlite_flags := \
            7  + -DHAVE_USLEEP=1 \
            8  + -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
            9  + -DSQLITE_THREADSAFE=1 \
           10  + -DNDEBUG=1 \
           11  + -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \
           12  + -DSQLITE_DEFAULT_AUTOVACUUM=1 \
           13  + -DSQLITE_TEMP_STORE=3 \
           14  + -DSQLITE_ENABLE_FTS3 \
           15  + -DSQLITE_ENABLE_FTS3_BACKWARDS \
           16  + -DSQLITE_ENABLE_RTREE=1 \
           17  + -DSQLITE_DEFAULT_FILE_FORMAT=4
           18  +
           19  +# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI
           20  +spatialite_flags := \
           21  + -DOMIT_FREEXL \
           22  + -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \
           23  + -Dfdatasync=fsync \
           24  + -DSQLITE_ENABLE_RTREE=1 \
           25  + -DSQLITE_OMIT_BUILTIN_TEST=1
           26  +
           27  +# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI
           28  +rasterlite2_flags := \
           29  + -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \
           30  + -O
           31  +
           32  +LOCAL_CFLAGS    := \
           33  + $(common_sqlite_flags) \
           34  + $(spatialite_flags) \
           35  + $(rasterlite2_flags)
           36  +
           37  +LOCAL_C_INCLUDES := \
           38  + $(SQLITE_PATH) \
           39  + $(GEOTIFF_PATH)/libxtiff \
           40  + $(GEOTIFF_PATH) \
           41  + $(TIFF_PATH) \
           42  + $(JPEG_PATH) \
           43  + $(GIF_PATH) \
           44  + $(PNG_PATH) \
           45  + $(WEBP_PATH)/src/webp \
           46  + $(WEBP_PATH)/src/dec \
           47  + $(WEBP_PATH)/src/dsp \
           48  + $(WEBP_PATH)/src/enc \
           49  + $(WEBP_PATH)/src/utils \
           50  + $(WEBP_PATH)/src \
           51  + $(WEBP_PATH) \
           52  + $(CAIRO_PATH) \
           53  + $(ICONV_PATH)/include \
           54  + $(ICONV_PATH)/libcharset/include \
           55  + $(XML2_PATH)/include \
           56  + $(CURL_PATH) \
           57  + $(CURL_PATH)/include \
           58  + $(CURL_PATH)/lib \
           59  + $(RASTERLITE2_PATH) \
           60  + $(RASTERLITE2_PATH)/headers \
           61  + $(SPATIALITE_PATH)/src/headers \
           62  + $(LZMA_PATH)/src/liblzma/api
           63  +LOCAL_SRC_FILES := \
           64  + $(RASTERLITE2_PATH)/src/rasterlite2.c \
           65  + $(RASTERLITE2_PATH)/src/rl2ascii.c \
           66  + $(RASTERLITE2_PATH)/src/rl2codec.c \
           67  + $(RASTERLITE2_PATH)/src/rl2dbms.c \
           68  + $(RASTERLITE2_PATH)/src/rl2gif.c \
           69  + $(RASTERLITE2_PATH)/src/rl2import.c \
           70  + $(RASTERLITE2_PATH)/src/rl2jpeg.c \
           71  + $(RASTERLITE2_PATH)/src/rl2paint.c \
           72  + $(RASTERLITE2_PATH)/src/rl2png.c \
           73  + $(RASTERLITE2_PATH)/src/rl2rastersym.c \
           74  + $(RASTERLITE2_PATH)/src/rl2raw.c \
           75  + $(RASTERLITE2_PATH)/src/rl2sql.c \
           76  + $(RASTERLITE2_PATH)/src/rl2sqlaux.c \
           77  + $(RASTERLITE2_PATH)/src/rl2svg.c \
           78  + $(RASTERLITE2_PATH)/src/rl2svgaux.c \
           79  + $(RASTERLITE2_PATH)/src/rl2svgxml.c \
           80  + $(RASTERLITE2_PATH)/src/rl2symbolizer.c \
           81  + $(RASTERLITE2_PATH)/src/rl2tiff.c \
           82  + $(RASTERLITE2_PATH)/src/rl2version.c \
           83  + $(RASTERLITE2_PATH)/src/rl2webp.c \
           84  + $(RASTERLITE2_PATH)/src/rl2wms.c
           85  +LOCAL_STATIC_LIBRARIES := libpng libwebp libxml2 spatialite libfreetype libcairo libcurl libgeotiff libtiff libgif libjpeg
           86  +include $(BUILD_STATIC_LIBRARY)

Deleted rasterlite2-4.3.0.mk.

     1         -include $(CLEAR_VARS)
     2         -# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi
     3         -LOCAL_MODULE    := rasterlite2
     4         -
     5         -# SQLite flags copied from ASOP [may not be needed for rasterlite2]
     6         -common_sqlite_flags := \
     7         - -DHAVE_USLEEP=1 \
     8         - -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
     9         - -DSQLITE_THREADSAFE=1 \
    10         - -DNDEBUG=1 \
    11         - -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \
    12         - -DSQLITE_DEFAULT_AUTOVACUUM=1 \
    13         - -DSQLITE_TEMP_STORE=3 \
    14         - -DSQLITE_ENABLE_FTS3 \
    15         - -DSQLITE_ENABLE_FTS3_BACKWARDS \
    16         - -DSQLITE_ENABLE_RTREE=1 \
    17         - -DSQLITE_DEFAULT_FILE_FORMAT=4
    18         -
    19         -# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI
    20         -spatialite_flags := \
    21         - -DOMIT_FREEXL \
    22         - -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \
    23         - -Dfdatasync=fsync \
    24         - -DSQLITE_ENABLE_RTREE=1 \
    25         - -DENABLE_GCP=1 \
    26         - -DENABLE_GEOPACKAGE=1 \
    27         - -DENABLE_LIBXML2=1 \
    28         - -DSQLITE_OMIT_BUILTIN_TEST=1
    29         -
    30         -# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI
    31         -# comment out VERSION in config.h - manually set to avoid conflict with other packages
    32         -rasterlite2_flags := \
    33         - -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \
    34         - -DVERSION=\"0.9\" \
    35         - -O
    36         -
    37         -LOCAL_CFLAGS    := \
    38         - $(common_sqlite_flags) \
    39         - $(spatialite_flags) \
    40         - $(rasterlite2_flags)
    41         -
    42         -# 2014-10-03 - adapted based on ls -1 result
    43         -LOCAL_C_INCLUDES := \
    44         - $(SQLITE_PATH) \
    45         - $(GEOTIFF_PATH)/libxtiff \
    46         - $(GEOTIFF_PATH) \
    47         - $(TIFF_PATH) \
    48         - $(JPEG_PATH) \
    49         - $(GIF_PATH) \
    50         - $(PNG_PATH) \
    51         - $(WEBP_PATH)/src/webp \
    52         - $(WEBP_PATH)/src/dec \
    53         - $(WEBP_PATH)/src/dsp \
    54         - $(WEBP_PATH)/src/enc \
    55         - $(WEBP_PATH)/src/utils \
    56         - $(WEBP_PATH)/src \
    57         - $(WEBP_PATH) \
    58         - $(CAIRO_PATH) \
    59         - $(FONTCONFIG_PATH) \
    60         - $(ICONV_PATH)/include \
    61         - $(FREETYPE_PATH)/include \
    62         - $(ICONV_PATH)/libcharset/include \
    63         - $(XML2_PATH)/include \
    64         - $(CURL_PATH) \
    65         - $(CURL_PATH)/include \
    66         - $(CURL_PATH)/lib \
    67         - $(RASTERLITE2_PATH) \
    68         - $(RASTERLITE2_PATH)/headers \
    69         - $(SPATIALITE_PATH)/src/headers \
    70         - $(LZMA_PATH)/src/liblzma/api \
    71         - $(OPENJPEG_PATH)/src/lib/openjp2 \
    72         - $(CHARLS_PATH)
    73         -
    74         -LOCAL_SRC_FILES := \
    75         - $(RASTERLITE2_PATH)/src/md5.c \
    76         - $(RASTERLITE2_PATH)/src/rasterlite2.c \
    77         - $(RASTERLITE2_PATH)/src/rl2ascii.c \
    78         - $(RASTERLITE2_PATH)/src/rl2auxfont.c \
    79         - $(RASTERLITE2_PATH)/src/rl2auxgeom.c \
    80         - $(RASTERLITE2_PATH)/src/rl2auxrender.c \
    81         - $(RASTERLITE2_PATH)/src/rl2charls.c \
    82         - $(RASTERLITE2_PATH)/src/rl2codec.c \
    83         - $(RASTERLITE2_PATH)/src/rl2dbms.c \
    84         - $(RASTERLITE2_PATH)/src/rl2gif.c \
    85         - $(RASTERLITE2_PATH)/src/rl2import.c \
    86         - $(RASTERLITE2_PATH)/src/rl2jpeg.c \
    87         - $(RASTERLITE2_PATH)/src/rl2md5.c \
    88         - $(RASTERLITE2_PATH)/src/rl2openjpeg.c \
    89         - $(RASTERLITE2_PATH)/src/rl2paint.c \
    90         - $(RASTERLITE2_PATH)/src/rl2png.c \
    91         - $(RASTERLITE2_PATH)/src/rl2pyramid.c \
    92         - $(RASTERLITE2_PATH)/src/rl2rastersym.c \
    93         - $(RASTERLITE2_PATH)/src/rl2raw.c \
    94         - $(RASTERLITE2_PATH)/src/rl2sql.c \
    95         - $(RASTERLITE2_PATH)/src/rl2sqlaux.c \
    96         - $(RASTERLITE2_PATH)/src/rl2svg.c \
    97         - $(RASTERLITE2_PATH)/src/rl2svgaux.c \
    98         - $(RASTERLITE2_PATH)/src/rl2svgxml.c \
    99         - $(RASTERLITE2_PATH)/src/rl2symbaux.c \
   100         - $(RASTERLITE2_PATH)/src/rl2symbolizer.c \
   101         - $(RASTERLITE2_PATH)/src/rl2tiff.c \
   102         - $(RASTERLITE2_PATH)/src/rl2version.c \
   103         - $(RASTERLITE2_PATH)/src/rl2webp.c \
   104         - $(RASTERLITE2_PATH)/src/rl2wms.c
   105         -LOCAL_STATIC_LIBRARIES := libcharls libopenjpeg libpng libwebp libxml2 spatialite libfreetype libcairo libcurl libgeotiff libtiff libgif libjpeg
   106         -include $(BUILD_STATIC_LIBRARY)

Changes to src/Makefile.am.

    21     21   	@LIBLZMA_LIBS@ @LIBCAIRO_LIBS@	@LIBCURL_LIBS@ \
    22     22   	@LIBXML2_LIBS@ @LIBFREETYPE2_LIBS@
    23     23   
    24     24   if MINGW
    25     25   librasterlite2_la_LDFLAGS = -avoid-version -no-undefined
    26     26   librasterlite2_la_LIBADD += -lm
    27     27   else
    28         -librasterlite2_la_LDFLAGS = -version-info 1:0:0
           28  +librasterlite2_la_LDFLAGS = -version-info 0:0:0
    29     29   librasterlite2_la_LIBADD += -lpthread -lm
    30     30   endif
    31     31   
    32     32   mod_rasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \
    33     33   	rl2jpeg.c rl2png.c rl2gif.c rl2webp.c rl2tiff.c rl2wms.c \
    34     34   	rl2ascii.c rl2paint.c rl2dbms.c rl2import.c rl2pyramid.c \
    35     35   	rl2sql.c rl2sqlaux.c rl2auxrender.c rl2svg.c rl2svgxml.c \
................................................................................
    46     46   mod_rasterlite2_la_CPPFLAGS += -DLOADABLE_EXTENSION
    47     47   mod_rasterlite2_la_LIBTOOLFLAGS = --tag=disable-static
    48     48   
    49     49   if MINGW
    50     50   mod_rasterlite2_la_LDFLAGS = -module -avoid-version -no-undefined
    51     51   mod_rasterlite2_la_LIBADD += -lm
    52     52   else
    53         -mod_rasterlite2_la_LDFLAGS = -module -version-info 1:0:0
           53  +mod_rasterlite2_la_LDFLAGS = -module -version-info 0:0:0
    54     54   mod_rasterlite2_la_LIBADD += -lpthread -lm
    55     55   endif
    56     56   
    57     57   MOSTLYCLEANFILES = *.gcna *.gcno *.gcda

Changes to src/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
................................................................................
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   
    17     17   
    18     18   VPATH = @srcdir@
    19         -am__is_gnu_make = { \
    20         -  if test -z '$(MAKELEVEL)'; then \
    21         -    false; \
    22         -  elif test -n '$(MAKE_HOST)'; then \
    23         -    true; \
    24         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    25         -    true; \
    26         -  else \
    27         -    false; \
    28         -  fi; \
    29         -}
           19  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    30     20   am__make_running_with_option = \
    31     21     case $${target_option-} in \
    32     22         ?) ;; \
    33     23         *) echo "am__make_running_with_option: internal error: invalid" \
    34     24                 "target option '$${target_option-}' specified" >&2; \
    35     25            exit 1;; \
    36     26     esac; \
................................................................................
    90     80   build_triplet = @build@
    91     81   host_triplet = @host@
    92     82   @MINGW_TRUE@am__append_1 = -lm
    93     83   @MINGW_FALSE@am__append_2 = -lpthread -lm
    94     84   @MINGW_TRUE@am__append_3 = -lm
    95     85   @MINGW_FALSE@am__append_4 = -lpthread -lm
    96     86   subdir = src
           87  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
           88  +	$(top_srcdir)/depcomp $(noinst_HEADERS)
    97     89   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    98     90   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    99     91   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
   100     92   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
   101     93   	$(top_srcdir)/configure.ac
   102     94   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
   103     95   	$(ACLOCAL_M4)
   104         -DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
   105         -	$(am__DIST_COMMON)
   106     96   mkinstalldirs = $(install_sh) -d
   107     97   CONFIG_HEADER = $(top_builddir)/config.h
   108     98   CONFIG_CLEAN_FILES =
   109     99   CONFIG_CLEAN_VPATH_FILES =
   110    100   am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
   111    101   am__vpath_adj = case $$p in \
   112    102       $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
................................................................................
   240    230   am__define_uniq_tagged_files = \
   241    231     list='$(am__tagged_files)'; \
   242    232     unique=`for i in $$list; do \
   243    233       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   244    234     done | $(am__uniquify_input)`
   245    235   ETAGS = etags
   246    236   CTAGS = ctags
   247         -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
   248    237   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   249    238   ACLOCAL = @ACLOCAL@
   250    239   AMTAR = @AMTAR@
   251    240   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   252    241   AR = @AR@
   253    242   AS = @AS@
   254    243   AUTOCONF = @AUTOCONF@
................................................................................
   402    391   	rl2svgaux.c rl2symbolizer.c rl2symbaux.c rl2rastersym.c \
   403    392   	rl2version.c rl2md5.c md5.c rl2charls.c rl2openjpeg.c \
   404    393   	rl2auxgeom.c rl2auxfont.c
   405    394   
   406    395   librasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ @LIBLZMA_LIBS@ \
   407    396   	@LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \
   408    397   	@LIBFREETYPE2_LIBS@ $(am__append_1) $(am__append_2)
   409         -@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 1:0:0
          398  +@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 0:0:0
   410    399   @MINGW_TRUE@librasterlite2_la_LDFLAGS = -avoid-version -no-undefined
   411    400   mod_rasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \
   412    401   	rl2jpeg.c rl2png.c rl2gif.c rl2webp.c rl2tiff.c rl2wms.c \
   413    402   	rl2ascii.c rl2paint.c rl2dbms.c rl2import.c rl2pyramid.c \
   414    403   	rl2sql.c rl2sqlaux.c rl2auxrender.c rl2svg.c rl2svgxml.c \
   415    404   	rl2svgaux.c rl2symbolizer.c rl2symbaux.c rl2rastersym.c \
   416    405   	rl2version.c rl2md5.c md5.c rl2charls.c rl2openjpeg.c \
................................................................................
   418    407   
   419    408   mod_rasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ \
   420    409   	@LIBLZMA_LIBS@ @LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \
   421    410   	@LIBFREETYPE2_LIBS@ $(am__append_3) $(am__append_4)
   422    411   mod_rasterlite2_la_CPPFLAGS = @CFLAGS@ -I$(top_srcdir)/headers -I. \
   423    412   	-DLOADABLE_EXTENSION
   424    413   mod_rasterlite2_la_LIBTOOLFLAGS = --tag=disable-static
   425         -@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 1:0:0
          414  +@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 0:0:0
   426    415   @MINGW_TRUE@mod_rasterlite2_la_LDFLAGS = -module -avoid-version -no-undefined
   427    416   MOSTLYCLEANFILES = *.gcna *.gcno *.gcda
   428    417   all: all-am
   429    418   
   430    419   .SUFFIXES:
   431    420   .SUFFIXES: .c .lo .o .obj
   432    421   $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
................................................................................
   437    426   	        && { if test -f $@; then exit 0; else break; fi; }; \
   438    427   	      exit 1;; \
   439    428   	  esac; \
   440    429   	done; \
   441    430   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
   442    431   	$(am__cd) $(top_srcdir) && \
   443    432   	  $(AUTOMAKE) --gnu src/Makefile
          433  +.PRECIOUS: Makefile
   444    434   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   445    435   	@case '$?' in \
   446    436   	  *config.status*) \
   447    437   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   448    438   	  *) \
   449    439   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   450    440   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1007    997   	install-info-am install-libLTLIBRARIES install-man install-pdf \
  1008    998   	install-pdf-am install-ps install-ps-am install-strip \
  1009    999   	installcheck installcheck-am installdirs maintainer-clean \
  1010   1000   	maintainer-clean-generic mostlyclean mostlyclean-compile \
  1011   1001   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
  1012   1002   	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
  1013   1003   
  1014         -.PRECIOUS: Makefile
  1015         -
  1016   1004   
  1017   1005   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  1018   1006   # Otherwise a system limit (for SysV at least) may be exceeded.
  1019   1007   .NOEXPORT:

Changes to src/rasterlite2.c.

   510    510   	  return RL2_FALSE;
   511    511   #endif
   512    512         };
   513    513       return RL2_ERROR;
   514    514   }
   515    515   
   516    516   static int
   517         -check_coverage_no_data (rl2PrivPixelPtr pxl_no_data,
   518         -			unsigned char sample_type, unsigned char pixel_type,
   519         -			unsigned char num_samples)
          517  +check_coverage_no_data (rl2PrivPixelPtr pxl_no_data, unsigned char sample_type,
          518  +			unsigned char pixel_type, unsigned char num_samples)
   520    519   {
   521    520   /* checking if the NoData pixel is consistent with the Coverage */
   522    521       if (pxl_no_data == NULL)
   523    522   	return 1;
   524    523       if (pxl_no_data->sampleType != sample_type)
   525    524   	return 0;
   526    525       if (pxl_no_data->pixelType != pixel_type)
................................................................................
  1252   1251       return (rl2RasterPtr) rst;
  1253   1252   }
  1254   1253   
  1255   1254   RL2_DECLARE rl2RasterPtr
  1256   1255   rl2_create_raster (unsigned int width, unsigned int height,
  1257   1256   		   unsigned char sample_type, unsigned char pixel_type,
  1258   1257   		   unsigned char num_samples, unsigned char *bufpix,
  1259         -		   int bufpix_size, rl2PalettePtr palette,
  1260         -		   unsigned char *mask, int mask_size, rl2PixelPtr no_data)
         1258  +		   int bufpix_size, rl2PalettePtr palette, unsigned char *mask,
         1259  +		   int mask_size, rl2PixelPtr no_data)
  1261   1260   {
  1262   1261   /* allocating and initializing a Raster object with an optional Transparency Mask */
  1263   1262       return create_raster_common (width, height, sample_type, pixel_type,
  1264   1263   				 num_samples, bufpix, bufpix_size, palette,
  1265   1264   				 mask, mask_size, no_data, 0);
  1266   1265   }
  1267   1266   
................................................................................
  1429   1428       rst->minY = cy - vExt;
  1430   1429       rst->maxX = cx + hExt;
  1431   1430       rst->maxY = cy + vExt;
  1432   1431       return RL2_OK;
  1433   1432   }
  1434   1433   
  1435   1434   RL2_DECLARE int
  1436         -rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid,
  1437         -				    double horz_res, double vert_res,
  1438         -				    double x, double y)
         1435  +rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid, double horz_res,
         1436  +				    double vert_res, double x, double y)
  1439   1437   {
  1440   1438   /* setting the Raster's georeferencing infos - UpperLeft corner */
  1441   1439       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1442   1440       double hExt;
  1443   1441       double vExt;
  1444   1442       if (rst == NULL)
  1445   1443   	return RL2_ERROR;
................................................................................
  1453   1451       rst->maxX = x + hExt;
  1454   1452       rst->maxY = y;
  1455   1453       return RL2_OK;
  1456   1454   }
  1457   1455   
  1458   1456   RL2_DECLARE int
  1459   1457   rl2_raster_georeference_upper_right (rl2RasterPtr ptr, int srid,
  1460         -				     double horz_res, double vert_res,
  1461         -				     double x, double y)
         1458  +				     double horz_res, double vert_res, double x,
         1459  +				     double y)
  1462   1460   {
  1463   1461   /* setting the Raster's georeferencing infos - UpperRight corner */
  1464   1462       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1465   1463       double hExt;
  1466   1464       double vExt;
  1467   1465       if (rst == NULL)
  1468   1466   	return RL2_ERROR;
................................................................................
  1475   1473       rst->minY = y - vExt;
  1476   1474       rst->maxX = x;
  1477   1475       rst->maxY = y;
  1478   1476       return RL2_OK;
  1479   1477   }
  1480   1478   
  1481   1479   RL2_DECLARE int
  1482         -rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid,
  1483         -				    double horz_res, double vert_res,
  1484         -				    double x, double y)
         1480  +rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid, double horz_res,
         1481  +				    double vert_res, double x, double y)
  1485   1482   {
  1486   1483   /* setting the Raster's georeferencing infos - LowerLeft corner */
  1487   1484       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1488   1485       double hExt;
  1489   1486       double vExt;
  1490   1487       if (rst == NULL)
  1491   1488   	return RL2_ERROR;
................................................................................
  1499   1496       rst->maxX = x + hExt;
  1500   1497       rst->maxY = y + vExt;
  1501   1498       return RL2_OK;
  1502   1499   }
  1503   1500   
  1504   1501   RL2_DECLARE int
  1505   1502   rl2_raster_georeference_lower_right (rl2RasterPtr ptr, int srid,
  1506         -				     double horz_res, double vert_res,
  1507         -				     double x, double y)
         1503  +				     double horz_res, double vert_res, double x,
         1504  +				     double y)
  1508   1505   {
  1509   1506   /* setting the Raster's georeferencing infos - LowerRight corner */
  1510   1507       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1511   1508       double hExt;
  1512   1509       double vExt;
  1513   1510       if (rst == NULL)
  1514   1511   	return RL2_ERROR;
................................................................................
  1806   1803       entry->red = r;
  1807   1804       entry->green = g;
  1808   1805       entry->blue = b;
  1809   1806       return RL2_OK;
  1810   1807   }
  1811   1808   
  1812   1809   RL2_DECLARE int
  1813         -rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index,
  1814         -		       unsigned char r, unsigned char g, unsigned char b)
         1810  +rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index, unsigned char r,
         1811  +		       unsigned char g, unsigned char b)
  1815   1812   {
  1816   1813   /* finding the index corresponding to the given color (if any) */
  1817   1814       int i;
  1818   1815       rl2PrivPaletteEntryPtr entry;
  1819   1816       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) ptr;
  1820   1817       if (plt == NULL)
  1821   1818   	return RL2_ERROR;

Changes to src/rl2ascii.c.

   316    316   	 &no_data))
   317    317         {
   318    318   	  fprintf (stderr, "ASCII Origin: invalid Header found on %s\n", path);
   319    319   	  goto error;
   320    320         }
   321    321   
   322    322       ascii =
   323         -	alloc_ascii_origin (path, srid, sample_type, width, height, minx,
   324         -			    miny, maxx, maxy, xres, yres, no_data);
          323  +	alloc_ascii_origin (path, srid, sample_type, width, height, minx, miny,
          324  +			    maxx, maxy, xres, yres, no_data);
   325    325       if (ascii == NULL)
   326    326   	goto error;
   327    327   
   328    328       *buf = '\0';
   329    329       col_no = width;
   330    330   /* creating the helper Temporary File */
   331    331       ascii->tmp = tmpfile ();
................................................................................
   614    614   	return RL2_FALSE;
   615    615       if (coverage->Srid != srid)
   616    616         {
   617    617   	  if (verbose)
   618    618   	      fprintf (stderr, "Mismatching SRID !!!\n");
   619    619   	  return RL2_FALSE;
   620    620         }
   621         -    if (rl2_get_ascii_grid_origin_resolution
   622         -	(ascii, &hResolution, &vResolution) != RL2_OK)
          621  +    if (rl2_get_ascii_grid_origin_resolution (ascii, &hResolution, &vResolution)
          622  +	!= RL2_OK)
   623    623   	return RL2_FALSE;
   624    624       confidence = coverage->hResolution / 100.0;
   625    625       if (hResolution < (coverage->hResolution - confidence)
   626    626   	|| hResolution > (coverage->hResolution + confidence))
   627    627         {
   628    628   	  if (verbose)
   629    629   	      fprintf (stderr, "Mismatching Horizontal Resolution !!!\n");
................................................................................
   748    748   	  unsigned short *p_out = pixels + (y * width);
   749    749   	  if (fseek (origin->tmp, offset, SEEK_SET) != 0)
   750    750   	      return 0;
   751    751   	  for (x = 0, col = startCol; x < width && col < origin->width;
   752    752   	       x++, col++)
   753    753   	    {
   754    754   		unsigned short uint16;
   755         -		if (fread (&uint16, sizeof (unsigned short), 1, origin->tmp)
   756         -		    <= 0)
          755  +		if (fread (&uint16, sizeof (unsigned short), 1, origin->tmp) <=
          756  +		    0)
   757    757   		    return 0;
   758    758   		*p_out++ = uint16;
   759    759   	    }
   760    760         }
   761    761       return 1;
   762    762   }
   763    763   
................................................................................
  1068   1068   		      /* setting opaque pixels */
  1069   1069   		      memset (p, 1, shadow_x);
  1070   1070   		  }
  1071   1071   	    }
  1072   1072         }
  1073   1073       raster =
  1074   1074   	rl2_create_raster (coverage->tileWidth, coverage->tileHeight,
  1075         -			   coverage->sampleType, RL2_PIXEL_DATAGRID, 1,
  1076         -			   pixels, pixels_sz, NULL, mask, mask_size, NULL);
         1075  +			   coverage->sampleType, RL2_PIXEL_DATAGRID, 1, pixels,
         1076  +			   pixels_sz, NULL, mask, mask_size, NULL);
  1077   1077       if (raster == NULL)
  1078   1078   	goto error;
  1079   1079       return raster;
  1080   1080     error:
  1081   1081       if (pixels != NULL)
  1082   1082   	free (pixels);
  1083   1083       if (mask != NULL)

Changes to src/rl2auxfont.c.

   690    690   		      const unsigned char *blob = sqlite3_column_blob (stmt, 0);
   691    691   		      int blob_sz = sqlite3_column_bytes (stmt, 0);
   692    692   		      if (xfont != NULL)
   693    693   			{
   694    694   			    free (xfont);
   695    695   			    xfont = NULL;
   696    696   			}
   697         -		      if (rl2_font_decode (blob, blob_sz, &xfont, &xfont_sz)
   698         -			  == RL2_OK)
          697  +		      if (rl2_font_decode (blob, blob_sz, &xfont, &xfont_sz) ==
          698  +			  RL2_OK)
   699    699   			{
   700    700   			    *font = xfont;
   701    701   			    *font_sz = xfont_sz;
   702    702   			}
   703    703   		  }
   704    704   	    }
   705    705   	  else
................................................................................
   723    723   		       unsigned char **font, int *font_sz)
   724    724   {
   725    725   /* attempting to fetch a BLOB-encoded TrueType Font */
   726    726       const char *sql;
   727    727       int ret;
   728    728       sqlite3_stmt *stmt = NULL;
   729    729       unsigned char *xfont = NULL;
          730  +    int xfont_sz;
   730    731       if (facename == NULL)
   731    732   	return RL2_ERROR;
   732    733   
   733    734       *font = NULL;
   734    735       *font_sz = 0;
   735    736   /* preparing the SQL query statement */
   736    737       sql = "SELECT font FROM SE_fonts WHERE Lower(font_facename) = Lower(?)";
................................................................................
   781    782   }
   782    783   
   783    784   RL2_DECLARE rl2GraphicsFontPtr
   784    785   rl2_search_TrueType_font (sqlite3 * handle, const void *priv_data,
   785    786   			  const char *facename, double size)
   786    787   {
   787    788   /* attempting to fetch and create a TrueType Font */
   788         -    rl2GraphicsFontPtr font;
   789    789       unsigned char *ttf = NULL;
   790    790       int ttf_sz;
   791    791       if (facename == NULL)
   792    792   	return NULL;
   793    793   
   794    794       if (rl2_get_TrueType_font (handle, facename, &ttf, &ttf_sz) != RL2_OK)
   795    795   	return NULL;
   796         -    font = rl2_graph_create_TrueType_font (priv_data, ttf, ttf_sz, size);
   797         -    if (ttf != NULL)
   798         -	free (ttf);
   799         -    return font;
          796  +    return rl2_graph_create_TrueType_font (priv_data, ttf, ttf_sz, size);
   800    797   }

Changes to src/rl2auxgeom.c.

   122    122   static rl2LinestringPtr
   123    123   rl2CreateLinestring (int vert)
   124    124   {
   125    125   /* LINESTRING object constructor */
   126    126       rl2LinestringPtr p = malloc (sizeof (rl2Linestring));
   127    127       p->coords = malloc (sizeof (double) * (vert * 2));
   128    128       p->points = vert;
   129         -    p->minx = DBL_MAX;
   130         -    p->miny = DBL_MAX;
   131         -    p->maxx = 0.0 - DBL_MAX;
   132         -    p->maxy = 0.0 - DBL_MAX;
   133    129       p->next = NULL;
   134    130       return p;
   135    131   }
   136    132   
   137         -RL2_PRIVATE void
          133  +static void
   138    134   rl2DestroyLinestring (rl2LinestringPtr ptr)
   139    135   {
   140    136   /* LINESTRING object desctructror */
   141    137       if (ptr)
   142    138         {
   143    139   	  if (ptr->coords)
   144    140   	      free (ptr->coords);
   145    141   	  free (ptr);
   146    142         }
   147    143   }
   148    144   
   149         -RL2_PRIVATE rl2LinestringPtr
   150         -rl2_linestring_to_image (rl2LinestringPtr line, int height, double minx,
   151         -			 double miny, double x_res, double y_res)
   152         -{
   153         -/* creating a Linestring in image coordinates */
   154         -    rl2LinestringPtr out = NULL;
   155         -    int iv;
   156         -    double x;
   157         -    double y;
   158         -    double dx;
   159         -    double dy;
   160         -
   161         -    if (line == NULL)
   162         -	return NULL;
   163         -    out = rl2CreateLinestring (line->points);
   164         -    if (out == NULL)
   165         -	return out;
   166         -    for (iv = 0; iv < line->points; iv++)
   167         -      {
   168         -	  /* populating the X and Y arrays */
   169         -	  rl2GetPoint (line->coords, iv, &x, &y);
   170         -	  dx = (x - minx) / x_res;
   171         -	  dy = (double) height - ((y - miny) / y_res);
   172         -	  rl2SetPoint (out->coords, iv, dx, dy);
   173         -      }
   174         -    return out;
   175         -}
   176         -
   177    145   static rl2RingPtr
   178    146   rl2CreateRing (int vert)
   179    147   {
   180    148   /* ring object constructor */
   181    149       rl2RingPtr p = malloc (sizeof (rl2Ring));
   182    150       p->coords = malloc (sizeof (double) * (vert * 2));
   183    151       p->points = vert;
   184         -    p->minx = DBL_MAX;
   185         -    p->miny = DBL_MAX;
   186         -    p->maxx = 0.0 - DBL_MAX;
   187         -    p->maxy = 0.0 - DBL_MAX;
   188    152       p->next = NULL;
   189    153       return p;
   190    154   }
   191    155   
   192         -RL2_PRIVATE rl2RingPtr
   193         -rl2_ring_to_image (rl2RingPtr ring, int height, double minx, double miny,
   194         -		   double x_res, double y_res)
   195         -{
   196         -/* creating a Ring in image coordinates */
   197         -    rl2RingPtr out = NULL;
   198         -    int iv;
   199         -    double x;
   200         -    double y;
   201         -    double dx;
   202         -    double dy;
   203         -
   204         -    if (ring == NULL)
   205         -	return NULL;
   206         -    out = rl2CreateRing (ring->points);
   207         -    if (out == NULL)
   208         -	return out;
   209         -    for (iv = 0; iv < ring->points; iv++)
   210         -      {
   211         -	  /* populating the X and Y arrays */
   212         -	  rl2GetPoint (ring->coords, iv, &x, &y);
   213         -	  dx = (x - minx) / x_res;
   214         -	  dy = (double) height - ((y - miny) / y_res);
   215         -	  rl2SetPoint (out->coords, iv, dx, dy);
   216         -      }
   217         -    return out;
   218         -}
   219         -
   220         -RL2_PRIVATE void
          156  +static void
   221    157   rl2DestroyRing (rl2RingPtr ptr)
   222    158   {
   223    159   /* ring object destructor */
   224    160       if (ptr)
   225    161         {
   226    162   	  if (ptr->coords)
   227    163   	      free (ptr->coords);
................................................................................
   245    181       else
   246    182   	p->interiors = malloc (sizeof (rl2Ring) * excl);
   247    183       for (ind = 0; ind < p->num_interiors; ind++)
   248    184         {
   249    185   	  pP = p->interiors + ind;
   250    186   	  pP->points = 0;
   251    187   	  pP->coords = NULL;
   252         -	  pP->minx = DBL_MAX;
   253         -	  pP->miny = DBL_MAX;
   254         -	  pP->maxx = 0.0 - DBL_MAX;
   255         -	  pP->maxy = 0.0 - DBL_MAX;
   256    188         }
   257    189       return p;
   258    190   }
   259    191   
   260    192   static void
   261    193   rl2DestroyPolygon (rl2PolygonPtr p)
   262    194   {
................................................................................
   690    622   	return;
   691    623       line = rl2AddLinestringToGeometry (geom, points);
   692    624       for (iv = 0; iv < points; iv++)
   693    625         {
   694    626   	  x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   695    627   	  y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   696    628   	  rl2SetPoint (line->coords, iv, x, y);
   697         -	  if (x < line->minx)
   698         -	      line->minx = x;
   699         -	  if (x > line->maxx)
   700         -	      line->maxx = x;
   701         -	  if (y < line->miny)
   702         -	      line->miny = y;
   703         -	  if (y > line->maxy)
   704         -	      line->maxy = y;
   705    629   	  *offset += 16;
   706    630         }
   707    631   }
   708    632   
   709    633   static void
   710    634   rl2ParseLineZ (rl2GeometryPtr geom, const unsigned char *blob, int size,
   711    635   	       int endian, int endian_arch, int *offset)
................................................................................
   724    648   	return;
   725    649       line = rl2AddLinestringToGeometry (geom, points);
   726    650       for (iv = 0; iv < points; iv++)
   727    651         {
   728    652   	  x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   729    653   	  y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   730    654   	  rl2SetPoint (line->coords, iv, x, y);
   731         -	  if (x < line->minx)
   732         -	      line->minx = x;
   733         -	  if (x > line->maxx)
   734         -	      line->maxx = x;
   735         -	  if (y < line->miny)
   736         -	      line->miny = y;
   737         -	  if (y > line->maxy)
   738         -	      line->maxy = y;
   739    655   	  *offset += 24;
   740    656         }
   741    657   }
   742    658   
   743    659   static void
   744    660   rl2ParseLineM (rl2GeometryPtr geom, const unsigned char *blob, int size,
   745    661   	       int endian, int endian_arch, int *offset)
................................................................................
   758    674   	return;
   759    675       line = rl2AddLinestringToGeometry (geom, points);
   760    676       for (iv = 0; iv < points; iv++)
   761    677         {
   762    678   	  x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   763    679   	  y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   764    680   	  rl2SetPoint (line->coords, iv, x, y);
   765         -	  if (x < line->minx)
   766         -	      line->minx = x;
   767         -	  if (x > line->maxx)
   768         -	      line->maxx = x;
   769         -	  if (y < line->miny)
   770         -	      line->miny = y;
   771         -	  if (y > line->maxy)
   772         -	      line->maxy = y;
   773    681   	  *offset += 24;
   774    682         }
   775    683   }
   776    684   
   777    685   static void
   778    686   rl2ParseLineZM (rl2GeometryPtr geom, const unsigned char *blob, int size,
   779    687   		int endian, int endian_arch, int *offset)
................................................................................
   792    700   	return;
   793    701       line = rl2AddLinestringToGeometry (geom, points);
   794    702       for (iv = 0; iv < points; iv++)
   795    703         {
   796    704   	  x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   797    705   	  y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   798    706   	  rl2SetPoint (line->coords, iv, x, y);
   799         -	  if (x < line->minx)
   800         -	      line->minx = x;
   801         -	  if (x > line->maxx)
   802         -	      line->maxx = x;
   803         -	  if (y < line->miny)
   804         -	      line->miny = y;
   805         -	  if (y > line->maxy)
   806         -	      line->maxy = y;
   807    707   	  *offset += 32;
   808    708         }
   809    709   }
   810    710   
   811    711   static rl2PolygonPtr
   812    712   rl2AddPolygonToGeometry (rl2GeometryPtr p, int vert, int interiors)
   813    713   {
................................................................................
   865    765   	      ring = rl2AddInteriorRing (polyg, ib - 1, nverts);
   866    766   	  for (iv = 0; iv < nverts; iv++)
   867    767   	    {
   868    768   		x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   869    769   		y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   870    770   		*offset += 16;
   871    771   		rl2SetPoint (ring->coords, iv, x, y);
   872         -		if (x < ring->minx)
   873         -		    ring->minx = x;
   874         -		if (x > ring->maxx)
   875         -		    ring->maxx = x;
   876         -		if (y < ring->miny)
   877         -		    ring->miny = y;
   878         -		if (y > ring->maxy)
   879         -		    ring->maxy = y;
   880    772   	    }
   881    773         }
   882    774   }
   883    775   
   884    776   static void
   885    777   rl2ParsePolygonZ (rl2GeometryPtr geom, const unsigned char *blob, int size,
   886    778   		  int endian, int endian_arch, int *offset)
................................................................................
   915    807   	      ring = rl2AddInteriorRing (polyg, ib - 1, nverts);
   916    808   	  for (iv = 0; iv < nverts; iv++)
   917    809   	    {
   918    810   		x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   919    811   		y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   920    812   		*offset += 24;
   921    813   		rl2SetPoint (ring->coords, iv, x, y);
   922         -		if (x < ring->minx)
   923         -		    ring->minx = x;
   924         -		if (x > ring->maxx)
   925         -		    ring->maxx = x;
   926         -		if (y < ring->miny)
   927         -		    ring->miny = y;
   928         -		if (y > ring->maxy)
   929         -		    ring->maxy = y;
   930    814   	    }
   931    815         }
   932    816   }
   933    817   
   934    818   static void
   935    819   rl2ParsePolygonM (rl2GeometryPtr geom, const unsigned char *blob, int size,
   936    820   		  int endian, int endian_arch, int *offset)
................................................................................
   965    849   	      ring = rl2AddInteriorRing (polyg, ib - 1, nverts);
   966    850   	  for (iv = 0; iv < nverts; iv++)
   967    851   	    {
   968    852   		x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
   969    853   		y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
   970    854   		*offset += 24;
   971    855   		rl2SetPoint (ring->coords, iv, x, y);
   972         -		if (x < ring->minx)
   973         -		    ring->minx = x;
   974         -		if (x > ring->maxx)
   975         -		    ring->maxx = x;
   976         -		if (y < ring->miny)
   977         -		    ring->miny = y;
   978         -		if (y > ring->maxy)
   979         -		    ring->maxy = y;
   980    856   	    }
   981    857         }
   982    858   }
   983    859   
   984    860   static void
   985    861   rl2ParsePolygonZM (rl2GeometryPtr geom, const unsigned char *blob, int size,
   986    862   		   int endian, int endian_arch, int *offset)
................................................................................
  1015    891   	      ring = rl2AddInteriorRing (polyg, ib - 1, nverts);
  1016    892   	  for (iv = 0; iv < nverts; iv++)
  1017    893   	    {
  1018    894   		x = rl2GeomImport64 (blob + *offset, endian, endian_arch);
  1019    895   		y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch);
  1020    896   		*offset += 32;
  1021    897   		rl2SetPoint (ring->coords, iv, x, y);
  1022         -		if (x < ring->minx)
  1023         -		    ring->minx = x;
  1024         -		if (x > ring->maxx)
  1025         -		    ring->maxx = x;
  1026         -		if (y < ring->miny)
  1027         -		    ring->miny = y;
  1028         -		if (y > ring->maxy)
  1029         -		    ring->maxy = y;
  1030    898   	    }
  1031    899         }
  1032    900   }
  1033    901   
  1034    902   static void
  1035    903   rl2ParseCompressedLine (rl2GeometryPtr geom, const unsigned char *blob,
  1036    904   			int size, int endian, int endian_arch, int *offset)
................................................................................
  1068    936   		fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1069    937   				       endian_arch);
  1070    938   		x = last_x + fx;
  1071    939   		y = last_y + fy;
  1072    940   		*offset += 8;
  1073    941   	    }
  1074    942   	  rl2SetPoint (line->coords, iv, x, y);
  1075         -	  if (x < line->minx)
  1076         -	      line->minx = x;
  1077         -	  if (x > line->maxx)
  1078         -	      line->maxx = x;
  1079         -	  if (y < line->miny)
  1080         -	      line->miny = y;
  1081         -	  if (y > line->maxy)
  1082         -	      line->maxy = y;
  1083    943   	  last_x = x;
  1084    944   	  last_y = y;
  1085    945         }
  1086    946   }
  1087    947   
  1088    948   static void
  1089    949   rl2ParseCompressedLineZ (rl2GeometryPtr geom, const unsigned char *blob,
................................................................................
  1122    982   		fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1123    983   				       endian_arch);
  1124    984   		x = last_x + fx;
  1125    985   		y = last_y + fy;
  1126    986   		*offset += 12;
  1127    987   	    }
  1128    988   	  rl2SetPoint (line->coords, iv, x, y);
  1129         -	  if (x < line->minx)
  1130         -	      line->minx = x;
  1131         -	  if (x > line->maxx)
  1132         -	      line->maxx = x;
  1133         -	  if (y < line->miny)
  1134         -	      line->miny = y;
  1135         -	  if (y > line->maxy)
  1136         -	      line->maxy = y;
  1137    989   	  last_x = x;
  1138    990   	  last_y = y;
  1139    991         }
  1140    992   }
  1141    993   
  1142    994   static void
  1143    995   rl2ParseCompressedLineM (rl2GeometryPtr geom, const unsigned char *blob,
................................................................................
  1176   1028   		fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1177   1029   				       endian_arch);
  1178   1030   		x = last_x + fx;
  1179   1031   		y = last_y + fy;
  1180   1032   		*offset += 16;
  1181   1033   	    }
  1182   1034   	  rl2SetPoint (line->coords, iv, x, y);
  1183         -	  if (x < line->minx)
  1184         -	      line->minx = x;
  1185         -	  if (x > line->maxx)
  1186         -	      line->maxx = x;
  1187         -	  if (y < line->miny)
  1188         -	      line->miny = y;
  1189         -	  if (y > line->maxy)
  1190         -	      line->maxy = y;
  1191   1035   	  last_x = x;
  1192   1036   	  last_y = y;
  1193   1037         }
  1194   1038   }
  1195   1039   
  1196   1040   static void
  1197   1041   rl2ParseCompressedLineZM (rl2GeometryPtr geom, const unsigned char *blob,
................................................................................
  1230   1074   		fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1231   1075   				       endian_arch);
  1232   1076   		x = last_x + fx;
  1233   1077   		y = last_y + fy;
  1234   1078   		*offset += 20;
  1235   1079   	    }
  1236   1080   	  rl2SetPoint (line->coords, iv, x, y);
  1237         -	  if (x < line->minx)
  1238         -	      line->minx = x;
  1239         -	  if (x > line->maxx)
  1240         -	      line->maxx = x;
  1241         -	  if (y < line->miny)
  1242         -	      line->miny = y;
  1243         -	  if (y > line->maxy)
  1244         -	      line->maxy = y;
  1245   1081   	  last_x = x;
  1246   1082   	  last_y = y;
  1247   1083         }
  1248   1084   }
  1249   1085   
  1250   1086   static void
  1251   1087   rl2ParseCompressedPolygon (rl2GeometryPtr geom, const unsigned char *blob,
................................................................................
  1301   1137   		      fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1302   1138   					     endian_arch);
  1303   1139   		      x = last_x + fx;
  1304   1140   		      y = last_y + fy;
  1305   1141   		      *offset += 8;
  1306   1142   		  }
  1307   1143   		rl2SetPoint (ring->coords, iv, x, y);
  1308         -		if (x < ring->minx)
  1309         -		    ring->minx = x;
  1310         -		if (x > ring->maxx)
  1311         -		    ring->maxx = x;
  1312         -		if (y < ring->miny)
  1313         -		    ring->miny = y;
  1314         -		if (y > ring->maxy)
  1315         -		    ring->maxy = y;
  1316   1144   		last_x = x;
  1317   1145   		last_y = y;
  1318   1146   	    }
  1319   1147         }
  1320   1148   }
  1321   1149   
  1322   1150   static void
................................................................................
  1373   1201   		      fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1374   1202   					     endian_arch);
  1375   1203   		      x = last_x + fx;
  1376   1204   		      y = last_y + fy;
  1377   1205   		      *offset += 12;
  1378   1206   		  }
  1379   1207   		rl2SetPoint (ring->coords, iv, x, y);
  1380         -		if (x < ring->minx)
  1381         -		    ring->minx = x;
  1382         -		if (x > ring->maxx)
  1383         -		    ring->maxx = x;
  1384         -		if (y < ring->miny)
  1385         -		    ring->miny = y;
  1386         -		if (y > ring->maxy)
  1387         -		    ring->maxy = y;
  1388   1208   		last_x = x;
  1389   1209   		last_y = y;
  1390   1210   	    }
  1391   1211         }
  1392   1212   }
  1393   1213   
  1394   1214   static void
................................................................................
  1445   1265   		      fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1446   1266   					     endian_arch);
  1447   1267   		      x = last_x + fx;
  1448   1268   		      y = last_y + fy;
  1449   1269   		      *offset += 16;
  1450   1270   		  }
  1451   1271   		rl2SetPoint (ring->coords, iv, x, y);
  1452         -		if (x < ring->minx)
  1453         -		    ring->minx = x;
  1454         -		if (x > ring->maxx)
  1455         -		    ring->maxx = x;
  1456         -		if (y < ring->miny)
  1457         -		    ring->miny = y;
  1458         -		if (y > ring->maxy)
  1459         -		    ring->maxy = y;
  1460   1272   		last_x = x;
  1461   1273   		last_y = y;
  1462   1274   	    }
  1463   1275         }
  1464   1276   }
  1465   1277   
  1466   1278   static void
................................................................................
  1517   1329   		      fy = rl2GeomImportF32 (blob + (*offset + 4), endian,
  1518   1330   					     endian_arch);
  1519   1331   		      x = last_x + fx;
  1520   1332   		      y = last_y + fy;
  1521   1333   		      *offset += 20;
  1522   1334   		  }
  1523   1335   		rl2SetPoint (ring->coords, iv, x, y);
  1524         -		if (x < ring->minx)
  1525         -		    ring->minx = x;
  1526         -		if (x > ring->maxx)
  1527         -		    ring->maxx = x;
  1528         -		if (y < ring->miny)
  1529         -		    ring->miny = y;
  1530         -		if (y > ring->maxy)
  1531         -		    ring->maxy = y;
  1532   1336   		last_x = x;
  1533   1337   		last_y = y;
  1534   1338   	    }
  1535   1339         }
  1536   1340   }
  1537   1341   
  1538   1342   static void
................................................................................
  1595   1399   				   offset);
  1596   1400   		break;
  1597   1401   	    case GAIA_COMPRESSED_LINESTRING:
  1598   1402   		rl2ParseCompressedLine (geom, blob, size, endian, endian_arch,
  1599   1403   					offset);
  1600   1404   		break;
  1601   1405   	    case GAIA_COMPRESSED_LINESTRINGZ:
  1602         -		rl2ParseCompressedLineZ (geom, blob, size, endian,
  1603         -					 endian_arch, offset);
         1406  +		rl2ParseCompressedLineZ (geom, blob, size, endian, endian_arch,
         1407  +					 offset);
  1604   1408   		break;
  1605   1409   	    case GAIA_COMPRESSED_LINESTRINGM:
  1606         -		rl2ParseCompressedLineM (geom, blob, size, endian,
  1607         -					 endian_arch, offset);
         1410  +		rl2ParseCompressedLineM (geom, blob, size, endian, endian_arch,
         1411  +					 offset);
  1608   1412   		break;
  1609   1413   	    case GAIA_COMPRESSED_LINESTRINGZM:
  1610         -		rl2ParseCompressedLineZM (geom, blob, size, endian,
  1611         -					  endian_arch, offset);
         1414  +		rl2ParseCompressedLineZM (geom, blob, size, endian, endian_arch,
         1415  +					  offset);
  1612   1416   		break;
  1613   1417   	    case GAIA_COMPRESSED_POLYGON:
  1614   1418   		rl2ParseCompressedPolygon (geom, blob, size, endian,
  1615   1419   					   endian_arch, offset);
  1616   1420   		break;
  1617   1421   	    case GAIA_COMPRESSED_POLYGONZ:
  1618   1422   		rl2ParseCompressedPolygonZ (geom, blob, size, endian,
................................................................................
  1702   1506   			    &offset);
  1703   1507   	  break;
  1704   1508         case GAIA_POLYGONZM:
  1705   1509   	  rl2ParsePolygonZM (geom, blob, size, little_endian, endian_arch,
  1706   1510   			     &offset);
  1707   1511   	  break;
  1708   1512         case GAIA_COMPRESSED_LINESTRING:
  1709         -	  rl2ParseCompressedLine (geom, blob, size, little_endian,
  1710         -				  endian_arch, &offset);
         1513  +	  rl2ParseCompressedLine (geom, blob, size, little_endian, endian_arch,
         1514  +				  &offset);
  1711   1515   	  break;
  1712   1516         case GAIA_COMPRESSED_LINESTRINGZ:
  1713         -	  rl2ParseCompressedLineZ (geom, blob, size, little_endian,
  1714         -				   endian_arch, &offset);
         1517  +	  rl2ParseCompressedLineZ (geom, blob, size, little_endian, endian_arch,
         1518  +				   &offset);
  1715   1519   	  break;
  1716   1520         case GAIA_COMPRESSED_LINESTRINGM:
  1717         -	  rl2ParseCompressedLineM (geom, blob, size, little_endian,
  1718         -				   endian_arch, &offset);
         1521  +	  rl2ParseCompressedLineM (geom, blob, size, little_endian, endian_arch,
         1522  +				   &offset);
  1719   1523   	  break;
  1720   1524         case GAIA_COMPRESSED_LINESTRINGZM:
  1721   1525   	  rl2ParseCompressedLineZM (geom, blob, size, little_endian,
  1722   1526   				    endian_arch, &offset);
  1723   1527   	  break;
  1724   1528         case GAIA_COMPRESSED_POLYGON:
  1725   1529   	  rl2ParseCompressedPolygon (geom, blob, size, little_endian,
................................................................................
  1916   1720   	  rl2GeomExport64 (ptr + 8, y, 1, endian_arch);	/* Y - exterior ring */
  1917   1721   	  ptr += 16;
  1918   1722         }
  1919   1723       *ptr = GAIA_MARK_END;	/* END signature */
  1920   1724       return 1;
  1921   1725   }
  1922   1726   
  1923         -RL2_PRIVATE int
  1924         -rl2_serialize_ring_as_linestring (rl2RingPtr ring, unsigned char **result,
  1925         -				  int *size)
  1926         -{
  1927         -/* serializing a BLOB Geometry - polygon ring as linestring */
  1928         -    int iv;
  1929         -    unsigned char *ptr;
  1930         -    int endian_arch = rl2GeomEndianArch ();
  1931         -    double minx = DBL_MAX;
  1932         -    double maxx = 0.0 - DBL_MAX;
  1933         -    double miny = DBL_MAX;
  1934         -    double maxy = 0.0 - DBL_MAX;
  1935         -    double x;
  1936         -    double y;
  1937         -
  1938         -    *result = NULL;
  1939         -    *size = 0;
  1940         -    if (ring == NULL)
  1941         -	return 0;
  1942         -
  1943         -/* computing the MBR */
  1944         -    for (iv = 0; iv < ring->points; iv++)
  1945         -      {
  1946         -	  rl2GetPoint (ring->coords, iv, &x, &y);
  1947         -	  if (x < minx)
  1948         -	      minx = x;
  1949         -	  if (x > maxx)
  1950         -	      maxx = x;
  1951         -	  if (y < miny)
  1952         -	      miny = y;
  1953         -	  if (y > maxy)
  1954         -	      maxy = y;
  1955         -      }
  1956         -/* computing the size of BLOB */
  1957         -    *size = 44;			/* header size */
  1958         -    *size += (4 + ((sizeof (double) * 2) * ring->points));	/* # points + [x,y] for each vertex */
  1959         -    *result = malloc (*size);
  1960         -    ptr = *result;
  1961         -/* building the BLOB */
  1962         -    *ptr = GAIA_MARK_START;	/* START signature */
  1963         -    *(ptr + 1) = GAIA_LITTLE_ENDIAN;	/* byte ordering */
  1964         -    rl2GeomExport32 (ptr + 2, 4326, 1, endian_arch);	/* the SRID */
  1965         -    rl2GeomExport64 (ptr + 6, minx, 1, endian_arch);	/* MBR - minimum X */
  1966         -    rl2GeomExport64 (ptr + 14, miny, 1, endian_arch);	/* MBR - minimum Y */
  1967         -    rl2GeomExport64 (ptr + 22, maxx, 1, endian_arch);	/* MBR - maximum X */
  1968         -    rl2GeomExport64 (ptr + 30, maxy, 1, endian_arch);	/* MBR - maximum Y */
  1969         -    *(ptr + 38) = GAIA_MARK_MBR;	/* MBR signature */
  1970         -    rl2GeomExport32 (ptr + 39, GAIA_LINESTRING, 1, endian_arch);	/* class LINESTRING */
  1971         -    rl2GeomExport32 (ptr + 43, ring->points, 1, endian_arch);	/* # points */
  1972         -    ptr += 47;
  1973         -    for (iv = 0; iv < ring->points; iv++)
  1974         -      {
  1975         -	  rl2GetPoint (ring->coords, iv, &x, &y);
  1976         -	  rl2GeomExport64 (ptr, x, 1, endian_arch);
  1977         -	  rl2GeomExport64 (ptr + 8, y, 1, endian_arch);
  1978         -	  ptr += 16;
  1979         -      }
  1980         -    *ptr = GAIA_MARK_END;	/* END signature */
  1981         -    return 1;
  1982         -}
  1983         -
  1984   1727   RL2_PRIVATE rl2GeometryPtr
  1985   1728   rl2_curve_from_XY (int points, double *x, double *y)
  1986   1729   {
  1987   1730   /* creating a Linestring Geometry from X,Y coordinate arrays */
  1988   1731       rl2GeometryPtr geom = NULL;
  1989   1732       rl2LinestringPtr ln;
  1990   1733       int iv;
  1991   1734   
  1992   1735       if (points <= 0 || x == NULL || y == NULL)
  1993   1736   	return 0;
  1994   1737       geom = rl2CreateGeometry ();
  1995   1738       ln = rl2AddLinestringToGeometry (geom, points);
  1996   1739       for (iv = 0; iv < points; iv++)
  1997         -      {
  1998         -	  rl2SetPoint (ln->coords, iv, *(x + iv), *(y + iv));
  1999         -	  if (*(x + iv) < ln->minx)
  2000         -	      ln->minx = *(x + iv);
  2001         -	  if (*(x + iv) > ln->maxx)
  2002         -	      ln->maxx = *(x + iv);
  2003         -	  if (*(y + iv) < ln->miny)
  2004         -	      ln->miny = *(y + iv);
  2005         -	  if (*(y + iv) > ln->maxy)
  2006         -	      ln->maxy = *(y + iv);
  2007         -      }
         1740  +	rl2SetPoint (ln->coords, iv, *(x + iv), *(y + iv));
  2008   1741       return geom;
  2009   1742   }
  2010   1743   
  2011   1744   RL2_PRIVATE double
  2012   1745   rl2_compute_curve_length (rl2GeometryPtr geom)
  2013   1746   {
  2014   1747   /* computing the total length of some curve (single linestring expected) */
................................................................................
  2117   1850       ln_out = rl2AddLinestringToGeometry (out, ln_in->points);
  2118   1851       for (iv = 0; iv < ln_in->points; iv++)
  2119   1852         {
  2120   1853   	  double x;
  2121   1854   	  double y;
  2122   1855   	  rl2GetPoint (ln_in->coords, iv, &x, &y);
  2123   1856   	  rl2SetPoint (ln_out->coords, iv, x, y);
  2124         -	  if (x < ln_out->minx)
  2125         -	      ln_out->minx = x;
  2126         -	  if (x > ln_out->maxx)
  2127         -	      ln_out->maxx = x;
  2128         -	  if (y < ln_out->miny)
  2129         -	      ln_out->miny = y;
  2130         -	  if (y > ln_out->maxy)
  2131         -	      ln_out->maxy = y;
  2132   1857         }
  2133   1858       return out;
  2134   1859   }
  2135   1860   
  2136   1861   RL2_PRIVATE rl2GeometryPtr
  2137   1862   rl2_clone_linestring (rl2LinestringPtr in)
  2138   1863   {
................................................................................
  2145   1870       ln_out = rl2AddLinestringToGeometry (out, in->points);
  2146   1871       for (iv = 0; iv < in->points; iv++)
  2147   1872         {
  2148   1873   	  double x;
  2149   1874   	  double y;
  2150   1875   	  rl2GetPoint (in->coords, iv, &x, &y);
  2151   1876   	  rl2SetPoint (ln_out->coords, iv, x, y);
  2152         -	  if (x < ln_out->minx)
  2153         -	      ln_out->minx = x;
  2154         -	  if (x > ln_out->maxx)
  2155         -	      ln_out->maxx = x;
  2156         -	  if (y < ln_out->miny)
  2157         -	      ln_out->miny = y;
  2158         -	  if (y > ln_out->maxy)
  2159         -	      ln_out->maxy = y;
  2160   1877         }
  2161   1878       return out;
  2162   1879   }
  2163   1880   
  2164   1881   RL2_PRIVATE rl2GeometryPtr
  2165   1882   rl2_build_circle (double cx, double cy, double radius)
  2166   1883   {
  2167         -/* creating a circle */
         1884  +/* creating a cicrle */
  2168   1885       int iv = 0;
  2169   1886       double pi = 3.14159265359;
  2170   1887       double rads;
  2171   1888       double x;
  2172   1889       double y;
  2173   1890       rl2LinestringPtr ln;
  2174   1891       rl2GeometryPtr out = rl2CreateGeometry ();
  2175   1892       ln = rl2AddLinestringToGeometry (out, 129);
  2176   1893       for (rads = 0.0; rads <= (pi * 2.0); rads += pi / 64.0)
  2177   1894         {
  2178   1895   	  x = cx + (radius * cos (rads));
  2179   1896   	  y = cy + (radius * sin (rads));
  2180   1897   	  rl2SetPoint (ln->coords, iv, x, y);
  2181         -	  if (x < ln->minx)
  2182         -	      ln->minx = x;
  2183         -	  if (x > ln->maxx)
  2184         -	      ln->maxx = x;
  2185         -	  if (y < ln->miny)
  2186         -	      ln->miny = y;
  2187         -	  if (y > ln->maxy)
  2188         -	      ln->maxy = y;
  2189   1898   	  iv++;
  2190   1899         }
  2191   1900       /* closure */
  2192   1901       rl2GetPoint (ln->coords, 0, &x, &y);
  2193   1902       rl2SetPoint (ln->coords, 128, x, y);
  2194   1903       return out;
  2195   1904   }

Changes to src/rl2auxrender.c.

   288    288   		  }
   289    289   	    }
   290    290         }
   291    291   }
   292    292   
   293    293   static void
   294    294   copy_palette (unsigned char *rgba, unsigned int width, unsigned int height,
   295         -	      unsigned char *inbuf, rl2PalettePtr palette,
   296         -	      unsigned char bg_red, unsigned char bg_green,
   297         -	      unsigned char bg_blue)
          295  +	      unsigned char *inbuf, rl2PalettePtr palette, unsigned char bg_red,
          296  +	      unsigned char bg_green, unsigned char bg_blue)
   298    297   {
   299    298   /* copying from Palette to RGBA */
   300    299       unsigned int x;
   301    300       unsigned int y;
   302    301       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette;
   303    302       unsigned char *p_in = inbuf;
   304    303       unsigned char *p_out = rgba;
................................................................................
   451    450   	goto error;
   452    451   
   453    452       if (aux->base_width == aux->width && aux->base_height == aux->height)
   454    453         {
   455    454   	  if (aux->out_pixel == RL2_PIXEL_MONOCHROME)
   456    455   	    {
   457    456   		/* Monochrome */
   458         -		copy_monochrome (aggreg_rgba, aux->base_width,
   459         -				 aux->base_height, aux->outbuf);
          457  +		copy_monochrome (aggreg_rgba, aux->base_width, aux->base_height,
          458  +				 aux->outbuf);
   460    459   		aux->outbuf = NULL;
   461    460   	    }
   462    461   	  else if (aux->out_pixel == RL2_PIXEL_PALETTE)
   463    462   	    {
   464    463   		/* Palette */
   465    464   		copy_palette (aggreg_rgba, aux->base_width, aux->base_height,
   466    465   			      aux->outbuf, aux->palette, aux->bg_red,
   467    466   			      aux->bg_green, aux->bg_blue);
   468    467   		aux->outbuf = NULL;
   469    468   	    }
   470    469   	  else if (aux->out_pixel == RL2_PIXEL_GRAYSCALE)
   471    470   	    {
   472    471   		/* Grayscale */
   473         -		copy_grayscale (aggreg_rgba, aux->base_width,
   474         -				aux->base_height, aux->outbuf, aux->bg_red);
          472  +		copy_grayscale (aggreg_rgba, aux->base_width, aux->base_height,
          473  +				aux->outbuf, aux->bg_red);
   475    474   		aux->outbuf = NULL;
   476    475   	    }
   477    476   	  else
   478    477   	    {
   479    478   		/* RGB */
   480    479   		copy_rgb (aggreg_rgba, aux->base_width, aux->base_height,
   481    480   			  aux->outbuf, aux->bg_red, aux->bg_green,
................................................................................
   608    607   			}
   609    608   		  }
   610    609   		else
   611    610   		  {
   612    611   		      if (!get_payload_from_monochrome_opaque
   613    612   			  (aux->base_width, aux->base_height, aux->sqlite,
   614    613   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   615         -			   aux->srid, aux->outbuf, aux->format_id,
   616         -			   aux->quality, &image, &image_size))
          614  +			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
          615  +			   &image, &image_size))
   617    616   			{
   618    617   			    aux->outbuf = NULL;
   619    618   			    goto error;
   620    619   			}
   621    620   		  }
   622    621   		aux->outbuf = NULL;
   623    622   	    }
................................................................................
   637    636   			}
   638    637   		  }
   639    638   		else
   640    639   		  {
   641    640   		      if (!get_payload_from_palette_opaque
   642    641   			  (aux->base_width, aux->base_height, aux->sqlite,
   643    642   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   644         -			   aux->srid, aux->outbuf, aux->palette,
   645         -			   aux->format_id, aux->quality, &image, &image_size))
          643  +			   aux->srid, aux->outbuf, aux->palette, aux->format_id,
          644  +			   aux->quality, &image, &image_size))
   646    645   			{
   647    646   			    aux->outbuf = NULL;
   648    647   			    goto error;
   649    648   			}
   650    649   		  }
   651    650   		aux->outbuf = NULL;
   652    651   	    }
................................................................................
   665    664   			}
   666    665   		  }
   667    666   		else
   668    667   		  {
   669    668   		      if (!get_payload_from_grayscale_opaque
   670    669   			  (aux->base_width, aux->base_height, aux->sqlite,
   671    670   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   672         -			   aux->srid, aux->outbuf, aux->format_id,
   673         -			   aux->quality, &image, &image_size))
          671  +			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
          672  +			   &image, &image_size))
   674    673   			{
   675    674   			    aux->outbuf = NULL;
   676    675   			    goto error;
   677    676   			}
   678    677   		  }
   679    678   		aux->outbuf = NULL;
   680    679   	    }
................................................................................
   694    693   			}
   695    694   		  }
   696    695   		else
   697    696   		  {
   698    697   		      if (!get_payload_from_rgb_opaque
   699    698   			  (aux->base_width, aux->base_height, aux->sqlite,
   700    699   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   701         -			   aux->srid, aux->outbuf, aux->format_id,
   702         -			   aux->quality, &image, &image_size))
          700  +			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
          701  +			   &image, &image_size))
   703    702   			{
   704    703   			    aux->outbuf = NULL;
   705    704   			    goto error;
   706    705   			}
   707    706   		  }
   708    707   		aux->outbuf = NULL;
   709    708   	    }
................................................................................
   740    739   			    goto error;
   741    740   			}
   742    741   		  }
   743    742   		aux->outbuf = NULL;
   744    743   	    }
   745    744   	  else if (aux->out_pixel == RL2_PIXEL_PALETTE)
   746    745   	    {
   747         -		/* Palette - upsampled */
          746  +		/* Monochrome - upsampled */
   748    747   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   749    748   		  {
   750    749   		      if (!get_rgba_from_palette_transparent
   751    750   			  (aux->base_width, aux->base_height, aux->outbuf,
   752    751   			   aux->palette, rgba, aux->bg_red, aux->bg_green,
   753    752   			   aux->bg_blue))
   754    753   			{
................................................................................
   770    769   	    }
   771    770   	  else if (aux->out_pixel == RL2_PIXEL_GRAYSCALE)
   772    771   	    {
   773    772   		/* Grayscale */
   774    773   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   775    774   		  {
   776    775   		      if (!get_rgba_from_grayscale_transparent
   777         -			  (aux->base_width, aux->base_height, aux->outbuf,
   778         -			   rgba, aux->bg_red))
          776  +			  (aux->base_width, aux->base_height, aux->outbuf, rgba,
          777  +			   aux->bg_red))
   779    778   			{
   780    779   			    aux->outbuf = NULL;
   781    780   			    goto error;
   782    781   			}
   783    782   		  }
   784    783   		else
   785    784   		  {
................................................................................
   795    794   	    }
   796    795   	  else
   797    796   	    {
   798    797   		/* RGB */
   799    798   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   800    799   		  {
   801    800   		      if (!get_rgba_from_rgb_transparent
   802         -			  (aux->base_width, aux->base_height, aux->outbuf,
   803         -			   rgba, aux->bg_red, aux->bg_green, aux->bg_blue))
          801  +			  (aux->base_width, aux->base_height, aux->outbuf, rgba,
          802  +			   aux->bg_red, aux->bg_green, aux->bg_blue))
   804    803   			{
   805    804   			    aux->outbuf = NULL;
   806    805   			    goto error;
   807    806   			}
   808    807   		  }
   809    808   		else
   810    809   		  {
................................................................................
   839    838   	    {
   840    839   		/* Grayscale or Monochrome upsampled */
   841    840   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   842    841   		  {
   843    842   		      if (alpha == NULL)
   844    843   			  goto error;
   845    844   		      if (!get_payload_from_gray_rgba_transparent
   846         -			  (aux->width, aux->height, rgb, alpha,
   847         -			   aux->format_id, aux->quality, &image, &image_size,
   848         -			   aux->opacity))
          845  +			  (aux->width, aux->height, rgb, alpha, aux->format_id,
          846  +			   aux->quality, &image, &image_size, aux->opacity))
   849    847   			  goto error;
   850    848   		  }
   851    849   		else
   852    850   		  {
   853    851   		      if (alpha != NULL)
   854    852   			  free (alpha);
   855    853   		      alpha = NULL;
................................................................................
   864    862   	    {
   865    863   		/* RGB */
   866    864   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   867    865   		  {
   868    866   		      if (alpha == NULL)
   869    867   			  goto error;
   870    868   		      if (!get_payload_from_rgb_rgba_transparent
   871         -			  (aux->width, aux->height, rgb, alpha,
   872         -			   aux->format_id, aux->quality, &image, &image_size,
   873         -			   aux->opacity, 0))
          869  +			  (aux->width, aux->height, rgb, alpha, aux->format_id,
          870  +			   aux->quality, &image, &image_size, aux->opacity, 0))
   874    871   			  goto error;
   875    872   		  }
   876    873   		else
   877    874   		  {
   878    875   		      if (alpha != NULL)
   879    876   			  free (alpha);
   880    877   		      alpha = NULL;
................................................................................
   954    951   	free (rgb);
   955    952       if (alpha != NULL)
   956    953   	free (alpha);
   957    954       return 0;
   958    955   }
   959    956   
   960    957   static int
   961         -aux_shaded_relief_mask (struct aux_renderer *aux,
   962         -			int by_section, sqlite3_int64 section_id,
   963         -			double relief_factor, unsigned char **shaded_relief)
          958  +aux_shaded_relief_mask (struct aux_renderer *aux, double relief_factor,
          959  +			unsigned char **shaded_relief)
   964    960   {
   965    961   /* attempting to create a Shaded Relief brightness-only mask */
   966    962       rl2GraphicsBitmapPtr base_img = NULL;
   967    963       rl2GraphicsContextPtr ctx = NULL;
   968    964       float *shr_mask;
   969    965       int shr_size;
   970    966       const char *coverage;
................................................................................
   981    977       *shaded_relief = NULL;
   982    978       coverage = rl2_get_coverage_name (aux->coverage);
   983    979       if (coverage == NULL)
   984    980   	return 0;
   985    981       scale_factor = rl2_get_shaded_relief_scale_factor (aux->sqlite, coverage);
   986    982   
   987    983       if (rl2_build_shaded_relief_mask
   988         -	(aux->sqlite, aux->max_threads, aux->coverage, by_section, section_id,
   989         -	 relief_factor, scale_factor, aux->base_width, aux->base_height,
   990         -	 aux->minx, aux->miny, aux->maxx, aux->maxy, aux->xx_res, aux->yy_res,
   991         -	 &shr_mask, &shr_size) != RL2_OK)
          984  +	(aux->sqlite, aux->max_threads, aux->coverage, relief_factor,
          985  +	 scale_factor, aux->base_width, aux->base_height, aux->minx, aux->miny,
          986  +	 aux->maxx, aux->maxy, aux->xx_res, aux->yy_res, &shr_mask,
          987  +	 &shr_size) != RL2_OK)
   992    988   	return 0;
   993    989   
   994    990   /* allocating the RGBA buffer */
   995    991       rgba = malloc (aux->base_width * aux->base_height * 4);
   996    992       if (rgba == NULL)
   997    993   	return 0;
   998    994   
................................................................................
  1329   1325   	  aux.out_pixel = out_pixel;
  1330   1326   	  if (is_shaded_relief)
  1331   1327   	    {
  1332   1328   		/* requesting a shaded relief mask */
  1333   1329   		if (shaded_relief_mask != NULL)
  1334   1330   		    free (shaded_relief_mask);
  1335   1331   		if (!aux_shaded_relief_mask
  1336         -		    (&aux, 0, 0, symbolizer->reliefFactor, &shaded_relief_mask))
         1332  +		    (&aux, symbolizer->reliefFactor, &shaded_relief_mask))
  1337   1333   		    goto error;
  1338   1334   	    }
  1339   1335   	  else
  1340   1336   	    {
  1341   1337   		/* rendering an image */
  1342   1338   		if (!aux_render_composed_image (&aux, rgba))
  1343   1339   		    goto error;
................................................................................
  1538   1534   RL2_DECLARE int
  1539   1535   rl2_get_raw_raster_data_mixed_resolutions (sqlite3 * handle, int max_threads,
  1540   1536   					   rl2CoveragePtr cvg,
  1541   1537   					   unsigned int width,
  1542   1538   					   unsigned int height, double minx,
  1543   1539   					   double miny, double maxx,
  1544   1540   					   double maxy, double x_res,
  1545         -					   double y_res,
  1546         -					   unsigned char **buffer,
         1541  +					   double y_res, unsigned char **buffer,
  1547   1542   					   int *buf_size,
  1548   1543   					   rl2PalettePtr * palette,
  1549   1544   					   unsigned char *out_pixel,
  1550   1545   					   unsigned char bg_red,
  1551   1546   					   unsigned char bg_green,
  1552   1547   					   unsigned char bg_blue,
  1553   1548   					   rl2RasterSymbolizerPtr style,
................................................................................
  1677   1672   		double xx_res;
  1678   1673   		double yy_res;
  1679   1674   		int level_id;
  1680   1675   		int scale;
  1681   1676   		int xscale;
  1682   1677   		unsigned int w;
  1683   1678   		unsigned int h;
  1684         -		unsigned int w2;
  1685         -		unsigned int h2;
  1686   1679   		int base_x;
  1687   1680   		int base_y;
  1688   1681   		unsigned char *bufpix = NULL;
  1689   1682   		int bufpix_size;
  1690   1683   		double img_res_x = (maxx - minx) / (double) width;
  1691   1684   		double img_res_y = (maxy - miny) / (double) height;
  1692   1685   		double mnx = minx;
  1693   1686   		double mny = miny;
  1694   1687   		double mxx = maxx;
  1695   1688   		double mxy = maxy;
         1689  +		if (section_id > 3)
         1690  +		    continue;
  1696   1691   		/* normalizing the visible portion of the Section */
  1697   1692   		if (mnx < section_minx)
  1698   1693   		    mnx = section_minx;
  1699   1694   		if (mny < section_miny)
  1700   1695   		    mny = section_miny;
  1701   1696   		if (mxx > section_maxx)
  1702   1697   		    mxx = section_maxx;
................................................................................
  1711   1706   		if (((double) w * xx_res) < (mxx - mnx))
  1712   1707   		    w++;
  1713   1708   		h = (unsigned int) ((mxy - mny) / yy_res);
  1714   1709   		if (((double) h * yy_res) < (mxy - mny))
  1715   1710   		    h++;
  1716   1711   		base_x = (int) ((mnx - minx) / img_res_x);
  1717   1712   		base_y = (int) ((maxy - mxy) / img_res_y);
  1718         -
  1719   1713   		if (rl2_get_raw_raster_data_common
  1720   1714   		    (handle, max_threads, cvg, 1, section_id, w, h, mnx, mny,
  1721   1715   		     mxx, mxy, xx_res, yy_res, &bufpix, &bufpix_size, palette,
  1722   1716   		     *out_pixel, no_data, xstyle, stats) != RL2_OK)
  1723   1717   		    goto error;
  1724         -
  1725         -		w2 = (unsigned int) ((mxx - mnx) / img_res_x);
  1726         -		if (((double) w2 * img_res_x) < (mxx - mnx))
  1727         -		    w2++;
  1728         -		h2 = (unsigned int) ((mxy - mny) / img_res_y);
  1729         -		if (((double) h2 * img_res_y) < (mxy - mny))
  1730         -		    h2++;
  1731         -		if (w == w2 && h == h2)
  1732         -		  {
  1733         -		      /* already rescaled */
  1734         -		  }
  1735         -		else
  1736         -		  {
  1737         -		      /* rescaling the pixbuf */
  1738         -		      unsigned char *rescaled = NULL;
  1739         -		      int pix_sz = 1;
  1740         -		      if (*out_pixel == RL2_PIXEL_RGB)
  1741         -			  pix_sz = 3;
  1742         -		      rescaled = malloc (pix_sz * w2 * h2);
  1743         -		      if (rescaled == NULL)
  1744         -			{
  1745         -			    fprintf (stderr,
  1746         -				     "rl2_get_raw_raster_data_mixed_resolutions: Insufficient Memory !!!\n");
  1747         -			    goto error;
  1748         -			}
  1749         -		      if (!rl2_rescale_pixbuf
  1750         -			  (bufpix, w, h, *out_pixel, rescaled, w2, h2))
  1751         -			  goto error;
  1752         -		      free (bufpix);
  1753         -		      bufpix = rescaled;
  1754         -		  }
  1755         -
  1756   1718   		if (*out_pixel == RL2_PIXEL_RGB)
  1757         -		    do_copy_rgb (outbuf, bufpix, width, height, w2, h2, base_x,
         1719  +		    do_copy_rgb (outbuf, bufpix, width, height, w, h, base_x,
  1758   1720   				 base_y, bg_red, bg_green, bg_blue);
  1759   1721   		else
  1760         -		    do_copy_gray (outbuf, bufpix, width, height, w2, h2, base_x,
         1722  +		    do_copy_gray (outbuf, bufpix, width, height, w, h, base_x,
  1761   1723   				  base_y, bg_red);
  1762   1724   		free (bufpix);
  1763   1725   	    }
  1764   1726   	  else
  1765   1727   	    {
  1766   1728   		fprintf (stderr, "SQL error: %s\n%s\n", sql,
  1767   1729   			 sqlite3_errmsg (handle));
................................................................................
  1783   1745       if (no_data != NULL)
  1784   1746   	rl2_destroy_pixel (no_data);
  1785   1747       if (outbuf != NULL)
  1786   1748   	free (outbuf);
  1787   1749       return RL2_ERROR;
  1788   1750   }
  1789   1751   
  1790         -static int
  1791         -point_bbox_matches (rl2PointPtr point, double minx, double miny, double maxx,
  1792         -		    double maxy)
         1752  +static rl2GraphicsPatternPtr
         1753  +load_external_graphic_from_dbms (sqlite3 * handle, rl2PrivGraphicPtr graphic)
         1754  +{
         1755  +/* attempting to load an External Graphic from the DBMS */
         1756  +    int ret;
         1757  +    sqlite3_stmt *stmt = NULL;
         1758  +    const char *sql;
         1759  +    const char *xlink_href = NULL;
         1760  +    rl2GraphicsPatternPtr pattern = NULL;
         1761  +    rl2PrivGraphicItemPtr item;
         1762  +
         1763  +    if (graphic == NULL)
         1764  +	return NULL;
         1765  +    /* searching for an xlink_href pseudo-URL */
         1766  +    item = graphic->first;
         1767  +    while (item != NULL)
         1768  +      {
         1769  +	  if (item->type == RL2_EXTERNAL_GRAPHIC && item->item != NULL)
         1770  +	    {
         1771  +		rl2PrivExternalGraphicPtr ext =
         1772  +		    (rl2PrivExternalGraphicPtr) (item->item);
         1773  +		if (ext->xlink_href != NULL)
         1774  +		  {
         1775  +		      xlink_href = ext->xlink_href;
         1776  +		      break;
         1777  +		  }
         1778  +	    }
         1779  +	  item = item->next;
         1780  +      }
         1781  +    if (xlink_href == NULL)
         1782  +	return NULL;
         1783  +
         1784  +    sql = "SELECT resource, GetMimeType(resource) FROM SE_external_graphics "
         1785  +	"WHERE xlink_href = ?";
         1786  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         1787  +    if (ret != SQLITE_OK)
         1788  +	return NULL;
         1789  +
         1790  +    sqlite3_reset (stmt);
         1791  +    sqlite3_clear_bindings (stmt);
         1792  +    sqlite3_bind_text (stmt, 1, xlink_href, strlen (xlink_href), SQLITE_STATIC);
         1793  +    while (1)
         1794  +      {
         1795  +	  /* scrolling the result set rows */
         1796  +	  ret = sqlite3_step (stmt);
         1797  +	  if (ret == SQLITE_DONE)
         1798  +	      break;		/* end of result set */
         1799  +	  if (ret == SQLITE_ROW)
         1800  +	    {
         1801  +		rl2RasterPtr raster = NULL;
         1802  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB
         1803  +		    && sqlite3_column_type (stmt, 1) == SQLITE_TEXT)
         1804  +		  {
         1805  +		      const unsigned char *blob = sqlite3_column_blob (stmt, 0);
         1806  +		      int blob_sz = sqlite3_column_bytes (stmt, 0);
         1807  +		      const char *mime_type =
         1808  +			  (const char *) sqlite3_column_text (stmt, 1);
         1809  +		      if (strcmp (mime_type, "image/gif") == 0)
         1810  +			  raster = rl2_raster_from_gif (blob, blob_sz);
         1811  +		      if (strcmp (mime_type, "image/png") == 0)
         1812  +			  raster = rl2_raster_from_png (blob, blob_sz, 1);
         1813  +		      if (strcmp (mime_type, "image/jpeg") == 0)
         1814  +			  raster = rl2_raster_from_jpeg (blob, blob_sz);
         1815  +		      if (strcmp (mime_type, "image/tiff") == 0)
         1816  +			  raster = rl2_raster_from_tiff (blob, blob_sz);
         1817  +		  }
         1818  +		if (raster != NULL)
         1819  +		  {
         1820  +		      unsigned char *rgba;
         1821  +		      int rgba_sz;
         1822  +		      unsigned int width;
         1823  +		      unsigned int height;
         1824  +		      if (rl2_get_raster_size (raster, &width, &height) !=
         1825  +			  RL2_OK)
         1826  +			{
         1827  +			    rl2_destroy_raster (raster);
         1828  +			    goto error;
         1829  +			}
         1830  +		      if (rl2_raster_data_to_RGBA (raster, &rgba, &rgba_sz) !=
         1831  +			  RL2_OK)
         1832  +			{
         1833  +			    rl2_destroy_raster (raster);
         1834  +			    goto error;
         1835  +			}
         1836  +		      pattern =
         1837  +			  rl2_graph_create_pattern (rgba, width, height, 0);
         1838  +		      rl2_destroy_raster (raster);
         1839  +		  }
         1840  +	    }
         1841  +	  else
         1842  +	    {
         1843  +		fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1844  +			 sqlite3_errmsg (handle));
         1845  +		goto error;
         1846  +	    }
         1847  +      }
         1848  +    return pattern;
         1849  +
         1850  +  error:
         1851  +    if (stmt != NULL)
         1852  +	sqlite3_finalize (stmt);
         1853  +    return NULL;
         1854  +}
         1855  +
         1856  +static rl2GraphicsBitmapPtr
         1857  +load_external_bitmap_from_dbms (sqlite3 * handle, const char *xlink_href)
  1793   1858   {
  1794         -/* checks if the Point is visible */
  1795         -    if (minx > point->x)
  1796         -	return 0;
  1797         -    if (maxx < point->x)
  1798         -	return 0;
  1799         -    if (miny > point->y)
  1800         -	return 0;
  1801         -    if (maxy < point->y)
  1802         -	return 0;
  1803         -    return 1;
         1859  +/* attempting to load an External Graphic from the DBMS */
         1860  +    int ret;
         1861  +    sqlite3_stmt *stmt = NULL;
         1862  +    const char *sql;
         1863  +    rl2GraphicsBitmapPtr bitmap = NULL;
         1864  +
         1865  +    if (xlink_href == NULL)
         1866  +	return NULL;
         1867  +
         1868  +    sql = "SELECT resource, GetMimeType(resource) FROM SE_external_graphics "
         1869  +	"WHERE xlink_href = ?";
         1870  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         1871  +    if (ret != SQLITE_OK)
         1872  +	return NULL;
         1873  +
         1874  +    sqlite3_reset (stmt);
         1875  +    sqlite3_clear_bindings (stmt);
         1876  +    sqlite3_bind_text (stmt, 1, xlink_href, strlen (xlink_href), SQLITE_STATIC);
         1877  +    while (1)
         1878  +      {
         1879  +	  /* scrolling the result set rows */
         1880  +	  ret = sqlite3_step (stmt);
         1881  +	  if (ret == SQLITE_DONE)
         1882  +	      break;		/* end of result set */
         1883  +	  if (ret == SQLITE_ROW)
         1884  +	    {
         1885  +		rl2RasterPtr raster = NULL;
         1886  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB
         1887  +		    && sqlite3_column_type (stmt, 1) == SQLITE_TEXT)
         1888  +		  {
         1889  +		      const unsigned char *blob = sqlite3_column_blob (stmt, 0);
         1890  +		      int blob_sz = sqlite3_column_bytes (stmt, 0);
         1891  +		      const char *mime_type =
         1892  +			  (const char *) sqlite3_column_text (stmt, 1);
         1893  +		      if (strcmp (mime_type, "image/gif") == 0)
         1894  +			  raster = rl2_raster_from_gif (blob, blob_sz);
         1895  +		      if (strcmp (mime_type, "image/png") == 0)
         1896  +			  raster = rl2_raster_from_png (blob, blob_sz, 1);
         1897  +		      if (strcmp (mime_type, "image/jpeg") == 0)
         1898  +			  raster = rl2_raster_from_jpeg (blob, blob_sz);
         1899  +		      if (strcmp (mime_type, "image/tiff") == 0)
         1900  +			  raster = rl2_raster_from_tiff (blob, blob_sz);
         1901  +		  }
         1902  +		if (raster != NULL)
         1903  +		  {
         1904  +		      unsigned char *rgba;
         1905  +		      int rgba_sz;
         1906  +		      unsigned int width;
         1907  +		      unsigned int height;
         1908  +		      if (rl2_get_raster_size (raster, &width, &height) !=
         1909  +			  RL2_OK)
         1910  +			{
         1911  +			    rl2_destroy_raster (raster);
         1912  +			    goto error;
         1913  +			}
         1914  +		      if (rl2_raster_data_to_RGBA (raster, &rgba, &rgba_sz) !=
         1915  +			  RL2_OK)
         1916  +			{
         1917  +			    rl2_destroy_raster (raster);
         1918  +			    goto error;
         1919  +			}
         1920  +		      bitmap = rl2_graph_create_bitmap (rgba, width, height);
         1921  +		      rl2_destroy_raster (raster);
         1922  +		  }
         1923  +	    }
         1924  +	  else
         1925  +	    {
         1926  +		fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1927  +			 sqlite3_errmsg (handle));
         1928  +		goto error;
         1929  +	    }
         1930  +      }
         1931  +    return bitmap;
         1932  +
         1933  +  error:
         1934  +    if (stmt != NULL)
         1935  +	sqlite3_finalize (stmt);
         1936  +    return NULL;
  1804   1937   }
  1805   1938   
  1806   1939   static void
  1807   1940   draw_points (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  1808   1941   	     rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  1809         -	     double miny, double maxx, double maxy, double x_res,
  1810         -	     double y_res, rl2GeometryPtr geom)
         1942  +	     double miny, double x_res, double y_res, rl2GeometryPtr geom)
  1811   1943   {
  1812   1944   /* drawing Point-type features */
  1813   1945       rl2PrivVectorSymbolizerItemPtr item;
  1814   1946       rl2PointPtr point;
  1815   1947   
  1816   1948       item = sym->first;
  1817   1949       while (item != NULL)
................................................................................
  1836   1968   		      unsigned char well_known_type;
  1837   1969   		      int fill = 0;
  1838   1970   		      int stroke = 0;
  1839   1971   		      int pen_cap;
  1840   1972   		      int pen_join;
  1841   1973   		      double opacity;
  1842   1974   		      unsigned char norm_opacity;
  1843         -		      rl2GraphicsPatternPtr pattern = NULL;
         1975  +		      rl2GraphicsBitmapPtr pattern = NULL;
  1844   1976   		      rl2GraphicsPatternPtr pattern_fill = NULL;
  1845   1977   		      rl2GraphicsPatternPtr pattern_stroke = NULL;
  1846   1978   
  1847   1979   		      if (graphic->type == RL2_MARK_GRAPHIC)
  1848   1980   			{
  1849   1981   			    rl2PrivMarkPtr mark =
  1850   1982   				(rl2PrivMarkPtr) (graphic->item);
................................................................................
  1853   1985   				  well_known_type = mark->well_known_type;
  1854   1986   				  is_mark = 1;
  1855   1987   				  if (mark->fill != NULL)
  1856   1988   				    {
  1857   1989   					if (mark->fill->graphic != NULL)
  1858   1990   					  {
  1859   1991   					      /* external Graphic fill */
  1860         -					      const char *xlink_href = NULL;
  1861         -					      int recolor = 0;
  1862         -					      unsigned char red;
  1863         -					      unsigned char green;
  1864         -					      unsigned char blue;
  1865         -					      pattern_fill = NULL;
  1866         -					      if (mark->fill->graphic->first !=
  1867         -						  NULL)
  1868         -						{
  1869         -						    if (mark->fill->
  1870         -							graphic->first->type ==
  1871         -							RL2_EXTERNAL_GRAPHIC)
  1872         -						      {
  1873         -							  rl2PrivExternalGraphicPtr
  1874         -							      ext =
  1875         -							      (rl2PrivExternalGraphicPtr)
  1876         -							      (mark->
  1877         -							       fill->graphic->
  1878         -							       first->item);
  1879         -							  xlink_href =
  1880         -							      ext->xlink_href;
  1881         -							  if (ext->first !=
  1882         -							      NULL)
  1883         -							    {
  1884         -								recolor = 1;
  1885         -								red =
  1886         -								    ext->
  1887         -								    first->red;
  1888         -								green =
  1889         -								    ext->
  1890         -								    first->green;
  1891         -								blue =
  1892         -								    ext->
  1893         -								    first->blue;
  1894         -							    }
  1895         -						      }
  1896         -						}
  1897         -					      if (xlink_href != NULL)
  1898         -						  pattern_fill =
  1899         -						      rl2_create_pattern_from_external_graphic
  1900         -						      (handle, xlink_href, 1);
         1992  +					      pattern_fill =
         1993  +						  load_external_graphic_from_dbms
         1994  +						  (handle, mark->fill->graphic);
  1901   1995   					      if (pattern_fill != NULL)
  1902   1996   						{
  1903         -						    if (recolor)
  1904         -						      {
  1905         -							  /* attempting to recolor the External Graphic resource */
  1906         -							  rl2_graph_pattern_recolor
  1907         -							      (pattern_fill,
  1908         -							       red, green,
  1909         -							       blue);
  1910         -						      }
  1911         -						    if (mark->fill->opacity <=
  1912         -							0.0)
  1913         -							norm_opacity = 0;
  1914         -						    else if (mark->
  1915         -							     fill->opacity >=
  1916         -							     1.0)
  1917         -							norm_opacity = 255;
  1918         -						    else
  1919         -						      {
  1920         -							  opacity =
  1921         -							      255.0 *
  1922         -							      mark->
  1923         -							      fill->opacity;
  1924         -							  if (opacity <= 0.0)
  1925         -							      norm_opacity = 0;
  1926         -							  else if (opacity >=
  1927         -								   255.0)
  1928         -							      norm_opacity =
  1929         -								  255;
  1930         -							  else
  1931         -							      norm_opacity =
  1932         -								  opacity;
  1933         -						      }
  1934         -						    if (norm_opacity < 1.0)
  1935         -							rl2_graph_pattern_transparency
  1936         -							    (pattern_fill,
  1937         -							     norm_opacity);
  1938   1997   						    rl2_graph_set_pattern_brush
  1939   1998   							(ctx, pattern_fill);
         1999  +						    fill = 1;
  1940   2000   						}
  1941         -					      else
  1942         -						{
  1943         -						    /* invalid Pattern: defaulting to a Gray brush */
  1944         -						    rl2_graph_set_brush (ctx,
  1945         -									 128,
  1946         -									 128,
  1947         -									 128,
  1948         -									 255);
  1949         -						}
  1950         -					      fill = 1;
  1951   2001   					  }
  1952   2002   					else
  1953   2003   					  {
  1954   2004   					      /* solid RGB fill */
  1955   2005   					      if (gr->opacity <= 0.0)
  1956   2006   						  norm_opacity = 0;
  1957   2007   					      else if (gr->opacity >= 1.0)
................................................................................
  1978   2028   					      fill = 1;
  1979   2029   					  }
  1980   2030   				    }
  1981   2031   				  if (mark->stroke != NULL)
  1982   2032   				    {
  1983   2033   					if (mark->stroke->graphic != NULL)
  1984   2034   					  {
  1985         -					      const char *xlink_href = NULL;
  1986         -					      int recolor = 0;
  1987         -					      unsigned char red;
  1988         -					      unsigned char green;
  1989         -					      unsigned char blue;
  1990         -					      pattern_stroke = NULL;
  1991         -					      if (mark->stroke->
  1992         -						  graphic->first != NULL)
         2035  +					      /* external Graphic stroke */
         2036  +					      pattern_stroke =
         2037  +						  load_external_graphic_from_dbms
         2038  +						  (handle,
         2039  +						   mark->stroke->graphic);
         2040  +					      if (pattern_stroke != NULL)
  1993   2041   						{
  1994         -						    if (mark->stroke->
  1995         -							graphic->first->type ==
  1996         -							RL2_EXTERNAL_GRAPHIC)
         2042  +						    switch (mark->
         2043  +							    stroke->linecap)
  1997   2044   						      {
  1998         -							  rl2PrivExternalGraphicPtr
  1999         -							      ext =
  2000         -							      (rl2PrivExternalGraphicPtr)
  2001         -							      (mark->
  2002         -							       stroke->graphic->
  2003         -							       first->item);
  2004         -							  xlink_href =
  2005         -							      ext->xlink_href;
  2006         -							  if (ext->first !=
  2007         -							      NULL)
  2008         -							    {
  2009         -								recolor = 1;
  2010         -								red =
  2011         -								    ext->
  2012         -								    first->red;
  2013         -								green =
  2014         -								    ext->
  2015         -								    first->green;
  2016         -								blue =
  2017         -								    ext->
  2018         -								    first->blue;
  2019         -							    }
  2020         -						      }
  2021         -						}
  2022         -					      if (xlink_href != NULL)
  2023         -						  pattern_stroke =
  2024         -						      rl2_create_pattern_from_external_graphic
  2025         -						      (handle, xlink_href, 1);
  2026         -					      if (pattern != NULL)
  2027         -						{
  2028         -						    if (recolor)
         2045  +						      case RL2_STROKE_LINECAP_ROUND:
         2046  +							  pen_cap =
         2047  +							      RL2_PEN_CAP_ROUND;
         2048  +							  break;
         2049  +						      case RL2_STROKE_LINECAP_SQUARE:
         2050  +							  pen_cap =
         2051  +							      RL2_PEN_CAP_SQUARE;
         2052  +							  break;
         2053  +						      default:
         2054  +							  pen_cap =
         2055  +							      RL2_PEN_CAP_BUTT;
         2056  +							  break;
         2057  +						      };
         2058  +						    switch (mark->
         2059  +							    stroke->linejoin)
  2029   2060   						      {
  2030         -							  /* attempting to recolor the External Graphic resource */
  2031         -							  rl2_graph_pattern_recolor
  2032         -							      (pattern_stroke,
  2033         -							       red, green,
  2034         -							       blue);
  2035         -						      }
  2036         -						    if (mark->stroke->opacity <=
  2037         -							0.0)
  2038         -							norm_opacity = 0;
  2039         -						    else if (mark->
  2040         -							     stroke->opacity >=
  2041         -							     1.0)
  2042         -							norm_opacity = 255;
         2061  +						      case RL2_STROKE_LINEJOIN_BEVEL:
         2062  +							  pen_join =
         2063  +							      RL2_PEN_JOIN_BEVEL;
         2064  +							  break;
         2065  +						      case RL2_STROKE_LINEJOIN_ROUND:
         2066  +							  pen_join =
         2067  +							      RL2_PEN_JOIN_ROUND;
         2068  +							  break;
         2069  +						      default:
         2070  +							  pen_join =
         2071  +							      RL2_PEN_JOIN_MITER;
         2072  +							  break;
         2073  +						      };
         2074  +						    if (mark->
         2075  +							stroke->dash_count > 0
         2076  +							&& mark->
         2077  +							stroke->dash_list !=
         2078  +							NULL)
         2079  +							rl2_graph_set_pattern_dashed_pen
         2080  +							    (ctx,
         2081  +							     pattern_stroke,
         2082  +							     mark->
         2083  +							     stroke->width,
         2084  +							     pen_cap, pen_join,
         2085  +							     mark->
         2086  +							     stroke->dash_count,
         2087  +							     mark->
         2088  +							     stroke->dash_list,
         2089  +							     mark->
         2090  +							     stroke->dash_offset);
  2043   2091   						    else
  2044         -						      {
  2045         -							  opacity =
  2046         -							      255.0 *
  2047         -							      mark->
  2048         -							      stroke->opacity;
  2049         -							  if (opacity <= 0.0)
  2050         -							      norm_opacity = 0;
  2051         -							  else if (opacity >=
  2052         -								   255.0)
  2053         -							      norm_opacity =
  2054         -								  255;
  2055         -							  else
  2056         -							      norm_opacity =
  2057         -								  opacity;
  2058         -						      }
  2059         -						    if (norm_opacity < 1.0)
  2060         -							rl2_graph_pattern_transparency
  2061         -							    (pattern_stroke,
  2062         -							     norm_opacity);
  2063         -						    if (pattern_stroke != NULL)
  2064         -						      {
  2065         -							  switch
  2066         -							      (mark->
  2067         -							       stroke->linecap)
  2068         -							    {
  2069         -							    case RL2_STROKE_LINECAP_ROUND:
  2070         -								pen_cap =
  2071         -								    RL2_PEN_CAP_ROUND;
  2072         -								break;
  2073         -							    case RL2_STROKE_LINECAP_SQUARE:
  2074         -								pen_cap =
  2075         -								    RL2_PEN_CAP_SQUARE;
  2076         -								break;
  2077         -							    default:
  2078         -								pen_cap =
  2079         -								    RL2_PEN_CAP_BUTT;
  2080         -								break;
  2081         -							    };
  2082         -							  switch
  2083         -							      (mark->
  2084         -							       stroke->linejoin)
  2085         -							    {
  2086         -							    case RL2_STROKE_LINEJOIN_BEVEL:
  2087         -								pen_join =
  2088         -								    RL2_PEN_JOIN_BEVEL;
  2089         -								break;
  2090         -							    case RL2_STROKE_LINEJOIN_ROUND:
  2091         -								pen_join =
  2092         -								    RL2_PEN_JOIN_ROUND;
  2093         -								break;
  2094         -							    default:
  2095         -								pen_join =
  2096         -								    RL2_PEN_JOIN_MITER;
  2097         -								break;
  2098         -							    };
  2099         -							  if (mark->
  2100         -							      stroke->dash_count
  2101         -							      > 0
  2102         -							      && mark->
  2103         -							      stroke->dash_list
  2104         -							      != NULL)
  2105         -							      rl2_graph_set_pattern_dashed_pen
  2106         -								  (ctx,
  2107         -								   pattern_stroke,
  2108         -								   mark->
  2109         -								   stroke->width,
  2110         -								   pen_cap,
  2111         -								   pen_join,
  2112         -								   mark->
  2113         -								   stroke->dash_count,
  2114         -								   mark->
  2115         -								   stroke->dash_list,
  2116         -								   mark->
  2117         -								   stroke->dash_offset);
  2118         -							  else
  2119         -							      rl2_graph_set_pattern_solid_pen
  2120         -								  (ctx,
  2121         -								   pattern_stroke,
  2122         -								   mark->
  2123         -								   stroke->width,
  2124         -								   pen_cap,
  2125         -								   pen_join);
  2126         -							  stroke = 1;
  2127         -						      }
         2092  +							rl2_graph_set_pattern_solid_pen
         2093  +							    (ctx,
         2094  +							     pattern_stroke,
         2095  +							     mark->
         2096  +							     stroke->width,
         2097  +							     pen_cap, pen_join);
         2098  +						    stroke = 1;
  2128   2099   						}
  2129   2100   					  }
  2130   2101   					else
  2131   2102   					  {
  2132   2103   					      /* solid RGB stroke */
  2133   2104   					      if (gr->opacity <= 0.0)
  2134   2105   						  norm_opacity = 0;
................................................................................
  2180   2151   									    mark->stroke->red,
  2181   2152   									    mark->stroke->green,
  2182   2153   									    mark->stroke->blue,
  2183   2154   									    norm_opacity,
  2184   2155   									    mark->stroke->width,
  2185   2156   									    pen_cap,
  2186   2157   									    pen_join,
  2187         -									    mark->
  2188         -									    stroke->dash_count,
  2189         -									    mark->
  2190         -									    stroke->dash_list,
  2191         -									    mark->
  2192         -									    stroke->dash_offset);
         2158  +									    mark->stroke->dash_count,
         2159  +									    mark->stroke->dash_list,
         2160  +									    mark->stroke->dash_offset);
  2193   2161   					      else
  2194         -						  rl2_graph_set_solid_pen
  2195         -						      (ctx, mark->stroke->red,
  2196         -						       mark->stroke->green,
  2197         -						       mark->stroke->blue,
  2198         -						       norm_opacity,
  2199         -						       mark->stroke->width,
  2200         -						       pen_cap, pen_join);
         2162  +						  rl2_graph_set_solid_pen (ctx,
         2163  +									   mark->stroke->red,
         2164  +									   mark->stroke->green,
         2165  +									   mark->stroke->blue,
         2166  +									   norm_opacity,
         2167  +									   mark->stroke->width,
         2168  +									   pen_cap,
         2169  +									   pen_join);
  2201   2170   					      stroke = 1;
  2202   2171   					  }
  2203   2172   				    }
  2204   2173   			      }
  2205   2174   			}
  2206   2175   		      if (graphic->type == RL2_EXTERNAL_GRAPHIC)
  2207   2176   			{
  2208   2177   			    rl2PrivExternalGraphicPtr ext =
  2209   2178   				(rl2PrivExternalGraphicPtr) (graphic->item);
  2210         -			    const char *xlink_href = NULL;
  2211         -			    int recolor = 0;
  2212         -			    unsigned char red;
  2213         -			    unsigned char green;
  2214         -			    unsigned char blue;
  2215         -			    pattern = NULL;
  2216   2179   			    if (ext != NULL)
  2217   2180   			      {
  2218   2181   				  is_external = 1;
  2219         -				  if (ext->xlink_href != NULL)
  2220         -				      xlink_href = ext->xlink_href;
  2221         -				  if (ext->first != NULL)
  2222         -				    {
  2223         -					recolor = 1;
  2224         -					red = ext->first->red;
  2225         -					green = ext->first->green;
  2226         -					blue = ext->first->blue;
  2227         -				    }
  2228         -				  if (xlink_href != NULL)
  2229         -				    {
  2230         -					/* first attempt: Bitmap */
  2231         -					pattern =
  2232         -					    rl2_create_pattern_from_external_graphic
  2233         -					    (handle, xlink_href, 1);
  2234         -					if (pattern == NULL)
  2235         -					  {
  2236         -					      /* second attempt: SVG */
  2237         -					      pattern =
  2238         -						  rl2_create_pattern_from_external_svg
  2239         -						  (handle, xlink_href,
  2240         -						   point_sym->graphic->size);
  2241         -					  }
  2242         -				    }
  2243         -			      }
  2244         -			    if (pattern != NULL)
  2245         -			      {
  2246         -				  if (recolor)
  2247         -				    {
  2248         -					/* attempting to recolor the External Graphic resource */
  2249         -					rl2_graph_pattern_recolor (pattern,
  2250         -								   red, green,
  2251         -								   blue);
  2252         -				    }
  2253         -				  if (point_sym->graphic->opacity <= 0.0)
  2254         -				      norm_opacity = 0;
  2255         -				  else if (point_sym->graphic->opacity >= 1.0)
  2256         -				      norm_opacity = 255;
  2257         -				  else
  2258         -				    {
  2259         -					opacity =
  2260         -					    255.0 * point_sym->graphic->opacity;
  2261         -					if (opacity <= 0.0)
  2262         -					    norm_opacity = 0;
  2263         -					else if (opacity >= 255.0)
  2264         -					    norm_opacity = 255;
  2265         -					else
  2266         -					    norm_opacity = opacity;
  2267         -				    }
  2268         -				  if (norm_opacity < 1.0)
  2269         -				      rl2_graph_pattern_transparency
  2270         -					  (pattern, norm_opacity);
  2271         -				  rl2_graph_set_pattern_brush (ctx, pattern);
  2272         -			      }
  2273         -			    else
  2274         -			      {
  2275         -				  /* invalid Pattern: defaulting to a Gray brush */
  2276         -				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
         2182  +				  pattern =
         2183  +				      load_external_bitmap_from_dbms (handle,
         2184  +								      ext->xlink_href);
  2277   2185   			      }
  2278   2186   			}
  2279   2187   
  2280   2188   		      /* actual Point rendering */
  2281   2189   		      point = geom->first_point;
  2282   2190   		      while (point)
  2283   2191   			{
  2284   2192   			    /* drawing a POINT */
  2285         -			    if (point_bbox_matches
  2286         -				(point, minx, miny, maxx, maxy))
  2287         -			      {
  2288         -				  double x = (point->x - minx) / x_res;
  2289         -				  double y =
  2290         -				      (double) height -
  2291         -				      ((point->y - miny) / y_res);
  2292         -				  double size2 = gr->size / 2.0;
  2293         -				  double size4 = gr->size / 4.0;
  2294         -				  double size6 = gr->size / 6.0;
  2295         -				  double size13 = gr->size / 3.0;
  2296         -				  double size23 = (gr->size / 3.0) * 2.0;
  2297         -				  int i;
  2298         -				  double rads;
  2299         -				  if (size2 <= 0.0)
  2300         -				      size2 = 1.0;
  2301         -				  if (size4 <= 0.0)
  2302         -				      size4 = 1.0;
  2303         -				  if (size6 <= 0.0)
  2304         -				      size6 = 1.0;
  2305         -				  if (size13 <= 0.0)
  2306         -				      size13 = 1.0;
  2307         -				  if (size23 <= 0.0)
  2308         -				      size23 = 1.0;
  2309         -				  if (is_mark)
         2193  +			    double x = (point->x - minx) / x_res;
         2194  +			    double y =
         2195  +				(double) height - ((point->y - miny) / y_res);
         2196  +			    double size2 = gr->size / 2.0;
         2197  +			    double size4 = gr->size / 4.0;
         2198  +			    double size6 = gr->size / 6.0;
         2199  +			    double size13 = gr->size / 3.0;
         2200  +			    double size23 = (gr->size / 3.0) * 2.0;
         2201  +			    int i;
         2202  +			    double rads;
         2203  +			    if (size2 <= 0.0)
         2204  +				size2 = 1.0;
         2205  +			    if (size4 <= 0.0)
         2206  +				size4 = 1.0;
         2207  +			    if (size6 <= 0.0)
         2208  +				size6 = 1.0;
         2209  +			    if (size13 <= 0.0)
         2210  +				size13 = 1.0;
         2211  +			    if (size23 <= 0.0)
         2212  +				size23 = 1.0;
         2213  +			    if (is_mark)
         2214  +			      {
         2215  +				  /* drawing a well-known Mark */
         2216  +				  switch (well_known_type)
  2310   2217   				    {
  2311         -					/* drawing a well-known Mark */
  2312         -					switch (well_known_type)
         2218  +				    case RL2_GRAPHIC_MARK_CIRCLE:
         2219  +					rads = 0.0;
         2220  +					for (i = 0; i < 32; i++)
         2221  +					  {
         2222  +					      double tic = 6.28318530718 / 32.0;
         2223  +					      double cx =
         2224  +						  x + (size2 * sin (rads));
         2225  +					      double cy =
         2226  +						  y + (size2 * cos (rads));
         2227  +					      if (i == 0)
         2228  +						  rl2_graph_move_to_point (ctx,
         2229  +									   cx,
         2230  +									   cy);
         2231  +					      else
         2232  +						  rl2_graph_add_line_to_path
         2233  +						      (ctx, cx, cy);
         2234  +					      rads += tic;
         2235  +					  }
         2236  +					rl2_graph_close_subpath (ctx);
         2237  +					break;
         2238  +				    case RL2_GRAPHIC_MARK_TRIANGLE:
         2239  +					rl2_graph_move_to_point (ctx, x,
         2240  +								 y - size23);
         2241  +					rl2_graph_add_line_to_path (ctx,
         2242  +								    x - size2,
         2243  +								    y + size13);
         2244  +					rl2_graph_add_line_to_path (ctx,
         2245  +								    x + size2,
         2246  +								    y + size13);
         2247  +					rl2_graph_close_subpath (ctx);
         2248  +					break;
         2249  +				    case RL2_GRAPHIC_MARK_STAR:
         2250  +					rads = 3.14159265359;
         2251  +					for (i = 0; i < 10; i++)
  2313   2252   					  {
  2314         -					  case RL2_GRAPHIC_MARK_CIRCLE:
  2315         -					      rads = 0.0;
  2316         -					      for (i = 0; i < 32; i++)
  2317         -						{
  2318         -						    double tic =
  2319         -							6.28318530718 / 32.0;
  2320         -						    double cx =
  2321         -							x +
  2322         -							(size2 * sin (rads));
  2323         -						    double cy =
  2324         -							y +
  2325         -							(size2 * cos (rads));
  2326         -						    if (i == 0)
  2327         -							rl2_graph_move_to_point
  2328         -							    (ctx, cx, cy);
  2329         -						    else
  2330         -							rl2_graph_add_line_to_path
  2331         -							    (ctx, cx, cy);
  2332         -						    rads += tic;
  2333         -						}
  2334         -					      rl2_graph_close_subpath (ctx);
  2335         -					      break;
  2336         -					  case RL2_GRAPHIC_MARK_TRIANGLE:
  2337         -					      rl2_graph_move_to_point (ctx, x,
  2338         -								       y -
  2339         -								       size23);
  2340         -					      rl2_graph_add_line_to_path (ctx,
  2341         -									  x -
  2342         -									  size2,
  2343         -									  y +
  2344         -									  size13);
  2345         -					      rl2_graph_add_line_to_path (ctx,
  2346         -									  x +
  2347         -									  size2,
  2348         -									  y +
  2349         -									  size13);
  2350         -					      rl2_graph_close_subpath (ctx);
  2351         -					      break;
  2352         -					  case RL2_GRAPHIC_MARK_STAR:
  2353         -					      rads = 3.14159265359;
  2354         -					      for (i = 0; i < 10; i++)
  2355         -						{
  2356         -						    double tic =
  2357         -							(i % 2) ? size6 : size2;
  2358         -						    double cx =
  2359         -							x + (tic * sin (rads));
  2360         -						    double cy =
  2361         -							y + (tic * cos (rads));
  2362         -						    if (i == 0)
  2363         -							rl2_graph_move_to_point
  2364         -							    (ctx, cx, cy);
  2365         -						    else
  2366         -							rl2_graph_add_line_to_path
  2367         -							    (ctx, cx, cy);
  2368         -						    rads += 0.628318530718;
  2369         -						}
  2370         -					      rl2_graph_close_subpath (ctx);
  2371         -					      break;
  2372         -					  case RL2_GRAPHIC_MARK_CROSS:
  2373         -					      rl2_graph_move_to_point (ctx,
  2374         -								       x -
  2375         -								       size6,
  2376         -								       y -
  2377         -								       size2);
  2378         -					      rl2_graph_add_line_to_path (ctx,
  2379         -									  x +
  2380         -									  size6,
  2381         -									  y -
  2382         -									  size2);
  2383         -					      rl2_graph_add_line_to_path (ctx,
  2384         -									  x +
  2385         -									  size6,
  2386         -									  y -
  2387         -									  size6);
  2388         -					      rl2_graph_add_line_to_path (ctx,
  2389         -									  x +
  2390         -									  size2,
  2391         -									  y -
  2392         -									  size6);
  2393         -					      rl2_graph_add_line_to_path (ctx,
  2394         -									  x +
  2395         -									  size2,
  2396         -									  y +
  2397         -									  size6);
  2398         -					      rl2_graph_add_line_to_path (ctx,
  2399         -									  x +
  2400         -									  size6,
  2401         -									  y +
  2402         -									  size6);
  2403         -					      rl2_graph_add_line_to_path (ctx,
  2404         -									  x +
  2405         -									  size6,
  2406         -									  y +
  2407         -									  size2);
  2408         -					      rl2_graph_add_line_to_path (ctx,
  2409         -									  x -
  2410         -									  size6,
  2411         -									  y +
  2412         -									  size2);
  2413         -					      rl2_graph_add_line_to_path (ctx,
  2414         -									  x -
  2415         -									  size6,
  2416         -									  y +
  2417         -									  size6);
  2418         -					      rl2_graph_add_line_to_path (ctx,
  2419         -									  x -
  2420         -									  size2,
  2421         -									  y +
  2422         -									  size6);
  2423         -					      rl2_graph_add_line_to_path (ctx,
  2424         -									  x -
  2425         -									  size2,
  2426         -									  y -
  2427         -									  size6);
  2428         -					      rl2_graph_add_line_to_path (ctx,
  2429         -									  x -
  2430         -									  size6,
  2431         -									  y -
  2432         -									  size6);
  2433         -					      rl2_graph_close_subpath (ctx);
  2434         -					      break;
  2435         -					  case RL2_GRAPHIC_MARK_X:
  2436         -					      rl2_graph_move_to_point (ctx,
  2437         -								       x -
  2438         -								       size2,
  2439         -								       y -
  2440         -								       size2);
  2441         -					      rl2_graph_add_line_to_path (ctx,
  2442         -									  x -
  2443         -									  size4,
  2444         -									  y -
  2445         -									  size2);
  2446         -					      rl2_graph_add_line_to_path (ctx,
  2447         -									  x,
  2448         -									  y -
  2449         -									  size6);
  2450         -					      rl2_graph_add_line_to_path (ctx,
  2451         -									  x +
  2452         -									  size6,
  2453         -									  y -
  2454         -									  size2);
  2455         -					      rl2_graph_add_line_to_path (ctx,
  2456         -									  x +
  2457         -									  size2,
  2458         -									  y -
  2459         -									  size2);
  2460         -					      rl2_graph_add_line_to_path (ctx,
  2461         -									  x +
  2462         -									  size4,
  2463         -									  y);
  2464         -					      rl2_graph_add_line_to_path (ctx,
  2465         -									  x +
  2466         -									  size2,
  2467         -									  y +
  2468         -									  size2);
  2469         -					      rl2_graph_add_line_to_path (ctx,
  2470         -									  x +
  2471         -									  size4,
  2472         -									  y +
  2473         -									  size2);
  2474         -					      rl2_graph_add_line_to_path (ctx,
  2475         -									  x,
  2476         -									  y +
  2477         -									  size6);
  2478         -					      rl2_graph_add_line_to_path (ctx,
  2479         -									  x -
  2480         -									  size6,
  2481         -									  y +
  2482         -									  size2);
  2483         -					      rl2_graph_add_line_to_path (ctx,
  2484         -									  x -
  2485         -									  size2,
  2486         -									  y +
  2487         -									  size2);
  2488         -					      rl2_graph_add_line_to_path (ctx,
  2489         -									  x -
  2490         -									  size4,
  2491         -									  y);
  2492         -					      rl2_graph_close_subpath (ctx);
  2493         -					      break;
  2494         -					  case RL2_GRAPHIC_MARK_SQUARE:
  2495         -					  default:
  2496         -					      rl2_graph_move_to_point (ctx,
  2497         -								       x -
  2498         -								       size2,
  2499         -								       y -
  2500         -								       size2);
  2501         -					      rl2_graph_add_line_to_path (ctx,
  2502         -									  x -
  2503         -									  size2,
  2504         -									  y +
  2505         -									  size2);
  2506         -					      rl2_graph_add_line_to_path (ctx,
  2507         -									  x +
  2508         -									  size2,
  2509         -									  y +
  2510         -									  size2);
  2511         -					      rl2_graph_add_line_to_path (ctx,
  2512         -									  x +
  2513         -									  size2,
  2514         -									  y -
  2515         -									  size2);
  2516         -					      rl2_graph_close_subpath (ctx);
  2517         -					      break;
  2518         -					  };
  2519         -					if (fill)
  2520         -					  {
  2521         -					      if (stroke)
  2522         -						  rl2_graph_fill_path (ctx,
  2523         -								       RL2_PRESERVE_PATH);
         2253  +					      double tic =
         2254  +						  (i % 2) ? size6 : size2;
         2255  +					      double cx =
         2256  +						  x + (tic * sin (rads));
         2257  +					      double cy =
         2258  +						  y + (tic * cos (rads));
         2259  +					      if (i == 0)
         2260  +						  rl2_graph_move_to_point (ctx,
         2261  +									   cx,
         2262  +									   cy);
  2524   2263   					      else
  2525         -						  rl2_graph_fill_path (ctx,
  2526         -								       RL2_CLEAR_PATH);
         2264  +						  rl2_graph_add_line_to_path
         2265  +						      (ctx, cx, cy);
         2266  +					      rads += 0.628318530718;
  2527   2267   					  }
         2268  +					rl2_graph_close_subpath (ctx);
         2269  +					break;
         2270  +				    case RL2_GRAPHIC_MARK_CROSS:
         2271  +					rl2_graph_move_to_point (ctx, x - size6,
         2272  +								 y - size2);
         2273  +					rl2_graph_add_line_to_path (ctx,
         2274  +								    x + size6,
         2275  +								    y - size2);
         2276  +					rl2_graph_add_line_to_path (ctx,
         2277  +								    x + size6,
         2278  +								    y - size6);
         2279  +					rl2_graph_add_line_to_path (ctx,
         2280  +								    x + size2,
         2281  +								    y - size6);
         2282  +					rl2_graph_add_line_to_path (ctx,
         2283  +								    x + size2,
         2284  +								    y + size6);
         2285  +					rl2_graph_add_line_to_path (ctx,
         2286  +								    x + size6,
         2287  +								    y + size6);
         2288  +					rl2_graph_add_line_to_path (ctx,
         2289  +								    x + size6,
         2290  +								    y + size2);
         2291  +					rl2_graph_add_line_to_path (ctx,
         2292  +								    x - size6,
         2293  +								    y + size2);
         2294  +					rl2_graph_add_line_to_path (ctx,
         2295  +								    x - size6,
         2296  +								    y + size6);
         2297  +					rl2_graph_add_line_to_path (ctx,
         2298  +								    x - size2,
         2299  +								    y + size6);
         2300  +					rl2_graph_add_line_to_path (ctx,
         2301  +								    x - size2,
         2302  +								    y - size6);
         2303  +					rl2_graph_add_line_to_path (ctx,
         2304  +								    x - size6,
         2305  +								    y - size6);
         2306  +					rl2_graph_close_subpath (ctx);
         2307  +					break;
         2308  +				    case RL2_GRAPHIC_MARK_X:
         2309  +					rl2_graph_move_to_point (ctx, x - size2,
         2310  +								 y - size2);
         2311  +					rl2_graph_add_line_to_path (ctx,
         2312  +								    x - size4,
         2313  +								    y - size2);
         2314  +					rl2_graph_add_line_to_path (ctx, x,
         2315  +								    y - size6);
         2316  +					rl2_graph_add_line_to_path (ctx,
         2317  +								    x + size6,
         2318  +								    y - size2);
         2319  +					rl2_graph_add_line_to_path (ctx,
         2320  +								    x + size2,
         2321  +								    y - size2);
         2322  +					rl2_graph_add_line_to_path (ctx,
         2323  +								    x + size4,
         2324  +								    y);
         2325  +					rl2_graph_add_line_to_path (ctx,
         2326  +								    x + size2,
         2327  +								    y + size2);
         2328  +					rl2_graph_add_line_to_path (ctx,
         2329  +								    x + size4,
         2330  +								    y + size2);
         2331  +					rl2_graph_add_line_to_path (ctx, x,
         2332  +								    y + size6);
         2333  +					rl2_graph_add_line_to_path (ctx,
         2334  +								    x - size6,
         2335  +								    y + size2);
         2336  +					rl2_graph_add_line_to_path (ctx,
         2337  +								    x - size2,
         2338  +								    y + size2);
         2339  +					rl2_graph_add_line_to_path (ctx,
         2340  +								    x - size4,
         2341  +								    y);
         2342  +					rl2_graph_close_subpath (ctx);
         2343  +					break;
         2344  +				    case RL2_GRAPHIC_MARK_SQUARE:
         2345  +				    default:
         2346  +					rl2_graph_move_to_point (ctx, x - size2,
         2347  +								 y - size2);
         2348  +					rl2_graph_add_line_to_path (ctx,
         2349  +								    x - size2,
         2350  +								    y + size2);
         2351  +					rl2_graph_add_line_to_path (ctx,
         2352  +								    x + size2,
         2353  +								    y + size2);
         2354  +					rl2_graph_add_line_to_path (ctx,
         2355  +								    x + size2,
         2356  +								    y - size2);
         2357  +					rl2_graph_close_subpath (ctx);
         2358  +					break;
         2359  +				    };
         2360  +				  if (fill)
         2361  +				    {
  2528   2362   					if (stroke)
  2529         -					    rl2_graph_stroke_path (ctx,
  2530         -								   RL2_CLEAR_PATH);
         2363  +					    rl2_graph_fill_path (ctx,
         2364  +								 RL2_PRESERVE_PATH);
         2365  +					else
         2366  +					    rl2_graph_fill_path (ctx,
         2367  +								 RL2_CLEAR_PATH);
  2531   2368   				    }
  2532         -				  if (is_external && pattern != NULL)
  2533         -				    {
  2534         -					/* drawing an External Graphic pattern */
  2535         -					unsigned int width;
  2536         -					unsigned int height;
  2537         -					rl2_graph_get_pattern_size (pattern,
  2538         -								    &width,
  2539         -								    &height);
  2540         -					double out_width = width;
  2541         -					double out_height = height;
  2542         -					rl2_graph_draw_graphic_symbol (ctx,
  2543         -								       pattern,
  2544         -								       out_width,
  2545         -								       out_height,
  2546         -								       x +
  2547         -								       point_sym->graphic->displacement_x,
  2548         -								       y -
  2549         -								       point_sym->graphic->displacement_y,
  2550         -								       point_sym->graphic->rotation,
  2551         -								       point_sym->graphic->anchor_point_x,
  2552         -								       point_sym->graphic->anchor_point_y);
  2553         -				    }
         2369  +				  if (stroke)
         2370  +				      rl2_graph_stroke_path (ctx,
         2371  +							     RL2_CLEAR_PATH);
         2372  +			      }
         2373  +			    if (is_external && pattern != NULL)
         2374  +			      {
         2375  +				  /* drawing an External Graphic bitmap */
         2376  +				  rl2_graph_draw_bitmap (ctx, pattern, x, y);
  2554   2377   			      }
  2555   2378   			    point = point->next;
  2556   2379   			}
  2557   2380   
  2558   2381   		      /* releasing Patterns */
  2559   2382   		      if (pattern != NULL)
  2560         -			  rl2_graph_destroy_pattern (pattern);
         2383  +			  rl2_graph_destroy_bitmap (pattern);
  2561   2384   		      if (pattern_fill != NULL)
  2562   2385   			{
  2563   2386   			    rl2_graph_release_pattern_pen (ctx);
  2564   2387   			    rl2_graph_destroy_pattern (pattern_fill);
  2565   2388   			}
  2566   2389   		      if (pattern_stroke != NULL)
  2567   2390   			{
................................................................................
  2571   2394   		      graphic = graphic->next;
  2572   2395   		  }
  2573   2396   	    }
  2574   2397   	  item = item->next;
  2575   2398         }
  2576   2399   }
  2577   2400   
  2578         -static int
  2579         -linestring_bbox_matches (rl2LinestringPtr ring, double minx, double miny,
  2580         -			 double maxx, double maxy)
  2581         -{
  2582         -/* checks if the Linestring BBOX is visible */
  2583         -    if (minx > ring->maxx)
  2584         -	return 0;
  2585         -    if (maxx < ring->minx)
  2586         -	return 0;
  2587         -    if (miny > ring->maxy)
  2588         -	return 0;
  2589         -    if (maxy < ring->miny)
  2590         -	return 0;
  2591         -    return 1;
  2592         -}
  2593         -
  2594   2401   static void
  2595   2402   draw_lines (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  2596   2403   	    rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  2597         -	    double miny, double maxx, double maxy, double x_res, double y_res,
  2598         -	    rl2GeometryPtr geom)
         2404  +	    double miny, double x_res, double y_res, rl2GeometryPtr geom)
  2599   2405   {
  2600   2406   /* drawing Linear-type features */
  2601   2407       rl2PrivVectorSymbolizerItemPtr item;
  2602         -    int pen_cap = RL2_PEN_CAP_BUTT;
  2603         -    int pen_join = RL2_PEN_JOIN_MITER;
         2408  +    int pen_cap;
         2409  +    int pen_join;
  2604   2410       double opacity;
  2605   2411       unsigned char norm_opacity;
  2606   2412       rl2LinestringPtr line;
  2607   2413       rl2GraphicsPatternPtr pattern = NULL;
  2608   2414       rl2PrivMultiStrokePtr multi_stroke = rl2_create_multi_stroke ();
  2609   2415   
  2610   2416       item = sym->first;
................................................................................
  2615   2421   		rl2PrivLineSymbolizerPtr line_sym =
  2616   2422   		    (rl2PrivLineSymbolizerPtr) (item->symbolizer);
  2617   2423   		if (line_sym->stroke != NULL)
  2618   2424   		  {
  2619   2425   		      if (line_sym->stroke->graphic != NULL)
  2620   2426   			{
  2621   2427   			    /* external Graphic stroke */
  2622         -			    const char *xlink_href = NULL;
  2623         -			    int recolor = 0;
  2624         -			    unsigned char red;
  2625         -			    unsigned char green;
  2626         -			    unsigned char blue;
  2627         -			    pattern = NULL;
  2628         -			    if (line_sym->stroke->graphic->first != NULL)
  2629         -			      {
  2630         -				  if (line_sym->stroke->graphic->first->type ==
  2631         -				      RL2_EXTERNAL_GRAPHIC)
  2632         -				    {
  2633         -					rl2PrivExternalGraphicPtr ext =
  2634         -					    (rl2PrivExternalGraphicPtr)
  2635         -					    (line_sym->stroke->graphic->
  2636         -					     first->item);
  2637         -					xlink_href = ext->xlink_href;
  2638         -					if (ext->first != NULL)
  2639         -					  {
  2640         -					      recolor = 1;
  2641         -					      red = ext->first->red;
  2642         -					      green = ext->first->green;
  2643         -					      blue = ext->first->blue;
  2644         -					  }
  2645         -				    }
  2646         -			      }
  2647         -			    if (xlink_href != NULL)
  2648         -				pattern =
  2649         -				    rl2_create_pattern_from_external_graphic
  2650         -				    (handle, xlink_href, 1);
         2428  +			    pattern = load_external_graphic_from_dbms (handle,
         2429  +								       line_sym->stroke->graphic);
  2651   2430   			    if (pattern != NULL)
  2652   2431   			      {
  2653         -				  if (recolor)
         2432  +				  switch (line_sym->stroke->linecap)
  2654   2433   				    {
  2655         -					/* attempting to recolor the External Graphic resource */
  2656         -					rl2_graph_pattern_recolor (pattern,
  2657         -								   red, green,
  2658         -								   blue);
  2659         -				    }
  2660         -				  if (line_sym->stroke->opacity <= 0.0)
  2661         -				      norm_opacity = 0;
  2662         -				  else if (line_sym->stroke->opacity >= 1.0)
  2663         -				      norm_opacity = 255;
  2664         -				  else
         2434  +				    case RL2_STROKE_LINECAP_ROUND:
         2435  +					pen_cap = RL2_PEN_CAP_ROUND;
         2436  +					break;
         2437  +				    case RL2_STROKE_LINECAP_SQUARE:
         2438  +					pen_cap = RL2_PEN_CAP_SQUARE;
         2439  +					break;
         2440  +				    default:
         2441  +					pen_cap = RL2_PEN_CAP_BUTT;
         2442  +					break;
         2443  +				    };
         2444  +				  switch (line_sym->stroke->linejoin)
  2665   2445   				    {
  2666         -					opacity =
  2667         -					    255.0 * line_sym->stroke->opacity;
  2668         -					if (opacity <= 0.0)
  2669         -					    norm_opacity = 0;
  2670         -					else if (opacity >= 255.0)
  2671         -					    norm_opacity = 255;
  2672         -					else
  2673         -					    norm_opacity = opacity;
  2674         -				    }
  2675         -				  if (norm_opacity < 1.0)
  2676         -				      rl2_graph_pattern_transparency
  2677         -					  (pattern, norm_opacity);
         2446  +				    case RL2_STROKE_LINEJOIN_BEVEL:
         2447  +					pen_join = RL2_PEN_JOIN_BEVEL;
         2448  +					break;
         2449  +				    case RL2_STROKE_LINEJOIN_ROUND:
         2450  +					pen_join = RL2_PEN_JOIN_ROUND;
         2451  +					break;
         2452  +				    default:
         2453  +					pen_join = RL2_PEN_JOIN_MITER;
         2454  +					break;
         2455  +				    };
  2678   2456   				  if (line_sym->stroke->dash_count > 0
  2679   2457   				      && line_sym->stroke->dash_list != NULL)
  2680   2458   				      rl2_add_pattern_to_multi_stroke_dash
  2681   2459   					  (multi_stroke, pattern,
  2682   2460   					   line_sym->stroke->width, pen_cap,
  2683   2461   					   pen_join,
  2684   2462   					   line_sym->stroke->dash_count,
................................................................................
  2686   2464   					   line_sym->stroke->dash_offset);
  2687   2465   				  else
  2688   2466   				      rl2_add_pattern_to_multi_stroke
  2689   2467   					  (multi_stroke, pattern,
  2690   2468   					   line_sym->stroke->width, pen_cap,
  2691   2469   					   pen_join);
  2692   2470   			      }
  2693         -			    else
  2694         -			      {
  2695         -				  /* invalid Pattern: defaulting to a Gray brush */
  2696         -				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
  2697         -			      }
  2698   2471   			}
  2699   2472   		      else
  2700   2473   			{
  2701   2474   			    /* solid RGB stroke */
  2702   2475   			    if (line_sym->stroke->opacity <= 0.0)
  2703   2476   				norm_opacity = 0;
  2704   2477   			    else if (line_sym->stroke->opacity >= 1.0)
................................................................................
  2774   2547       if (multi_stroke == NULL)
  2775   2548   	return;
  2776   2549   
  2777   2550       line = geom->first_linestring;
  2778   2551       while (line)
  2779   2552         {
  2780   2553   	  /* drawing a LINESTRING */
  2781         -	  if (linestring_bbox_matches (line, minx, miny, maxx, maxy))
         2554  +	  rl2PrivMultiStrokeItemPtr stroke_item;
         2555  +	  int iv;
         2556  +	  double dx;
         2557  +	  double dy;
         2558  +	  int x;
         2559  +	  int y;
         2560  +	  int lastX = 0;
         2561  +	  int lastY = 0;
         2562  +	  for (iv = 0; iv < line->points; iv++)
  2782   2563   	    {
  2783         -		rl2PrivMultiStrokeItemPtr stroke_item;
  2784         -		int iv;
  2785         -		double dx;
  2786         -		double dy;
  2787         -		int x;
  2788         -		int y;
  2789         -		int lastX = 0;
  2790         -		int lastY = 0;
  2791         -		for (iv = 0; iv < line->points; iv++)
         2564  +		rl2GetPoint (line->coords, iv, &dx, &dy);
         2565  +		x = (int) ((dx - minx) / x_res);
         2566  +		y = height - (int) ((dy - miny) / y_res);
         2567  +		if (iv == 0)
         2568  +		  {
         2569  +		      rl2_graph_move_to_point (ctx, x, y);
         2570  +		      lastX = x;
         2571  +		      lastY = y;
         2572  +		  }
         2573  +		else
  2792   2574   		  {
  2793         -		      rl2GetPoint (line->coords, iv, &dx, &dy);
  2794         -		      x = (int) ((dx - minx) / x_res);
  2795         -		      y = height - (int) ((dy - miny) / y_res);
  2796         -		      if (iv == 0)
         2575  +		      if (x == lastX && y == lastY)
         2576  +			  ;
         2577  +		      else
  2797   2578   			{
  2798         -			    rl2_graph_move_to_point (ctx, x, y);
         2579  +			    rl2_graph_add_line_to_path (ctx, x, y);
  2799   2580   			    lastX = x;
  2800   2581   			    lastY = y;
  2801   2582   			}
         2583  +		  }
         2584  +	    }
         2585  +	  stroke_item = multi_stroke->first;
         2586  +	  while (stroke_item != NULL)
         2587  +	    {
         2588  +		/* applying all strokes, one after the other */
         2589  +		if (stroke_item->dash_count > 0
         2590  +		    && stroke_item->dash_list != NULL)
         2591  +		  {
         2592  +		      if (stroke_item->pattern != NULL)
         2593  +			  rl2_graph_set_pattern_dashed_pen (ctx,
         2594  +							    stroke_item->pattern,
         2595  +							    stroke_item->width,
         2596  +							    stroke_item->pen_cap,
         2597  +							    stroke_item->pen_join,
         2598  +							    stroke_item->dash_count,
         2599  +							    stroke_item->dash_list,
         2600  +							    stroke_item->dash_offset);
  2802   2601   		      else
  2803         -			{
  2804         -			    if (x == lastX && y == lastY)
  2805         -				;
  2806         -			    else
  2807         -			      {
  2808         -				  rl2_graph_add_line_to_path (ctx, x, y);
  2809         -				  lastX = x;
  2810         -				  lastY = y;
  2811         -			      }
  2812         -			}
         2602  +			  rl2_graph_set_dashed_pen (ctx, stroke_item->red,
         2603  +						    stroke_item->green,
         2604  +						    stroke_item->blue,
         2605  +						    stroke_item->opacity,
         2606  +						    stroke_item->width,
         2607  +						    stroke_item->pen_cap,
         2608  +						    stroke_item->pen_join,
         2609  +						    stroke_item->dash_count,
         2610  +						    stroke_item->dash_list,
         2611  +						    stroke_item->dash_offset);
  2813   2612   		  }
  2814         -		stroke_item = multi_stroke->first;
  2815         -		while (stroke_item != NULL)
         2613  +		else
  2816   2614   		  {
  2817         -		      /* applying all strokes, one after the other */
  2818         -		      if (stroke_item->dash_count > 0
  2819         -			  && stroke_item->dash_list != NULL)
  2820         -			{
  2821         -			    if (stroke_item->pattern != NULL)
  2822         -				rl2_graph_set_pattern_dashed_pen (ctx,
  2823         -								  stroke_item->pattern,
  2824         -								  stroke_item->width,
  2825         -								  stroke_item->pen_cap,
  2826         -								  stroke_item->pen_join,
  2827         -								  stroke_item->dash_count,
  2828         -								  stroke_item->dash_list,
  2829         -								  stroke_item->dash_offset);
  2830         -			    else
  2831         -				rl2_graph_set_dashed_pen (ctx,
  2832         -							  stroke_item->red,
  2833         -							  stroke_item->green,
  2834         -							  stroke_item->blue,
  2835         -							  stroke_item->opacity,
  2836         -							  stroke_item->width,
  2837         -							  stroke_item->pen_cap,
  2838         -							  stroke_item->pen_join,
  2839         -							  stroke_item->dash_count,
  2840         -							  stroke_item->dash_list,
  2841         -							  stroke_item->dash_offset);
  2842         -			}
         2615  +		      if (stroke_item->pattern != NULL)
         2616  +			  rl2_graph_set_pattern_solid_pen (ctx,
         2617  +							   stroke_item->pattern,
         2618  +							   stroke_item->width,
         2619  +							   stroke_item->pen_cap,
         2620  +							   stroke_item->pen_join);
  2843   2621   		      else
  2844         -			{
  2845         -			    if (stroke_item->pattern != NULL)
  2846         -				rl2_graph_set_pattern_solid_pen (ctx,
  2847         -								 stroke_item->pattern,
  2848         -								 stroke_item->width,
  2849         -								 stroke_item->pen_cap,
  2850         -								 stroke_item->pen_join);
  2851         -			    else
  2852         -				rl2_graph_set_solid_pen (ctx,
  2853         -							 stroke_item->red,
  2854         -							 stroke_item->green,
  2855         -							 stroke_item->blue,
  2856         -							 stroke_item->opacity,
  2857         -							 stroke_item->width,
  2858         -							 stroke_item->pen_cap,
  2859         -							 stroke_item->pen_join);
  2860         -			}
  2861         -
  2862         -		      if (stroke_item == multi_stroke->last)
  2863         -			  rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH);
  2864         -		      else
  2865         -			  rl2_graph_stroke_path (ctx, RL2_PRESERVE_PATH);
  2866         -
  2867         -		      stroke_item = stroke_item->next;
  2868         -		      if (stroke_item == multi_stroke->last)
  2869         -			  rl2_graph_release_pattern_pen (ctx);
         2622  +			  rl2_graph_set_solid_pen (ctx, stroke_item->red,
         2623  +						   stroke_item->green,
         2624  +						   stroke_item->blue,
         2625  +						   stroke_item->opacity,
         2626  +						   stroke_item->width,
         2627  +						   stroke_item->pen_cap,
         2628  +						   stroke_item->pen_join);
  2870   2629   		  }
         2630  +
         2631  +		if (stroke_item == multi_stroke->last)
         2632  +		    rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH);
         2633  +		else
         2634  +		    rl2_graph_stroke_path (ctx, RL2_PRESERVE_PATH);
         2635  +
         2636  +		stroke_item = stroke_item->next;
         2637  +		if (stroke_item == multi_stroke->last)
         2638  +		    rl2_graph_release_pattern_pen (ctx);
  2871   2639   	    }
  2872   2640   	  line = line->next;
  2873   2641         }
  2874   2642       rl2_destroy_multi_stroke (multi_stroke);
  2875   2643   }
  2876   2644   
  2877         -static int
  2878         -ring_bbox_matches (rl2RingPtr ring, double minx, double miny, double maxx,
  2879         -		   double maxy)
  2880         -{
  2881         -/* checks if the Ring BBOX is visible */
  2882         -    if (minx > ring->maxx)
  2883         -	return 0;
  2884         -    if (maxx < ring->minx)
  2885         -	return 0;
  2886         -    if (miny > ring->maxy)
  2887         -	return 0;
  2888         -    if (maxy < ring->miny)
  2889         -	return 0;
  2890         -    return 1;
  2891         -}
  2892         -
  2893   2645   static void
  2894   2646   draw_polygons (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  2895   2647   	       rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  2896         -	       double miny, double maxx, double maxy, double x_res,
  2897         -	       double y_res, rl2GeometryPtr geom)
         2648  +	       double miny, double x_res, double y_res, rl2GeometryPtr geom)
  2898   2649   {
  2899   2650   /* drawing Polygonal-type features */
  2900   2651       rl2PrivVectorSymbolizerItemPtr item;
  2901   2652       int stroke = 0;
  2902   2653       int fill = 0;
  2903   2654       int pen_cap;
  2904   2655       int pen_join;
................................................................................
  2953   2704   				    rl2_create_pattern_from_external_graphic
  2954   2705   				    (handle, xlink_href, 1);
  2955   2706   			    if (pattern_fill != NULL)
  2956   2707   			      {
  2957   2708   				  if (recolor)
  2958   2709   				    {
  2959   2710   					/* attempting to recolor the External Graphic resource */
  2960         -					rl2_graph_pattern_recolor
  2961         -					    (pattern_fill, red, green, blue);
         2711  +					rl2_graph_pattern_recolor (pattern_fill,
         2712  +								   red, green,
         2713  +								   blue);
  2962   2714   				    }
  2963   2715   				  if (polyg_sym->fill->opacity <= 0.0)
  2964   2716   				      norm_opacity = 0;
  2965   2717   				  else if (polyg_sym->fill->opacity >= 1.0)
  2966   2718   				      norm_opacity = 255;
  2967   2719   				  else
  2968   2720   				    {
................................................................................
  3013   2765   			}
  3014   2766   		  }
  3015   2767   		if (polyg_sym->stroke != NULL)
  3016   2768   		  {
  3017   2769   		      if (polyg_sym->stroke->graphic != NULL)
  3018   2770   			{
  3019   2771   			    /* external Graphic stroke */
  3020         -			    const char *xlink_href = NULL;
  3021         -			    int recolor = 0;
  3022         -			    unsigned char red;
  3023         -			    unsigned char green;
  3024         -			    unsigned char blue;
  3025         -			    pattern_stroke = NULL;
  3026         -			    if (polyg_sym->stroke->graphic->first != NULL)
  3027         -			      {
  3028         -				  if (polyg_sym->stroke->graphic->first->type ==
  3029         -				      RL2_EXTERNAL_GRAPHIC)
  3030         -				    {
  3031         -					rl2PrivExternalGraphicPtr ext =
  3032         -					    (rl2PrivExternalGraphicPtr)
  3033         -					    (polyg_sym->stroke->graphic->
  3034         -					     first->item);
  3035         -					xlink_href = ext->xlink_href;
  3036         -					if (ext->first != NULL)
  3037         -					  {
  3038         -					      recolor = 1;
  3039         -					      red = ext->first->red;
  3040         -					      green = ext->first->green;
  3041         -					      blue = ext->first->blue;
  3042         -					  }
  3043         -				    }
  3044         -			      }
  3045         -			    if (xlink_href != NULL)
  3046         -				pattern_stroke =
  3047         -				    rl2_create_pattern_from_external_graphic
  3048         -				    (handle, xlink_href, 1);
         2772  +			    pattern_stroke =
         2773  +				load_external_graphic_from_dbms (handle,
         2774  +								 polyg_sym->stroke->graphic);
  3049   2775   			    if (pattern_stroke != NULL)
  3050   2776   			      {
  3051         -				  if (recolor)
         2777  +				  switch (polyg_sym->stroke->linecap)
  3052   2778   				    {
  3053         -					/* attempting to recolor the External Graphic resource */
  3054         -					rl2_graph_pattern_recolor
  3055         -					    (pattern_stroke, red, green, blue);
  3056         -				    }
  3057         -				  if (polyg_sym->stroke->opacity <= 0.0)
  3058         -				      norm_opacity = 0;
  3059         -				  else if (polyg_sym->stroke->opacity >= 1.0)
  3060         -				      norm_opacity = 255;
  3061         -				  else
         2779  +				    case RL2_STROKE_LINECAP_ROUND:
         2780  +					pen_cap = RL2_PEN_CAP_ROUND;
         2781  +					break;
         2782  +				    case RL2_STROKE_LINECAP_SQUARE:
         2783  +					pen_cap = RL2_PEN_CAP_SQUARE;
         2784  +					break;
         2785  +				    default:
         2786  +					pen_cap = RL2_PEN_CAP_BUTT;
         2787  +					break;
         2788  +				    };
         2789  +				  switch (polyg_sym->stroke->linejoin)
  3062   2790   				    {
  3063         -					opacity =
  3064         -					    255.0 * polyg_sym->stroke->opacity;
  3065         -					if (opacity <= 0.0)
  3066         -					    norm_opacity = 0;
  3067         -					else if (opacity >= 255.0)
  3068         -					    norm_opacity = 255;
  3069         -					else
  3070         -					    norm_opacity = opacity;
  3071         -				    }
  3072         -				  if (norm_opacity < 1.0)
  3073         -				      rl2_graph_pattern_transparency
  3074         -					  (pattern_stroke, norm_opacity);
  3075         -				  rl2_graph_set_pattern_brush (ctx,
  3076         -							       pattern_stroke);
  3077         -			      }
  3078         -			    else
  3079         -			      {
  3080         -				  /* invalid Pattern: defaulting to a Gray brush */
  3081         -				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
  3082         -			      }
  3083         -			    stroke = 1;
         2791  +				    case RL2_STROKE_LINEJOIN_BEVEL:
         2792  +					pen_join = RL2_PEN_JOIN_BEVEL;
         2793  +					break;
         2794  +				    case RL2_STROKE_LINEJOIN_ROUND:
         2795  +					pen_join = RL2_PEN_JOIN_ROUND;
         2796  +					break;
         2797  +				    default:
         2798  +					pen_join = RL2_PEN_JOIN_MITER;
         2799  +					break;
         2800  +				    };
         2801  +				  if (polyg_sym->stroke->dash_count > 0
         2802  +				      && polyg_sym->stroke->dash_list != NULL)
         2803  +				      rl2_graph_set_pattern_dashed_pen (ctx,
         2804  +									pattern_stroke,
         2805  +									polyg_sym->
         2806  +									stroke->width,
         2807  +									pen_cap,
         2808  +									pen_join,
         2809  +									polyg_sym->stroke->dash_count,
         2810  +									polyg_sym->stroke->dash_list,
         2811  +									polyg_sym->stroke->dash_offset);
         2812  +				  else
         2813  +				      rl2_graph_set_pattern_solid_pen (ctx,
         2814  +								       pattern_stroke,
         2815  +								       polyg_sym->
         2816  +								       stroke->width,
         2817  +								       pen_cap,
         2818  +								       pen_join);
         2819  +				  stroke = 1;
         2820  +			      }
  3084   2821   			}
  3085   2822   		      else
  3086   2823   			{
  3087   2824   			    /* solid RGB stroke */
  3088   2825   			    if (polyg_sym->stroke->opacity <= 0.0)
  3089   2826   				norm_opacity = 0;
  3090   2827   			    else if (polyg_sym->stroke->opacity >= 1.0)
................................................................................
  3173   2910   		int x;
  3174   2911   		int y;
  3175   2912   		int lastX = 0;
  3176   2913   		int lastY = 0;
  3177   2914   		int ib;
  3178   2915   		rl2RingPtr ring = polyg->exterior;
  3179   2916   		/* exterior border */
  3180         -		if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
         2917  +		for (iv = 0; iv < ring->points; iv++)
         2918  +		  {
         2919  +		      rl2GetPoint (ring->coords, iv, &dx, &dy);
         2920  +		      x = (int) ((dx - minx) / x_res);
         2921  +		      y = height - (int) ((dy - miny) / y_res);
         2922  +		      if (iv == 0)
         2923  +			{
         2924  +			    rl2_graph_move_to_point (ctx, x, y);
         2925  +			    lastX = x;
         2926  +			    lastY = y;
         2927  +			}
         2928  +		      else
         2929  +			{
         2930  +			    if (x == lastX && y == lastY)
         2931  +				;
         2932  +			    else
         2933  +			      {
         2934  +				  rl2_graph_add_line_to_path (ctx, x, y);
         2935  +				  lastX = x;
         2936  +				  lastY = y;
         2937  +			      }
         2938  +			}
         2939  +		  }
         2940  +		rl2_graph_close_subpath (ctx);
         2941  +		for (ib = 0; ib < polyg->num_interiors; ib++)
  3181   2942   		  {
         2943  +		      /* interior borders */
         2944  +		      ring = polyg->interiors + ib;
  3182   2945   		      for (iv = 0; iv < ring->points; iv++)
  3183   2946   			{
  3184   2947   			    rl2GetPoint (ring->coords, iv, &dx, &dy);
  3185   2948   			    x = (int) ((dx - minx) / x_res);
  3186   2949   			    y = height - (int) ((dy - miny) / y_res);
  3187   2950   			    if (iv == 0)
  3188   2951   			      {
................................................................................
  3199   2962   					rl2_graph_add_line_to_path (ctx, x, y);
  3200   2963   					lastX = x;
  3201   2964   					lastY = y;
  3202   2965   				    }
  3203   2966   			      }
  3204   2967   			}
  3205   2968   		      rl2_graph_close_subpath (ctx);
  3206         -		  }
  3207         -		else
  3208         -		  {
  3209         -		      /* if the exterior ring is invisible we'll ignore all internal rings */
  3210         -		      polyg = polyg->next;
  3211         -		      continue;
  3212         -		  }
  3213         -		for (ib = 0; ib < polyg->num_interiors; ib++)
  3214         -		  {
  3215         -		      /* interior borders */
  3216         -		      ring = polyg->interiors + ib;
  3217         -		      if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
  3218         -			{
  3219         -			    for (iv = 0; iv < ring->points; iv++)
  3220         -			      {
  3221         -				  rl2GetPoint (ring->coords, iv, &dx, &dy);
  3222         -				  x = (int) ((dx - minx) / x_res);
  3223         -				  y = height - (int) ((dy - miny) / y_res);
  3224         -				  if (iv == 0)
  3225         -				    {
  3226         -					rl2_graph_move_to_point (ctx, x, y);
  3227         -					lastX = x;
  3228         -					lastY = y;
  3229         -				    }
  3230         -				  else
  3231         -				    {
  3232         -					if (x == lastX && y == lastY)
  3233         -					    ;
  3234         -					else
  3235         -					  {
  3236         -					      rl2_graph_add_line_to_path (ctx,
  3237         -									  x, y);
  3238         -					      lastX = x;
  3239         -					      lastY = y;
  3240         -					  }
  3241         -				    }
  3242         -			      }
  3243         -			    rl2_graph_close_subpath (ctx);
  3244         -			}
  3245   2969   		  }
  3246   2970   		if (fill)
  3247   2971   		  {
  3248   2972   		      if (stroke)
  3249   2973   			  rl2_graph_fill_path (ctx, RL2_PRESERVE_PATH);
  3250   2974   		      else
  3251   2975   			  rl2_graph_fill_path (ctx, RL2_CLEAR_PATH);
................................................................................
  3265   2989   		rl2_graph_destroy_pattern (pattern_stroke);
  3266   2990   	    }
  3267   2991   	  item = item->next;
  3268   2992         }
  3269   2993   }
  3270   2994   
  3271   2995   static int
  3272         -label_get_xy (sqlite3 * handle, const unsigned char *blob, int size,
  3273         -	      double *x, double *y)
         2996  +label_get_xy (sqlite3 * handle, const unsigned char *blob, int size, double *x,
         2997  +	      double *y)
  3274   2998   {
  3275   2999   /* resolving Point XY coords */
  3276   3000       const char *sql;
  3277   3001       int ret;
  3278   3002       sqlite3_stmt *stmt = NULL;
  3279   3003       int ok = 0;
  3280   3004   
................................................................................
  3337   3061   	  if (ret == SQLITE_DONE)
  3338   3062   	      break;		/* end of result set */
  3339   3063   	  if (ret == SQLITE_ROW)
  3340   3064   	    {
  3341   3065   		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3342   3066   		  {
  3343   3067   		      const unsigned char *g_blob =
  3344         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3345         -								       0);
         3068  +			  (const unsigned char *) sqlite3_column_blob (stmt, 0);
  3346   3069   		      int g_size = sqlite3_column_bytes (stmt, 0);
  3347   3070   		      if (label_get_xy (handle, g_blob, g_size, x, y))
  3348   3071   			  ok = 1;
  3349   3072   		  }
  3350   3073   	    }
  3351   3074         }
  3352   3075       sqlite3_finalize (stmt);
................................................................................
  3385   3108   	  if (ret == SQLITE_DONE)
  3386   3109   	      break;		/* end of result set */
  3387   3110   	  if (ret == SQLITE_ROW)
  3388   3111   	    {
  3389   3112   		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3390   3113   		  {
  3391   3114   		      const unsigned char *g_blob =
  3392         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3393         -								       0);
         3115  +			  (const unsigned char *) sqlite3_column_blob (stmt, 0);
  3394   3116   		      int g_size = sqlite3_column_bytes (stmt, 0);
  3395   3117   		      if (label_get_xy (handle, g_blob, g_size, x, y))
  3396   3118   			  ok = 1;
  3397   3119   		  }
  3398   3120   	    }
  3399   3121         }
  3400   3122       sqlite3_finalize (stmt);
  3401   3123       return ok;
  3402   3124   }
  3403   3125   
  3404         -static int
  3405         -label_get_ring_midpoint (sqlite3 * handle, rl2RingPtr ring, double *x,
  3406         -			 double *y)
  3407         -{
  3408         -/* computing a Ring MidPoint */
  3409         -    unsigned char *blob;
  3410         -    int blob_sz;
  3411         -    const char *sql;
  3412         -    int ret;
  3413         -    sqlite3_stmt *stmt = NULL;
  3414         -    int ok = 0;
  3415         -
  3416         -    if (ring == NULL)
  3417         -	return 0;
  3418         -    if (!rl2_serialize_ring_as_linestring (ring, &blob, &blob_sz))
  3419         -	return 0;
  3420         -
  3421         -    sql = "SELECT ST_Line_Interpolate_Point(?, 0.5)";
  3422         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  3423         -    if (ret != SQLITE_OK)
  3424         -	return 0;
  3425         -
  3426         -    sqlite3_reset (stmt);
  3427         -    sqlite3_clear_bindings (stmt);
  3428         -    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
  3429         -    while (1)
  3430         -      {
  3431         -	  /* scrolling the result set rows */
  3432         -	  ret = sqlite3_step (stmt);
  3433         -	  if (ret == SQLITE_DONE)
  3434         -	      break;		/* end of result set */
  3435         -	  if (ret == SQLITE_ROW)
  3436         -	    {
  3437         -		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3438         -		  {
  3439         -		      const unsigned char *g_blob =
  3440         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3441         -								       0);
  3442         -		      int g_size = sqlite3_column_bytes (stmt, 0);
  3443         -		      if (label_get_xy (handle, g_blob, g_size, x, y))
  3444         -			  ok = 1;
  3445         -		  }
  3446         -	    }
  3447         -      }
  3448         -    sqlite3_finalize (stmt);
  3449         -    return ok;
  3450         -}
  3451         -
  3452         -static rl2GeometryPtr
  3453         -do_generalize_linestring (sqlite3 * handle, rl2LinestringPtr line,
  3454         -			  double generalize_factor)
  3455         -{
  3456         -/* simplifying a Linestring */
  3457         -    rl2GeometryPtr geom = NULL;
  3458         -    unsigned char *blob;
  3459         -    int blob_sz;
  3460         -    const char *sql;
  3461         -    int ret;
  3462         -    sqlite3_stmt *stmt = NULL;
  3463         -
  3464         -    if (line == NULL)
  3465         -	return NULL;
  3466         -    if (line->points < 2)
  3467         -	return NULL;
  3468         -    if (!rl2_serialize_linestring (line, &blob, &blob_sz))
  3469         -	return NULL;
  3470         -
  3471         -    sql = "SELECT ST_Simplify(?, ?)";
  3472         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  3473         -    if (ret != SQLITE_OK)
  3474         -	return NULL;
  3475         -
  3476         -    sqlite3_reset (stmt);
  3477         -    sqlite3_clear_bindings (stmt);
  3478         -    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
  3479         -    sqlite3_bind_double (stmt, 2, generalize_factor);
  3480         -    while (1)
  3481         -      {
  3482         -	  /* scrolling the result set rows */
  3483         -	  ret = sqlite3_step (stmt);
  3484         -	  if (ret == SQLITE_DONE)
  3485         -	      break;		/* end of result set */
  3486         -	  if (ret == SQLITE_ROW)
  3487         -	    {
  3488         -		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3489         -		  {
  3490         -		      const unsigned char *g_blob =
  3491         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3492         -								       0);
  3493         -		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
  3494         -		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
  3495         -		  }
  3496         -	    }
  3497         -      }
  3498         -    sqlite3_finalize (stmt);
  3499         -    return geom;
  3500         -}
  3501         -
  3502         -static rl2GeometryPtr
  3503         -do_generalize_ring (sqlite3 * handle, rl2RingPtr ring, double generalize_factor)
  3504         -{
  3505         -/* simplifying a Ring */
  3506         -    rl2GeometryPtr geom = NULL;
  3507         -    unsigned char *blob;
  3508         -    int blob_sz;
  3509         -    const char *sql;
  3510         -    int ret;
  3511         -    sqlite3_stmt *stmt = NULL;
  3512         -
  3513         -    if (ring == NULL)
  3514         -	return NULL;
  3515         -    if (ring->points < 2)
  3516         -	return NULL;
  3517         -    if (!rl2_serialize_ring (ring, &blob, &blob_sz))
  3518         -	return NULL;
  3519         -
  3520         -    sql = "SELECT ST_SimplifyPreserveTopology(?, ?)";
  3521         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  3522         -    if (ret != SQLITE_OK)
  3523         -	return NULL;
  3524         -
  3525         -    sqlite3_reset (stmt);
  3526         -    sqlite3_clear_bindings (stmt);
  3527         -    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
  3528         -    sqlite3_bind_double (stmt, 2, generalize_factor);
  3529         -    while (1)
  3530         -      {
  3531         -	  /* scrolling the result set rows */
  3532         -	  ret = sqlite3_step (stmt);
  3533         -	  if (ret == SQLITE_DONE)
  3534         -	      break;		/* end of result set */
  3535         -	  if (ret == SQLITE_ROW)
  3536         -	    {
  3537         -		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3538         -		  {
  3539         -		      const unsigned char *g_blob =
  3540         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3541         -								       0);
  3542         -		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
  3543         -		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
  3544         -		  }
  3545         -	    }
  3546         -      }
  3547         -    sqlite3_finalize (stmt);
  3548         -    return geom;
  3549         -}
  3550         -
  3551         -static int
  3552         -check_valid_line (rl2LinestringPtr line)
  3553         -{
  3554         -/* testing for a valid linestring */
  3555         -    int iv;
  3556         -    int pts = 0;
  3557         -    double x;
  3558         -    double y;
  3559         -    double x0;
  3560         -    double y0;
  3561         -
  3562         -    if (line == NULL)
  3563         -	return 0;
  3564         -    if (line->points < 2)
  3565         -	return 0;
  3566         -    rl2GetPoint (line->coords, 0, &x0, &y0);
  3567         -    for (iv = 1; iv < line->points; iv++)
  3568         -      {
  3569         -	  rl2GetPoint (line->coords, iv, &x, &y);
  3570         -	  if (x != x0 || y != y0)
  3571         -	    {
  3572         -		pts++;
  3573         -		break;
  3574         -	    }
  3575         -      }
  3576         -    if (pts == 0)
  3577         -	return 0;
  3578         -    return 1;
  3579         -}
  3580         -
  3581         -static rl2GeometryPtr
  3582         -do_offset_linestring (sqlite3 * handle, rl2LinestringPtr line,
  3583         -		      double perpendicular_offset)
  3584         -{
  3585         -/* Offest Curve (from Linestring) */
  3586         -    rl2GeometryPtr geom = NULL;
  3587         -    unsigned char *blob;
  3588         -    int blob_sz;
  3589         -    const char *sql;
  3590         -    int ret;
  3591         -    sqlite3_stmt *stmt = NULL;
  3592         -
  3593         -    if (!check_valid_line (line))
  3594         -	return NULL;
  3595         -    if (!rl2_serialize_linestring (line, &blob, &blob_sz))
  3596         -	return NULL;
  3597         -
  3598         -    sql = "SELECT ST_OffsetCurve(?, ?)";
  3599         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  3600         -    if (ret != SQLITE_OK)
  3601         -	return NULL;
  3602         -
  3603         -    sqlite3_reset (stmt);
  3604         -    sqlite3_clear_bindings (stmt);
  3605         -    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
  3606         -    sqlite3_bind_double (stmt, 2, perpendicular_offset);
  3607         -    while (1)
  3608         -      {
  3609         -	  /* scrolling the result set rows */
  3610         -	  ret = sqlite3_step (stmt);
  3611         -	  if (ret == SQLITE_DONE)
  3612         -	      break;		/* end of result set */
  3613         -	  if (ret == SQLITE_ROW)
  3614         -	    {
  3615         -		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3616         -		  {
  3617         -		      const unsigned char *g_blob =
  3618         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3619         -								       0);
  3620         -		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
  3621         -		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
  3622         -		  }
  3623         -	    }
  3624         -      }
  3625         -    sqlite3_finalize (stmt);
  3626         -    return geom;
  3627         -}
  3628         -
  3629         -static int
  3630         -check_valid_ring (rl2RingPtr ring)
  3631         -{
  3632         -/* testing for a valid ring */
  3633         -    int iv;
  3634         -    int pts = 0;
  3635         -    int last;
  3636         -    double x;
  3637         -    double y;
  3638         -    double x0;
  3639         -    double y0;
  3640         -    double x1;
  3641         -    double y1;
  3642         -
  3643         -    if (ring == NULL)
  3644         -	return 0;
  3645         -    if (ring->points < 4)
  3646         -	return 0;
  3647         -    rl2GetPoint (ring->coords, 0, &x0, &y0);
  3648         -    for (iv = 1; iv < ring->points; iv++)
  3649         -      {
  3650         -	  rl2GetPoint (ring->coords, iv, &x, &y);
  3651         -	  if (pts == 0)
  3652         -	    {
  3653         -		if (x != x0 || y != y0)
  3654         -		  {
  3655         -		      pts++;
  3656         -		      x1 = x;
  3657         -		      y1 = y;
  3658         -		  }
  3659         -	    }
  3660         -	  else
  3661         -	    {
  3662         -		if ((x != x0 || y != y0) && (x != x1 || y != y1))
  3663         -		  {
  3664         -		      pts++;
  3665         -		      break;
  3666         -		  }
  3667         -	    }
  3668         -      }
  3669         -    last = ring->points - 1;
  3670         -    rl2GetPoint (ring->coords, last, &x1, &y1);
  3671         -    if (pts == 2 && x0 == x1 && y0 == y1)
  3672         -	return 1;
  3673         -    return 0;
  3674         -}
  3675         -
  3676         -static rl2GeometryPtr
  3677         -do_buffered_ring (sqlite3 * handle, rl2RingPtr ring,
  3678         -		  double perpendicular_offset)
  3679         -{
  3680         -/* Buffer (from Ring) */
  3681         -    rl2GeometryPtr geom = NULL;
  3682         -    unsigned char *blob;
  3683         -    int blob_sz;
  3684         -    const char *sql;
  3685         -    int ret;
  3686         -    sqlite3_stmt *stmt = NULL;
  3687         -
  3688         -    if (!check_valid_ring (ring))
  3689         -	return NULL;
  3690         -    if (!rl2_serialize_ring (ring, &blob, &blob_sz))
  3691         -	return NULL;
  3692         -
  3693         -    sql = "SELECT ST_Buffer(?, ?)";
  3694         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  3695         -    if (ret != SQLITE_OK)
  3696         -	return NULL;
  3697         -
  3698         -    sqlite3_reset (stmt);
  3699         -    sqlite3_clear_bindings (stmt);
  3700         -    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
  3701         -    sqlite3_bind_double (stmt, 2, perpendicular_offset);
  3702         -    while (1)
  3703         -      {
  3704         -	  /* scrolling the result set rows */
  3705         -	  ret = sqlite3_step (stmt);
  3706         -	  if (ret == SQLITE_DONE)
  3707         -	      break;		/* end of result set */
  3708         -	  if (ret == SQLITE_ROW)
  3709         -	    {
  3710         -		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3711         -		  {
  3712         -		      const unsigned char *g_blob =
  3713         -			  (const unsigned char *) sqlite3_column_blob (stmt,
  3714         -								       0);
  3715         -		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
  3716         -		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
  3717         -		  }
  3718         -	    }
  3719         -      }
  3720         -    sqlite3_finalize (stmt);
  3721         -    return geom;
  3722         -}
  3723         -
  3724         -static void
  3725         -create_line_array_from_linestring (sqlite3 * handle, rl2LinestringPtr line,
  3726         -				   double perpendicular_offset, int *points,
  3727         -				   double **x_array, double **y_array,
  3728         -				   int generalize_line,
  3729         -				   double generalize_factor, int height,
  3730         -				   double minx, double miny, double x_res,
  3731         -				   double y_res)
  3732         -{
  3733         -/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */
  3734         -    rl2GeometryPtr geom = NULL;
  3735         -    rl2GeometryPtr geom2 = NULL;
  3736         -    rl2LinestringPtr aux_line;
  3737         -    rl2LinestringPtr in_line;
  3738         -    double *xx = NULL;
  3739         -    double *yy = NULL;
  3740         -    int iv;
  3741         -    double x;
  3742         -    double y;
  3743         -
  3744         -    *points = 0;
  3745         -    *x_array = NULL;
  3746         -    *y_array = NULL;
  3747         -    if (line == NULL)
  3748         -	goto error;
  3749         -
  3750         -    aux_line = rl2_linestring_to_image (line, height, minx, miny, x_res, y_res);
  3751         -    if (aux_line == NULL)
  3752         -	goto error;
  3753         -    in_line = aux_line;
  3754         -    if (generalize_line)
  3755         -      {
  3756         -	  geom = do_generalize_linestring (handle, in_line, generalize_factor);
  3757         -	  if (geom == NULL)
  3758         -	      goto error;
  3759         -	  in_line = geom->first_linestring;
  3760         -	  if (in_line == NULL)
  3761         -	      goto error;
  3762         -      }
  3763         -    if (perpendicular_offset != 0.0)
  3764         -      {
  3765         -	  geom2 = do_offset_linestring (handle, in_line, perpendicular_offset);
  3766         -	  if (geom2 == NULL)
  3767         -	      goto error;
  3768         -	  in_line = geom2->first_linestring;
  3769         -	  if (in_line == NULL)
  3770         -	      goto error;
  3771         -      }
  3772         -
  3773         -/* allocating the X and Y arrays */
  3774         -    if (in_line->points < 2)
  3775         -	goto error;
  3776         -    xx = malloc (sizeof (double) * in_line->points);
  3777         -    yy = malloc (sizeof (double) * in_line->points);
  3778         -    if (xx == NULL || yy == NULL)
  3779         -      {
  3780         -	  if (xx != NULL)
  3781         -	      free (xx);
  3782         -	  if (yy != NULL)
  3783         -	      free (yy);
  3784         -	  goto error;
  3785         -      }
  3786         -    for (iv = 0; iv < in_line->points; iv++)
  3787         -      {
  3788         -	  /* populating the X and Y arrays */
  3789         -	  rl2GetPoint (in_line->coords, iv, &x, &y);
  3790         -	  *(xx + iv) = x;
  3791         -	  *(yy + iv) = y;
  3792         -      }
  3793         -    *points = in_line->points;
  3794         -    *x_array = xx;
  3795         -    *y_array = yy;
  3796         -
  3797         -  error:
  3798         -    if (aux_line)
  3799         -	rl2DestroyLinestring (aux_line);
  3800         -    if (geom)
  3801         -	rl2_destroy_geometry (geom);
  3802         -    if (geom2)
  3803         -	rl2_destroy_geometry (geom2);
  3804         -}
  3805         -
  3806         -static void
  3807         -create_line_array_from_ring (sqlite3 * handle, rl2RingPtr ring,
  3808         -			     double perpendicular_offset, int *points,
  3809         -			     double **x_array, double **y_array,
  3810         -			     int generalize_line, double generalize_factor,
  3811         -			     int height, double minx, double miny, double x_res,
  3812         -			     double y_res)
  3813         -{
  3814         -/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */
  3815         -    rl2GeometryPtr geom = NULL;
  3816         -    rl2GeometryPtr geom2 = NULL;
  3817         -    rl2PolygonPtr pg;
  3818         -    rl2RingPtr aux_ring;
  3819         -    rl2RingPtr in_ring;
  3820         -    double *xx = NULL;
  3821         -    double *yy = NULL;
  3822         -    int iv;
  3823         -    double x;
  3824         -    double y;
  3825         -
  3826         -    *points = 0;
  3827         -    *x_array = NULL;
  3828         -    *y_array = NULL;
  3829         -    if (ring == NULL)
  3830         -	goto error;
  3831         -
  3832         -    aux_ring = rl2_ring_to_image (ring, height, minx, miny, x_res, y_res);
  3833         -    if (aux_ring == NULL)
  3834         -	goto error;
  3835         -    in_ring = aux_ring;
  3836         -    if (generalize_line)
  3837         -      {
  3838         -	  geom = do_generalize_ring (handle, in_ring, generalize_factor);
  3839         -	  if (geom == NULL)
  3840         -	      goto error;
  3841         -	  pg = geom->first_polygon;
  3842         -	  if (pg == NULL)
  3843         -	      goto error;
  3844         -	  in_ring = pg->exterior;
  3845         -	  if (in_ring == NULL)
  3846         -	      goto error;
  3847         -      }
  3848         -    if (perpendicular_offset != 0.0)
  3849         -      {
  3850         -	  geom2 = do_buffered_ring (handle, in_ring, perpendicular_offset);
  3851         -	  if (geom2 == NULL)
  3852         -	      goto error;
  3853         -	  pg = geom2->first_polygon;
  3854         -	  if (pg == NULL)
  3855         -	      goto error;
  3856         -	  in_ring = pg->exterior;
  3857         -	  if (in_ring == NULL)
  3858         -	      goto error;
  3859         -      }
  3860         -
  3861         -/* allocating the X and Y arrays */
  3862         -    if (in_ring->points < 2)
  3863         -	goto error;
  3864         -    xx = malloc (sizeof (double) * in_ring->points);
  3865         -    yy = malloc (sizeof (double) * in_ring->points);
  3866         -    if (xx == NULL || yy == NULL)
  3867         -      {
  3868         -	  if (xx != NULL)
  3869         -	      free (xx);
  3870         -	  if (yy != NULL)
  3871         -	      free (yy);
  3872         -	  goto error;
  3873         -      }
  3874         -    for (iv = 0; iv < in_ring->points; iv++)
  3875         -      {
  3876         -	  /* populating the X and Y arrays */
  3877         -	  rl2GetPoint (in_ring->coords, iv, &x, &y);
  3878         -	  *(xx + iv) = x;
  3879         -	  *(yy + iv) = y;
  3880         -      }
  3881         -    *points = in_ring->points;
  3882         -    *x_array = xx;
  3883         -    *y_array = yy;
  3884         -
  3885         -  error:
  3886         -    if (aux_ring)
  3887         -	rl2DestroyRing (aux_ring);
  3888         -    if (geom)
  3889         -	rl2_destroy_geometry (geom);
  3890         -    if (geom2)
  3891         -	rl2_destroy_geometry (geom2);
  3892         -}
  3893         -
  3894   3126   static void
  3895   3127   draw_labels (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  3896         -	     const void *priv_data, rl2PrivTextSymbolizerPtr sym, int height,
  3897         -	     double minx, double miny, double maxx, double maxy, double x_res,
  3898         -	     double y_res, rl2GeometryPtr geom, rl2PrivVariantValuePtr value)
         3128  +	     rl2PrivTextSymbolizerPtr sym, int height, double minx, double miny,
         3129  +	     double x_res, double y_res, rl2GeometryPtr geom,
         3130  +	     rl2PrivVariantValuePtr value)
  3899   3131   {
  3900   3132   /* drawing TextLabels */
  3901   3133       rl2GraphicsFontPtr font = NULL;
  3902   3134       char *dummy = NULL;
  3903   3135       const char *label = NULL;
  3904   3136       int font_style;
  3905   3137       int font_weight;
  3906   3138       double opacity;
  3907   3139       unsigned char norm_opacity;
  3908   3140       rl2PointPtr point;
  3909   3141       rl2LinestringPtr line;
  3910   3142       rl2PolygonPtr polyg;
  3911         -    double rotation = 0.0;
  3912         -    double anchor_point_x = 0.0;
  3913         -    double anchor_point_y = 0.0;
  3914         -    double displacement_x = 0.0;
  3915         -    double displacement_y = 0.0;
  3916         -    double perpendicular_offset = 0.0;
  3917         -    int is_repeated = 0;
  3918         -    double initial_gap = 0.0;
  3919         -    double gap = 0.0;
  3920         -    int is_aligned = 0;
  3921         -    int generalize_line = 0;
  3922         -    int i;
  3923   3143   
  3924   3144   /* preparing the Text */
  3925   3145       if (value->sqlite3_type == SQLITE_INTEGER)
  3926   3146         {
  3927   3147   	  dummy = sqlite3_malloc (1024);
  3928   3148   #if defined(_WIN32) && !defined(__MINGW32__)
  3929   3149   	  sprintf (dummy, "%I64d", value->int_value);
................................................................................
  3962   3182   	  font_weight = RL2_FONTWEIGHT_BOLD;
  3963   3183   	  break;
  3964   3184         case RL2_FONT_WEIGHT_NORMAL:
  3965   3185         default:
  3966   3186   	  font_weight = RL2_FONTWEIGHT_NORMAL;
  3967   3187   	  break;
  3968   3188         };
  3969         -    for (i = 0; i < RL2_MAX_FONT_FAMILIES; i++)
  3970         -      {
  3971         -	  const char *facename = sym->font_families[i];
  3972         -	  if (facename != NULL)
  3973         -	      font =
  3974         -		  rl2_search_TrueType_font (handle, priv_data, facename,
  3975         -					    sym->font_size);
  3976         -	  if (font != NULL)
  3977         -	      break;
  3978         -      }
  3979         -    if (font == NULL)
  3980         -      {
  3981         -	  /* defaulting to a toy font */
  3982         -	  font =
  3983         -	      rl2_graph_create_toy_font (NULL, sym->font_size, font_style,
  3984         -					 font_weight);
  3985         -      }
         3189  +    font =
         3190  +	rl2_graph_create_toy_font (NULL, sym->font_size, font_style,
         3191  +				   font_weight);
  3986   3192       if (font == NULL)
  3987   3193   	goto stop;
  3988   3194       if (sym->fill != NULL)
  3989   3195         {
  3990   3196   	  if (sym->fill->opacity <= 0.0)
  3991   3197   	      norm_opacity = 0;
  3992   3198   	  else if (sym->fill->opacity >= 1.0)
................................................................................
  4017   3223   		    norm_opacity = 0;
  4018   3224   		else if (opacity >= 255.0)
  4019   3225   		    norm_opacity = 255;
  4020   3226   		else
  4021   3227   		    norm_opacity = opacity;
  4022   3228   	    }
  4023   3229   	  rl2_graph_font_set_halo (font, sym->halo->radius,
  4024         -				   sym->halo->fill->red,
  4025         -				   sym->halo->fill->green,
         3230  +				   sym->halo->fill->red, sym->halo->fill->green,
  4026   3231   				   sym->halo->fill->blue, norm_opacity);
  4027   3232         }
  4028   3233       rl2_graph_set_font (ctx, font);
  4029   3234   
  4030         -    if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT)
  4031         -      {
  4032         -	  /* retrieving eventual Point Placement arguments */
  4033         -	  rl2PrivPointPlacementPtr ptpl =
  4034         -	      (rl2PrivPointPlacementPtr) (sym->label_placement);
  4035         -	  if (ptpl != NULL)
  4036         -	    {
  4037         -		anchor_point_x = ptpl->anchor_point_x;
  4038         -		anchor_point_y = ptpl->anchor_point_y;
  4039         -		displacement_x = ptpl->displacement_x;
  4040         -		displacement_y = ptpl->displacement_y;
  4041         -		rotation = ptpl->rotation;
  4042         -	    }
  4043         -      }
  4044         -    else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE)
         3235  +    polyg = geom->first_polygon;
         3236  +    while (polyg)
  4045   3237         {
  4046         -	  /* retrieving eventual Lineo Placement arguments */
  4047         -	  rl2PrivLinePlacementPtr lnpl =
  4048         -	      (rl2PrivLinePlacementPtr) (sym->label_placement);
  4049         -	  if (lnpl != NULL)
  4050         -	    {
  4051         -		perpendicular_offset = lnpl->perpendicular_offset;
  4052         -		is_repeated = lnpl->is_repeated;
  4053         -		initial_gap = lnpl->initial_gap;
  4054         -		gap = lnpl->gap;
  4055         -		is_aligned = lnpl->is_aligned;
  4056         -		generalize_line = lnpl->generalize_line;
  4057         -	    }
  4058         -      }
  4059         -
  4060         -    if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT)
  4061         -      {
  4062         -	  /* POINT PLACEMENT */
  4063         -	  rl2Point pt;
         3238  +	  /* drawing a POLYGON-based text label */
         3239  +	  double pre_x;
         3240  +	  double pre_y;
         3241  +	  double lbl_width = 0.0;
         3242  +	  double lbl_height = 0.0;
         3243  +	  double post_x;
         3244  +	  double post_y;
         3245  +	  double shift_x;
         3246  +	  double shift_y;
  4064   3247   	  double cx;
  4065   3248   	  double cy;
  4066   3249   	  double x;
  4067   3250   	  double y;
  4068         -
  4069         -	  polyg = geom->first_polygon;
  4070         -	  while (polyg)
         3251  +	  if (!label_get_centroid (handle, polyg, &cx, &cy))
  4071   3252   	    {
  4072         -		/* drawing a POLYGON-based text label */
  4073         -		if (!label_get_centroid (handle, polyg, &cx, &cy))
  4074         -		  {
  4075         -		      polyg = polyg->next;
  4076         -		      continue;
  4077         -		  }
  4078         -		pt.x = cx;
  4079         -		pt.y = cy;
  4080         -		if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
  4081         -		  {
  4082         -		      x = (cx - minx) / x_res;
  4083         -		      y = (double) height - ((cy - miny) / y_res);
  4084         -		      rl2_graph_draw_text (ctx, label, x + displacement_x,
  4085         -					   y - displacement_y, rotation,
  4086         -					   anchor_point_x, anchor_point_y);
  4087         -		  }
  4088   3253   		polyg = polyg->next;
         3254  +		continue;
  4089   3255   	    }
         3256  +	  x = (cx - minx) / x_res;
         3257  +	  y = (double) height - ((cy - miny) / y_res);
         3258  +	  rl2_graph_get_text_extent (ctx, label, &pre_x, &pre_y, &lbl_width,
         3259  +				     &lbl_height, &post_x, &post_y);
         3260  +	  shift_x = 0.0 - (lbl_width / 2.0);
         3261  +	  shift_y = 0.0 + (lbl_height / 2.0);
         3262  +	  rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0,
         3263  +			       0.0);
         3264  +	  polyg = polyg->next;
         3265  +      }
  4090   3266   
  4091         -	  line = geom->first_linestring;
  4092         -	  while (line)
  4093         -	    {
  4094         -		/* drawing a LINESTRING-based text label */
  4095         -		label_get_midpoint (handle, line, &cx, &cy);
  4096         -		pt.x = cx;
  4097         -		pt.y = cy;
  4098         -		if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
  4099         -		  {
  4100         -		      x = (cx - minx) / x_res;
  4101         -		      y = (double) height - ((cy - miny) / y_res);
  4102         -		      rl2_graph_draw_text (ctx, label, x + displacement_x,
  4103         -					   y - displacement_y, rotation,
  4104         -					   anchor_point_x, anchor_point_y);
  4105         -		  }
  4106         -		line = line->next;
  4107         -	    }
  4108         -
  4109         -	  point = geom->first_point;
  4110         -	  while (point)
  4111         -	    {
  4112         -		/* drawing a POINT-based text label */
  4113         -		if (point_bbox_matches (point, minx, miny, maxx, maxy))
  4114         -		  {
  4115         -		      double x = (point->x - minx) / x_res;
  4116         -		      double y = (double) height - ((point->y - miny) / y_res);
  4117         -		      rl2_graph_draw_text (ctx, label, x + displacement_x,
  4118         -					   y - displacement_y, rotation,
  4119         -					   anchor_point_x, anchor_point_y);
  4120         -		  }
  4121         -		point = point->next;
  4122         -	    }
  4123         -
  4124         -      }
  4125         -    else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE)
         3267  +    line = geom->first_linestring;
         3268  +    while (line)
  4126   3269         {
  4127         -	  /* LINE PLACEMENT */
  4128         -	  rl2Point pt;
  4129         -	  int ib;
         3270  +	  /* drawing a LINESTRING-based text label */
         3271  +	  double pre_x;
         3272  +	  double pre_y;
         3273  +	  double lbl_width = 0.0;
         3274  +	  double lbl_height = 0.0;
         3275  +	  double post_x;
         3276  +	  double post_y;
         3277  +	  double shift_x;
         3278  +	  double shift_y;
  4130   3279   	  double cx;
  4131   3280   	  double cy;
  4132   3281   	  double x;
  4133   3282   	  double y;
  4134         -	  double generalize_factor = 8.0;
  4135         -
  4136         -	  line = geom->first_linestring;
  4137         -	  while (line)
         3283  +	  label_get_midpoint (handle, line, &cx, &cy);
         3284  +	  if (!rl2_graph_get_text_extent
         3285  +	      (ctx, label, &pre_x, &pre_y, &lbl_width, &lbl_height, &post_x,
         3286  +	       &post_y))
  4138   3287   	    {
  4139         -		/* drawing a LINESTRING-based text label */
  4140         -		if (!is_aligned)
  4141         -		  {
  4142         -		      /* horizontal label aligned to center point */
  4143         -		      label_get_midpoint (handle, line, &cx, &cy);
  4144         -		      pt.x = cx;
  4145         -		      pt.y = cy;
  4146         -		      if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
  4147         -			{
  4148         -			    x = (cx - minx) / x_res;
  4149         -			    y = (double) height - ((cy - miny) / y_res);
  4150         -			    rl2_graph_draw_text (ctx, label, x, y, 0.0, 0.5,
  4151         -						 0.5);
  4152         -			}
  4153         -		  }
  4154         -		else
  4155         -		  {
  4156         -		      /* label is warped along the line */
  4157         -		      double *x_array = NULL;
  4158         -		      double *y_array = NULL;
  4159         -		      int points;
  4160         -		      if (linestring_bbox_matches
  4161         -			  (line, minx, miny, maxx, maxy))
  4162         -			{
  4163         -			    create_line_array_from_linestring (handle, line,
  4164         -							       perpendicular_offset,
  4165         -							       &points,
  4166         -							       &x_array,
  4167         -							       &y_array,
  4168         -							       generalize_line,
  4169         -							       generalize_factor,
  4170         -							       height, minx,
  4171         -							       miny, x_res,
  4172         -							       y_res);
  4173         -			    if (x_array != NULL && y_array != NULL)
  4174         -				rl2_graph_draw_warped_text (handle, ctx, label,
  4175         -							    points, x_array,
  4176         -							    y_array,
  4177         -							    initial_gap, gap,
  4178         -							    is_repeated);
  4179         -			    if (x_array)
  4180         -				free (x_array);
  4181         -			    if (y_array)
  4182         -				free (y_array);
  4183         -			}
  4184         -		  }
  4185   3288   		line = line->next;
         3289  +		continue;
  4186   3290   	    }
         3291  +	  x = (cx - minx) / x_res;
         3292  +	  y = (double) height - ((cy - miny) / y_res);
         3293  +	  shift_x = 0.0 - (lbl_width / 2.0);
         3294  +	  shift_y = 0.0 + (lbl_height / 2.0);
         3295  +	  rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0,
         3296  +			       0.0);
         3297  +	  line = line->next;
         3298  +      }
  4187   3299   
  4188         -	  polyg = geom->first_polygon;
  4189         -	  while (polyg)
  4190         -	    {
  4191         -		/* drawing a POLYGON-based text label */
  4192         -		rl2RingPtr ring = polyg->exterior;
  4193         -		/* exterior border */
  4194         -		if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
  4195         -		  {
  4196         -		      if (!is_aligned)
  4197         -			{
  4198         -			    /* horizontal label aligned to Ring's center point */
  4199         -			    label_get_ring_midpoint (handle, ring, &cx, &cy);
  4200         -			    pt.x = cx;
  4201         -			    pt.y = cy;
  4202         -			    if (point_bbox_matches
  4203         -				(&pt, minx, miny, maxx, maxy))
  4204         -			      {
  4205         -				  x = (cx - minx) / x_res;
  4206         -				  y = (double) height - ((cy - miny) / y_res);
  4207         -				  rl2_graph_draw_text (ctx, label, x, y, 0.0,
  4208         -						       0.5, 0.5);
  4209         -			      }
  4210         -			}
  4211         -		      else
  4212         -			{
  4213         -			    /* label is warped along the Ring */
  4214         -			    double *x_array = NULL;
  4215         -			    double *y_array = NULL;
  4216         -			    int points;
  4217         -			    if (ring_bbox_matches
  4218         -				(ring, minx, miny, maxx, maxy))
  4219         -			      {
  4220         -				  create_line_array_from_ring (handle, ring,
  4221         -							       perpendicular_offset,
  4222         -							       &points,
  4223         -							       &x_array,
  4224         -							       &y_array,
  4225         -							       generalize_line,
  4226         -							       generalize_factor,
  4227         -							       height, minx,
  4228         -							       miny, x_res,
  4229         -							       y_res);
  4230         -				  if (x_array != NULL && y_array != NULL)
  4231         -				    {
  4232         -					rl2_graph_draw_warped_text (handle, ctx,
  4233         -								    label,
  4234         -								    points,
  4235         -								    x_array,
  4236         -								    y_array,
  4237         -								    initial_gap,
  4238         -								    gap,
  4239         -								    is_repeated);
  4240         -				    }
  4241         -				  if (x_array)
  4242         -				      free (x_array);
  4243         -				  if (y_array)
  4244         -				      free (y_array);
  4245         -			      }
  4246         -			}
  4247         -		  }
  4248         -		else
  4249         -		  {
  4250         -		      /* if the exterior ring is invisible we'll ignore all internal rings */
  4251         -		      polyg = polyg->next;
  4252         -		      continue;
  4253         -		  }
  4254         -		for (ib = 0; ib < polyg->num_interiors; ib++)
  4255         -		  {
  4256         -		      /* interior borders */
  4257         -		      ring = polyg->interiors + ib;
  4258         -		      if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
  4259         -			{
  4260         -			    if (!is_aligned)
  4261         -			      {
  4262         -				  /* horizontal label aligned to Ring's center point */
  4263         -				  label_get_ring_midpoint (handle, ring, &cx,
  4264         -							   &cy);
  4265         -				  pt.x = cx;
  4266         -				  pt.y = cy;
  4267         -				  if (point_bbox_matches
  4268         -				      (&pt, minx, miny, maxx, maxy))
  4269         -				    {
  4270         -					x = (cx - minx) / x_res;
  4271         -					y = (double) height -
  4272         -					    ((cy - miny) / y_res);
  4273         -					rl2_graph_draw_text (ctx, label, x, y,
  4274         -							     0.0, 0.5, 0.5);
  4275         -				    }
  4276         -			      }
  4277         -			    else
  4278         -			      {
  4279         -				  /* label is warped along the Ring */
  4280         -				  double *x_array = NULL;
  4281         -				  double *y_array = NULL;
  4282         -				  int points;
  4283         -				  if (ring_bbox_matches
  4284         -				      (ring, minx, miny, maxx, maxy))
  4285         -				    {
  4286         -					create_line_array_from_ring (handle,
  4287         -								     ring,
  4288         -								     perpendicular_offset,
  4289         -								     &points,
  4290         -								     &x_array,
  4291         -								     &y_array,
  4292         -								     generalize_line,
  4293         -								     generalize_factor,
  4294         -								     height,
  4295         -								     minx, miny,
  4296         -								     x_res,
  4297         -								     y_res);
  4298         -					if (x_array != NULL && y_array != NULL)
  4299         -					    rl2_graph_draw_warped_text (handle,
  4300         -									ctx,
  4301         -									label,
  4302         -									points,
  4303         -									x_array,
  4304         -									y_array,
  4305         -									initial_gap,
  4306         -									gap,
  4307         -									is_repeated);
  4308         -					if (x_array)
  4309         -					    free (x_array);
  4310         -					if (y_array)
  4311         -					    free (y_array);
  4312         -				    }
  4313         -			      }
  4314         -			}
  4315         -		  }
  4316         -		polyg = polyg->next;
  4317         -	    }
         3300  +    point = geom->first_point;
         3301  +    while (point)
         3302  +      {
         3303  +	  /* drawing a POINT-based text label */
         3304  +	  double pre_x;
         3305  +	  double pre_y;
         3306  +	  double lbl_width = 0.0;
         3307  +	  double lbl_height = 0.0;
         3308  +	  double post_x;
         3309  +	  double post_y;
         3310  +	  double shift_x;
         3311  +	  double shift_y;
         3312  +	  double x = (point->x - minx) / x_res;
         3313  +	  double y = (double) height - ((point->y - miny) / y_res);
         3314  +	  rl2_graph_get_text_extent (ctx, label, &pre_x, &pre_y, &lbl_width,
         3315  +				     &lbl_height, &post_x, &post_y);
         3316  +	  shift_x = 0.0 - (lbl_width / 2.0);
         3317  +	  shift_y = 0.0 + (lbl_height / 2.0);
         3318  +	  rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0,
         3319  +			       0.0);
         3320  +	  point = point->next;
  4318   3321         }
  4319   3322   
  4320   3323   /* final cleanup - relasing resources */
  4321   3324     stop:
  4322   3325       if (dummy != NULL)
  4323   3326   	sqlite3_free (dummy);
  4324   3327       if (font != NULL)
  4325         -      {
  4326         -	  rl2_graph_release_font (ctx);
  4327         -	  rl2_graph_destroy_font (font);
  4328         -      }
         3328  +	rl2_graph_destroy_font (font);
  4329   3329   }
  4330   3330   
  4331   3331   RL2_PRIVATE void
  4332         -rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle, const void *priv_data,
         3332  +rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle,
  4333   3333   			 rl2VectorSymbolizerPtr symbolizer, int height,
  4334         -			 double minx, double miny, double maxx, double maxy,
  4335         -			 double x_res, double y_res, rl2GeometryPtr geom,
  4336         -			 rl2VariantArrayPtr variant)
         3334  +			 double minx, double miny, double x_res, double y_res,
         3335  +			 rl2GeometryPtr geom, rl2VariantArrayPtr variant)
  4337   3336   {
  4338   3337   /* drawing a vector feature on the current canvass */
  4339   3338       rl2PrivVectorSymbolizerItemPtr item;
  4340   3339       rl2GraphicsContextPtr ctx = (rl2GraphicsContextPtr) p_ctx;
  4341   3340       rl2PrivVectorSymbolizerPtr sym = (rl2PrivVectorSymbolizerPtr) symbolizer;
  4342   3341       rl2PrivVectorSymbolizerPtr default_symbolizer = NULL;
  4343   3342   
................................................................................
  4420   3419   	      default_symbolizer->last->next = item;
  4421   3420   	  default_symbolizer->last = item;
  4422   3421   	  sym = default_symbolizer;
  4423   3422         }
  4424   3423   
  4425   3424   /* we'll render all geometries first */
  4426   3425       if (geom->first_polygon != NULL)
  4427         -	draw_polygons (ctx, handle, sym, height, minx, miny, maxx, maxy,
  4428         -		       x_res, y_res, geom);
         3426  +	draw_polygons (ctx, handle, sym, height, minx, miny, x_res, y_res,
         3427  +		       geom);
  4429   3428       if (geom->first_linestring != NULL)
  4430         -	draw_lines (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
  4431         -		    y_res, geom);
         3429  +	draw_lines (ctx, handle, sym, height, minx, miny, x_res, y_res, geom);
  4432   3430       if (geom->first_point != NULL)
  4433         -	draw_points (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
  4434         -		     y_res, geom);
         3431  +	draw_points (ctx, handle, sym, height, minx, miny, x_res, y_res, geom);
  4435   3432   
  4436   3433       if (sym != NULL)
  4437   3434         {
  4438   3435   	  /* then we'll render any eventual TextSymbolizer */
  4439   3436   	  item = sym->first;
  4440   3437   	  while (item != NULL)
  4441   3438   	    {
................................................................................
  4445   3442   		      rl2PrivTextSymbolizerPtr text =
  4446   3443   			  (rl2PrivTextSymbolizerPtr) (item->symbolizer);
  4447   3444   		      if (text->label != NULL)
  4448   3445   			{
  4449   3446   			    int v;
  4450   3447   			    rl2PrivVariantArrayPtr var =
  4451   3448   				(rl2PrivVariantArrayPtr) variant;
  4452         -			    if (var != NULL)
         3449  +			    for (v = 0; v < var->count; v++)
  4453   3450   			      {
  4454         -				  for (v = 0; v < var->count; v++)
  4455         -				    {
  4456         -					rl2PrivVariantValuePtr val =
  4457         -					    *(var->array + v);
  4458         -					if (val == NULL)
  4459         -					    continue;
  4460         -					if (val->column_name == NULL)
  4461         -					    continue;
  4462         -					if (strcasecmp
  4463         -					    (text->label,
  4464         -					     val->column_name) != 0)
  4465         -					    continue;
  4466         -/* to be fixed - sometimes it raises a Cairo exception about Fonts 
  4467         -					draw_labels (ctx, handle, priv_data,
  4468         -						     text, height, minx, miny,
  4469         -						     maxx, maxy, x_res, y_res,
  4470         -						     geom, val);
  4471         -
  4472         -*/
  4473         -				    }
         3451  +				  rl2PrivVariantValuePtr val =
         3452  +				      *(var->array + v);
         3453  +				  if (val == NULL)
         3454  +				      continue;
         3455  +				  if (val->column_name == NULL)
         3456  +				      continue;
         3457  +				  if (strcasecmp (text->label, val->column_name)
         3458  +				      != 0)
         3459  +				      continue;
         3460  +				  draw_labels (ctx, handle, text, height, minx,
         3461  +					       miny, x_res, y_res, geom, val);
  4474   3462   			      }
  4475   3463   			}
  4476   3464   		  }
  4477   3465   		item = item->next;
  4478   3466   	    }
  4479   3467         }
  4480   3468   
  4481   3469       if (default_symbolizer != NULL)
  4482   3470   	rl2_destroy_vector_symbolizer (default_symbolizer);
  4483   3471   }
  4484         -
  4485         -RL2_PRIVATE int
  4486         -rl2_aux_default_image (unsigned int width, unsigned int height,
  4487         -		       unsigned char red, unsigned char green,
  4488         -		       unsigned char blue, int format, int transparent,
  4489         -		       int quality, unsigned char **ximage, int *ximage_sz)
  4490         -{
  4491         -/* creating a default image */
  4492         -    unsigned int x;
  4493         -    unsigned int y;
  4494         -    unsigned char *pixels = malloc (width * height * 3);
  4495         -    unsigned char *po = pixels;
  4496         -    unsigned char *mask = NULL;
  4497         -    unsigned char *pm;
  4498         -
  4499         -    *ximage = NULL;
  4500         -    *ximage_sz = 0;
  4501         -    if (pixels == NULL)
  4502         -	return 0;
  4503         -
  4504         -    mask = malloc (width * height);
  4505         -    if (mask == NULL)
  4506         -	goto error;
  4507         -    pm = mask;
  4508         -
  4509         -/* priming the image buffer to background color */
  4510         -    for (y = 0; y < height; y++)
  4511         -      {
  4512         -	  for (x = 0; x < width; x++)
  4513         -	    {
  4514         -		*po++ = red;
  4515         -		*po++ = green;
  4516         -		*po++ = blue;
  4517         -		if (mask != NULL)
  4518         -		    *pm++ = 0;
  4519         -	    }
  4520         -      }
  4521         -
  4522         -    if (format == RL2_OUTPUT_FORMAT_PNG)
  4523         -      {
  4524         -	  if (transparent)
  4525         -	    {
  4526         -		if (rl2_rgb_alpha_to_png
  4527         -		    (width, height, pixels, mask, ximage, ximage_sz,
  4528         -		     1.0) != RL2_OK)
  4529         -		    goto error;
  4530         -	    }
  4531         -	  else
  4532         -	    {
  4533         -		if (rl2_rgb_to_png (width, height, pixels, ximage, ximage_sz)
  4534         -		    != RL2_OK)
  4535         -		    goto error;
  4536         -	    }
  4537         -      }
  4538         -    else if (format == RL2_OUTPUT_FORMAT_JPEG)
  4539         -      {
  4540         -	  if (rl2_rgb_to_jpeg
  4541         -	      (width, height, pixels, quality, ximage, ximage_sz) != RL2_OK)
  4542         -	      goto error;
  4543         -      }
  4544         -    else if (format == RL2_OUTPUT_FORMAT_TIFF)
  4545         -      {
  4546         -	  if (rl2_rgb_to_tiff (width, height, pixels, ximage, ximage_sz) !=
  4547         -	      RL2_OK)
  4548         -	      goto error;
  4549         -      }
  4550         -    else
  4551         -	goto error;
  4552         -    free (pixels);
  4553         -    if (mask != NULL)
  4554         -	free (mask);
  4555         -    return 1;
  4556         -
  4557         -  error:
  4558         -    if (pixels != NULL)
  4559         -	free (pixels);
  4560         -    if (mask != NULL)
  4561         -	free (mask);
  4562         -    return 0;
  4563         -}

Changes to src/rl2charls.c.

    52     52   #endif
    53     53   
    54     54   #include "rasterlite2/rasterlite2.h"
    55     55   #include "rasterlite2_private.h"
    56     56   
    57     57   #ifndef OMIT_CHARLS		/* only if CharLS is enabled */
    58     58   
    59         -#ifdef __ANDROID__		/* Android specific */
    60         -#include <interface.h>
    61         -#else
    62     59   #include <CharLS/interface.h>
    63         -#endif
    64     60   
    65     61   static int
    66     62   endianness ()
    67     63   {
    68     64   /* checking if target CPU is a little-endian one */
    69     65       union cvt
    70     66       {
................................................................................
   282    278   		      p_out += num_bands;
   283    279   		  }
   284    280   	    }
   285    281         }
   286    282   }
   287    283   
   288    284   static void
   289         -from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width,
   290         -		   int height, int num_bands)
          285  +from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width, int height,
          286  +		   int num_bands)
   291    287   {
   292    288   /* rearranging pixels from separate LINE components - UINT 8 */
   293    289       int x;
   294    290       int y;
   295    291       int ib;
   296    292       unsigned char *p_in = in;
   297    293   
................................................................................
   453    449         {
   454    450   	  if (*sample_type == RL2_SAMPLE_UINT16)
   455    451   	      from_ilv_buffer_16 ((unsigned short *) (*pixels),
   456    452   				  (unsigned short *) out_buffer, *width,
   457    453   				  *height, *num_bands);
   458    454   	  else
   459    455   	      from_ilv_buffer_8 ((unsigned char *) (*pixels),
   460         -				 (unsigned char *) out_buffer, *width,
   461         -				 *height, *num_bands);
          456  +				 (unsigned char *) out_buffer, *width, *height,
          457  +				 *num_bands);
   462    458         }
   463    459       free (out_buffer);
   464    460       return RL2_OK;
   465    461   
   466    462     error:
   467    463       if (out_buffer != NULL)
   468    464   	free (out_buffer);
   469    465       return RL2_ERROR;
   470    466   }
   471    467   
   472    468   #endif /* end CharLS conditional */

Changes to src/rl2codec.c.

  2018   2018       *pixels_even = pix_even;
  2019   2019       *size_odd = o_size;
  2020   2020       *size_even = e_size;
  2021   2021       return 1;
  2022   2022   }
  2023   2023   
  2024   2024   RL2_DECLARE int
  2025         -rl2_raster_encode (rl2RasterPtr rst, int compression,
  2026         -		   unsigned char **blob_odd, int *blob_odd_sz,
  2027         -		   unsigned char **blob_even, int *blob_even_sz, int quality,
  2028         -		   int little_endian)
         2025  +rl2_raster_encode (rl2RasterPtr rst, int compression, unsigned char **blob_odd,
         2026  +		   int *blob_odd_sz, unsigned char **blob_even,
         2027  +		   int *blob_even_sz, int quality, int little_endian)
  2029   2028   {
  2030   2029   /* encoding a Raster into the internal RL2 binary format */
  2031   2030       rl2PrivRasterPtr raster = (rl2PrivRasterPtr) rst;
  2032   2031       int odd_rows;
  2033   2032       unsigned char *pixels_odd = NULL;
  2034   2033       int size_odd;
  2035   2034       int even_rows = 0;
................................................................................
  2123   2122   	|| compression == RL2_COMPRESSION_LZMA_NO)
  2124   2123         {
  2125   2124   	  /* preparing the pixels buffers */
  2126   2125   	  if (raster->sampleType == RL2_SAMPLE_1_BIT)
  2127   2126   	    {
  2128   2127   		/* packing 1-BIT data */
  2129   2128   		if (!pack_1bit_rows
  2130         -		    (raster, raster->rasterBuffer, &row_stride_odd,
  2131         -		     &pixels_odd, &size_odd))
         2129  +		    (raster, raster->rasterBuffer, &row_stride_odd, &pixels_odd,
         2130  +		     &size_odd))
  2132   2131   		    return RL2_ERROR;
  2133   2132   		odd_rows = raster->height;
  2134   2133   	    }
  2135   2134   	  else if (raster->sampleType == RL2_SAMPLE_2_BIT)
  2136   2135   	    {
  2137   2136   		/* packing 2-BIT data */
  2138   2137   		if (!pack_2bit_rows
................................................................................
  2148   2147   		    return RL2_ERROR;
  2149   2148   		odd_rows = raster->height;
  2150   2149   	    }
  2151   2150   	  else
  2152   2151   	    {
  2153   2152   		/* Odd/Even raster */
  2154   2153   		if (!odd_even_rows
  2155         -		    (raster, &odd_rows, &row_stride_odd, &pixels_odd,
  2156         -		     &size_odd, &even_rows, &row_stride_even, &pixels_even,
  2157         -		     &size_even, little_endian))
         2154  +		    (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd,
         2155  +		     &even_rows, &row_stride_even, &pixels_even, &size_even,
         2156  +		     little_endian))
  2158   2157   		    return RL2_ERROR;
  2159   2158   	    }
  2160   2159         }
  2161   2160       else if (compression == RL2_COMPRESSION_PNG)
  2162   2161         {
  2163   2162   	  if (raster->sampleType == RL2_SAMPLE_1_BIT
  2164   2163   	      || raster->sampleType == RL2_SAMPLE_2_BIT
................................................................................
  2166   2165   	    {
  2167   2166   		/* no special action is required */
  2168   2167   	    }
  2169   2168   	  else
  2170   2169   	    {
  2171   2170   		/* Odd/Even raster */
  2172   2171   		if (!odd_even_rows
  2173         -		    (raster, &odd_rows, &row_stride_odd, &pixels_odd,
  2174         -		     &size_odd, &even_rows, &row_stride_even, &pixels_even,
  2175         -		     &size_even, little_endian))
         2172  +		    (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd,
         2173  +		     &even_rows, &row_stride_even, &pixels_even, &size_even,
         2174  +		     little_endian))
  2176   2175   		    return RL2_ERROR;
  2177   2176   	    }
  2178   2177         }
  2179   2178       else if (compression == RL2_COMPRESSION_CHARLS)
  2180   2179         {
  2181   2180   	  /* Odd/Even raster */
  2182   2181   	  if (!odd_even_rows
................................................................................
  2468   2467   	  goto error;
  2469   2468   #endif /* end WebP conditional */
  2470   2469         }
  2471   2470       else if (compression == RL2_COMPRESSION_LOSSY_WEBP)
  2472   2471         {
  2473   2472   #ifndef OMIT_WEBP		/* only if WebP is enabled */
  2474   2473   	  /* compressing as lossy WEBP */
  2475         -	  if (rl2_raster_to_lossy_webp
  2476         -	      (rst, &compr_data, &compressed, quality) == RL2_OK)
         2474  +	  if (rl2_raster_to_lossy_webp (rst, &compr_data, &compressed, quality)
         2475  +	      == RL2_OK)
  2477   2476   	    {
  2478   2477   		/* ok, lossy WEBP compression was successful */
  2479   2478   		uncompressed = raster->width * raster->height * raster->nBands;
  2480   2479   		to_clean1 = compr_data;
  2481   2480   	    }
  2482   2481   	  else
  2483   2482   	      goto error;
................................................................................
  2588   2587   	  else
  2589   2588   	      goto error;
  2590   2589         }
  2591   2590       else if (compression == RL2_COMPRESSION_LOSSLESS_JP2)
  2592   2591         {
  2593   2592   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
  2594   2593   	  /* compressing as lossless Jpeg2000 */
  2595         -	  if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed)
  2596         -	      == RL2_OK)
         2594  +	  if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed) ==
         2595  +	      RL2_OK)
  2597   2596   	    {
  2598   2597   		/* ok, lossless Jpeg2000 compression was successful */
  2599   2598   		uncompressed = raster->width * raster->height * raster->nBands;
  2600   2599   		to_clean1 = compr_data;
  2601   2600   	    }
  2602   2601   	  else
  2603   2602   	      goto error;
................................................................................
  2720   2719   		      compressed = (int) zLen;
  2721   2720   		      compr_data = zip_buf;
  2722   2721   		      to_clean2 = zip_buf;
  2723   2722   		  }
  2724   2723   		else if (ret == Z_BUF_ERROR)
  2725   2724   		  {
  2726   2725   		      /* ZIP compression actually causes inflation: saving uncompressed data */
  2727         -		      if (rl2_delta_decode
  2728         -			  (pixels_even, size_even, delta_dist) != RL2_OK)
         2726  +		      if (rl2_delta_decode (pixels_even, size_even, delta_dist)
         2727  +			  != RL2_OK)
  2729   2728   			  goto error;
  2730   2729   		      uncompressed = size_even;
  2731   2730   		      compressed = size_even;
  2732   2731   		      compr_data = pixels_even;
  2733   2732   		      free (zip_buf);
  2734   2733   		      zip_buf = NULL;
  2735   2734   		  }
................................................................................
  3130   3129       *xnum_bands = num_bands;
  3131   3130       *xcompression = compression;
  3132   3131       *xcrc = crc;
  3133   3132       return 1;
  3134   3133   }
  3135   3134   
  3136   3135   static int
  3137         -check_blob_even (const unsigned char *blob, int blob_sz,
  3138         -		 unsigned short xwidth, unsigned short xheight,
  3139         -		 unsigned char xsample_type, unsigned char xpixel_type,
  3140         -		 unsigned char xnum_bands, unsigned char xcompression,
  3141         -		 uLong xcrc)
         3136  +check_blob_even (const unsigned char *blob, int blob_sz, unsigned short xwidth,
         3137  +		 unsigned short xheight, unsigned char xsample_type,
         3138  +		 unsigned char xpixel_type, unsigned char xnum_bands,
         3139  +		 unsigned char xcompression, uLong xcrc)
  3142   3140   {
  3143   3141   /* checking the EvenBlock for validity */
  3144   3142       const unsigned char *ptr;
  3145   3143       unsigned short width;
  3146   3144       unsigned short height;
  3147   3145       unsigned char sample_type;
  3148   3146       unsigned char pixel_type;
................................................................................
  3216   3214   check_scale (int scale, unsigned char sample_type, unsigned char compression,
  3217   3215   	     const unsigned char *blob_even)
  3218   3216   {
  3219   3217   /* checking if the encoded raster could be decoded at given scale */
  3220   3218       switch (scale)
  3221   3219         {
  3222   3220         case RL2_SCALE_1:
  3223         -	  if (sample_type == RL2_SAMPLE_1_BIT
  3224         -	      || sample_type == RL2_SAMPLE_2_BIT
         3221  +	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
  3225   3222   	      || sample_type == RL2_SAMPLE_4_BIT)
  3226   3223   	      ;
  3227   3224   	  else if (compression == RL2_COMPRESSION_JPEG
  3228   3225   		   || compression == RL2_COMPRESSION_LOSSY_WEBP
  3229   3226   		   || compression == RL2_COMPRESSION_LOSSLESS_WEBP
  3230   3227   		   || compression == RL2_COMPRESSION_CCITTFAX4
  3231   3228   		   || compression == RL2_COMPRESSION_LOSSY_JP2
................................................................................
  3233   3230   	    {
  3234   3231   		if (blob_even != NULL)
  3235   3232   		    return 0;
  3236   3233   	    }
  3237   3234   	  else if (blob_even == NULL)
  3238   3235   	      return 0;
  3239   3236   	  break;
  3240         -      case RL2_SCALE_2:
  3241         -      case RL2_SCALE_4:
  3242         -      case RL2_SCALE_8:
  3243         -	  break;
  3244         -      default:
  3245         -	  return 0;
  3246         -      };
  3247         -    switch (sample_type)
  3248         -      {
  3249         -      case RL2_SAMPLE_1_BIT:
  3250         -      case RL2_SAMPLE_2_BIT:
  3251         -      case RL2_SAMPLE_4_BIT:
  3252         -	  if (scale != RL2_SCALE_1)
  3253         -	      return 0;
  3254         -	  break;
  3255         -      };
  3256         -    return 1;
  3257         -}
  3258         -
  3259         -static int
  3260         -check_scale2 (int scale, unsigned char sample_type)
  3261         -{
  3262         -/* checking if the encoded raster could be decoded at given scale */
  3263         -    switch (scale)
  3264         -      {
  3265         -      case RL2_SCALE_1:
  3266   3237         case RL2_SCALE_2:
  3267   3238         case RL2_SCALE_4:
  3268   3239         case RL2_SCALE_8:
  3269   3240   	  break;
  3270   3241         default:
  3271   3242   	  return 0;
  3272   3243         };
................................................................................
  4219   4190   		else
  4220   4191   		    *p_out++ = *p_even++;
  4221   4192   	    }
  4222   4193         }
  4223   4194   }
  4224   4195   
  4225   4196   static void
  4226         -do_copy_uint32 (int swap, const unsigned int *p_odd,
  4227         -		const unsigned int *p_even, unsigned int *buf,
  4228         -		unsigned short width, unsigned short odd_rows,
  4229         -		unsigned short even_rows)
         4197  +do_copy_uint32 (int swap, const unsigned int *p_odd, const unsigned int *p_even,
         4198  +		unsigned int *buf, unsigned short width,
         4199  +		unsigned short odd_rows, unsigned short even_rows)
  4230   4200   {
  4231   4201   /* reassembling an UINT32 raster - scale 1:1 */
  4232   4202       int row;
  4233   4203       int col;
  4234   4204       unsigned int *p_out;
  4235   4205   
  4236   4206       p_out = buf;
................................................................................
  4908   4878       return 1;
  4909   4879   }
  4910   4880   
  4911   4881   RL2_DECLARE int
  4912   4882   rl2_is_valid_dbms_raster_tile (unsigned short level, unsigned int tile_width,
  4913   4883   			       unsigned int tile_height,
  4914   4884   			       const unsigned char *blob_odd, int blob_odd_sz,
  4915         -			       const unsigned char *blob_even,
  4916         -			       int blob_even_sz, unsigned char sample_type,
         4885  +			       const unsigned char *blob_even, int blob_even_sz,
         4886  +			       unsigned char sample_type,
  4917   4887   			       unsigned char pixel_type,
  4918   4888   			       unsigned char num_bands,
  4919   4889   			       unsigned char compression)
  4920   4890   {
  4921   4891   /* testing a serialized Raster Tile object for validity */
  4922   4892       unsigned int width;
  4923   4893       unsigned int height;
................................................................................
  4967   4937   	    {
  4968   4938   		/* small-PALETTE: expecting an RGB/PNG Pyramid tile */
  4969   4939   		if (xsample_type == RL2_SAMPLE_UINT8
  4970   4940   		    && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3
  4971   4941   		    && xcompression == RL2_COMPRESSION_PNG)
  4972   4942   		    return RL2_OK;
  4973   4943   	    }
  4974         -	  if (sample_type == RL2_SAMPLE_UINT8
  4975         -	      && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1)
         4944  +	  if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE
         4945  +	      && num_bands == 1)
  4976   4946   	    {
  4977   4947   		/* PALETTE 8bits: expecting an RGB/PNG Pyramid tile */
  4978   4948   		if (xsample_type == RL2_SAMPLE_UINT8
  4979   4949   		    && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3
  4980   4950   		    && xcompression == RL2_COMPRESSION_PNG)
  4981   4951   		    return RL2_OK;
  4982   4952   	    }
................................................................................
  5040   5010       if (!check_blob_odd
  5041   5011   	(blob_odd, blob_odd_sz, &width, &height, &sample_type, &pixel_type,
  5042   5012   	 &num_bands, &compression, &crc))
  5043   5013   	return NULL;
  5044   5014       if (blob_even != NULL)
  5045   5015         {
  5046   5016   	  if (!check_blob_even
  5047         -	      (blob_even, blob_even_sz, width, height, sample_type,
  5048         -	       pixel_type, num_bands, compression, crc))
         5017  +	      (blob_even, blob_even_sz, width, height, sample_type, pixel_type,
         5018  +	       num_bands, compression, crc))
  5049   5019   	      return NULL;
  5050   5020         }
  5051   5021       if (!check_scale (scale, sample_type, compression, blob_even))
  5052   5022   	return NULL;
  5053   5023   
  5054   5024       switch (pixel_type)
  5055   5025         {
................................................................................
  5176   5146   		const Bytef *in = pixels_even;
  5177   5147   		even_data = malloc (uncompressed_even);
  5178   5148   		if (even_data == NULL)
  5179   5149   		    goto error;
  5180   5150   		if (uncompress (even_data, &refLen, in, compressed_even) !=
  5181   5151   		    Z_OK)
  5182   5152   		    goto error;
  5183         -		if (rl2_delta_decode
  5184         -		    (even_data, uncompressed_even, delta_dist) != RL2_OK)
         5153  +		if (rl2_delta_decode (even_data, uncompressed_even, delta_dist)
         5154  +		    != RL2_OK)
  5185   5155   		    goto error;
  5186   5156   		pixels_even = even_data;
  5187   5157   	    }
  5188   5158         }
  5189   5159       if (compression == RL2_COMPRESSION_DEFLATE_NO
  5190   5160   	&& uncompressed_odd != compressed_odd)
  5191   5161         {
................................................................................
  5334   5304   	  int ret = RL2_ERROR;
  5335   5305   	  unsigned char pix_typ;
  5336   5306   	  switch (scale)
  5337   5307   	    {
  5338   5308   	    case RL2_SCALE_1:
  5339   5309   		ret =
  5340   5310   		    rl2_decode_jpeg_scaled (1, pixels_odd, compressed_odd,
  5341         -					    &width, &height, &pix_typ,
  5342         -					    &pixels, &pixels_sz);
         5311  +					    &width, &height, &pix_typ, &pixels,
         5312  +					    &pixels_sz);
  5343   5313   		break;
  5344   5314   	    case RL2_SCALE_2:
  5345   5315   		ret =
  5346   5316   		    rl2_decode_jpeg_scaled (2, pixels_odd, compressed_odd,
  5347         -					    &width, &height, &pix_typ,
  5348         -					    &pixels, &pixels_sz);
         5317  +					    &width, &height, &pix_typ, &pixels,
         5318  +					    &pixels_sz);
  5349   5319   		break;
  5350   5320   	    case RL2_SCALE_4:
  5351   5321   		ret =
  5352   5322   		    rl2_decode_jpeg_scaled (4, pixels_odd, compressed_odd,
  5353         -					    &width, &height, &pix_typ,
  5354         -					    &pixels, &pixels_sz);
         5323  +					    &width, &height, &pix_typ, &pixels,
         5324  +					    &pixels_sz);
  5355   5325   		break;
  5356   5326   	    case RL2_SCALE_8:
  5357   5327   		ret =
  5358   5328   		    rl2_decode_jpeg_scaled (8, pixels_odd, compressed_odd,
  5359         -					    &width, &height, &pix_typ,
  5360         -					    &pixels, &pixels_sz);
         5329  +					    &width, &height, &pix_typ, &pixels,
         5330  +					    &pixels_sz);
  5361   5331   		break;
  5362   5332   	    };
  5363   5333   	  if (ret != RL2_OK)
  5364   5334   	      goto error;
  5365   5335   	  goto done;
  5366   5336         }
  5367   5337       if (compression == RL2_COMPRESSION_LOSSY_WEBP
................................................................................
  5410   5380   	  goto error;
  5411   5381   #endif /* end WebP conditional */
  5412   5382         }
  5413   5383       if (compression == RL2_COMPRESSION_PNG)
  5414   5384         {
  5415   5385   	  /* decompressing from PNG */
  5416   5386   	  int ret;
  5417         -	  if (sample_type == RL2_SAMPLE_1_BIT
  5418         -	      || sample_type == RL2_SAMPLE_2_BIT
         5387  +	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
  5419   5388   	      || sample_type == RL2_SAMPLE_4_BIT)
  5420   5389   	    {
  5421   5390   		/* Palette or Grayscale - 1,2 or 4 bit isn't scalable */
  5422   5391   		if (scale != RL2_SCALE_1)
  5423   5392   		    goto error;
  5424   5393   		ret =
  5425   5394   		    rl2_decode_png (pixels_odd, compressed_odd,
  5426         -				    &width, &height, &sample_type,
  5427         -				    &pixel_type, &num_bands, &pixels,
  5428         -				    &pixels_sz, &mask, &mask_sz, &palette, 0);
         5395  +				    &width, &height, &sample_type, &pixel_type,
         5396  +				    &num_bands, &pixels, &pixels_sz, &mask,
         5397  +				    &mask_sz, &palette, 0);
  5429   5398   		if (ret != RL2_OK)
  5430   5399   		    goto error;
  5431   5400   		goto done;
  5432   5401   	    }
  5433   5402   	  else
  5434   5403   	    {
  5435   5404   		ret = rl2_decode_png (pixels_odd, compressed_odd,
................................................................................
  5440   5409   		if (ret != RL2_OK)
  5441   5410   		    goto error;
  5442   5411   		pixels_odd = odd_data;
  5443   5412   		if (scale == RL2_SCALE_1)
  5444   5413   		  {
  5445   5414   		      ret = rl2_decode_png (pixels_even, compressed_even,
  5446   5415   					    &width, &even_rows, &sample_type,
  5447         -					    &pixel_type, &num_bands,
  5448         -					    &even_data, &pixels_sz,
  5449         -					    &even_mask, &even_mask_sz,
  5450         -					    &palette2, 0);
         5416  +					    &pixel_type, &num_bands, &even_data,
         5417  +					    &pixels_sz, &even_mask,
         5418  +					    &even_mask_sz, &palette2, 0);
  5451   5419   		      if (ret != RL2_OK)
  5452   5420   			  goto error;
  5453   5421   		      rl2_destroy_palette (palette2);
  5454   5422   		  }
  5455   5423   		pixels_even = even_data;
  5456   5424   		if (odd_mask != NULL)
  5457   5425   		    free (odd_mask);
................................................................................
  5514   5482   	  int ret = RL2_ERROR;
  5515   5483   	  switch (scale)
  5516   5484   	    {
  5517   5485   	    case RL2_SCALE_1:
  5518   5486   		ret =
  5519   5487   		    rl2_decode_jpeg2000_scaled (1, pixels_odd, compressed_odd,
  5520   5488   						&width, &height, sample_type,
  5521         -						pixel_type, num_bands,
  5522         -						&pixels, &pixels_sz);
         5489  +						pixel_type, num_bands, &pixels,
         5490  +						&pixels_sz);
  5523   5491   		break;
  5524   5492   	    case RL2_SCALE_2:
  5525   5493   		ret =
  5526   5494   		    rl2_decode_jpeg2000_scaled (2, pixels_odd, compressed_odd,
  5527   5495   						&width, &height, sample_type,
  5528         -						pixel_type, num_bands,
  5529         -						&pixels, &pixels_sz);
         5496  +						pixel_type, num_bands, &pixels,
         5497  +						&pixels_sz);
  5530   5498   		break;
  5531   5499   	    case RL2_SCALE_4:
  5532   5500   		ret =
  5533   5501   		    rl2_decode_jpeg2000_scaled (4, pixels_odd, compressed_odd,
  5534   5502   						&width, &height, sample_type,
  5535         -						pixel_type, num_bands,
  5536         -						&pixels, &pixels_sz);
         5503  +						pixel_type, num_bands, &pixels,
         5504  +						&pixels_sz);
  5537   5505   		break;
  5538   5506   	    case RL2_SCALE_8:
  5539   5507   		ret =
  5540   5508   		    rl2_decode_jpeg2000_scaled (8, pixels_odd, compressed_odd,
  5541   5509   						&width, &height, sample_type,
  5542         -						pixel_type, num_bands,
  5543         -						&pixels, &pixels_sz);
         5510  +						pixel_type, num_bands, &pixels,
         5511  +						&pixels_sz);
  5544   5512   		break;
  5545   5513   	    };
  5546   5514   	  if (ret != RL2_OK)
  5547   5515   	      goto error;
  5548   5516   	  goto done;
  5549   5517   #else /* OpenJpeg is disabled */
  5550   5518   	  fprintf (stderr,
................................................................................
  5590   5558         {
  5591   5559   	  /* unpacking the mask */
  5592   5560   	  unsigned char *mask_pix;
  5593   5561   	  int mask_pix_sz;
  5594   5562   	  if (uncompressed_mask != (mask_width * mask_height))
  5595   5563   	      goto error;
  5596   5564   	  if (!unpack_rle
  5597         -	      (mask_width, mask_height, pixels_mask, compressed_mask,
  5598         -	       &mask_pix, &mask_pix_sz))
         5565  +	      (mask_width, mask_height, pixels_mask, compressed_mask, &mask_pix,
         5566  +	       &mask_pix_sz))
  5599   5567   	      goto error;
  5600   5568   	  if (!rescale_mask
  5601   5569   	      (scale, &mask_width, &mask_height, mask_pix, &mask, &mask_sz))
  5602   5570   	    {
  5603   5571   		free (mask_pix);
  5604   5572   		goto error;
  5605   5573   	    }
................................................................................
  5642   5610       if (palette != NULL)
  5643   5611   	rl2_destroy_palette (palette);
  5644   5612       if (ext_palette != NULL)
  5645   5613   	rl2_destroy_palette (ext_palette);
  5646   5614       return NULL;
  5647   5615   }
  5648   5616   
  5649         -RL2_PRIVATE rl2RasterPtr
  5650         -rl2_raster_decode_mask (int scale, const unsigned char *blob_odd,
  5651         -			int blob_odd_sz, int *status)
  5652         -{
  5653         -/* decoding from internal RL2 binary format to Raster - transparency mask only */
  5654         -    rl2RasterPtr raster;
  5655         -    unsigned int width;
  5656         -    unsigned int height;
  5657         -    unsigned short mask_width = 0;
  5658         -    unsigned short mask_height = 0;
  5659         -    unsigned char sample_type;
  5660         -    unsigned char pixel_type;
  5661         -    unsigned char num_bands;
  5662         -    unsigned char compression;
  5663         -    int compressed_odd;
  5664         -    int uncompressed_mask;
  5665         -    int compressed_mask;
  5666         -    uLong crc;
  5667         -    const unsigned char *pixels_mask = NULL;
  5668         -    unsigned char *pixels = NULL;
  5669         -    int pixels_sz;
  5670         -    unsigned char *mask = NULL;
  5671         -    int mask_sz = 0;
  5672         -    const unsigned char *ptr;
  5673         -    int endian;
  5674         -    int endian_arch = endianArch ();
  5675         -
  5676         -    *status = RL2_ERROR;
  5677         -    if (blob_odd == NULL)
  5678         -	return NULL;
  5679         -    if (!check_blob_odd
  5680         -	(blob_odd, blob_odd_sz, &width, &height, &sample_type, &pixel_type,
  5681         -	 &num_bands, &compression, &crc))
  5682         -	return NULL;
  5683         -    if (!check_scale2 (scale, sample_type))
  5684         -	return NULL;
  5685         -
  5686         -    endian = *(blob_odd + 2);
  5687         -    num_bands = *(blob_odd + 6);
  5688         -    ptr = blob_odd + 11;
  5689         -    ptr += 2;
  5690         -    ptr += 2;
  5691         -    ptr += 4;
  5692         -    compressed_odd = importU32 (ptr, endian, endian_arch);
  5693         -    ptr += 4;
  5694         -    uncompressed_mask = importU32 (ptr, endian, endian_arch);
  5695         -    ptr += 4;
  5696         -    compressed_mask = importU32 (ptr, endian, endian_arch);
  5697         -    ptr += 4;
  5698         -    if (*ptr++ != RL2_DATA_START)
  5699         -	return NULL;
  5700         -    if (uncompressed_mask > 0)
  5701         -      {
  5702         -	  /* retrieving the mask */
  5703         -	  ptr += compressed_odd;
  5704         -	  if (*ptr++ != RL2_DATA_END)
  5705         -	      return NULL;
  5706         -	  if (*ptr++ != RL2_MASK_START)
  5707         -	      return NULL;
  5708         -	  pixels_mask = ptr;
  5709         -	  mask_width = width;
  5710         -	  mask_height = height;
  5711         -	  ptr += compressed_mask;
  5712         -	  if (*ptr++ != RL2_MASK_END)
  5713         -	      return NULL;
  5714         -      }
  5715         -
  5716         -    if (pixels_mask == NULL)
  5717         -      {
  5718         -	  /* not existing Mask - not an error */
  5719         -	  *status = RL2_OK;
  5720         -	  return NULL;
  5721         -      }
  5722         -
  5723         -    /* unpacking the mask */
  5724         -    unsigned char *mask_pix;
  5725         -    int mask_pix_sz;
  5726         -    if (uncompressed_mask != (mask_width * mask_height))
  5727         -	goto error;
  5728         -    if (!unpack_rle
  5729         -	(mask_width, mask_height, pixels_mask, compressed_mask,
  5730         -	 &mask_pix, &mask_pix_sz))
  5731         -	goto error;
  5732         -    if (!rescale_mask
  5733         -	(scale, &mask_width, &mask_height, mask_pix, &mask, &mask_sz))
  5734         -      {
  5735         -	  free (mask_pix);
  5736         -	  goto error;
  5737         -      }
  5738         -    free (mask_pix);
  5739         -
  5740         -    /* will always return a full BLACK grayscale UINT8 raster */
  5741         -    pixels_sz = width * height;
  5742         -    pixels = malloc (pixels_sz);
  5743         -    memset (pixels, 0, pixels_sz);
  5744         -    raster =
  5745         -	rl2_create_raster (width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE,
  5746         -			   1, pixels, pixels_sz, NULL, mask, mask_sz, NULL);
  5747         -    if (raster == NULL)
  5748         -	goto error;
  5749         -    *status = RL2_OK;
  5750         -    return raster;
  5751         -  error:
  5752         -    if (pixels != NULL)
  5753         -	free (pixels);
  5754         -    if (mask != NULL)
  5755         -	free (mask);
  5756         -    *status = RL2_ERROR;
  5757         -    return NULL;
  5758         -}
  5759         -
  5760   5617   static void
  5761   5618   add_pooled_variance (rl2PrivBandStatisticsPtr band_in,
  5762   5619   		     rl2PrivBandStatisticsPtr band_out, double count)
  5763   5620   {
  5764   5621   /* adding a Pooled Variance item */
  5765   5622       rl2PoolVariancePtr pool = malloc (sizeof (rl2PoolVariance));
  5766   5623       pool->count = count;
................................................................................
  6026   5883         {
  6027   5884   	  ignore_no_data = 0;
  6028   5885   	  if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands)
  6029   5886   	      != RL2_OK)
  6030   5887   	      ignore_no_data = 1;
  6031   5888   	  if (nbands != num_bands)
  6032   5889   	      ignore_no_data = 1;
  6033         -	  if (sample_type == RL2_SAMPLE_1_BIT
  6034         -	      || sample_type == RL2_SAMPLE_2_BIT
         5890  +	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
  6035   5891   	      || sample_type == RL2_SAMPLE_4_BIT
  6036   5892   	      || sample_type == RL2_SAMPLE_UINT8)
  6037   5893   	      ;
  6038   5894   	  else
  6039   5895   	      ignore_no_data = 1;
  6040   5896         }
  6041   5897   
................................................................................
  6637   6493   	    }
  6638   6494         }
  6639   6495       compute_int32_histogram (width, height, pixels, mask, st, no_data);
  6640   6496   }
  6641   6497   
  6642   6498   static void
  6643   6499   compute_uint32_histogram (unsigned short width, unsigned short height,
  6644         -			  const unsigned int *pixels,
  6645         -			  const unsigned char *mask,
         6500  +			  const unsigned int *pixels, const unsigned char *mask,
  6646   6501   			  rl2PrivRasterStatisticsPtr st, rl2PixelPtr no_data)
  6647   6502   {
  6648   6503   /* computing INT16 tile histogram */
  6649   6504       int x;
  6650   6505       int y;
  6651   6506       const unsigned int *p_in = pixels;
  6652   6507       const unsigned char *p_msk = mask;

Changes to src/rl2dbms.c.

    75     75   			      unsigned char sample, unsigned char pixel,
    76     76   			      unsigned char num_bands,
    77     77   			      unsigned char compression, int quality,
    78     78   			      unsigned int tile_width,
    79     79   			      unsigned int tile_height, int srid,
    80     80   			      double x_res, double y_res,
    81     81   			      unsigned char *blob, int blob_sz,
    82         -			      unsigned char *blob_no_data,
    83         -			      int blob_no_data_sz, int strict_resolution,
    84         -			      int mixed_resolutions, int section_paths,
    85         -			      int section_md5, int section_summary)
           82  +			      unsigned char *blob_no_data, int blob_no_data_sz,
           83  +			      int strict_resolution, int mixed_resolutions,
           84  +			      int section_paths, int section_md5,
           85  +			      int section_summary)
    86     86   {
    87     87   /* inserting into "raster_coverages" */
    88     88       int ret;
    89     89       char *sql;
    90     90       sqlite3_stmt *stmt;
    91     91       const char *xsample = "UNKNOWN";
    92     92       const char *xpixel = "UNKNOWN";
................................................................................
   276    276   			   "\ty_resolution_1_4 DOUBLE,\n"
   277    277   			   "\tx_resolution_1_8 DOUBLE,\n"
   278    278   			   "\ty_resolution_1_8 DOUBLE)\n", xxcoverage);
   279    279       ret = sqlite3_exec (handle, sql, NULL, NULL, &sql_err);
   280    280       sqlite3_free (sql);
   281    281       if (ret != SQLITE_OK)
   282    282         {
   283         -	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n",
   284         -		   xxcoverage, sql_err);
          283  +	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", xxcoverage,
          284  +		   sql_err);
   285    285   	  sqlite3_free (sql_err);
   286    286   	  free (xxcoverage);
   287    287   	  return 0;
   288    288         }
   289    289       free (xxcoverage);
   290    290       return 1;
   291    291   }
................................................................................
   336    336       ret = sqlite3_exec (handle, sql, NULL, NULL, &sql_err);
   337    337       sqlite3_free (sql);
   338    338       free (xpk_name);
   339    339       free (xfk_name);
   340    340       free (xmother);
   341    341       if (ret != SQLITE_OK)
   342    342         {
   343         -	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n",
   344         -		   xxcoverage, sql_err);
          343  +	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", xxcoverage,
          344  +		   sql_err);
   345    345   	  sqlite3_free (sql_err);
   346    346   	  free (xxcoverage);
   347    347   	  return 0;
   348    348         }
   349    349       free (xxcoverage);
   350    350       return 1;
   351    351   }
................................................................................
  1244   1244       if (stmt != NULL)
  1245   1245   	sqlite3_finalize (stmt);
  1246   1246       return RL2_ERROR;
  1247   1247   }
  1248   1248   
  1249   1249   RL2_DECLARE int
  1250   1250   rl2_resolve_base_resolution_from_dbms (sqlite3 * handle, const char *coverage,
  1251         -				       int by_section,
  1252         -				       sqlite3_int64 section_id,
         1251  +				       int by_section, sqlite3_int64 section_id,
  1253   1252   				       double *x_res, double *y_res)
  1254   1253   {
  1255   1254   /* resolving the Base Resolution */
  1256   1255       int ret;
  1257   1256       char *sql;
  1258   1257       double xres;
  1259   1258       double yres;
................................................................................
  1440   1439       sqlite3_stmt *stmt = NULL;
  1441   1440   
  1442   1441       *duplicate = 0;
  1443   1442       table = sqlite3_mprintf ("%s_sections", coverage);
  1444   1443       xtable = rl2_double_quoted_sql (table);
  1445   1444       sqlite3_free (table);
  1446   1445       sql =
  1447         -	sqlite3_mprintf
  1448         -	("SELECT section_id FROM \"%s\" WHERE section_name = ?", xtable);
         1446  +	sqlite3_mprintf ("SELECT section_id FROM \"%s\" WHERE section_name = ?",
         1447  +			 xtable);
  1449   1448       free (xtable);
  1450   1449       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  1451   1450       sqlite3_free (sql);
  1452   1451       if (ret != SQLITE_OK)
  1453   1452         {
  1454   1453   	  printf ("SELECT section_id SQL error: %s\n", sqlite3_errmsg (handle));
  1455   1454   	  goto error;
................................................................................
  2387   2386   		  }
  2388   2387   		if (sqlite3_column_type (stmt, 15) == SQLITE_INTEGER)
  2389   2388   		  {
  2390   2389   		      section_summary = sqlite3_column_int (stmt, 15);
  2391   2390   		      ok_summary = 1;
  2392   2391   		  }
  2393   2392   		if (ok_sample && ok_pixel && ok_num_bands && ok_compression
  2394         -		    && ok_quality && ok_tile_width && ok_tile_height
  2395         -		    && ok_x_res && ok_y_res && ok_srid && ok_nodata
  2396         -		    && ok_strict && ok_mixed && ok_paths && ok_md5
  2397         -		    && ok_summary)
         2393  +		    && ok_quality && ok_tile_width && ok_tile_height && ok_x_res
         2394  +		    && ok_y_res && ok_srid && ok_nodata && ok_strict && ok_mixed
         2395  +		    && ok_paths && ok_md5 && ok_summary)
  2398   2396   		    ok = 1;
  2399   2397   	    }
  2400   2398         }
  2401   2399       sqlite3_finalize (stmt);
  2402   2400   
  2403   2401       if (!ok)
  2404   2402         {
................................................................................
  2422   2420   	  fprintf (stderr,
  2423   2421   		   "ERROR: unable to Georeference a Coverage Object supporting \"%s\"\n",
  2424   2422   		   coverage);
  2425   2423   	  rl2_destroy_coverage (cvg);
  2426   2424   	  return NULL;
  2427   2425         }
  2428   2426       if (rl2_set_coverage_policies
  2429         -	(cvg, strict_resolution, mixed_resolutions, section_paths,
  2430         -	 section_md5, section_summary) != RL2_OK)
         2427  +	(cvg, strict_resolution, mixed_resolutions, section_paths, section_md5,
         2428  +	 section_summary) != RL2_OK)
  2431   2429         {
  2432   2430   	  fprintf (stderr,
  2433   2431   		   "ERROR: unable to set the Policies on the Coverage Object supporting \"%s\"\n",
  2434   2432   		   coverage);
  2435   2433   	  rl2_destroy_coverage (cvg);
  2436   2434   	  return NULL;
  2437   2435         }
................................................................................
  2535   2533   	      free (f_table_name);
  2536   2534   	  if (f_geometry_column != NULL)
  2537   2535   	      free (f_geometry_column);
  2538   2536   	  return NULL;
  2539   2537         }
  2540   2538   
  2541   2539       vector =
  2542         -	rl2_create_vector_layer (f_table_name, f_geometry_column,
  2543         -				 geometry_type, srid, spatial_index);
         2540  +	rl2_create_vector_layer (f_table_name, f_geometry_column, geometry_type,
         2541  +				 srid, spatial_index);
  2544   2542       free (f_table_name);
  2545   2543       free (f_geometry_column);
  2546   2544       if (vector == NULL)
  2547   2545         {
  2548   2546   	  fprintf (stderr,
  2549   2547   		   "ERROR: unable to create a Vector Layer Object supporting \"%s\"\n",
  2550   2548   		   coverage);
................................................................................
  2601   2599       if (!has_nodata)
  2602   2600         {
  2603   2601   	  for (y = 0; y < height; y++)
  2604   2602   	    {
  2605   2603   		for (x = 0; x < width; x++)
  2606   2604   		  {
  2607   2605   		      for (b = 0; b < num_bands; b++)
  2608         -			  *p++ = 255;
         2606  +			  *p++ = 0;
  2609   2607   		  }
  2610   2608   	    }
  2611   2609         }
  2612   2610       else
  2613   2611         {
  2614   2612   	  for (y = 0; y < height; y++)
  2615   2613   	    {
................................................................................
  2890   2888   }
  2891   2889   
  2892   2890   static void
  2893   2891   do_decode_tile (rl2AuxDecoderPtr decoder)
  2894   2892   {
  2895   2893   /* servicing an AuxDecoder Tile request */
  2896   2894       decoder->raster =
  2897         -	(rl2PrivRasterPtr) rl2_raster_decode (decoder->scale,
  2898         -					      decoder->blob_odd,
         2895  +	(rl2PrivRasterPtr) rl2_raster_decode (decoder->scale, decoder->blob_odd,
  2899   2896   					      decoder->blob_odd_sz,
  2900   2897   					      decoder->blob_even,
  2901   2898   					      decoder->blob_even_sz,
  2902   2899   					      (rl2PalettePtr)
  2903   2900   					      (decoder->palette));
  2904   2901       if (decoder->blob_odd != NULL)
  2905   2902   	free (decoder->blob_odd);
................................................................................
  2927   2924   	  return;
  2928   2925         }
  2929   2926       rl2_destroy_raster ((rl2RasterPtr) (decoder->raster));
  2930   2927       decoder->raster = NULL;
  2931   2928       decoder->retcode = RL2_OK;
  2932   2929   }
  2933   2930   
  2934         -static void
  2935         -do_decode_masktile (rl2AuxMaskDecoderPtr decoder)
  2936         -{
  2937         -/* servicing an AuxMaskDecoder Tile request */
  2938         -    int status;
  2939         -    decoder->raster =
  2940         -	(rl2PrivRasterPtr) rl2_raster_decode_mask (decoder->scale,
  2941         -						   decoder->blob_odd,
  2942         -						   decoder->blob_odd_sz,
  2943         -						   &status);
  2944         -    if (decoder->blob_odd != NULL)
  2945         -	free (decoder->blob_odd);
  2946         -    decoder->blob_odd = NULL;
  2947         -    if (decoder->raster == NULL)
  2948         -      {
  2949         -	  decoder->retcode = status;
  2950         -	  return;
  2951         -      }
  2952         -    if (!rl2_copy_raw_mask
  2953         -	((rl2RasterPtr) (decoder->raster), decoder->maskbuf, decoder->width,
  2954         -	 decoder->height, decoder->x_res, decoder->y_res, decoder->minx,
  2955         -	 decoder->maxy, decoder->tile_minx, decoder->tile_maxy))
  2956         -      {
  2957         -	  decoder->retcode = RL2_ERROR;
  2958         -	  return;
  2959         -      }
  2960         -
  2961         -    rl2_destroy_raster ((rl2RasterPtr) (decoder->raster));
  2962         -    decoder->raster = NULL;
  2963         -    decoder->retcode = RL2_OK;
  2964         -}
  2965         -
  2966   2931   #ifdef _WIN32
  2967   2932   DWORD WINAPI
  2968   2933   doRunDecoderThread (void *arg)
  2969   2934   #else
  2970   2935   void *
  2971   2936   doRunDecoderThread (void *arg)
  2972   2937   #endif
  2973   2938   {
  2974   2939   /* threaded function: decoding a Tile */
  2975   2940       rl2AuxDecoderPtr decoder = (rl2AuxDecoderPtr) arg;
  2976   2941       do_decode_tile (decoder);
  2977   2942   #ifdef _WIN32
  2978         -    return 0;
  2979         -#else
  2980         -    pthread_exit (NULL);
  2981         -#endif
  2982         -}
  2983         -
  2984         -#ifdef _WIN32
  2985         -DWORD WINAPI
  2986         -doRunMaskDecoderThread (void *arg)
  2987         -#else
  2988         -void *
  2989         -doRunMaskDecoderThread (void *arg)
  2990         -#endif
  2991         -{
  2992         -/* threaded function: decoding a Tile */
  2993         -    rl2AuxMaskDecoderPtr decoder = (rl2AuxMaskDecoderPtr) arg;
  2994         -    do_decode_masktile (decoder);
  2995         -#ifdef _WIN32
  2996   2943       return 0;
  2997   2944   #else
  2998   2945       pthread_exit (NULL);
  2999   2946   #endif
  3000   2947   }
  3001   2948   
  3002   2949   static void
................................................................................
  3039   2986   	    }
  3040   2987         }
  3041   2988       if (!ok_prior)
  3042   2989         {
  3043   2990   	  /* failure: using standard priority */
  3044   2991   	  pthread_create (&thread_id, NULL, doRunDecoderThread, decoder);
  3045   2992         }
  3046         -    p_thread = malloc (sizeof (pthread_t));
  3047         -    *p_thread = thread_id;
  3048         -    decoder->opaque_thread_id = p_thread;
  3049         -#endif
  3050         -}
  3051         -
  3052         -static void
  3053         -start_mask_decoder_thread (rl2AuxMaskDecoderPtr decoder)
  3054         -{
  3055         -/* starting a concurrent thread */
  3056         -#ifdef _WIN32
  3057         -    HANDLE thread_handle;
  3058         -    HANDLE *p_thread;
  3059         -    DWORD dwThreadId;
  3060         -    thread_handle =
  3061         -	CreateThread (NULL, 0, doRunMaskDecoderThread, decoder, 0, &dwThreadId);
  3062         -    SetThreadPriority (thread_handle, THREAD_PRIORITY_IDLE);
  3063         -    p_thread = malloc (sizeof (HANDLE));
  3064         -    *p_thread = thread_handle;
  3065         -    decoder->opaque_thread_id = p_thread;
  3066         -#else
  3067         -    pthread_t thread_id;
  3068         -    pthread_t *p_thread;
  3069         -    int ok_prior = 0;
  3070         -    int policy;
  3071         -    int min_prio;
  3072         -    pthread_attr_t attr;
  3073         -    struct sched_param sp;
  3074         -    pthread_attr_init (&attr);
  3075         -    if (pthread_attr_setschedpolicy (&attr, SCHED_RR) == 0)
  3076         -      {
  3077         -	  /* attempting to set the lowest priority */
  3078         -	  if (pthread_attr_getschedpolicy (&attr, &policy) == 0)
  3079         -	    {
  3080         -		min_prio = sched_get_priority_min (policy);
  3081         -		sp.sched_priority = min_prio;
  3082         -		if (pthread_attr_setschedparam (&attr, &sp) == 0)
  3083         -		  {
  3084         -		      /* ok, setting the lowest priority */
  3085         -		      ok_prior = 1;
  3086         -		      pthread_create (&thread_id, &attr, doRunMaskDecoderThread,
  3087         -				      decoder);
  3088         -		  }
  3089         -	    }
  3090         -      }
  3091         -    if (!ok_prior)
  3092         -      {
  3093         -	  /* failure: using standard priority */
  3094         -	  pthread_create (&thread_id, NULL, doRunMaskDecoderThread, decoder);
  3095         -      }
  3096   2993       p_thread = malloc (sizeof (pthread_t));
  3097   2994       *p_thread = thread_id;
  3098   2995       decoder->opaque_thread_id = p_thread;
  3099   2996   #endif
  3100   2997   }
  3101   2998   
  3102   2999   static int
................................................................................
  3174   3071         }
  3175   3072       return 1;
  3176   3073   
  3177   3074     error:
  3178   3075       return 0;
  3179   3076   }
  3180   3077   
  3181         -static int
  3182         -do_run_mask_decoder_children (rl2AuxMaskDecoderPtr * thread_slots,
  3183         -			      int thread_count)
  3184         -{
  3185         -/* concurrent execution of all mask decoder children threads */
  3186         -    rl2AuxMaskDecoderPtr decoder;
  3187         -    int i;
  3188         -#ifdef _WIN32
  3189         -    HANDLE *handles;
  3190         -#endif
  3191         -
  3192         -    for (i = 0; i < thread_count; i++)
  3193         -      {
  3194         -	  /* starting all children threads */
  3195         -	  decoder = *(thread_slots + i);
  3196         -	  start_mask_decoder_thread (decoder);
  3197         -      }
  3198         -
  3199         -/* waiting until all child threads exit */
  3200         -#ifdef _WIN32
  3201         -    handles = malloc (sizeof (HANDLE) * thread_count);
  3202         -    for (i = 0; i < thread_count; i++)
  3203         -      {
  3204         -	  /* initializing the HANDLEs array */
  3205         -	  HANDLE *pOpaque;
  3206         -	  decoder = *(thread_slots + i);
  3207         -	  pOpaque = (HANDLE *) (decoder->opaque_thread_id);
  3208         -	  *(handles + i) = *pOpaque;
  3209         -      }
  3210         -    WaitForMultipleObjects (thread_count, handles, TRUE, INFINITE);
  3211         -    free (handles);
  3212         -#else
  3213         -    for (i = 0; i < thread_count; i++)
  3214         -      {
  3215         -	  pthread_t *pOpaque;
  3216         -	  decoder = *(thread_slots + i);
  3217         -	  pOpaque = (pthread_t *) (decoder->opaque_thread_id);
  3218         -	  pthread_join (*pOpaque, NULL);
  3219         -      }
  3220         -#endif
  3221         -
  3222         -/* all children threads have now finished: resuming the main thread */
  3223         -    for (i = 0; i < thread_count; i++)
  3224         -      {
  3225         -	  /* cleaning up a request slot */
  3226         -	  decoder = *(thread_slots + i);
  3227         -	  if (decoder->blob_odd != NULL)
  3228         -	      free (decoder->blob_odd);
  3229         -	  if (decoder->raster != NULL)
  3230         -	      rl2_destroy_raster ((rl2RasterPtr) (decoder->raster));
  3231         -	  if (decoder->opaque_thread_id != NULL)
  3232         -	      free (decoder->opaque_thread_id);
  3233         -	  decoder->blob_odd = NULL;
  3234         -	  decoder->blob_odd_sz = 0;
  3235         -	  decoder->raster = NULL;
  3236         -	  decoder->opaque_thread_id = NULL;
  3237         -      }
  3238         -    for (i = 0; i < thread_count; i++)
  3239         -      {
  3240         -	  /* checking for eventual errors */
  3241         -	  decoder = *(thread_slots + i);
  3242         -	  if (decoder->retcode != RL2_OK)
  3243         -	    {
  3244         -		fprintf (stderr, ERR_FRMT64, decoder->tile_id);
  3245         -		goto error;
  3246         -	    }
  3247         -      }
  3248         -    return 1;
  3249         -
  3250         -  error:
  3251         -    return 0;
  3252         -}
  3253         -
  3254         -static int
  3255         -rl2_load_dbms_masktiles (sqlite3 * handle, int max_threads, int by_section,
  3256         -			 sqlite3_int64 section_id, sqlite3_stmt * stmt_tiles,
  3257         -			 sqlite3_stmt * stmt_data, unsigned char *maskbuf,
  3258         -			 unsigned int width, unsigned int height, double x_res,
  3259         -			 double y_res, double minx, double miny, double maxx,
  3260         -			 double maxy, int level, int scale)
  3261         -{
  3262         -/* retrieving a transparenct mask from DBMS tiles */
  3263         -    rl2RasterPtr raster = NULL;
  3264         -    int ret;
  3265         -    rl2AuxMaskDecoderPtr aux = NULL;
  3266         -    rl2AuxMaskDecoderPtr decoder;
  3267         -    rl2AuxMaskDecoderPtr *thread_slots = NULL;
  3268         -    int thread_count;
  3269         -    int iaux;
  3270         -
  3271         -    if (max_threads < 1)
  3272         -	max_threads = 1;
  3273         -    if (max_threads > 64)
  3274         -	max_threads = 64;
  3275         -/* allocating the AuxDecoder array */
  3276         -    aux = malloc (sizeof (rl2AuxMaskDecoder) * max_threads);
  3277         -    if (aux == NULL)
  3278         -	return 0;
  3279         -    for (iaux = 0; iaux < max_threads; iaux++)
  3280         -      {
  3281         -	  /* initializing an empty AuxDecoder */
  3282         -	  decoder = aux + iaux;
  3283         -	  decoder->opaque_thread_id = NULL;
  3284         -	  decoder->blob_odd = NULL;
  3285         -	  decoder->blob_odd_sz = 0;
  3286         -	  decoder->maskbuf = maskbuf;
  3287         -	  decoder->width = width;
  3288         -	  decoder->height = height;
  3289         -	  decoder->x_res = x_res;
  3290         -	  decoder->y_res = y_res;
  3291         -	  decoder->scale = scale;
  3292         -	  decoder->minx = minx;
  3293         -	  decoder->maxy = maxy;
  3294         -	  decoder->raster = NULL;
  3295         -      }
  3296         -
  3297         -/* preparing the thread_slots stuct */
  3298         -    thread_slots = malloc (sizeof (rl2AuxMaskDecoderPtr) * max_threads);
  3299         -    for (thread_count = 0; thread_count < max_threads; thread_count++)
  3300         -	*(thread_slots + thread_count) = NULL;
  3301         -    thread_count = 0;
  3302         -
  3303         -/* binding the query args */
  3304         -    sqlite3_reset (stmt_tiles);
  3305         -    sqlite3_clear_bindings (stmt_tiles);
  3306         -    if (by_section)
  3307         -      {
  3308         -	  sqlite3_bind_int (stmt_tiles, 1, section_id);
  3309         -	  sqlite3_bind_int (stmt_tiles, 2, level);
  3310         -	  sqlite3_bind_double (stmt_tiles, 3, minx);
  3311         -	  sqlite3_bind_double (stmt_tiles, 4, miny);
  3312         -	  sqlite3_bind_double (stmt_tiles, 5, maxx);
  3313         -	  sqlite3_bind_double (stmt_tiles, 6, maxy);
  3314         -      }
  3315         -    else
  3316         -      {
  3317         -	  sqlite3_bind_int (stmt_tiles, 1, level);
  3318         -	  sqlite3_bind_double (stmt_tiles, 2, minx);
  3319         -	  sqlite3_bind_double (stmt_tiles, 3, miny);
  3320         -	  sqlite3_bind_double (stmt_tiles, 4, maxx);
  3321         -	  sqlite3_bind_double (stmt_tiles, 5, maxy);
  3322         -      }
  3323         -
  3324         -/* querying the tiles */
  3325         -    while (1)
  3326         -      {
  3327         -	  ret = sqlite3_step (stmt_tiles);
  3328         -	  if (ret == SQLITE_DONE)
  3329         -	      break;
  3330         -	  if (ret == SQLITE_ROW)
  3331         -	    {
  3332         -		int ok = 0;
  3333         -		const unsigned char *blob_odd = NULL;
  3334         -		int blob_odd_sz = 0;
  3335         -		sqlite3_int64 tile_id = sqlite3_column_int64 (stmt_tiles, 0);
  3336         -		double tile_minx = sqlite3_column_double (stmt_tiles, 1);
  3337         -		double tile_maxy = sqlite3_column_double (stmt_tiles, 2);
  3338         -		decoder = aux + thread_count;
  3339         -		decoder->tile_id = tile_id;
  3340         -		decoder->tile_minx = tile_minx;
  3341         -		decoder->tile_maxy = tile_maxy;
  3342         -
  3343         -		/* retrieving tile raw data from BLOBs */
  3344         -		sqlite3_reset (stmt_data);
  3345         -		sqlite3_clear_bindings (stmt_data);
  3346         -		sqlite3_bind_int64 (stmt_data, 1, tile_id);
  3347         -		ret = sqlite3_step (stmt_data);
  3348         -		if (ret == SQLITE_DONE)
  3349         -		    break;
  3350         -		if (ret == SQLITE_ROW)
  3351         -		  {
  3352         -		      /* decoding a Tile - may be by using concurrent multithreading */
  3353         -		      if (sqlite3_column_type (stmt_data, 0) == SQLITE_BLOB)
  3354         -			{
  3355         -			    blob_odd = sqlite3_column_blob (stmt_data, 0);
  3356         -			    blob_odd_sz = sqlite3_column_bytes (stmt_data, 0);
  3357         -			    decoder->blob_odd = malloc (blob_odd_sz);
  3358         -			    if (decoder->blob_odd == NULL)
  3359         -				goto error;
  3360         -			    memcpy (decoder->blob_odd, blob_odd, blob_odd_sz);
  3361         -			    decoder->blob_odd_sz = blob_odd_sz;
  3362         -			    ok = 1;
  3363         -			}
  3364         -		  }
  3365         -		else
  3366         -		  {
  3367         -		      fprintf (stderr,
  3368         -			       "SELECT tiles data; sqlite3_step() error: %s\n",
  3369         -			       sqlite3_errmsg (handle));
  3370         -		      goto error;
  3371         -		  }
  3372         -		if (!ok)
  3373         -		  {
  3374         -		      if (decoder->blob_odd != NULL)
  3375         -			  free (decoder->blob_odd);
  3376         -		      decoder->blob_odd = NULL;
  3377         -		      decoder->blob_odd_sz = 0;
  3378         -		  }
  3379         -		else
  3380         -		  {
  3381         -		      /* processing a Tile request (may be under parallel execution) */
  3382         -		      if (max_threads > 1)
  3383         -			{
  3384         -			    /* adopting a multithreaded strategy */
  3385         -			    *(thread_slots + thread_count) = decoder;
  3386         -			    thread_count++;
  3387         -			    if (thread_count == max_threads)
  3388         -			      {
  3389         -				  if (!do_run_mask_decoder_children
  3390         -				      (thread_slots, thread_count))
  3391         -				      goto error;
  3392         -				  thread_count = 0;
  3393         -			      }
  3394         -			}
  3395         -		      else
  3396         -			{
  3397         -			    /* single thread execution */
  3398         -			    do_decode_masktile (decoder);
  3399         -			    if (decoder->retcode != RL2_OK)
  3400         -			      {
  3401         -				  fprintf (stderr, ERR_FRMT64, tile_id);
  3402         -				  goto error;
  3403         -			      }
  3404         -			}
  3405         -		  }
  3406         -	    }
  3407         -	  else
  3408         -	    {
  3409         -		fprintf (stderr,
  3410         -			 "SELECT tiles; sqlite3_step() error: %s\n",
  3411         -			 sqlite3_errmsg (handle));
  3412         -		goto error;
  3413         -	    }
  3414         -      }
  3415         -    if (max_threads > 1 && thread_count > 0)
  3416         -      {
  3417         -	  /* launching the last multithreaded burst */
  3418         -	  if (!do_run_mask_decoder_children (thread_slots, thread_count))
  3419         -	      goto error;
  3420         -      }
  3421         -
  3422         -    free (aux);
  3423         -    free (thread_slots);
  3424         -    return 1;
  3425         -
  3426         -  error:
  3427         -    if (aux != NULL)
  3428         -      {
  3429         -	  /* AuxMaskDecoder cleanup */
  3430         -	  for (iaux = 0; iaux < max_threads; iaux++)
  3431         -	    {
  3432         -		decoder = aux + iaux;
  3433         -		if (decoder->blob_odd != NULL)
  3434         -		    free (decoder->blob_odd);
  3435         -		if (decoder->raster != NULL)
  3436         -		    rl2_destroy_raster ((rl2RasterPtr) (decoder->raster));
  3437         -		if (decoder->opaque_thread_id != NULL)
  3438         -		    free (decoder->opaque_thread_id);
  3439         -	    }
  3440         -	  free (aux);
  3441         -      }
  3442         -    if (thread_slots != NULL)
  3443         -	free (thread_slots);
  3444         -    if (raster != NULL)
  3445         -	rl2_destroy_raster (raster);
  3446         -    return 0;
  3447         -}
  3448         -
  3449   3078   static int
  3450   3079   rl2_load_dbms_tiles_common (sqlite3 * handle, int max_threads,
  3451         -			    sqlite3_stmt * stmt_tiles,
  3452         -			    sqlite3_stmt * stmt_data, unsigned char *outbuf,
  3453         -			    unsigned int width, unsigned int height,
  3454         -			    unsigned char sample_type,
         3080  +			    sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data,
         3081  +			    unsigned char *outbuf, unsigned int width,
         3082  +			    unsigned int height, unsigned char sample_type,
  3455   3083   			    unsigned char num_bands, unsigned char auto_ndvi,
  3456   3084   			    unsigned char red_band_index,
  3457   3085   			    unsigned char nir_band_index, double x_res,
  3458   3086   			    double y_res, double minx, double maxy, int scale,
  3459   3087   			    rl2PalettePtr palette, rl2PixelPtr no_data,
  3460   3088   			    rl2RasterSymbolizerPtr style,
  3461   3089   			    rl2RasterStatisticsPtr stats)
................................................................................
  4076   3704   		  {
  4077   3705   		      fprintf (stderr,
  4078   3706   			       "SELECT tiles data; sqlite3_step() error: %s\n",
  4079   3707   			       sqlite3_errmsg (handle));
  4080   3708   		      goto error;
  4081   3709   		  }
  4082   3710   		raster =
  4083         -		    rl2_raster_decode (scale, blob_odd, blob_odd_sz,
  4084         -				       blob_even, blob_even_sz, NULL);
         3711  +		    rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even,
         3712  +				       blob_even_sz, NULL);
  4085   3713   		if (raster == NULL)
  4086   3714   		  {
  4087   3715   		      fprintf (stderr, ERR_FRMT64, tile_id);
  4088   3716   		      goto error;
  4089   3717   		  }
  4090   3718   		if (!copy_triple_band_raw_pixels
  4091   3719   		    (raster, outbuf, width, height, red_band, green_band,
  4092         -		     blue_band, x_res, y_res, minx, maxy, tile_minx,
  4093         -		     tile_maxy, no_data))
         3720  +		     blue_band, x_res, y_res, minx, maxy, tile_minx, tile_maxy,
         3721  +		     no_data))
  4094   3722   		    goto error;
  4095   3723   		rl2_destroy_raster (raster);
  4096   3724   		raster = NULL;
  4097   3725   	    }
  4098   3726   	  else
  4099   3727   	    {
  4100   3728   		fprintf (stderr,
................................................................................
  4238   3866   
  4239   3867       return 1;
  4240   3868   }
  4241   3869   
  4242   3870   static int
  4243   3871   copy_mono_band_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf,
  4244   3872   			   unsigned int width, unsigned int height,
  4245         -			   unsigned char mono_band, double x_res,
  4246         -			   double y_res, double minx, double maxy,
  4247         -			   double tile_minx, double tile_maxy,
  4248         -			   rl2PixelPtr no_data)
         3873  +			   unsigned char mono_band, double x_res, double y_res,
         3874  +			   double minx, double maxy, double tile_minx,
         3875  +			   double tile_maxy, rl2PixelPtr no_data)
  4249   3876   {
  4250   3877   /* copying raw pixels into the output buffer */
  4251   3878       unsigned int tile_width;
  4252   3879       unsigned int tile_height;
  4253   3880       unsigned int x;
  4254   3881       unsigned int y;
  4255   3882       int out_x;
................................................................................
  4372   3999       return 1;
  4373   4000   }
  4374   4001   
  4375   4002   static int
  4376   4003   load_mono_band_dbms_tiles (sqlite3 * handle, sqlite3_stmt * stmt_tiles,
  4377   4004   			   sqlite3_stmt * stmt_data, unsigned char *outbuf,
  4378   4005   			   unsigned int width, unsigned int height,
  4379         -			   unsigned char mono_band, double x_res,
  4380         -			   double y_res, double minx, double miny,
  4381         -			   double maxx, double maxy, int level, int scale,
  4382         -			   rl2PixelPtr no_data)
         4006  +			   unsigned char mono_band, double x_res, double y_res,
         4007  +			   double minx, double miny, double maxx, double maxy,
         4008  +			   int level, int scale, rl2PixelPtr no_data)
  4383   4009   {
  4384   4010   /* retrieving a full image from DBMS tiles */
  4385   4011       rl2RasterPtr raster = NULL;
  4386   4012       int ret;
  4387   4013   
  4388   4014   /* binding the query args */
  4389   4015       sqlite3_reset (stmt_tiles);
................................................................................
  4434   4060   		  {
  4435   4061   		      fprintf (stderr,
  4436   4062   			       "SELECT tiles data; sqlite3_step() error: %s\n",
  4437   4063   			       sqlite3_errmsg (handle));
  4438   4064   		      goto error;
  4439   4065   		  }
  4440   4066   		raster =
  4441         -		    rl2_raster_decode (scale, blob_odd, blob_odd_sz,
  4442         -				       blob_even, blob_even_sz, NULL);
         4067  +		    rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even,
         4068  +				       blob_even_sz, NULL);
  4443   4069   		if (raster == NULL)
  4444   4070   		  {
  4445   4071   		      fprintf (stderr, ERR_FRMT64, tile_id);
  4446   4072   		      goto error;
  4447   4073   		  }
  4448   4074   		if (!copy_mono_band_raw_pixels
  4449   4075   		    (raster, outbuf, width, height, mono_band, x_res, y_res,
................................................................................
  4471   4097   
  4472   4098   RL2_PRIVATE int
  4473   4099   rl2_load_dbms_tiles (sqlite3 * handle, int max_threads,
  4474   4100   		     sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data,
  4475   4101   		     unsigned char *outbuf, unsigned int width,
  4476   4102   		     unsigned int height, unsigned char sample_type,
  4477   4103   		     unsigned char num_bands, unsigned char auto_ndvi,
  4478         -		     unsigned char red_band_index,
  4479         -		     unsigned char nir_band_index, double x_res, double y_res,
  4480         -		     double minx, double miny, double maxx, double maxy,
  4481         -		     int level, int scale, rl2PalettePtr palette,
  4482         -		     rl2PixelPtr no_data, rl2RasterSymbolizerPtr style,
  4483         -		     rl2RasterStatisticsPtr stats)
         4104  +		     unsigned char red_band_index, unsigned char nir_band_index,
         4105  +		     double x_res, double y_res, double minx, double miny,
         4106  +		     double maxx, double maxy, int level, int scale,
         4107  +		     rl2PalettePtr palette, rl2PixelPtr no_data,
         4108  +		     rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats)
  4484   4109   {
  4485   4110   /* binding the query args */
  4486   4111       sqlite3_reset (stmt_tiles);
  4487   4112       sqlite3_clear_bindings (stmt_tiles);
  4488   4113       sqlite3_bind_int (stmt_tiles, 1, level);
  4489   4114       sqlite3_bind_double (stmt_tiles, 2, minx);
  4490   4115       sqlite3_bind_double (stmt_tiles, 3, miny);
................................................................................
  4501   4126   
  4502   4127   RL2_PRIVATE int
  4503   4128   rl2_load_dbms_tiles_section (sqlite3 * handle, int max_threads,
  4504   4129   			     sqlite3_int64 section_id,
  4505   4130   			     sqlite3_stmt * stmt_tiles,
  4506   4131   			     sqlite3_stmt * stmt_data, unsigned char *outbuf,
  4507   4132   			     unsigned int width, unsigned int height,
  4508         -			     unsigned char sample_type,
  4509         -			     unsigned char num_bands, unsigned char auto_ndvi,
         4133  +			     unsigned char sample_type, unsigned char num_bands,
         4134  +			     unsigned char auto_ndvi,
  4510   4135   			     unsigned char red_band_index,
  4511   4136   			     unsigned char nir_band_index, double x_res,
  4512         -			     double y_res, double minx, double miny,
  4513         -			     double maxx, double maxy, int level, int scale,
         4137  +			     double y_res, double minx, double maxy, int scale,
  4514   4138   			     rl2PalettePtr palette, rl2PixelPtr no_data)
  4515   4139   {
  4516   4140   /* binding the query args */
  4517   4141       sqlite3_reset (stmt_tiles);
  4518   4142       sqlite3_clear_bindings (stmt_tiles);
  4519   4143       sqlite3_bind_int (stmt_tiles, 1, section_id);
  4520         -    sqlite3_bind_int (stmt_tiles, 2, level);
  4521         -    sqlite3_bind_double (stmt_tiles, 3, minx);
  4522         -    sqlite3_bind_double (stmt_tiles, 4, miny);
  4523         -    sqlite3_bind_double (stmt_tiles, 5, maxx);
  4524         -    sqlite3_bind_double (stmt_tiles, 6, maxy);
  4525   4144   
  4526   4145       if (!rl2_load_dbms_tiles_common
  4527   4146   	(handle, max_threads, stmt_tiles, stmt_data, outbuf, width, height,
  4528   4147   	 sample_type, num_bands, auto_ndvi, red_band_index, nir_band_index,
  4529   4148   	 x_res, y_res, minx, maxy, scale, palette, no_data, NULL, NULL))
  4530   4149   	return 0;
  4531   4150       return 1;
................................................................................
  4813   4432   	return scale_factor;
  4814   4433       for (i = 1; i <= rows; i++)
  4815   4434   	scale_factor = 11.1120;
  4816   4435       sqlite3_free_table (results);
  4817   4436       return scale_factor;
  4818   4437   }
  4819   4438   
  4820         -RL2_DECLARE int
  4821         -rl2_get_raw_raster_mask (sqlite3 * handle, int max_threads,
  4822         -			 rl2CoveragePtr cvg, unsigned int width,
  4823         -			 unsigned int height, double minx, double miny,
  4824         -			 double maxx, double maxy, double x_res,
  4825         -			 double y_res, unsigned char **mask, int *mask_size)
  4826         -{
  4827         -/* attempting to return a transparency mask from the DBMS Coverage */
  4828         -    return rl2_get_raw_raster_mask_common (handle, max_threads,
  4829         -					   cvg, 0, 0, width, height, minx, miny,
  4830         -					   maxx, maxy, x_res, y_res, mask,
  4831         -					   mask_size);
  4832         -}
  4833         -
  4834         -RL2_DECLARE int
  4835         -rl2_get_section_raw_raster_mask (sqlite3 * handle, int max_threads,
  4836         -				 rl2CoveragePtr cvg,
  4837         -				 sqlite3_int64 section_id,
  4838         -				 unsigned int width,
  4839         -				 unsigned int height, double minx,
  4840         -				 double miny, double maxx, double maxy,
  4841         -				 double x_res, double y_res,
  4842         -				 unsigned char **mask, int *mask_size)
  4843         -{
  4844         -/* attempting to return a transparency mask from the DBMS Coverage */
  4845         -    return rl2_get_raw_raster_mask_common (handle, max_threads,
  4846         -					   cvg, 1, section_id, width, height,
  4847         -					   minx, miny, maxx, maxy, x_res, y_res,
  4848         -					   mask, mask_size);
  4849         -}
  4850         -
  4851         -RL2_PRIVATE int
  4852         -rl2_get_raw_raster_mask_common (sqlite3 * handle, int max_threads,
  4853         -				rl2CoveragePtr cvg, int by_section,
  4854         -				sqlite3_int64 section_id, unsigned int width,
  4855         -				unsigned int height, double minx, double miny,
  4856         -				double maxx, double maxy, double x_res,
  4857         -				double y_res, unsigned char **mask,
  4858         -				int *mask_size)
  4859         -{
  4860         -/* attempting to return a transparency mask from the DBMS Coverage */
  4861         -    const char *coverage;
  4862         -    unsigned char level;
  4863         -    unsigned char scale;
  4864         -    double xx_res = x_res;
  4865         -    double yy_res = y_res;
  4866         -    unsigned char *bufpix = NULL;
  4867         -    int bufpix_size;
  4868         -    char *xtiles;
  4869         -    char *xxtiles;
  4870         -    char *xdata;
  4871         -    char *xxdata;
  4872         -    char *sql;
  4873         -    sqlite3_stmt *stmt_tiles = NULL;
  4874         -    sqlite3_stmt *stmt_data = NULL;
  4875         -    int ret;
  4876         -
  4877         -    if (cvg == NULL || handle == NULL)
  4878         -	goto error;
  4879         -    coverage = rl2_get_coverage_name (cvg);
  4880         -    if (coverage == NULL)
  4881         -	goto error;
  4882         -    if (rl2_find_matching_resolution
  4883         -	(handle, cvg, by_section, section_id, &xx_res, &yy_res, &level,
  4884         -	 &scale) != RL2_OK)
  4885         -	goto error;
  4886         -
  4887         -    bufpix_size = width * height;
  4888         -    bufpix = malloc (bufpix_size);
  4889         -    if (bufpix == NULL)
  4890         -      {
  4891         -	  fprintf (stderr,
  4892         -		   "rl2_get_raw_raster_mask: Insufficient Memory !!!\n");
  4893         -	  goto error;
  4894         -      }
  4895         -
  4896         -/* preparing the "tiles" SQL query */
  4897         -    xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  4898         -    xxtiles = rl2_double_quoted_sql (xtiles);
  4899         -    if (by_section)
  4900         -      {
  4901         -	  /* only from a single Section */
  4902         -	  sql =
  4903         -	      sqlite3_mprintf
  4904         -	      ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  4905         -	       "FROM \"%s\" "
  4906         -	       "WHERE section_id = ? AND pyramid_level = ? AND ROWID IN ( "
  4907         -	       "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
  4908         -	       "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles);
  4909         -      }
  4910         -    else
  4911         -      {
  4912         -	  /* whole Coverage */
  4913         -	  sql =
  4914         -	      sqlite3_mprintf
  4915         -	      ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  4916         -	       "FROM \"%s\" " "WHERE pyramid_level = ? AND ROWID IN ( "
  4917         -	       "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
  4918         -	       "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles);
  4919         -      }
  4920         -    sqlite3_free (xtiles);
  4921         -    free (xxtiles);
  4922         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL);
  4923         -    sqlite3_free (sql);
  4924         -    if (ret != SQLITE_OK)
  4925         -      {
  4926         -	  printf ("SELECT raw tiles SQL error: %s\n", sqlite3_errmsg (handle));
  4927         -	  goto error;
  4928         -      }
  4929         -
  4930         -    /* preparing the data SQL query - only ODD */
  4931         -    xdata = sqlite3_mprintf ("%s_tile_data", coverage);
  4932         -    xxdata = rl2_double_quoted_sql (xdata);
  4933         -    sqlite3_free (xdata);
  4934         -    sql = sqlite3_mprintf ("SELECT tile_data_odd "
  4935         -			   "FROM \"%s\" WHERE tile_id = ?", xxdata);
  4936         -    free (xxdata);
  4937         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_data, NULL);
  4938         -    sqlite3_free (sql);
  4939         -    if (ret != SQLITE_OK)
  4940         -      {
  4941         -	  printf ("SELECT raw tiles data(1) SQL error: %s\n",
  4942         -		  sqlite3_errmsg (handle));
  4943         -	  goto error;
  4944         -      }
  4945         -
  4946         -/* preparing a fully opaque mask */
  4947         -    memset (bufpix, 0, bufpix_size);
  4948         -
  4949         -    if (!rl2_load_dbms_masktiles
  4950         -	(handle, max_threads, by_section, section_id, stmt_tiles, stmt_data,
  4951         -	 bufpix, width, height, xx_res, yy_res, minx, miny, maxx, maxy, level,
  4952         -	 scale))
  4953         -	goto error;
  4954         -    sqlite3_finalize (stmt_tiles);
  4955         -    sqlite3_finalize (stmt_data);
  4956         -    *mask = bufpix;
  4957         -    *mask_size = bufpix_size;
  4958         -
  4959         -    return RL2_OK;
  4960         -
  4961         -  error:
  4962         -    if (stmt_tiles != NULL)
  4963         -	sqlite3_finalize (stmt_tiles);
  4964         -    if (stmt_data != NULL)
  4965         -	sqlite3_finalize (stmt_data);
  4966         -    if (bufpix != NULL)
  4967         -	free (bufpix);
  4968         -    return RL2_ERROR;
  4969         -}
  4970         -
  4971   4439   RL2_PRIVATE int
  4972   4440   rl2_get_raw_raster_data_common (sqlite3 * handle, int max_threads,
  4973   4441   				rl2CoveragePtr cvg, int by_section,
  4974   4442   				sqlite3_int64 section_id, unsigned int width,
  4975   4443   				unsigned int height, double minx, double miny,
  4976   4444   				double maxx, double maxy, double x_res,
  4977   4445   				double y_res, unsigned char **buffer,
................................................................................
  5115   4583   			    free (blue);
  5116   4584   			}
  5117   4585   		      if (!ok)
  5118   4586   			{
  5119   4587   			    /* default: white */
  5120   4588   			    rl2_set_pixel_sample_uint8 (no_data, RL2_RED_BAND,
  5121   4589   							255);
  5122         -			    rl2_set_pixel_sample_uint8 (no_data,
  5123         -							RL2_GREEN_BAND, 255);
  5124         -			    rl2_set_pixel_sample_uint8 (no_data,
  5125         -							RL2_BLUE_BAND, 255);
         4590  +			    rl2_set_pixel_sample_uint8 (no_data, RL2_GREEN_BAND,
         4591  +							255);
         4592  +			    rl2_set_pixel_sample_uint8 (no_data, RL2_BLUE_BAND,
         4593  +							255);
  5126   4594   			}
  5127   4595   		  }
  5128   4596   	    }
  5129   4597   	  if (plt != NULL)
  5130   4598   	      rl2_destroy_palette (plt);
  5131   4599   	  plt = NULL;
  5132   4600   	  sample_type = RL2_SAMPLE_UINT8;
................................................................................
  5209   4677   		/* preparing a Shaded Relief mask */
  5210   4678   		double scale_factor =
  5211   4679   		    rl2_get_shaded_relief_scale_factor (handle, coverage);
  5212   4680   		if (rl2_get_raster_symbolizer_shaded_relief
  5213   4681   		    (style, &brightness_only, &relief_factor) != RL2_OK)
  5214   4682   		    goto error;
  5215   4683   		if (rl2_build_shaded_relief_mask
  5216         -		    (handle, max_threads, cvg, by_section, section_id,
  5217         -		     relief_factor, scale_factor, width, height, minx, miny,
  5218         -		     maxx, maxy, x_res, y_res, &shaded_relief,
  5219         -		     &shaded_relief_sz) != RL2_OK)
         4684  +		    (handle, max_threads, cvg, relief_factor, scale_factor,
         4685  +		     width, height, minx, miny, maxx, maxy, x_res, y_res,
         4686  +		     &shaded_relief, &shaded_relief_sz) != RL2_OK)
  5220   4687   		    goto error;
  5221   4688   
  5222   4689   		if (brightness_only || !rl2_has_styled_rgb_colors (style))
  5223   4690   		  {
  5224   4691   		      /* returning a Grayscale ShadedRelief (BrightnessOnly) */
  5225   4692   		      unsigned int row;
  5226   4693   		      unsigned int col;
................................................................................
  5256   4723   
  5257   4724   /* preparing the "tiles" SQL query */
  5258   4725       xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  5259   4726       xxtiles = rl2_double_quoted_sql (xtiles);
  5260   4727       if (by_section)
  5261   4728         {
  5262   4729   	  /* only from a single Section */
         4730  +	  char sctn[1024];
         4731  +#if defined(_WIN32) && !defined(__MINGW32__)
         4732  +	  sprintf (sctn, "%I64d", section_id);
         4733  +#else
         4734  +	  sprintf (sctn, "%lld", section_id);
         4735  +#endif
  5263   4736   	  sql =
  5264   4737   	      sqlite3_mprintf
  5265   4738   	      ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  5266   4739   	       "FROM \"%s\" "
  5267         -	       "WHERE section_id = ? AND pyramid_level = ? AND ROWID IN ( "
         4740  +	       "WHERE section_id = %s AND pyramid_level = ? AND ROWID IN ( "
  5268   4741   	       "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
  5269         -	       "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles);
         4742  +	       "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, sctn,
         4743  +	       xtiles);
  5270   4744         }
  5271   4745       else
  5272   4746         {
  5273   4747   	  /* whole Coverage */
  5274   4748   	  sql =
  5275   4749   	      sqlite3_mprintf
  5276   4750   	      ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
................................................................................
  5335   4809   	  if (bgcolor != NULL)
  5336   4810   	      void_raw_buffer (bufpix, width, height, sample_type, num_bands,
  5337   4811   			       bgcolor);
  5338   4812   	  else
  5339   4813   	      void_raw_buffer (bufpix, width, height, sample_type, num_bands,
  5340   4814   			       no_data);
  5341   4815         }
  5342         -    if (by_section)
  5343         -      {
  5344         -	  /* only from a single Section */
  5345         -	  if (!rl2_load_dbms_tiles_section
  5346         -	      (handle, max_threads, section_id, stmt_tiles, stmt_data, bufpix,
  5347         -	       width, height, sample_type, num_bands, auto_ndvi, red_band,
  5348         -	       nir_band, xx_res, yy_res, minx, miny, maxx, maxy, level, scale,
  5349         -	       plt, no_data))
  5350         -	      goto error;
  5351         -      }
  5352         -    else
  5353         -      {
  5354         -	  /* whole Coverage */
  5355         -	  if (!rl2_load_dbms_tiles
  5356         -	      (handle, max_threads, stmt_tiles, stmt_data, bufpix, width,
  5357         -	       height, sample_type, num_bands, auto_ndvi, red_band, nir_band,
  5358         -	       xx_res, yy_res, minx, miny, maxx, maxy, level, scale, plt,
  5359         -	       no_data, style, stats))
  5360         -	      goto error;
  5361         -      }
         4816  +    if (!rl2_load_dbms_tiles
         4817  +	(handle, max_threads, stmt_tiles, stmt_data, bufpix, width, height,
         4818  +	 sample_type, num_bands, auto_ndvi, red_band, nir_band, xx_res, yy_res,
         4819  +	 minx, miny, maxx, maxy, level, scale, plt, no_data, style, stats))
         4820  +	goto error;
  5362   4821       if (kill_no_data != NULL)
  5363   4822   	rl2_destroy_pixel (kill_no_data);
  5364   4823       sqlite3_finalize (stmt_tiles);
  5365   4824       sqlite3_finalize (stmt_data);
  5366   4825       if (shaded_relief != NULL)
  5367   4826         {
  5368   4827   	  /* applying the Shaded Relief */
................................................................................
  5409   4868   	rl2_destroy_pixel (kill_no_data);
  5410   4869       if (shaded_relief != NULL)
  5411   4870   	free (shaded_relief);
  5412   4871       return RL2_ERROR;
  5413   4872   }
  5414   4873   
  5415   4874   RL2_DECLARE int
  5416         -rl2_get_raw_raster_data (sqlite3 * handle, int max_threads,
  5417         -			 rl2CoveragePtr cvg, unsigned int width,
  5418         -			 unsigned int height, double minx, double miny,
  5419         -			 double maxx, double maxy, double x_res, double y_res,
  5420         -			 unsigned char **buffer, int *buf_size,
  5421         -			 rl2PalettePtr * palette, unsigned char out_pixel)
         4875  +rl2_get_raw_raster_data (sqlite3 * handle, int max_threads, rl2CoveragePtr cvg,
         4876  +			 unsigned int width, unsigned int height,
         4877  +			 double minx, double miny, double maxx, double maxy,
         4878  +			 double x_res, double y_res, unsigned char **buffer,
         4879  +			 int *buf_size, rl2PalettePtr * palette,
         4880  +			 unsigned char out_pixel)
  5422   4881   {
  5423   4882   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  5424   4883       return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 0, 0,
  5425   4884   					   width, height, minx, miny, maxx,
  5426         -					   maxy, x_res, y_res, buffer,
  5427         -					   buf_size, palette, out_pixel, NULL,
  5428         -					   NULL, NULL);
         4885  +					   maxy, x_res, y_res, buffer, buf_size,
         4886  +					   palette, out_pixel, NULL, NULL,
         4887  +					   NULL);
  5429   4888   }
  5430   4889   
  5431   4890   RL2_DECLARE int
  5432   4891   rl2_get_section_raw_raster_data (sqlite3 * handle, int max_threads,
  5433   4892   				 rl2CoveragePtr cvg, sqlite3_int64 section_id,
  5434   4893   				 unsigned int width, unsigned int height,
  5435   4894   				 double minx, double miny, double maxx,
................................................................................
  5438   4897   				 rl2PalettePtr * palette,
  5439   4898   				 unsigned char out_pixel)
  5440   4899   {
  5441   4900   /* attempting to return a buffer containing raw pixels from the DBMS Coverage/Section */
  5442   4901       return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 1,
  5443   4902   					   section_id, width, height, minx,
  5444   4903   					   miny, maxx, maxy, x_res, y_res,
  5445         -					   buffer, buf_size, palette,
  5446         -					   out_pixel, NULL, NULL, NULL);
         4904  +					   buffer, buf_size, palette, out_pixel,
         4905  +					   NULL, NULL, NULL);
  5447   4906   }
  5448   4907   
  5449   4908   static int
  5450   4909   get_triple_band_raw_raster_data_common (int by_section, sqlite3 * handle,
  5451   4910   					rl2CoveragePtr cvg,
  5452   4911   					sqlite3_int64 section_id,
  5453         -					unsigned int width,
  5454         -					unsigned int height, double minx,
  5455         -					double miny, double maxx, double maxy,
  5456         -					double x_res, double y_res,
         4912  +					unsigned int width, unsigned int height,
         4913  +					double minx, double miny, double maxx,
         4914  +					double maxy, double x_res, double y_res,
  5457   4915   					unsigned char red_band,
  5458   4916   					unsigned char green_band,
  5459   4917   					unsigned char blue_band,
  5460   4918   					unsigned char **buffer, int *buf_size,
  5461   4919   					rl2PixelPtr bgcolor)
  5462   4920   {
  5463   4921   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
................................................................................
  5614   5072   				     unsigned char blue_band,
  5615   5073   				     unsigned char **buffer, int *buf_size,
  5616   5074   				     rl2PixelPtr bgcolor)
  5617   5075   {
  5618   5076   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  5619   5077       return get_triple_band_raw_raster_data_common (0, handle, cvg, 0, width,
  5620   5078   						   height, minx, miny, maxx,
  5621         -						   maxy, x_res, y_res,
  5622         -						   red_band, green_band,
  5623         -						   blue_band, buffer,
  5624         -						   buf_size, bgcolor);
         5079  +						   maxy, x_res, y_res, red_band,
         5080  +						   green_band, blue_band,
         5081  +						   buffer, buf_size, bgcolor);
  5625   5082   }
  5626   5083   
  5627   5084   RL2_DECLARE int
  5628   5085   rl2_get_section_triple_band_raw_raster_data (sqlite3 * handle,
  5629   5086   					     rl2CoveragePtr cvg,
  5630   5087   					     sqlite3_int64 section_id,
  5631   5088   					     unsigned int width,
................................................................................
  5640   5097   					     int *buf_size, rl2PixelPtr bgcolor)
  5641   5098   {
  5642   5099   /* attempting to return a buffer containing raw pixels - Section */
  5643   5100       return get_triple_band_raw_raster_data_common (1, handle, cvg, section_id,
  5644   5101   						   width, height, minx, miny,
  5645   5102   						   maxx, maxy, x_res, y_res,
  5646   5103   						   red_band, green_band,
  5647         -						   blue_band, buffer,
  5648         -						   buf_size, bgcolor);
         5104  +						   blue_band, buffer, buf_size,
         5105  +						   bgcolor);
  5649   5106   }
  5650   5107   
  5651   5108   static int
  5652   5109   get_mono_band_raw_raster_data_common (int by_section, sqlite3 * handle,
  5653   5110   				      rl2CoveragePtr cvg,
  5654   5111   				      sqlite3_int64 section_id,
  5655   5112   				      unsigned int width, unsigned int height,
................................................................................
  5806   5263   				   double x_res, double y_res,
  5807   5264   				   unsigned char mono_band,
  5808   5265   				   unsigned char **buffer, int *buf_size,
  5809   5266   				   rl2PixelPtr no_data)
  5810   5267   {
  5811   5268   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  5812   5269       return get_mono_band_raw_raster_data_common (0, handle, cvg, 0, width,
  5813         -						 height, minx, miny, maxx,
  5814         -						 maxy, x_res, y_res, buffer,
  5815         -						 buf_size, mono_band, no_data);
         5270  +						 height, minx, miny, maxx, maxy,
         5271  +						 x_res, y_res, buffer, buf_size,
         5272  +						 mono_band, no_data);
  5816   5273   }
  5817   5274   
  5818   5275   RL2_DECLARE int
  5819         -rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle,
  5820         -					   rl2CoveragePtr cvg,
         5276  +rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle, rl2CoveragePtr cvg,
  5821   5277   					   sqlite3_int64 section_id,
  5822   5278   					   unsigned int width,
  5823   5279   					   unsigned int height, double minx,
  5824   5280   					   double miny, double maxx,
  5825   5281   					   double maxy, double x_res,
  5826   5282   					   double y_res,
  5827   5283   					   unsigned char mono_band,
................................................................................
  5835   5291   						 buffer, buf_size, mono_band,
  5836   5292   						 no_data);
  5837   5293   }
  5838   5294   
  5839   5295   RL2_DECLARE int
  5840   5296   rl2_get_raw_raster_data_bgcolor (sqlite3 * handle, int max_threads,
  5841   5297   				 rl2CoveragePtr cvg, unsigned int width,
  5842         -				 unsigned int height, double minx,
  5843         -				 double miny, double maxx, double maxy,
  5844         -				 double x_res, double y_res,
  5845         -				 unsigned char **buffer, int *buf_size,
  5846         -				 rl2PalettePtr * palette,
  5847         -				 unsigned char *out_pixel,
  5848         -				 unsigned char bg_red, unsigned char bg_green,
  5849         -				 unsigned char bg_blue,
         5298  +				 unsigned int height, double minx, double miny,
         5299  +				 double maxx, double maxy, double x_res,
         5300  +				 double y_res, unsigned char **buffer,
         5301  +				 int *buf_size, rl2PalettePtr * palette,
         5302  +				 unsigned char *out_pixel, unsigned char bg_red,
         5303  +				 unsigned char bg_green, unsigned char bg_blue,
  5850   5304   				 rl2RasterSymbolizerPtr style,
  5851   5305   				 rl2RasterStatisticsPtr stats)
  5852   5306   {
  5853   5307   /* attempting to return a buffer containing raw pixels from the DBMS Coverage + bgcolor */
  5854   5308       int ret;
  5855   5309       rl2PixelPtr no_data = NULL;
  5856   5310       const char *coverage;
................................................................................
  5926   5380   	  if (index < 0)
  5927   5381   	    {
  5928   5382   		/* palette color found */
  5929   5383   		switch (sample_type)
  5930   5384   		  {
  5931   5385   		  case RL2_SAMPLE_1_BIT:
  5932   5386   		      no_data =
  5933         -			  rl2_create_pixel (RL2_SAMPLE_1_BIT,
  5934         -					    RL2_PIXEL_PALETTE, 1);
         5387  +			  rl2_create_pixel (RL2_SAMPLE_1_BIT, RL2_PIXEL_PALETTE,
         5388  +					    1);
  5935   5389   		      rl2_set_pixel_sample_1bit (no_data,
  5936   5390   						 (unsigned char) index);
  5937   5391   		      break;
  5938   5392   		  case RL2_SAMPLE_2_BIT:
  5939   5393   		      no_data =
  5940         -			  rl2_create_pixel (RL2_SAMPLE_2_BIT,
  5941         -					    RL2_PIXEL_PALETTE, 1);
         5394  +			  rl2_create_pixel (RL2_SAMPLE_2_BIT, RL2_PIXEL_PALETTE,
         5395  +					    1);
  5942   5396   		      rl2_set_pixel_sample_2bit (no_data,
  5943   5397   						 (unsigned char) index);
  5944   5398   		      break;
  5945   5399   		  case RL2_SAMPLE_4_BIT:
  5946   5400   		      no_data =
  5947         -			  rl2_create_pixel (RL2_SAMPLE_4_BIT,
  5948         -					    RL2_PIXEL_PALETTE, 1);
         5401  +			  rl2_create_pixel (RL2_SAMPLE_4_BIT, RL2_PIXEL_PALETTE,
         5402  +					    1);
  5949   5403   		      rl2_set_pixel_sample_4bit (no_data,
  5950   5404   						 (unsigned char) index);
  5951   5405   		      break;
  5952   5406   		  case RL2_SAMPLE_UINT8:
  5953   5407   		      no_data =
  5954         -			  rl2_create_pixel (RL2_SAMPLE_UINT8,
  5955         -					    RL2_PIXEL_PALETTE, 1);
         5408  +			  rl2_create_pixel (RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE,
         5409  +					    1);
  5956   5410   		      rl2_set_pixel_sample_uint8 (no_data, RL2_PALETTE_BAND,
  5957   5411   						  (unsigned char) index);
  5958   5412   		      break;
  5959   5413   
  5960   5414   		  };
  5961   5415   	    }
  5962   5416         }
................................................................................
  6249   5703       sqlite3_stmt *stmt = NULL;
  6250   5704       char *sql;
  6251   5705       int ret;
  6252   5706       if (handle == NULL || coverage == NULL || palette == NULL)
  6253   5707   	return RL2_ERROR;
  6254   5708   
  6255   5709       sql =
  6256         -	sqlite3_mprintf
  6257         -	("SELECT sample_type, pixel_type FROM raster_coverages "
  6258         -	 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
         5710  +	sqlite3_mprintf ("SELECT sample_type, pixel_type FROM raster_coverages "
         5711  +			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
  6259   5712       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  6260   5713       sqlite3_free (sql);
  6261   5714       if (ret != SQLITE_OK)
  6262   5715         {
  6263   5716   	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
  6264   5717   	  goto error;
  6265   5718         }
................................................................................
  6778   6231   	sqlite3_finalize (stmt);
  6779   6232       if (stl != NULL)
  6780   6233   	rl2_destroy_coverage_style (stl);
  6781   6234       return NULL;
  6782   6235   }
  6783   6236   
  6784   6237   RL2_DECLARE rl2FeatureTypeStylePtr
  6785         -rl2_create_feature_type_style_from_dbms (sqlite3 * handle,
  6786         -					 const char *coverage,
         6238  +rl2_create_feature_type_style_from_dbms (sqlite3 * handle, const char *coverage,
  6787   6239   					 const char *style)
  6788   6240   {
  6789   6241   /* attempting to load and parse a Feature Type Style */
  6790   6242       const char *sql;
  6791   6243       int ret;
  6792   6244       sqlite3_stmt *stmt = NULL;
  6793   6245       rl2FeatureTypeStylePtr stl = NULL;
................................................................................
  6923   6375       char **results;
  6924   6376       int rows;
  6925   6377       int columns;
  6926   6378       int i;
  6927   6379       int ok = 0;
  6928   6380   /* testing if the Layer Style exists */
  6929   6381       char *sql =
  6930         -	sqlite3_mprintf
  6931         -	("SELECT style_name FROM SE_raster_styled_layers AS r "
  6932         -	 "JOIN SE_raster_styles AS s ON (r.style_id = s.style_id) "
  6933         -	 "WHERE Lower(r.coverage_name) = Lower(%Q) AND "
  6934         -	 "Lower(s.style_name) = Lower(%Q)", namedLayer,
  6935         -	 namedStyle);
         6382  +	sqlite3_mprintf ("SELECT style_name FROM SE_raster_styled_layers AS r "
         6383  +			 "JOIN SE_raster_styles AS s ON (r.style_id = s.style_id) "
         6384  +			 "WHERE Lower(r.coverage_name) = Lower(%Q) AND "
         6385  +			 "Lower(s.style_name) = Lower(%Q)", namedLayer,
         6386  +			 namedStyle);
  6936   6387       ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, NULL);
  6937   6388       sqlite3_free (sql);
  6938   6389       if (ret != SQLITE_OK)
  6939   6390   	return 0;
  6940   6391       for (i = 1; i <= rows; i++)
  6941   6392   	ok = 1;
  6942   6393       sqlite3_free_table (results);
................................................................................
  7550   7001       int section_summary = 0;
  7551   7002       rl2PixelPtr no_data = NULL;
  7552   7003       rl2PalettePtr palette = NULL;
  7553   7004       char *title = NULL;
  7554   7005       char *abstract = NULL;
  7555   7006       unsigned char *statistics = NULL;
  7556   7007       int statistics_sz;
  7557         -    int ok_geo = 0;
  7558   7008       int ok_bbox = 0;
  7559   7009       double geo_minx;
  7560   7010       double geo_miny;
  7561   7011       double geo_maxx;
  7562   7012       double geo_maxy;
  7563   7013       double ext_minx;
  7564   7014       double ext_miny;
................................................................................
  7949   7399   		      strcpy (abstract, value);
  7950   7400   		  }
  7951   7401   		if (sqlite3_column_type (stmt, 18) == SQLITE_BLOB)
  7952   7402   		  {
  7953   7403   		      statistics_sz = sqlite3_column_bytes (stmt, 18);
  7954   7404   		      statistics = malloc (statistics_sz);
  7955   7405   		      memcpy (statistics,
  7956         -			      (const unsigned char *)
  7957         -			      sqlite3_column_blob (stmt, 18), statistics_sz);
         7406  +			      (const unsigned char *) sqlite3_column_blob (stmt,
         7407  +									   18),
         7408  +			      statistics_sz);
  7958   7409   		  }
  7959   7410   		if (sqlite3_column_type (stmt, 19) == SQLITE_FLOAT)
  7960   7411   		  {
  7961   7412   		      geo_minx = sqlite3_column_double (stmt, 19);
  7962         -		      ok_geo++;
         7413  +		      ok_bbox++;
  7963   7414   		  }
  7964   7415   		if (sqlite3_column_type (stmt, 20) == SQLITE_FLOAT)
  7965   7416   		  {
  7966   7417   		      geo_miny = sqlite3_column_double (stmt, 20);
  7967         -		      ok_geo++;
         7418  +		      ok_bbox++;
  7968   7419   		  }
  7969   7420   		if (sqlite3_column_type (stmt, 21) == SQLITE_FLOAT)
  7970   7421   		  {
  7971   7422   		      geo_maxx = sqlite3_column_double (stmt, 21);
  7972         -		      ok_geo++;
         7423  +		      ok_bbox++;
  7973   7424   		  }
  7974   7425   		if (sqlite3_column_type (stmt, 22) == SQLITE_FLOAT)
  7975   7426   		  {
  7976   7427   		      geo_maxy = sqlite3_column_double (stmt, 22);
  7977         -		      ok_geo++;
         7428  +		      ok_bbox++;
  7978   7429   		  }
  7979   7430   		if (sqlite3_column_type (stmt, 23) == SQLITE_FLOAT)
  7980   7431   		  {
  7981   7432   		      ext_minx = sqlite3_column_double (stmt, 23);
  7982   7433   		      ok_bbox++;
  7983   7434   		  }
  7984   7435   		if (sqlite3_column_type (stmt, 24) == SQLITE_FLOAT)
................................................................................
  8030   7481   		  {
  8031   7482   		      const unsigned char *blob =
  8032   7483   			  sqlite3_column_blob (stmt, 33);
  8033   7484   		      int blob_sz = sqlite3_column_bytes (stmt, 33);
  8034   7485   		      palette = rl2_deserialize_dbms_palette (blob, blob_sz);
  8035   7486   		  }
  8036   7487   		if (ok_sample && ok_pixel && ok_num_bands && ok_compression
  8037         -		    && ok_quality && ok_tile_width && ok_tile_height
  8038         -		    && ok_x_res && ok_y_res && ok_srid && ok_nodata
  8039         -		    && ok_strict && ok_mixed && ok_paths && ok_md5
  8040         -		    && ok_summary)
         7488  +		    && ok_quality && ok_tile_width && ok_tile_height && ok_x_res
         7489  +		    && ok_y_res && ok_srid && ok_nodata && ok_strict && ok_mixed
         7490  +		    && ok_paths && ok_md5 && ok_summary)
  8041   7491   		    ok = 1;
  8042         -		if (ok_geo != 4)
  8043         -		    ok_geo = 0;
  8044         -		if (ok_bbox != 4)
         7492  +		if (ok_bbox != 8)
  8045   7493   		    ok_bbox = 0;
  8046   7494   	    }
  8047   7495         }
  8048   7496       sqlite3_finalize (stmt);
  8049   7497       stmt = NULL;
  8050   7498       if (!ok)
  8051   7499   	goto error;
................................................................................
  8056   7504   				    compr, quality,
  8057   7505   				    (unsigned short) tile_width,
  8058   7506   				    (unsigned short) tile_height, srid,
  8059   7507   				    horz_res, vert_res, no_data, palette,
  8060   7508   				    strict_resolution, mixed_resolutions,
  8061   7509   				    section_paths, section_md5,
  8062   7510   				    section_summary);
  8063         -    if (no_data != NULL)
  8064         -	rl2_destroy_pixel (no_data);
  8065         -    if (palette != NULL)
  8066         -	rl2_destroy_palette (palette);
         7511  +	if (no_data != NULL)
         7512  +	rl2_destroy_pixel(no_data);
         7513  +	if (palette != NULL)
         7514  +	rl2_destroy_palette(palette);
  8067   7515       if (ret != RL2_OK)
  8068   7516   	goto error;
  8069   7517   
  8070   7518   /* completing the destination coverage */
  8071   7519       sql = "UPDATE main.raster_coverages SET title = ?, "
  8072   7520   	"abstract = ?, statistics = ?, geo_minx = ?, geo_miny = ?, geo_maxx = ?, "
  8073   7521   	"geo_maxy = ?, extent_minx = ?, extent_miny = ?, extent_maxx = ?, "
................................................................................
  8090   7538   	sqlite3_bind_null (stmt, 2);
  8091   7539       else
  8092   7540   	sqlite3_bind_text (stmt, 2, abstract, strlen (abstract), free);
  8093   7541       if (statistics == NULL)
  8094   7542   	sqlite3_bind_null (stmt, 3);
  8095   7543       else
  8096   7544   	sqlite3_bind_blob (stmt, 3, statistics, statistics_sz, free);
  8097         -    if (ok_geo)
         7545  +    if (ok_bbox)
  8098   7546         {
  8099   7547   	  sqlite3_bind_double (stmt, 4, geo_minx);
  8100   7548   	  sqlite3_bind_double (stmt, 5, geo_miny);
  8101   7549   	  sqlite3_bind_double (stmt, 6, geo_maxx);
  8102   7550   	  sqlite3_bind_double (stmt, 7, geo_maxy);
         7551  +	  sqlite3_bind_double (stmt, 8, ext_minx);
         7552  +	  sqlite3_bind_double (stmt, 9, ext_miny);
         7553  +	  sqlite3_bind_double (stmt, 10, ext_maxx);
         7554  +	  sqlite3_bind_double (stmt, 11, ext_maxy);
  8103   7555         }
  8104   7556       else
  8105   7557         {
  8106   7558   	  sqlite3_bind_null (stmt, 4);
  8107   7559   	  sqlite3_bind_null (stmt, 5);
  8108   7560   	  sqlite3_bind_null (stmt, 6);
  8109   7561   	  sqlite3_bind_null (stmt, 7);
  8110         -      }
  8111         -    if (ok_bbox)
  8112         -      {
  8113         -	  sqlite3_bind_double (stmt, 8, ext_minx);
  8114         -	  sqlite3_bind_double (stmt, 9, ext_miny);
  8115         -	  sqlite3_bind_double (stmt, 10, ext_maxx);
  8116         -	  sqlite3_bind_double (stmt, 11, ext_maxy);
  8117         -      }
  8118         -    else
  8119         -      {
  8120   7562   	  sqlite3_bind_null (stmt, 8);
  8121   7563   	  sqlite3_bind_null (stmt, 9);
  8122   7564   	  sqlite3_bind_null (stmt, 10);
  8123   7565   	  sqlite3_bind_null (stmt, 11);
  8124   7566         }
  8125   7567       if (!ok_is_queryable)
  8126   7568   	sqlite3_bind_null (stmt, 12);
................................................................................
  8145   7587       if (!ok_enable_auto_ndvi)
  8146   7588   	sqlite3_bind_null (stmt, 17);
  8147   7589       else
  8148   7590   	sqlite3_bind_int (stmt, 17, enable_auto_ndvi);
  8149   7591       sqlite3_bind_text (stmt, 18, coverage_name, strlen (coverage_name),
  8150   7592   		       SQLITE_STATIC);
  8151   7593       ret = sqlite3_step (stmt);
  8152         -    sqlite3_finalize (stmt);
  8153         -    stmt = NULL;
         7594  +    sqlite3_finalize(stmt);
  8154   7595       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  8155   7596   	goto ok_continue;
  8156   7597       fprintf (stderr,
  8157   7598   	     "sqlite3_step() error: UPDATE raster_coverages \"%s\"\n",
  8158   7599   	     sqlite3_errmsg (sqlite));
  8159   7600       goto error;
  8160   7601   
................................................................................
  8168   7609   			   "x_resolution_1_4, y_resolution_1_4, x_resolution_1_8, y_resolution_1_8) "
  8169   7610   			   "SELECT pyramid_level, x_resolution_1_1, y_resolution_1_1, x_resolution_1_2, "
  8170   7611   			   "y_resolution_1_2, x_resolution_1_4, y_resolution_1_4, x_resolution_1_8, "
  8171   7612   			   "y_resolution_1_8 FROM \"%s\".\"%s\"", xxcoverage,
  8172   7613   			   xdb, xxcoverage);
  8173   7614       free (xxcoverage);
  8174   7615       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8175         -    sqlite3_free (sql);
         7616  +    sqlite3_free(sql);
  8176   7617       if (ret != SQLITE_OK)
  8177   7618   	goto error;
  8178   7619   
  8179   7620   /* copying  coverage-SECTIONS */
  8180   7621       xcoverage = sqlite3_mprintf ("%s_sections", coverage_name);
  8181   7622       xxcoverage = rl2_double_quoted_sql (xcoverage);
  8182   7623       sqlite3_free (xcoverage);
  8183         -    sql =
  8184         -	sqlite3_mprintf ("INSERT INTO main.\"%s\" (section_id, section_name, "
  8185         -			 "width, height, file_path, md5_checksum, summary, statistics, geometry) "
  8186         -			 "SELECT section_id, section_name, width, height, file_path, md5_checksum, "
  8187         -			 "summary, statistics, geometry FROM \"%s\".\"%s\"",
  8188         -			 xxcoverage, xdb, xxcoverage);
         7624  +    sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (section_id, section_name, "
         7625  +			   "width, height, file_path, md5_checksum, summary, statistics, geometry) "
         7626  +			   "SELECT section_id, section_name, width, height, file_path, md5_checksum, "
         7627  +			   "summary, statistics, geometry FROM \"%s\".\"%s\"",
         7628  +			   xxcoverage, xdb, xxcoverage);
  8189   7629       free (xxcoverage);
  8190   7630       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8191         -    sqlite3_free (sql);
         7631  +    sqlite3_free(sql);
  8192   7632       if (ret != SQLITE_OK)
  8193   7633   	goto error;
  8194   7634   
  8195   7635   /* copying  coverage-TILES */
  8196   7636       xcoverage = sqlite3_mprintf ("%s_tiles", coverage_name);
  8197   7637       xxcoverage = rl2_double_quoted_sql (xcoverage);
  8198   7638       sqlite3_free (xcoverage);
  8199   7639       sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, pyramid_level, "
  8200   7640   			   "section_id, geometry) SELECT tile_id, pyramid_level, section_id, geometry "
  8201   7641   			   "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage);
  8202   7642       free (xxcoverage);
  8203   7643       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8204         -    sqlite3_free (sql);
         7644  +    sqlite3_free(sql);
  8205   7645       if (ret != SQLITE_OK)
  8206   7646   	goto error;
  8207   7647   
  8208   7648   /* copying  coverage-TILE_DATA */
  8209   7649       xcoverage = sqlite3_mprintf ("%s_tile_data", coverage_name);
  8210   7650       xxcoverage = rl2_double_quoted_sql (xcoverage);
  8211   7651       sqlite3_free (xcoverage);
  8212   7652       sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, tile_data_odd, "
  8213   7653   			   "tile_data_even) SELECT tile_id, tile_data_odd, tile_data_even "
  8214   7654   			   "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage);
  8215   7655       free (xxcoverage);
  8216   7656       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8217         -    sqlite3_free (sql);
         7657  +    sqlite3_free(sql);
  8218   7658       if (ret != SQLITE_OK)
  8219   7659   	goto error;
  8220   7660   
  8221   7661   /* copying KEYWORDS */
  8222   7662       sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_keyword "
  8223   7663   			   "(coverage_name, keyword) SELECT coverage_name, keyword "
  8224   7664   			   "FROM \"%s\".raster_coverages_keyword", xdb);
  8225   7665       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8226         -    sqlite3_free (sql);
         7666  +    sqlite3_free(sql);
  8227   7667       if (ret != SQLITE_OK)
  8228   7668   	goto error;
  8229   7669   
  8230   7670   /* copying SRID */
  8231   7671       sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_srid "
  8232   7672   			   "(coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx) "
  8233   7673   			   "SELECT coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx "
  8234   7674   			   "FROM \"%s\".raster_coverages_srid", xdb);
  8235   7675       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  8236         -    sqlite3_free (sql);
         7676  +    sqlite3_free(sql);
  8237   7677       if (ret != SQLITE_OK)
  8238   7678   	goto error;
  8239   7679   
  8240   7680       free (xdb);
  8241   7681       return RL2_OK;
  8242   7682   
  8243   7683     error:
  8244   7684       if (xdb != NULL)
  8245   7685   	free (xdb);
  8246   7686       if (stmt != NULL)
  8247   7687   	sqlite3_finalize (stmt);
  8248   7688       return RL2_ERROR;
  8249   7689   }
  8250         -
  8251         -RL2_PRIVATE int
  8252         -do_check_initial_palette (sqlite3 * handle, rl2CoveragePtr cvg)
  8253         -{
  8254         -/* testing for an empty Palette Coverage */
  8255         -    rl2PrivCoveragePtr coverage = (rl2PrivCoveragePtr) cvg;
  8256         -    int ret;
  8257         -    char **results;
  8258         -    int rows;
  8259         -    int columns;
  8260         -    int i;
  8261         -    int initial = 0;
  8262         -    char *xcoverage;
  8263         -    char *xxcoverage;
  8264         -
  8265         -    if (coverage == NULL)
  8266         -	return RL2_ERROR;
  8267         -    if (coverage->coverageName == NULL)
  8268         -	return RL2_ERROR;
  8269         -
  8270         -    xcoverage = sqlite3_mprintf ("%s_tiles", coverage->coverageName);
  8271         -    xxcoverage = rl2_double_quoted_sql (xcoverage);
  8272         -    sqlite3_free (xcoverage);
  8273         -    char *sql = sqlite3_mprintf ("SELECT Count(*) FROM \"%s\"",
  8274         -				 xxcoverage);
  8275         -    free (xxcoverage);
  8276         -    ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, NULL);
  8277         -    sqlite3_free (sql);
  8278         -    if (ret != SQLITE_OK)
  8279         -	return RL2_ERROR;
  8280         -    for (i = 1; i <= rows; i++)
  8281         -      {
  8282         -	  if (atoi (results[(i * columns) + 0]) == 0)
  8283         -	      initial = 1;
  8284         -      }
  8285         -    sqlite3_free_table (results);
  8286         -    if (initial)
  8287         -	return RL2_TRUE;
  8288         -    return RL2_FALSE;
  8289         -}
  8290         -
  8291         -RL2_DECLARE int
  8292         -rl2_install_dbms_palette_from_tiff (sqlite3 * handle, rl2CoveragePtr coverage,
  8293         -				    rl2TiffOriginPtr tiff)
  8294         -{
  8295         -/*attempting to merge/update a Coverage's Palette */
  8296         -    int i;
  8297         -    int j;
  8298         -    int changed = 0;
  8299         -    int maxPalette = 0;
  8300         -    unsigned char red[256];
  8301         -    unsigned char green[256];
  8302         -    unsigned char blue[256];
  8303         -    int ok;
  8304         -    rl2PalettePtr palette = NULL;
  8305         -    rl2PrivCoveragePtr cvg = (rl2PrivCoveragePtr) coverage;
  8306         -    rl2PrivTiffOriginPtr origin = (rl2PrivTiffOriginPtr) tiff;
  8307         -    if (cvg == NULL || origin == NULL)
  8308         -	return RL2_ERROR;
  8309         -
  8310         -    for (i = 0; i < origin->maxPalette; i++)
  8311         -      {
  8312         -	  /* checking TIFF palette entries */
  8313         -	  unsigned char tiff_red = origin->red[i];
  8314         -	  unsigned char tiff_green = origin->green[i];
  8315         -	  unsigned char tiff_blue = origin->blue[i];
  8316         -	  ok = 0;
  8317         -	  for (j = 0; j < maxPalette; j++)
  8318         -	    {
  8319         -		if (tiff_red == red[j] && tiff_green == green[j]
  8320         -		    && tiff_blue == blue[j])
  8321         -		  {
  8322         -		      /* found a matching color */
  8323         -		      ok = 1;
  8324         -		      break;
  8325         -		  }
  8326         -	    }
  8327         -	  if (!ok)
  8328         -	    {
  8329         -		/* attempting to insert a new color into the pseudo-Palette */
  8330         -		if (maxPalette == 256)
  8331         -		    goto error;
  8332         -		red[maxPalette] = tiff_red;
  8333         -		green[maxPalette] = tiff_green;
  8334         -		blue[maxPalette] = tiff_blue;
  8335         -		maxPalette++;
  8336         -		changed = 1;
  8337         -	    }
  8338         -      }
  8339         -    if (changed)
  8340         -      {
  8341         -	  /* updating the DBMS Palette */
  8342         -	  palette = rl2_create_palette (maxPalette);
  8343         -	  if (palette == NULL)
  8344         -	      goto error;
  8345         -	  for (j = 0; j < maxPalette; j++)
  8346         -	      rl2_set_palette_color (palette, j, red[j], green[j], blue[j]);
  8347         -	  if (rl2_update_dbms_palette (handle, cvg->coverageName, palette) !=
  8348         -	      RL2_OK)
  8349         -	      goto error;
  8350         -      }
  8351         -    set_remapped_palette (origin, palette);
  8352         -    rl2_destroy_palette (palette);
  8353         -    return RL2_OK;
  8354         -
  8355         -  error:
  8356         -    if (palette != NULL)
  8357         -	rl2_destroy_palette (palette);
  8358         -    return RL2_ERROR;
  8359         -}

Changes to src/rl2gif.c.

   602    602   	rl2_destroy_palette (palette);
   603    603       return NULL;
   604    604   }
   605    605   
   606    606   RL2_PRIVATE int
   607    607   rl2_decode_gif (const unsigned char *gif, int gif_size, unsigned int *xwidth,
   608    608   		unsigned int *xheight, unsigned char *xsample_type,
   609         -		unsigned char *xpixel_type, unsigned char **blob,
   610         -		int *blob_sz, rl2PalettePtr * palette)
          609  +		unsigned char *xpixel_type, unsigned char **blob, int *blob_sz,
          610  +		rl2PalettePtr * palette)
   611    611   {
   612    612   /* attempting to create a raster from a GIF image - raw block */
   613    613       struct gif_memory_buffer membuf;
   614    614   #ifdef GIFLIB_MAJOR
   615    615       int ErrorCode;
   616    616   #endif
   617    617       GifFileType *GifFile = NULL;

Changes to src/rl2import.c.

   100    100       tile->blob_odd = NULL;
   101    101       tile->blob_even = NULL;
   102    102       rl2_destroy_raster (tile->raster);
   103    103       tile->raster = NULL;
   104    104   }
   105    105   
   106    106   static void
   107         -addTile2AuxImporter (rl2AuxImporterPtr aux, unsigned int row,
   108         -		     unsigned int col, double minx, double maxy)
          107  +addTile2AuxImporter (rl2AuxImporterPtr aux, unsigned int row, unsigned int col,
          108  +		     double minx, double maxy)
   109    109   {
   110    110   /* adding a Tile to some AuxImporter container */
   111    111       rl2AuxImporterTilePtr tile;
   112    112       if (aux == NULL)
   113    113   	return;
   114    114   
   115    115       tile = malloc (sizeof (rl2AuxImporterTile));
................................................................................
   346    346       switch (aux->origin_type)
   347    347         {
   348    348         case RL2_ORIGIN_ASCII_GRID:
   349    349   	  ascii_grid_origin = (rl2AsciiGridOriginPtr) (aux->origin);
   350    350   	  tile->raster =
   351    351   	      rl2_get_tile_from_ascii_grid_origin ((rl2CoveragePtr)
   352    352   						   (aux->coverage),
   353         -						   ascii_grid_origin,
   354         -						   tile->row, tile->col,
   355         -						   aux->verbose);
          353  +						   ascii_grid_origin, tile->row,
          354  +						   tile->col, aux->verbose);
   356    355   	  break;
   357    356         case RL2_ORIGIN_JPEG:
   358    357   	  raster_origin = (rl2RasterPtr) (aux->origin);
   359    358   	  tile->raster =
   360    359   	      rl2_get_tile_from_jpeg_origin ((rl2CoveragePtr) (aux->coverage),
   361    360   					     raster_origin, tile->row,
   362         -					     tile->col,
   363         -					     aux->forced_conversion,
          361  +					     tile->col, aux->forced_conversion,
   364    362   					     aux->verbose);
   365    363   	  break;
   366    364         case RL2_ORIGIN_JPEG2000:
   367    365   	  raster_origin = (rl2RasterPtr) (aux->origin);
   368    366   	  tile->raster =
   369    367   	      rl2_get_tile_from_jpeg2000_origin ((rl2CoveragePtr)
   370         -						 (aux->coverage),
   371         -						 raster_origin, tile->row,
   372         -						 tile->col,
          368  +						 (aux->coverage), raster_origin,
          369  +						 tile->row, tile->col,
   373    370   						 aux->forced_conversion,
   374    371   						 aux->verbose);
   375    372   	  break;
   376    373         case RL2_ORIGIN_TIFF:
   377    374   	  tiff_origin = (rl2TiffOriginPtr) (aux->origin);
   378    375   	  tile->raster =
   379    376   	      rl2_get_tile_from_tiff_origin ((rl2CoveragePtr) (aux->coverage),
   380         -					     tiff_origin, tile->row,
   381         -					     tile->col, aux->srid,
   382         -					     aux->verbose);
          377  +					     tiff_origin, tile->row, tile->col,
          378  +					     aux->srid, aux->verbose);
   383    379   	  break;
   384    380         case RL2_ORIGIN_RAW:
   385    381   	  raster_origin = (rl2RasterPtr) (aux->origin);
   386    382   	  tile->raster =
   387    383   	      rl2_get_tile_from_raw_pixels ((rl2CoveragePtr) (aux->coverage),
   388    384   					    raster_origin, tile->row,
   389    385   					    tile->col);
................................................................................
   592    588         }
   593    589       if (coverage->mixedResolutions)
   594    590         {
   595    591   	  /* accepting any resolution */
   596    592         }
   597    593       else if (coverage->strictResolution)
   598    594         {
   599         -	  /* enforcing Strict Resolution check */ double x_diff =
   600         -	      fabs (coverage->hResolution - res_x);
   601         -	  double y_diff = fabs (coverage->vResolution - res_y);
   602         -	  double x_lim = coverage->hResolution / 1000000.0;
   603         -	  double y_lim = coverage->vResolution / 1000000.0;
   604         -	  if (x_diff > x_lim)
          595  +	  /* enforcing Strict Resolution check */
          596  +	  if (res_x != coverage->hResolution)
   605    597   	    {
   606    598   		if (verbose)
   607    599   		    fprintf (stderr,
   608    600   			     "Mismatching Horizontal Resolution (Strict) !!!\n");
   609    601   		goto error;
   610    602   	    }
   611         -	  if (y_diff > y_lim)
          603  +	  if (res_y != coverage->vResolution)
   612    604   	    {
   613    605   		if (verbose)
   614    606   		    fprintf (stderr,
   615    607   			     "Mismatching Vertical Resolution (Strict) !!!\n");
   616    608   		goto error;
   617    609   	    }
   618    610         }
................................................................................
   645    637   	  fprintf (stderr, "Coverage/ASCII mismatch\n");
   646    638   	  goto error;
   647    639         }
   648    640       no_data = rl2_get_coverage_no_data (cvg);
   649    641   
   650    642   /* INSERTing the section */
   651    643       if (!rl2_do_insert_section
   652         -	(handle, src_path, section, srid, width, height, minx, miny, maxx,
   653         -	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
          644  +	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
          645  +	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
   654    646   	 coverage->sectionSummary, stmt_sect, &section_id))
   655    647   	goto error;
   656    648       section_stats = rl2_create_raster_statistics (sample_type, 1);
   657    649       if (section_stats == NULL)
   658    650   	goto error;
   659    651   /* INSERTing the base-levels */
   660    652       if (coverage->mixedResolutions)
................................................................................
   671    663   	      (handle, base_res_x, base_res_y, 1.0, sample_type, stmt_levl))
   672    664   	      goto error;
   673    665         }
   674    666   
   675    667   /* preparing all Tile Requests */
   676    668       aux =
   677    669   	createAuxImporter (coverage, srid, maxx, miny, tile_w, tile_h, res_x,
   678         -			   res_y, RL2_ORIGIN_ASCII_GRID, origin,
   679         -			   RL2_CONVERT_NO, verbose, compression, 100);
          670  +			   res_y, RL2_ORIGIN_ASCII_GRID, origin, RL2_CONVERT_NO,
          671  +			   verbose, compression, 100);
   680    672       tile_maxy = maxy;
   681    673       for (row = 0; row < height; row += tile_h)
   682    674         {
   683    675   	  tile_minx = minx;
   684    676   	  for (col = 0; col < width; col += tile_w)
   685    677   	    {
   686    678   		/* adding a Tile request */
................................................................................
   916    908   }
   917    909   
   918    910   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
   919    911   
   920    912   static int
   921    913   check_jpeg2000_origin_compatibility (rl2RasterPtr raster,
   922    914   				     rl2CoveragePtr coverage,
   923         -				     unsigned int *width,
   924         -				     unsigned int *height,
          915  +				     unsigned int *width, unsigned int *height,
   925    916   				     unsigned char *forced_conversion)
   926    917   {
   927    918   /* checking if the Jpeg2000 and the Coverage are mutually compatible */
   928    919       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
   929    920       rl2PrivCoveragePtr cvg = (rl2PrivCoveragePtr) coverage;
   930    921       if (rst == NULL || cvg == NULL)
   931    922   	return 0;
................................................................................
  1003    994   	    {
  1004    995   		*width = rst->width;
  1005    996   		*height = rst->height;
  1006    997   		*forced_conversion = RL2_CONVERT_NO;
  1007    998   		return 1;
  1008    999   	    }
  1009   1000         }
  1010         -    if (rst->sampleType == RL2_SAMPLE_UINT16
  1011         -	&& rst->pixelType == RL2_PIXEL_RGB && rst->nBands == 3)
         1001  +    if (rst->sampleType == RL2_SAMPLE_UINT16 && rst->pixelType == RL2_PIXEL_RGB
         1002  +	&& rst->nBands == 3)
  1012   1003         {
  1013   1004   	  if (cvg->sampleType == RL2_SAMPLE_UINT16
  1014   1005   	      && cvg->pixelType == RL2_PIXEL_RGB && cvg->nBands == 3)
  1015   1006   	    {
  1016   1007   		*width = rst->width;
  1017   1008   		*height = rst->height;
  1018   1009   		*forced_conversion = RL2_CONVERT_NO;
................................................................................
  1238   1229   	  maxy = height - 1.0;
  1239   1230   	  res_x = 1.0;
  1240   1231   	  res_y = 1.0;
  1241   1232         }
  1242   1233       raster_in = (rl2PrivRasterPtr) rst_in;
  1243   1234       xml_summary =
  1244   1235   	rl2_build_jpeg_xml_summary (width, height, raster_in->pixelType,
  1245         -				    is_georeferenced, res_x, res_y, minx,
  1246         -				    miny, maxx, maxy);
         1236  +				    is_georeferenced, res_x, res_y, minx, miny,
         1237  +				    maxx, maxy);
  1247   1238   
  1248   1239       printf ("------------------\n");
  1249   1240       if (total > 1)
  1250   1241   	printf ("%d/%d) Importing: %s\n", current, total, src_path);
  1251   1242       else
  1252   1243   	printf ("Importing: %s\n", src_path);
  1253   1244       printf ("    Image Size (pixels): %d x %d\n", width, height);
................................................................................
  1275   1266         }
  1276   1267       if (coverage->mixedResolutions)
  1277   1268         {
  1278   1269   	  /* accepting any resolution */
  1279   1270         }
  1280   1271       else if (coverage->strictResolution)
  1281   1272         {
  1282         -	  /* enforcing Strict Resolution check */ double x_diff =
  1283         -	      fabs (coverage->hResolution - res_x);
  1284         -	  double y_diff = fabs (coverage->vResolution - res_y);
  1285         -	  double x_lim = coverage->hResolution / 1000000.0;
  1286         -	  double y_lim = coverage->vResolution / 1000000.0;
  1287         -	  if (x_diff > x_lim)
         1273  +	  /* enforcing Strict Resolution check */
         1274  +	  if (res_x != coverage->hResolution)
  1288   1275   	    {
  1289   1276   		if (verbose)
  1290   1277   		    fprintf (stderr,
  1291   1278   			     "Mismatching Horizontal Resolution (Strict) !!!\n");
  1292   1279   		goto error;
  1293   1280   	    }
  1294         -	  if (y_diff > y_lim)
         1281  +	  if (res_y != coverage->vResolution)
  1295   1282   	    {
  1296   1283   		if (verbose)
  1297   1284   		    fprintf (stderr,
  1298   1285   			     "Mismatching Vertical Resolution (Strict) !!!\n");
  1299   1286   		goto error;
  1300   1287   	    }
  1301   1288         }
................................................................................
  1322   1309   	    }
  1323   1310         }
  1324   1311   
  1325   1312       no_data = rl2_get_coverage_no_data (cvg);
  1326   1313   
  1327   1314   /* INSERTing the section */
  1328   1315       if (!rl2_do_insert_section
  1329         -	(handle, src_path, section, srid, width, height, minx, miny, maxx,
  1330         -	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         1316  +	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
         1317  +	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  1331   1318   	 coverage->sectionSummary, stmt_sect, &section_id))
  1332   1319   	goto error;
  1333   1320       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  1334   1321       if (section_stats == NULL)
  1335   1322   	goto error;
  1336   1323   /* INSERTing the base-levels */
  1337   1324       if (coverage->mixedResolutions)
................................................................................
  1690   1677   	  maxy = height - 1.0;
  1691   1678   	  res_x = 1.0;
  1692   1679   	  res_y = 1.0;
  1693   1680         }
  1694   1681       raster_in = (rl2PrivRasterPtr) rst_in;
  1695   1682       xml_summary =
  1696   1683   	rl2_build_jpeg2000_xml_summary (width, height, raster_in->sampleType,
  1697         -					raster_in->pixelType,
  1698         -					raster_in->nBands, is_georeferenced,
  1699         -					res_x, res_y, minx, miny, maxx, maxy,
  1700         -					tile_width, tile_height);
         1684  +					raster_in->pixelType, raster_in->nBands,
         1685  +					is_georeferenced, res_x, res_y, minx,
         1686  +					miny, maxx, maxy, tile_width,
         1687  +					tile_height);
  1701   1688   
  1702   1689       printf ("------------------\n");
  1703   1690       if (total > 1)
  1704   1691   	printf ("%d/%d) Importing: %s\n", current, total, src_path);
  1705   1692       else
  1706   1693   	printf ("Importing: %s\n", src_path);
  1707   1694       printf ("    Image Size (pixels): %d x %d\n", width, height);
................................................................................
  1730   1717       if (coverage->mixedResolutions)
  1731   1718         {
  1732   1719   	  /* accepting any resolution */
  1733   1720         }
  1734   1721       else if (coverage->strictResolution)
  1735   1722         {
  1736   1723   	  /* enforcing Strict Resolution check */
  1737         -	  double x_diff = fabs (coverage->hResolution - res_x);
  1738         -	  double y_diff = fabs (coverage->vResolution - res_y);
  1739         -	  double x_lim = coverage->hResolution / 1000000.0;
  1740         -	  double y_lim = coverage->vResolution / 1000000.0;
  1741         -	  if (x_diff > x_lim)
         1724  +	  if (res_x != coverage->hResolution)
  1742   1725   	    {
  1743   1726   		if (verbose)
  1744   1727   		    fprintf (stderr,
  1745   1728   			     "Mismatching Horizontal Resolution (Strict) !!!\n");
  1746   1729   		goto error;
  1747   1730   	    }
  1748         -	  if (y_diff > y_lim)
         1731  +	  if (res_y != coverage->vResolution)
  1749   1732   	    {
  1750   1733   		if (verbose)
  1751   1734   		    fprintf (stderr,
  1752   1735   			     "Mismatching Vertical Resolution (Strict) !!!\n");
  1753   1736   		goto error;
  1754   1737   	    }
  1755   1738         }
................................................................................
  1776   1759   	    }
  1777   1760         }
  1778   1761   
  1779   1762       no_data = rl2_get_coverage_no_data (cvg);
  1780   1763   
  1781   1764   /* INSERTing the section */
  1782   1765       if (!rl2_do_insert_section
  1783         -	(handle, src_path, section, srid, width, height, minx, miny, maxx,
  1784         -	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         1766  +	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
         1767  +	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  1785   1768   	 coverage->sectionSummary, stmt_sect, &section_id))
  1786   1769   	goto error;
  1787   1770       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  1788   1771       if (section_stats == NULL)
  1789   1772   	goto error;
  1790   1773   /* INSERTing the base-levels */
  1791   1774       if (coverage->mixedResolutions)
................................................................................
  2087   2070       rl2AuxImporterTilePtr *thread_slots = NULL;
  2088   2071       int thread_count;
  2089   2072   
  2090   2073       if (is_ascii_grid (src_path))
  2091   2074   	return do_import_ascii_grid (handle, max_threads, src_path, cvg,
  2092   2075   				     section, force_srid, tile_w, tile_h,
  2093   2076   				     pyramidize, sample_type, compression,
  2094         -				     stmt_data, stmt_tils, stmt_sect,
  2095         -				     stmt_levl, stmt_upd_sect, verbose,
  2096         -				     current, total);
         2077  +				     stmt_data, stmt_tils, stmt_sect, stmt_levl,
         2078  +				     stmt_upd_sect, verbose, current, total);
  2097   2079   
  2098   2080       if (is_jpeg_image (src_path))
  2099   2081   	return do_import_jpeg_image (handle, max_threads, src_path, cvg,
  2100   2082   				     section, force_srid, tile_w, tile_h,
  2101   2083   				     pyramidize, sample_type, num_bands,
  2102         -				     compression, quality, stmt_data,
  2103         -				     stmt_tils, stmt_sect, stmt_levl,
  2104         -				     stmt_upd_sect, verbose, current, total);
         2084  +				     compression, quality, stmt_data, stmt_tils,
         2085  +				     stmt_sect, stmt_levl, stmt_upd_sect,
         2086  +				     verbose, current, total);
  2105   2087   
  2106   2088   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
  2107   2089       if (is_jpeg2000_image (src_path))
  2108   2090   	return do_import_jpeg2000_image (handle, max_threads, src_path, cvg,
  2109   2091   					 section, force_srid, tile_w, tile_h,
  2110   2092   					 pyramidize, sample_type, num_bands,
  2111   2093   					 compression, quality, stmt_data,
................................................................................
  2189   2171       if (coverage->mixedResolutions)
  2190   2172         {
  2191   2173   	  /* accepting any resolution */
  2192   2174         }
  2193   2175       else if (coverage->strictResolution)
  2194   2176         {
  2195   2177   	  /* enforcing Strict Resolution check */
  2196         -	  double x_diff = fabs (coverage->hResolution - res_x);
  2197         -	  double y_diff = fabs (coverage->vResolution - res_y);
  2198         -	  double x_lim = coverage->hResolution / 1000000.0;
  2199         -	  double y_lim = coverage->vResolution / 1000000.0;
  2200         -	  if (x_diff > x_lim)
         2178  +	  if (res_x != coverage->hResolution)
  2201   2179   	    {
  2202   2180   		if (verbose)
  2203   2181   		    fprintf (stderr,
  2204   2182   			     "Mismatching Horizontal Resolution (Strict) !!!\n");
  2205   2183   		goto error;
  2206   2184   	    }
  2207         -	  if (y_diff > y_lim)
         2185  +	  if (res_y != coverage->vResolution)
  2208   2186   	    {
  2209   2187   		if (verbose)
  2210   2188   		    fprintf (stderr,
  2211   2189   			     "Mismatching Vertical Resolution (Strict) !!!\n");
  2212   2190   		goto error;
  2213   2191   	    }
  2214   2192         }
................................................................................
  2234   2212   		goto error;
  2235   2213   	    }
  2236   2214         }
  2237   2215   
  2238   2216       if (pixel_type == RL2_PIXEL_PALETTE)
  2239   2217         {
  2240   2218   	  /* remapping the Palette */
  2241         -	  if (do_check_initial_palette (handle, cvg) == RL2_TRUE)
  2242         -	    {
  2243         -		if (rl2_install_dbms_palette_from_tiff (handle, cvg, origin) !=
  2244         -		    RL2_OK)
  2245         -		  {
  2246         -		      fprintf (stderr,
  2247         -			       "Unable to install the initial Palette !!!\n");
  2248         -		      goto error;
  2249         -		  }
  2250         -	    }
  2251   2219   	  if (rl2_check_dbms_palette (handle, cvg, origin) != RL2_OK)
  2252   2220   	    {
  2253   2221   		fprintf (stderr, "Mismatching Palette !!!\n");
  2254   2222   		goto error;
  2255   2223   	    }
  2256   2224         }
  2257   2225   
  2258         -    if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose)
  2259         -	!= RL2_TRUE)
         2226  +    if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose) !=
         2227  +	RL2_TRUE)
  2260   2228         {
  2261   2229   	  fprintf (stderr, "Coverage/TIFF mismatch\n");
  2262   2230   	  goto error;
  2263   2231         }
  2264   2232       no_data = rl2_get_coverage_no_data (cvg);
  2265   2233   
  2266   2234   /* INSERTing the section */
  2267   2235       if (!rl2_do_insert_section
  2268         -	(handle, src_path, section, srid, width, height, minx, miny, maxx,
  2269         -	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         2236  +	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
         2237  +	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  2270   2238   	 coverage->sectionSummary, stmt_sect, &section_id))
  2271   2239   	goto error;
  2272   2240       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  2273   2241       if (section_stats == NULL)
  2274   2242   	goto error;
  2275   2243   /* INSERTing the base-levels */
  2276   2244       if (coverage->mixedResolutions)
................................................................................
  2566   2534   		      if ((c_file.attrib & _A_RDONLY) == _A_RDONLY
  2567   2535   			  || (c_file.attrib & _A_NORMAL) == _A_NORMAL)
  2568   2536   			{
  2569   2537   			    path =
  2570   2538   				sqlite3_mprintf ("%s/%s", dir_path,
  2571   2539   						 c_file.name);
  2572   2540   			    ret =
  2573         -				do_import_file (handle, max_threads, path,
  2574         -						cvg, section, worldfile,
  2575         -						force_srid, pyramidize,
  2576         -						sample_type, pixel_type,
  2577         -						num_bands, tile_w, tile_h,
  2578         -						compression, quality,
  2579         -						stmt_data, stmt_tils,
  2580         -						stmt_sect, stmt_levl,
  2581         -						stmt_upd_sect, verbose,
  2582         -						cnt + 1, total);
         2541  +				do_import_file (handle, max_threads, path, cvg,
         2542  +						section, worldfile, force_srid,
         2543  +						pyramidize, sample_type,
         2544  +						pixel_type, num_bands, tile_w,
         2545  +						tile_h, compression, quality,
         2546  +						stmt_data, stmt_tils, stmt_sect,
         2547  +						stmt_levl, stmt_upd_sect,
         2548  +						verbose, cnt + 1, total);
  2583   2549   			    sqlite3_free (path);
  2584   2550   			    if (!ret)
  2585   2551   				goto error;
  2586   2552   			    cnt++;
  2587   2553   			}
  2588   2554   		      if (_findnext (hFile, &c_file) != 0)
  2589   2555   			  break;
................................................................................
  2806   2772   	       stmt_sect, stmt_levl, stmt_upd_sect, verbose, -1, -1))
  2807   2773   	      goto error;
  2808   2774         }
  2809   2775       else
  2810   2776         {
  2811   2777   	  /* importing all Image files from a whole directory */
  2812   2778   	  if (!do_import_dir
  2813         -	      (handle, max_threads, dir_path, file_ext, cvg, section,
  2814         -	       worldfile, force_srid, pyramidize, sample_type, pixel_type,
  2815         -	       num_bands, tile_w, tile_h, compression, quality, stmt_data,
  2816         -	       stmt_tils, stmt_sect, stmt_levl, stmt_upd_sect, verbose))
         2779  +	      (handle, max_threads, dir_path, file_ext, cvg, section, worldfile,
         2780  +	       force_srid, pyramidize, sample_type, pixel_type, num_bands,
         2781  +	       tile_w, tile_h, compression, quality, stmt_data, stmt_tils,
         2782  +	       stmt_sect, stmt_levl, stmt_upd_sect, verbose))
  2817   2783   	      goto error;
  2818   2784         }
  2819   2785   
  2820   2786       sqlite3_finalize (stmt_upd_sect);
  2821   2787       sqlite3_finalize (stmt_sect);
  2822   2788       sqlite3_finalize (stmt_levl);
  2823   2789       sqlite3_finalize (stmt_tils);
................................................................................
  2928   2894   		*p_out++ = *p_in++;
  2929   2895   	    }
  2930   2896         }
  2931   2897   }
  2932   2898   
  2933   2899   static void
  2934   2900   copy_uint8_outbuf_to_tile (const unsigned char *outbuf, unsigned char *tile,
  2935         -			   unsigned char pixel_type, unsigned char num_bands,
  2936         -			   unsigned int width, unsigned int height,
  2937         -			   unsigned int tile_width, unsigned int tile_height,
  2938         -			   unsigned int base_y, unsigned int base_x)
         2901  +			   unsigned char num_bands, unsigned int width,
         2902  +			   unsigned int height,
         2903  +			   unsigned int tile_width,
         2904  +			   unsigned int tile_height, unsigned int base_y,
         2905  +			   unsigned int base_x)
  2939   2906   {
  2940   2907   /* copying UINT8 pixels from the output buffer into the tile */
  2941   2908       unsigned int x;
  2942   2909       unsigned int y;
  2943   2910       int b;
  2944   2911       const unsigned char *p_in;
  2945   2912       unsigned char *p_out = tile;
................................................................................
  2955   2922   	    {
  2956   2923   		if ((base_x + x) >= width)
  2957   2924   		  {
  2958   2925   		      p_out += num_bands;
  2959   2926   		      p_in += num_bands;
  2960   2927   		      continue;
  2961   2928   		  }
  2962         -		if (pixel_type == RL2_PIXEL_MONOCHROME)
  2963         -		  {
  2964         -		      unsigned char pxl = *p_in++;
  2965         -		      if (pxl == 0)
  2966         -			  *p_out++ = 1;
  2967         -		      else
  2968         -			  *p_out++ = 0;
  2969         -		  }
  2970         -		else if (pixel_type == RL2_PIXEL_PALETTE)
  2971         -		  {
  2972         -		      unsigned char pxl = *p_in++;
  2973         -		      if (pxl == 0)
  2974         -			  *p_out++ = 1;
  2975         -		      else
  2976         -			  *p_out++ = 0;
  2977         -		  }
  2978         -		else
  2979         -		  {
  2980         -		      for (b = 0; b < num_bands; b++)
  2981         -			  *p_out++ = *p_in++;
  2982         -		  }
         2929  +		for (b = 0; b < num_bands; b++)
         2930  +		    *p_out++ = *p_in++;
  2983   2931   	    }
  2984   2932         }
  2985   2933   }
  2986   2934   
  2987   2935   static void
  2988   2936   copy_int16_outbuf_to_tile (const short *outbuf, short *tile,
  2989   2937   			   unsigned int width,
................................................................................
  3013   2961   		  }
  3014   2962   		*p_out++ = *p_in++;
  3015   2963   	    }
  3016   2964         }
  3017   2965   }
  3018   2966   
  3019   2967   static void
  3020         -copy_uint16_outbuf_to_tile (const unsigned short *outbuf,
  3021         -			    unsigned short *tile, unsigned char num_bands,
  3022         -			    unsigned int width, unsigned int height,
  3023         -			    unsigned int tile_width, unsigned int tile_height,
  3024         -			    unsigned int base_y, unsigned int base_x)
         2968  +copy_uint16_outbuf_to_tile (const unsigned short *outbuf, unsigned short *tile,
         2969  +			    unsigned char num_bands, unsigned int width,
         2970  +			    unsigned int height,
         2971  +			    unsigned int tile_width,
         2972  +			    unsigned int tile_height, unsigned int base_y,
         2973  +			    unsigned int base_x)
  3025   2974   {
  3026   2975   /* copying UINT16 pixels from the output buffer into the tile */
  3027   2976       unsigned int x;
  3028   2977       unsigned int y;
  3029   2978       int b;
  3030   2979       const unsigned short *p_in;
  3031   2980       unsigned short *p_out = tile;
................................................................................
  3176   3125   		*p_out++ = *p_in++;
  3177   3126   	    }
  3178   3127         }
  3179   3128   }
  3180   3129   
  3181   3130   static void
  3182   3131   copy_from_outbuf_to_tile (const unsigned char *outbuf, unsigned char *tile,
  3183         -			  unsigned char sample_type, unsigned char pixel_type,
  3184         -			  unsigned char num_bands, unsigned int width,
  3185         -			  unsigned int height, unsigned int tile_width,
  3186         -			  unsigned int tile_height, unsigned int base_y,
  3187         -			  unsigned int base_x)
         3132  +			  unsigned char sample_type, unsigned char num_bands,
         3133  +			  unsigned int width, unsigned int height,
         3134  +			  unsigned int tile_width, unsigned int tile_height,
         3135  +			  unsigned int base_y, unsigned int base_x)
  3188   3136   {
  3189   3137   /* copying pixels from the output buffer into the tile */
  3190   3138       switch (sample_type)
  3191   3139         {
  3192   3140         case RL2_SAMPLE_INT8:
  3193   3141   	  copy_int8_outbuf_to_tile ((char *) outbuf,
  3194   3142   				    (char *) tile, width, height, tile_width,
  3195   3143   				    tile_height, base_y, base_x);
  3196   3144   	  break;
  3197   3145         case RL2_SAMPLE_INT16:
  3198   3146   	  copy_int16_outbuf_to_tile ((short *) outbuf,
  3199         -				     (short *) tile, width, height,
  3200         -				     tile_width, tile_height, base_y, base_x);
         3147  +				     (short *) tile, width, height, tile_width,
         3148  +				     tile_height, base_y, base_x);
  3201   3149   	  break;
  3202   3150         case RL2_SAMPLE_UINT16:
  3203   3151   	  copy_uint16_outbuf_to_tile ((unsigned short *) outbuf,
  3204   3152   				      (unsigned short *) tile, num_bands,
  3205   3153   				      width, height, tile_width, tile_height,
  3206   3154   				      base_y, base_x);
  3207   3155   	  break;
................................................................................
  3213   3161         case RL2_SAMPLE_UINT32:
  3214   3162   	  copy_uint32_outbuf_to_tile ((unsigned int *) outbuf,
  3215   3163   				      (unsigned int *) tile, width, height,
  3216   3164   				      tile_width, tile_height, base_y, base_x);
  3217   3165   	  break;
  3218   3166         case RL2_SAMPLE_FLOAT:
  3219   3167   	  copy_float_outbuf_to_tile ((float *) outbuf,
  3220         -				     (float *) tile, width, height,
  3221         -				     tile_width, tile_height, base_y, base_x);
         3168  +				     (float *) tile, width, height, tile_width,
         3169  +				     tile_height, base_y, base_x);
  3222   3170   	  break;
  3223   3171         case RL2_SAMPLE_DOUBLE:
  3224   3172   	  copy_double_outbuf_to_tile ((double *) outbuf,
  3225   3173   				      (double *) tile, width, height,
  3226   3174   				      tile_width, tile_height, base_y, base_x);
  3227   3175   	  break;
  3228   3176         default:
  3229   3177   	  copy_uint8_outbuf_to_tile ((unsigned char *) outbuf,
  3230         -				     (unsigned char *) tile, pixel_type,
  3231         -				     num_bands, width, height, tile_width,
  3232         -				     tile_height, base_y, base_x);
         3178  +				     (unsigned char *) tile, num_bands, width,
         3179  +				     height, tile_width, tile_height, base_y,
         3180  +				     base_x);
  3233   3181   	  break;
  3234   3182         };
  3235   3183   }
  3236   3184   
  3237   3185   static int
  3238         -export_geotiff_common (sqlite3 * handle, int max_threads,
  3239         -		       const char *dst_path, rl2CoveragePtr cvg,
  3240         -		       int by_section, sqlite3_int64 section_id, double x_res,
  3241         -		       double y_res, double minx, double miny, double maxx,
  3242         -		       double maxy, unsigned int width, unsigned int height,
         3186  +export_geotiff_common (sqlite3 * handle, int max_threads, const char *dst_path,
         3187  +		       rl2CoveragePtr cvg, int by_section,
         3188  +		       sqlite3_int64 section_id, double x_res, double y_res,
         3189  +		       double minx, double miny, double maxx, double maxy,
         3190  +		       unsigned int width, unsigned int height,
  3243   3191   		       unsigned char compression, unsigned int tile_sz,
  3244   3192   		       int with_worldfile)
  3245   3193   {
  3246   3194   /* exporting a GeoTIFF common implementation */
  3247   3195       rl2RasterPtr raster = NULL;
  3248   3196       rl2PalettePtr palette = NULL;
  3249   3197       rl2PalettePtr plt2 = NULL;
................................................................................
  3306   3254   	    }
  3307   3255         }
  3308   3256   
  3309   3257       if (by_section)
  3310   3258         {
  3311   3259   	  /* just a single Section */
  3312   3260   	  if (rl2_get_section_raw_raster_data
  3313         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  3314         -	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
  3315         -	       &palette, pixel_type) != RL2_OK)
         3261  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         3262  +	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3263  +	       pixel_type) != RL2_OK)
  3316   3264   	      goto error;
  3317   3265         }
  3318   3266       else
  3319   3267         {
  3320   3268   	  /* whole Coverage */
  3321   3269   	  if (rl2_get_raw_raster_data
  3322         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  3323         -	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3270  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         3271  +	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3324   3272   	       pixel_type) != RL2_OK)
  3325   3273   	      goto error;
  3326   3274         }
  3327   3275   
  3328   3276   /* computing the sample size */
  3329   3277       switch (sample_type)
  3330   3278         {
................................................................................
  3363   3311   			       "rl2tool Export: Insufficient Memory !!!\n");
  3364   3312   		      goto error;
  3365   3313   		  }
  3366   3314   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3367   3315   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3368   3316   						 no_data);
  3369   3317   		else
  3370         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
  3371         -					 sample_type, num_bands, no_data);
         3318  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
         3319  +					 num_bands, no_data);
  3372   3320   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3373         -					  pixel_type, num_bands, width, height,
  3374         -					  tile_sz, tile_sz, base_y, base_x);
         3321  +					  num_bands, width, height, tile_sz,
         3322  +					  tile_sz, base_y, base_x);
  3375   3323   		plt2 = rl2_clone_palette (palette);
  3376   3324   		raster =
  3377   3325   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3378   3326   				       pixel_type, num_bands, bufpix,
  3379   3327   				       bufpix_size, plt2, NULL, 0, NULL);
  3380   3328   		bufpix = NULL;
  3381   3329   		if (raster == NULL)
................................................................................
  3428   3376       return export_geotiff_common (handle, max_threads, dst_path, cvg, 0, 0,
  3429   3377   				  x_res, y_res, minx, miny, maxx, maxy, width,
  3430   3378   				  height, compression, tile_sz, with_worldfile);
  3431   3379   }
  3432   3380   
  3433   3381   RL2_DECLARE int
  3434   3382   rl2_export_section_geotiff_from_dbms (sqlite3 * handle, int max_threads,
  3435         -				      const char *dst_path,
  3436         -				      rl2CoveragePtr cvg,
         3383  +				      const char *dst_path, rl2CoveragePtr cvg,
  3437   3384   				      sqlite3_int64 section_id, double x_res,
  3438   3385   				      double y_res, double minx, double miny,
  3439   3386   				      double maxx, double maxy,
  3440   3387   				      unsigned int width, unsigned int height,
  3441   3388   				      unsigned char compression,
  3442   3389   				      unsigned int tile_sz, int with_worldfile)
  3443   3390   {
................................................................................
  3520   3467   	    }
  3521   3468         }
  3522   3469   
  3523   3470       if (by_section)
  3524   3471         {
  3525   3472   	  /* just a single select Section */
  3526   3473   	  if (rl2_get_section_raw_raster_data
  3527         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  3528         -	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
  3529         -	       &palette, pixel_type) != RL2_OK)
         3474  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         3475  +	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3476  +	       pixel_type) != RL2_OK)
  3530   3477   	      goto error;
  3531   3478         }
  3532   3479       else
  3533   3480         {
  3534   3481   	  /* whole Coverage */
  3535   3482   	  if (rl2_get_raw_raster_data
  3536         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  3537         -	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3483  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         3484  +	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3538   3485   	       pixel_type) != RL2_OK)
  3539   3486   	      goto error;
  3540   3487         }
  3541   3488   
  3542   3489   /* computing the sample size */
  3543   3490       switch (sample_type)
  3544   3491         {
................................................................................
  3555   3502   	  pix_sz = 8;
  3556   3503   	  break;
  3557   3504         };
  3558   3505   
  3559   3506       tiff =
  3560   3507   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  3561   3508   					       sample_type, pixel_type,
  3562         -					       num_bands, palette,
  3563         -					       compression, 1, tile_sz, srid,
  3564         -					       minx, miny, maxx, maxy, xx_res,
  3565         -					       yy_res);
         3509  +					       num_bands, palette, compression,
         3510  +					       1, tile_sz, srid, minx, miny,
         3511  +					       maxx, maxy, xx_res, yy_res);
  3566   3512       if (tiff == NULL)
  3567   3513   	goto error;
  3568   3514       for (base_y = 0; base_y < height; base_y += tile_sz)
  3569   3515         {
  3570   3516   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  3571   3517   	    {
  3572   3518   		/* exporting all tiles from the output buffer */
................................................................................
  3578   3524   			       "rl2tool Export: Insufficient Memory !!!\n");
  3579   3525   		      goto error;
  3580   3526   		  }
  3581   3527   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3582   3528   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3583   3529   						 no_data);
  3584   3530   		else
  3585         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
  3586         -					 sample_type, num_bands, no_data);
         3531  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
         3532  +					 num_bands, no_data);
  3587   3533   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3588         -					  pixel_type, num_bands, width, height,
  3589         -					  tile_sz, tile_sz, base_y, base_x);
         3534  +					  num_bands, width, height, tile_sz,
         3535  +					  tile_sz, base_y, base_x);
  3590   3536   		plt2 = rl2_clone_palette (palette);
  3591   3537   		raster =
  3592   3538   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3593   3539   				       pixel_type, num_bands, bufpix,
  3594   3540   				       bufpix_size, plt2, NULL, 0, NULL);
  3595   3541   		bufpix = NULL;
  3596   3542   		if (raster == NULL)
................................................................................
  3634   3580   				     double miny, double maxx, double maxy,
  3635   3581   				     unsigned int width, unsigned int height,
  3636   3582   				     unsigned char compression,
  3637   3583   				     unsigned int tile_sz)
  3638   3584   {
  3639   3585   /* exporting a TIFF+TFW from the DBMS into the file-system */
  3640   3586       return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 0,
  3641         -					0, x_res, y_res, minx, miny, maxx,
  3642         -					maxy, width, height, compression,
  3643         -					tile_sz);
         3587  +					0, x_res, y_res, minx, miny, maxx, maxy,
         3588  +					width, height, compression, tile_sz);
  3644   3589   }
  3645   3590   
  3646   3591   RL2_DECLARE int
  3647         -rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle,
  3648         -					     int max_threads,
         3592  +rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle, int max_threads,
  3649   3593   					     const char *dst_path,
  3650   3594   					     rl2CoveragePtr cvg,
  3651   3595   					     sqlite3_int64 section_id,
  3652   3596   					     double x_res, double y_res,
  3653   3597   					     double minx, double miny,
  3654   3598   					     double maxx, double maxy,
  3655   3599   					     unsigned int width,
................................................................................
  3656   3600   					     unsigned int height,
  3657   3601   					     unsigned char compression,
  3658   3602   					     unsigned int tile_sz)
  3659   3603   {
  3660   3604   /* exporting a TIFF+TFW - single Section */
  3661   3605       return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 1,
  3662   3606   					section_id, x_res, y_res, minx, miny,
  3663         -					maxx, maxy, width, height,
  3664         -					compression, tile_sz);
         3607  +					maxx, maxy, width, height, compression,
         3608  +					tile_sz);
  3665   3609   }
  3666   3610   
  3667   3611   static int
  3668   3612   export_tiff_common (sqlite3 * handle, int max_threads, const char *dst_path,
  3669   3613   		    rl2CoveragePtr cvg, int by_section,
  3670   3614   		    sqlite3_int64 section_id, double x_res, double y_res,
  3671   3615   		    double minx, double miny, double maxx, double maxy,
................................................................................
  3737   3681   	    }
  3738   3682         }
  3739   3683   
  3740   3684       if (by_section)
  3741   3685         {
  3742   3686   	  /* just a single Section */
  3743   3687   	  if (rl2_get_section_raw_raster_data
  3744         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  3745         -	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
  3746         -	       &palette, pixel_type) != RL2_OK)
         3688  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         3689  +	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3690  +	       pixel_type) != RL2_OK)
  3747   3691   	      goto error;
  3748   3692         }
  3749   3693       else
  3750   3694         {
  3751   3695   	  /* whole Coverage */
  3752   3696   	  if (rl2_get_raw_raster_data
  3753         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  3754         -	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3697  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         3698  +	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3755   3699   	       pixel_type) != RL2_OK)
  3756   3700   	      goto error;
  3757   3701         }
  3758   3702   
  3759   3703   /* computing the sample size */
  3760   3704       switch (sample_type)
  3761   3705         {
................................................................................
  3792   3736   			       "rl2tool Export: Insufficient Memory !!!\n");
  3793   3737   		      goto error;
  3794   3738   		  }
  3795   3739   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3796   3740   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3797   3741   						 no_data);
  3798   3742   		else
  3799         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
  3800         -					 sample_type, num_bands, no_data);
         3743  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
         3744  +					 num_bands, no_data);
  3801   3745   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3802         -					  pixel_type, num_bands, width, height,
  3803         -					  tile_sz, tile_sz, base_y, base_x);
         3746  +					  num_bands, width, height, tile_sz,
         3747  +					  tile_sz, base_y, base_x);
  3804   3748   		plt2 = rl2_clone_palette (palette);
  3805   3749   		raster =
  3806   3750   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3807   3751   				       pixel_type, num_bands, bufpix,
  3808   3752   				       bufpix_size, plt2, NULL, 0, NULL);
  3809   3753   		bufpix = NULL;
  3810   3754   		if (raster == NULL)
................................................................................
  3836   3780   	rl2_destroy_palette (palette);
  3837   3781       return RL2_ERROR;
  3838   3782   }
  3839   3783   
  3840   3784   RL2_DECLARE int
  3841   3785   rl2_export_tiff_from_dbms (sqlite3 * handle, int max_threads,
  3842   3786   			   const char *dst_path, rl2CoveragePtr cvg,
  3843         -			   double x_res, double y_res, double minx,
  3844         -			   double miny, double maxx, double maxy,
  3845         -			   unsigned int width, unsigned int height,
  3846         -			   unsigned char compression, unsigned int tile_sz)
         3787  +			   double x_res, double y_res, double minx, double miny,
         3788  +			   double maxx, double maxy, unsigned int width,
         3789  +			   unsigned int height, unsigned char compression,
         3790  +			   unsigned int tile_sz)
  3847   3791   {
  3848   3792   /* exporting a plain TIFF from the DBMS into the file-system */
  3849         -    return export_tiff_common (handle, max_threads, dst_path, cvg, 0, 0,
  3850         -			       x_res, y_res, minx, miny, maxx, maxy, width,
  3851         -			       height, compression, tile_sz);
         3793  +    return export_tiff_common (handle, max_threads, dst_path, cvg, 0, 0, x_res,
         3794  +			       y_res, minx, miny, maxx, maxy, width, height,
         3795  +			       compression, tile_sz);
  3852   3796   }
  3853   3797   
  3854   3798   RL2_DECLARE int
  3855   3799   rl2_export_section_tiff_from_dbms (sqlite3 * handle, int max_threads,
  3856   3800   				   const char *dst_path, rl2CoveragePtr cvg,
  3857   3801   				   sqlite3_int64 section_id, double x_res,
  3858   3802   				   double y_res, double minx, double miny,
  3859         -				   double maxx, double maxy,
  3860         -				   unsigned int width, unsigned int height,
         3803  +				   double maxx, double maxy, unsigned int width,
         3804  +				   unsigned int height,
  3861   3805   				   unsigned char compression,
  3862   3806   				   unsigned int tile_sz)
  3863   3807   {
  3864   3808   /* exporting a plain TIFF - single Section*/
  3865   3809       return export_tiff_common (handle, max_threads, dst_path, cvg, 1,
  3866         -			       section_id, x_res, y_res, minx, miny, maxx,
  3867         -			       maxy, width, height, compression, tile_sz);
         3810  +			       section_id, x_res, y_res, minx, miny, maxx, maxy,
         3811  +			       width, height, compression, tile_sz);
  3868   3812   }
  3869   3813   
  3870   3814   static int
  3871   3815   export_triple_band_geotiff_common (int by_section, sqlite3 * handle,
  3872   3816   				   const char *dst_path,
  3873         -				   rl2CoveragePtr cvg,
  3874         -				   sqlite3_int64 section_id, double x_res,
  3875         -				   double y_res, double minx, double miny,
  3876         -				   double maxx, double maxy,
         3817  +				   rl2CoveragePtr cvg, sqlite3_int64 section_id,
         3818  +				   double x_res, double y_res, double minx,
         3819  +				   double miny, double maxx, double maxy,
  3877   3820   				   unsigned int width, unsigned int height,
  3878   3821   				   unsigned char red_band,
  3879   3822   				   unsigned char green_band,
  3880   3823   				   unsigned char blue_band,
  3881   3824   				   unsigned char compression,
  3882   3825   				   unsigned int tile_sz, int with_worldfile)
  3883   3826   {
................................................................................
  3949   3892   	      goto error;
  3950   3893         }
  3951   3894   
  3952   3895       tiff =
  3953   3896   	rl2_create_geotiff_destination (dst_path, handle, width, height,
  3954   3897   					sample_type, RL2_PIXEL_RGB, 3,
  3955   3898   					NULL, compression, 1, tile_sz, srid,
  3956         -					minx, miny, maxx, maxy, xx_res,
  3957         -					yy_res, with_worldfile);
         3899  +					minx, miny, maxx, maxy, xx_res, yy_res,
         3900  +					with_worldfile);
  3958   3901       if (tiff == NULL)
  3959   3902   	goto error;
  3960   3903       for (base_y = 0; base_y < height; base_y += tile_sz)
  3961   3904         {
  3962   3905   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  3963   3906   	    {
  3964   3907   		/* exporting all tiles from the output buffer */
................................................................................
  3971   3914   		      fprintf (stderr,
  3972   3915   			       "rl2tool Export: Insufficient Memory !!!\n");
  3973   3916   		      goto error;
  3974   3917   		  }
  3975   3918   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  3976   3919   				     3, no_data);
  3977   3920   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3978         -					  pixel_type, 3, width, height, tile_sz,
         3921  +					  3, width, height, tile_sz,
  3979   3922   					  tile_sz, base_y, base_x);
  3980   3923   		raster =
  3981   3924   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3982         -				       RL2_PIXEL_RGB, 3, bufpix, bufpix_size,
  3983         -				       NULL, NULL, 0, NULL);
         3925  +				       RL2_PIXEL_RGB, 3, bufpix,
         3926  +				       bufpix_size, NULL, NULL, 0, NULL);
  3984   3927   		bufpix = NULL;
  3985   3928   		if (raster == NULL)
  3986   3929   		    goto error;
  3987   3930   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  3988   3931   		    RL2_OK)
  3989   3932   		    goto error;
  3990   3933   		rl2_destroy_raster (raster);
................................................................................
  4147   4090       else
  4148   4091   	out_pixel = RL2_PIXEL_GRAYSCALE;
  4149   4092   
  4150   4093       tiff =
  4151   4094   	rl2_create_geotiff_destination (dst_path, handle, width, height,
  4152   4095   					sample_type, out_pixel, 1,
  4153   4096   					NULL, compression, 1, tile_sz, srid,
  4154         -					minx, miny, maxx, maxy, xx_res,
  4155         -					yy_res, with_worldfile);
         4097  +					minx, miny, maxx, maxy, xx_res, yy_res,
         4098  +					with_worldfile);
  4156   4099       if (tiff == NULL)
  4157   4100   	goto error;
  4158   4101       for (base_y = 0; base_y < height; base_y += tile_sz)
  4159   4102         {
  4160   4103   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4161   4104   	    {
  4162   4105   		/* exporting all tiles from the output buffer */
................................................................................
  4169   4112   		      fprintf (stderr,
  4170   4113   			       "rl2tool Export: Insufficient Memory !!!\n");
  4171   4114   		      goto error;
  4172   4115   		  }
  4173   4116   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  4174   4117   				     1, no_data);
  4175   4118   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  4176         -					  pixel_type, 1, width, height, tile_sz,
         4119  +					  1, width, height, tile_sz,
  4177   4120   					  tile_sz, base_y, base_x);
  4178   4121   		raster =
  4179         -		    rl2_create_raster (tile_sz, tile_sz, sample_type, out_pixel,
  4180         -				       1, bufpix, bufpix_size, NULL, NULL, 0,
  4181         -				       NULL);
         4122  +		    rl2_create_raster (tile_sz, tile_sz, sample_type,
         4123  +				       out_pixel, 1, bufpix,
         4124  +				       bufpix_size, NULL, NULL, 0, NULL);
  4182   4125   		bufpix = NULL;
  4183   4126   		if (raster == NULL)
  4184   4127   		    goto error;
  4185   4128   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  4186   4129   		    RL2_OK)
  4187   4130   		    goto error;
  4188   4131   		rl2_destroy_raster (raster);
................................................................................
  4227   4170   					unsigned int height,
  4228   4171   					unsigned char mono_band,
  4229   4172   					unsigned char compression,
  4230   4173   					unsigned int tile_sz,
  4231   4174   					int with_worldfile)
  4232   4175   {
  4233   4176   /* exporting a Mono-Band GeoTIFF from the DBMS into the file-system */
  4234         -    return export_mono_band_geotiff_common (0, handle, dst_path, cvg, 0,
  4235         -					    x_res, y_res, minx, miny, maxx,
  4236         -					    maxy, width, height, mono_band,
         4177  +    return export_mono_band_geotiff_common (0, handle, dst_path, cvg, 0, x_res,
         4178  +					    y_res, minx, miny, maxx, maxy,
         4179  +					    width, height, mono_band,
  4237   4180   					    compression, tile_sz,
  4238   4181   					    with_worldfile);
  4239   4182   }
  4240   4183   
  4241   4184   RL2_DECLARE int
  4242   4185   rl2_export_section_mono_band_geotiff_from_dbms (sqlite3 * handle,
  4243   4186   						const char *dst_path,
................................................................................
  4263   4206   
  4264   4207   static int
  4265   4208   export_triple_band_tiff_worldfile_common (int by_section, sqlite3 * handle,
  4266   4209   					  const char *dst_path,
  4267   4210   					  rl2CoveragePtr cvg,
  4268   4211   					  sqlite3_int64 section_id,
  4269   4212   					  double x_res, double y_res,
  4270         -					  double minx, double miny,
  4271         -					  double maxx, double maxy,
  4272         -					  unsigned int width,
         4213  +					  double minx, double miny, double maxx,
         4214  +					  double maxy, unsigned int width,
  4273   4215   					  unsigned int height,
  4274   4216   					  unsigned char red_band,
  4275   4217   					  unsigned char green_band,
  4276   4218   					  unsigned char blue_band,
  4277   4219   					  unsigned char compression,
  4278   4220   					  unsigned int tile_sz)
  4279   4221   {
................................................................................
  4344   4286   	       no_data) != RL2_OK)
  4345   4287   	      goto error;
  4346   4288         }
  4347   4289   
  4348   4290       tiff =
  4349   4291   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  4350   4292   					       sample_type, RL2_PIXEL_RGB,
  4351         -					       3, NULL, compression, 1,
  4352         -					       tile_sz, srid, minx, miny,
  4353         -					       maxx, maxy, xx_res, yy_res);
         4293  +					       3, NULL, compression, 1, tile_sz,
         4294  +					       srid, minx, miny, maxx, maxy,
         4295  +					       xx_res, yy_res);
  4354   4296       if (tiff == NULL)
  4355   4297   	goto error;
  4356   4298       for (base_y = 0; base_y < height; base_y += tile_sz)
  4357   4299         {
  4358   4300   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4359   4301   	    {
  4360   4302   		/* exporting all tiles from the output buffer */
................................................................................
  4367   4309   		      fprintf (stderr,
  4368   4310   			       "rl2tool Export: Insufficient Memory !!!\n");
  4369   4311   		      goto error;
  4370   4312   		  }
  4371   4313   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  4372   4314   				     3, no_data);
  4373   4315   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  4374         -					  pixel_type, 3, width, height, tile_sz,
         4316  +					  3, width, height, tile_sz,
  4375   4317   					  tile_sz, base_y, base_x);
  4376   4318   		raster =
  4377   4319   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  4378         -				       RL2_PIXEL_RGB, 3, bufpix, bufpix_size,
  4379         -				       NULL, NULL, 0, NULL);
         4320  +				       RL2_PIXEL_RGB, 3, bufpix,
         4321  +				       bufpix_size, NULL, NULL, 0, NULL);
  4380   4322   		bufpix = NULL;
  4381   4323   		if (raster == NULL)
  4382   4324   		    goto error;
  4383   4325   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  4384   4326   		    RL2_OK)
  4385   4327   		    goto error;
  4386   4328   		rl2_destroy_raster (raster);
................................................................................
  4446   4388   							 double y_res,
  4447   4389   							 double minx,
  4448   4390   							 double miny,
  4449   4391   							 double maxx,
  4450   4392   							 double maxy,
  4451   4393   							 unsigned int width,
  4452   4394   							 unsigned int height,
  4453         -							 unsigned char
  4454         -							 red_band,
         4395  +							 unsigned char red_band,
  4455   4396   							 unsigned char
  4456   4397   							 green_band,
  4457   4398   							 unsigned char
  4458   4399   							 blue_band,
  4459   4400   							 unsigned char
  4460   4401   							 compression,
  4461   4402   							 unsigned int tile_sz)
................................................................................
  4469   4410   						     compression, tile_sz);
  4470   4411   }
  4471   4412   
  4472   4413   static int
  4473   4414   export_mono_band_tiff_worldfile_common (int by_section, sqlite3 * handle,
  4474   4415   					const char *dst_path,
  4475   4416   					rl2CoveragePtr cvg,
  4476         -					sqlite3_int64 section_id,
  4477         -					double x_res, double y_res,
  4478         -					double minx, double miny, double maxx,
  4479         -					double maxy, unsigned int width,
  4480         -					unsigned int height,
         4417  +					sqlite3_int64 section_id, double x_res,
         4418  +					double y_res, double minx, double miny,
         4419  +					double maxx, double maxy,
         4420  +					unsigned int width, unsigned int height,
  4481   4421   					unsigned char mono_band,
  4482   4422   					unsigned char compression,
  4483   4423   					unsigned int tile_sz)
  4484   4424   {
  4485   4425   /* exporting a Mono-Band TIFF+TFW - common implementation */
  4486   4426       rl2RasterPtr raster = NULL;
  4487   4427       rl2PixelPtr no_data_multi = NULL;
................................................................................
  4548   4488   	out_pixel = RL2_PIXEL_DATAGRID;
  4549   4489       else
  4550   4490   	out_pixel = RL2_PIXEL_GRAYSCALE;
  4551   4491   
  4552   4492       tiff =
  4553   4493   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  4554   4494   					       sample_type, out_pixel,
  4555         -					       1, NULL, compression, 1,
  4556         -					       tile_sz, srid, minx, miny,
  4557         -					       maxx, maxy, xx_res, yy_res);
         4495  +					       1, NULL, compression, 1, tile_sz,
         4496  +					       srid, minx, miny, maxx, maxy,
         4497  +					       xx_res, yy_res);
  4558   4498       if (tiff == NULL)
  4559   4499   	goto error;
  4560   4500       for (base_y = 0; base_y < height; base_y += tile_sz)
  4561   4501         {
  4562   4502   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4563   4503   	    {
  4564   4504   		/* exporting all tiles from the output buffer */
................................................................................
  4571   4511   		      fprintf (stderr,
  4572   4512   			       "rl2tool Export: Insufficient Memory !!!\n");
  4573   4513   		      goto error;
  4574   4514   		  }
  4575   4515   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  4576   4516   				     1, no_data);
  4577   4517   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  4578         -					  pixel_type, 1, width, height, tile_sz,
         4518  +					  1, width, height, tile_sz,
  4579   4519   					  tile_sz, base_y, base_x);
  4580   4520   		raster =
  4581         -		    rl2_create_raster (tile_sz, tile_sz, sample_type, out_pixel,
  4582         -				       1, bufpix, bufpix_size, NULL, NULL, 0,
  4583         -				       NULL);
         4521  +		    rl2_create_raster (tile_sz, tile_sz, sample_type,
         4522  +				       out_pixel, 1, bufpix,
         4523  +				       bufpix_size, NULL, NULL, 0, NULL);
  4584   4524   		bufpix = NULL;
  4585   4525   		if (raster == NULL)
  4586   4526   		    goto error;
  4587   4527   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  4588   4528   		    RL2_OK)
  4589   4529   		    goto error;
  4590   4530   		rl2_destroy_raster (raster);
................................................................................
  4626   4566   					       unsigned int width,
  4627   4567   					       unsigned int height,
  4628   4568   					       unsigned char mono_band,
  4629   4569   					       unsigned char compression,
  4630   4570   					       unsigned int tile_sz)
  4631   4571   {
  4632   4572   /* exporting a Mono-Band TIFF+TFW from the DBMS into the file-system */
  4633         -    return export_mono_band_tiff_worldfile_common (0, handle, dst_path, cvg,
  4634         -						   0, x_res, y_res, minx,
  4635         -						   miny, maxx, maxy, width,
  4636         -						   height, mono_band,
  4637         -						   compression, tile_sz);
         4573  +    return export_mono_band_tiff_worldfile_common (0, handle, dst_path, cvg, 0,
         4574  +						   x_res, y_res, minx, miny,
         4575  +						   maxx, maxy, width, height,
         4576  +						   mono_band, compression,
         4577  +						   tile_sz);
  4638   4578   }
  4639   4579   
  4640   4580   RL2_DECLARE int
  4641   4581   rl2_export_section_mono_band_tiff_worldfile_from_dbms (sqlite3 * handle,
  4642   4582   						       const char *dst_path,
  4643   4583   						       rl2CoveragePtr cvg,
  4644         -						       sqlite3_int64
  4645         -						       section_id,
         4584  +						       sqlite3_int64 section_id,
  4646   4585   						       double x_res,
  4647   4586   						       double y_res,
  4648         -						       double minx,
  4649         -						       double miny,
  4650         -						       double maxx,
  4651         -						       double maxy,
         4587  +						       double minx, double miny,
         4588  +						       double maxx, double maxy,
  4652   4589   						       unsigned int width,
  4653   4590   						       unsigned int height,
  4654         -						       unsigned char
  4655         -						       mono_band,
         4591  +						       unsigned char mono_band,
  4656   4592   						       unsigned char
  4657   4593   						       compression,
  4658   4594   						       unsigned int tile_sz)
  4659   4595   {
  4660   4596   /* exporting a Mono-Band TIFF+TFW - Section */
  4661   4597       return export_mono_band_tiff_worldfile_common (1, handle, dst_path, cvg,
  4662   4598   						   section_id, x_res, y_res,
................................................................................
  4764   4700   		      fprintf (stderr,
  4765   4701   			       "rl2tool Export: Insufficient Memory !!!\n");
  4766   4702   		      goto error;
  4767   4703   		  }
  4768   4704   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  4769   4705   				     3, no_data);
  4770   4706   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  4771         -					  pixel_type, 3, width, height, tile_sz,
         4707  +					  3, width, height, tile_sz,
  4772   4708   					  tile_sz, base_y, base_x);
  4773   4709   		raster =
  4774   4710   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  4775         -				       RL2_PIXEL_RGB, 3, bufpix, bufpix_size,
  4776         -				       NULL, NULL, 0, NULL);
         4711  +				       RL2_PIXEL_RGB, 3, bufpix,
         4712  +				       bufpix_size, NULL, NULL, 0, NULL);
  4777   4713   		bufpix = NULL;
  4778   4714   		if (raster == NULL)
  4779   4715   		    goto error;
  4780   4716   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  4781   4717   		    RL2_OK)
  4782   4718   		    goto error;
  4783   4719   		rl2_destroy_raster (raster);
................................................................................
  4816   4752   				       unsigned char green_band,
  4817   4753   				       unsigned char blue_band,
  4818   4754   				       unsigned char compression,
  4819   4755   				       unsigned int tile_sz)
  4820   4756   {
  4821   4757   /* exporting a plain Band-Composed TIFF from the DBMS into the file-system */
  4822   4758       return export_triple_band_tiff_common (0, handle, dst_path, cvg, 0, x_res,
  4823         -					   y_res, minx, miny, maxx, maxy,
  4824         -					   width, height, red_band,
  4825         -					   green_band, blue_band, compression,
  4826         -					   tile_sz);
         4759  +					   y_res, minx, miny, maxx, maxy, width,
         4760  +					   height, red_band, green_band,
         4761  +					   blue_band, compression, tile_sz);
  4827   4762   }
  4828   4763   
  4829   4764   RL2_DECLARE int
  4830   4765   rl2_export_section_triple_band_tiff_from_dbms (sqlite3 * handle,
  4831   4766   					       const char *dst_path,
  4832   4767   					       rl2CoveragePtr cvg,
  4833   4768   					       sqlite3_int64 section_id,
................................................................................
  4839   4774   					       unsigned char red_band,
  4840   4775   					       unsigned char green_band,
  4841   4776   					       unsigned char blue_band,
  4842   4777   					       unsigned char compression,
  4843   4778   					       unsigned int tile_sz)
  4844   4779   {
  4845   4780   /* exporting a plain Band-Composed TIFF - Section */
  4846         -    return export_triple_band_tiff_common (1, handle, dst_path, cvg,
  4847         -					   section_id, x_res, y_res, minx,
  4848         -					   miny, maxx, maxy, width, height,
  4849         -					   red_band, green_band, blue_band,
  4850         -					   compression, tile_sz);
         4781  +    return export_triple_band_tiff_common (1, handle, dst_path, cvg, section_id,
         4782  +					   x_res, y_res, minx, miny, maxx, maxy,
         4783  +					   width, height, red_band, green_band,
         4784  +					   blue_band, compression, tile_sz);
  4851   4785   }
  4852   4786   
  4853   4787   static int
  4854   4788   export_mono_band_tiff_common (int by_section, sqlite3 * handle,
  4855   4789   			      const char *dst_path, rl2CoveragePtr cvg,
  4856   4790   			      sqlite3_int64 section_id, double x_res,
  4857   4791   			      double y_res, double minx, double miny,
................................................................................
  4946   4880   		      fprintf (stderr,
  4947   4881   			       "rl2tool Export: Insufficient Memory !!!\n");
  4948   4882   		      goto error;
  4949   4883   		  }
  4950   4884   		rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  4951   4885   				     1, no_data);
  4952   4886   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  4953         -					  pixel_type, 1, width, height, tile_sz,
         4887  +					  1, width, height, tile_sz,
  4954   4888   					  tile_sz, base_y, base_x);
  4955   4889   		raster =
  4956         -		    rl2_create_raster (tile_sz, tile_sz, sample_type, out_pixel,
  4957         -				       1, bufpix, bufpix_size, NULL, NULL, 0,
  4958         -				       NULL);
         4890  +		    rl2_create_raster (tile_sz, tile_sz, sample_type,
         4891  +				       out_pixel, 1, bufpix,
         4892  +				       bufpix_size, NULL, NULL, 0, NULL);
  4959   4893   		bufpix = NULL;
  4960   4894   		if (raster == NULL)
  4961   4895   		    goto error;
  4962   4896   		if (rl2_write_tiff_tile (tiff, raster, base_y, base_x) !=
  4963   4897   		    RL2_OK)
  4964   4898   		    goto error;
  4965   4899   		rl2_destroy_raster (raster);
................................................................................
  5018   4952   					     unsigned char mono_band,
  5019   4953   					     unsigned char compression,
  5020   4954   					     unsigned int tile_sz)
  5021   4955   {
  5022   4956   /* exporting a plain Mono-Band TIFF from the DBMS - Section */
  5023   4957       return export_mono_band_tiff_common (1, handle, dst_path, cvg, section_id,
  5024   4958   					 x_res, y_res, minx, miny, maxx, maxy,
  5025         -					 width, height, mono_band,
  5026         -					 compression, tile_sz);
         4959  +					 width, height, mono_band, compression,
         4960  +					 tile_sz);
  5027   4961   }
  5028   4962   
  5029   4963   static int
  5030   4964   export_ascii_grid_common (int by_section, sqlite3 * handle, int max_threads,
  5031   4965   			  const char *dst_path, rl2CoveragePtr cvg,
  5032   4966   			  sqlite3_int64 section_id, double res, double minx,
  5033   4967   			  double miny, double maxx, double maxy,
................................................................................
  5127   5061   	    }
  5128   5062         }
  5129   5063   
  5130   5064       if (by_section)
  5131   5065         {
  5132   5066   	  /* single Section */
  5133   5067   	  if (rl2_get_section_raw_raster_data
  5134         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  5135         -	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
         5068  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         5069  +	       maxx, maxy, res, res, &pixels, &pixels_size, &palette,
  5136   5070   	       RL2_PIXEL_DATAGRID) != RL2_OK)
  5137   5071   	      goto error;
  5138   5072         }
  5139   5073       else
  5140   5074         {
  5141   5075   	  /* whole Coverage */
  5142   5076   	  if (rl2_get_raw_raster_data
  5143         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  5144         -	       maxy, res, res, &pixels, &pixels_size, &palette,
         5077  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         5078  +	       res, res, &pixels, &pixels_size, &palette,
  5145   5079   	       RL2_PIXEL_DATAGRID) != RL2_OK)
  5146   5080   	      goto error;
  5147   5081         }
  5148   5082   
  5149   5083       ascii =
  5150   5084   	rl2_create_ascii_grid_destination (dst_path, width, height,
  5151   5085   					   xx_res, minx, miny, is_centered,
................................................................................
  5186   5120   				 double res, double minx, double miny,
  5187   5121   				 double maxx, double maxy, unsigned int width,
  5188   5122   				 unsigned int height, int is_centered,
  5189   5123   				 int decimal_digits)
  5190   5124   {
  5191   5125   /* exporting an ASCII Grid from the DBMS into the file-system */
  5192   5126       return export_ascii_grid_common (0, handle, max_threads, dst_path, cvg, 0,
  5193         -				     res, minx, miny, maxx, maxy, width,
  5194         -				     height, is_centered, decimal_digits);
         5127  +				     res, minx, miny, maxx, maxy, width, height,
         5128  +				     is_centered, decimal_digits);
  5195   5129   }
  5196   5130   
  5197   5131   RL2_DECLARE int
  5198   5132   rl2_export_section_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
  5199   5133   					 const char *dst_path,
  5200   5134   					 rl2CoveragePtr cvg,
  5201   5135   					 sqlite3_int64 section_id, double res,
  5202         -					 double minx, double miny,
  5203         -					 double maxx, double maxy,
  5204         -					 unsigned int width,
         5136  +					 double minx, double miny, double maxx,
         5137  +					 double maxy, unsigned int width,
  5205   5138   					 unsigned int height, int is_centered,
  5206   5139   					 int decimal_digits)
  5207   5140   {
  5208   5141   /* exporting an ASCII Grid - Section */
  5209   5142       return export_ascii_grid_common (1, handle, max_threads, dst_path, cvg,
  5210   5143   				     section_id, res, minx, miny, maxx, maxy,
  5211   5144   				     width, height, is_centered,
................................................................................
  5251   5184   	  if (match == no_data->nBands)
  5252   5185   	      return 1;
  5253   5186         }
  5254   5187       return 0;
  5255   5188   }
  5256   5189   
  5257   5190   static float
  5258         -compute_ndvi (void *pixels, unsigned char sample_type,
  5259         -	      unsigned char num_bands, unsigned short width,
  5260         -	      unsigned char red_band, unsigned char nir_band,
  5261         -	      unsigned short row, unsigned short col,
         5191  +compute_ndvi (void *pixels, unsigned char sample_type, unsigned char num_bands,
         5192  +	      unsigned short width, unsigned char red_band,
         5193  +	      unsigned char nir_band, unsigned short row, unsigned short col,
  5262   5194   	      rl2PrivPixelPtr in_no_data, float out_no_data)
  5263   5195   {
  5264   5196   /* computing a Normalized Difference Vegetaion Index -NDVI */
  5265   5197       float red;
  5266   5198       float nir;
  5267   5199       unsigned char *p8;
  5268   5200       unsigned short *p16;
................................................................................
  5291   5223   
  5292   5224   static int
  5293   5225   export_ndvi_ascii_grid_common (int by_section, sqlite3 * handle,
  5294   5226   			       int max_threads, const char *dst_path,
  5295   5227   			       rl2CoveragePtr cvg, sqlite3_int64 section_id,
  5296   5228   			       double res, double minx, double miny,
  5297   5229   			       double maxx, double maxy, unsigned int width,
  5298         -			       unsigned int height, int red_band,
  5299         -			       int nir_band, int is_centered,
  5300         -			       int decimal_digits)
         5230  +			       unsigned int height, int red_band, int nir_band,
         5231  +			       int is_centered, int decimal_digits)
  5301   5232   {
  5302   5233   /* exporting an NDVI ASCII Grid common implementation */
  5303   5234       rl2PalettePtr palette = NULL;
  5304   5235       rl2PixelPtr in_no_data;
  5305   5236       rl2AsciiGridDestinationPtr ascii = NULL;
  5306   5237       unsigned char level;
  5307   5238       unsigned char scale;
................................................................................
  5346   5277       if (red_band == nir_band)
  5347   5278   	goto error;
  5348   5279   
  5349   5280       if (by_section)
  5350   5281         {
  5351   5282   	  /* single Section */
  5352   5283   	  if (rl2_get_section_raw_raster_data
  5353         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  5354         -	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
         5284  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         5285  +	       maxx, maxy, res, res, &pixels, &pixels_size, &palette,
  5355   5286   	       RL2_PIXEL_MULTIBAND) != RL2_OK)
  5356   5287   	      goto error;
  5357   5288         }
  5358   5289       else
  5359   5290         {
  5360   5291   	  /* whole Coverage */
  5361   5292   	  if (rl2_get_raw_raster_data
  5362         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  5363         -	       maxy, res, res, &pixels, &pixels_size, &palette,
         5293  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         5294  +	       res, res, &pixels, &pixels_size, &palette,
  5364   5295   	       RL2_PIXEL_MULTIBAND) != RL2_OK)
  5365   5296   	      goto error;
  5366   5297         }
  5367   5298   
  5368   5299   /* creating the output NDVI raster */
  5369   5300       out_pixels_size = width * height * sizeof (float);
  5370   5301       out_pixels = malloc (out_pixels_size);
................................................................................
  5372   5303   	goto error;
  5373   5304       po = (float *) out_pixels;
  5374   5305       for (row = 0; row < height; row++)
  5375   5306         {
  5376   5307   	  /* computing NDVI */
  5377   5308   	  for (col = 0; col < width; col++)
  5378   5309   	      *po++ =
  5379         -		  compute_ndvi (pixels, sample_type, num_bands, width,
  5380         -				red_band, nir_band, row, col,
         5310  +		  compute_ndvi (pixels, sample_type, num_bands, width, red_band,
         5311  +				nir_band, row, col,
  5381   5312   				(rl2PrivPixelPtr) in_no_data, out_no_data);
  5382   5313         }
  5383   5314       free (pixels);
  5384   5315       pixels = NULL;
  5385   5316   
  5386   5317       ascii =
  5387   5318   	rl2_create_ascii_grid_destination (dst_path, width, height,
................................................................................
  5416   5347       if (palette != NULL)
  5417   5348   	rl2_destroy_palette (palette);
  5418   5349       return RL2_ERROR;
  5419   5350   }
  5420   5351   
  5421   5352   RL2_DECLARE int
  5422   5353   rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
  5423         -				      const char *dst_path,
  5424         -				      rl2CoveragePtr cvg, double res,
  5425         -				      double minx, double miny, double maxx,
  5426         -				      double maxy, unsigned int width,
  5427         -				      unsigned int height, int red_band,
  5428         -				      int nir_band, int is_centered,
  5429         -				      int decimal_digits)
         5354  +				      const char *dst_path, rl2CoveragePtr cvg,
         5355  +				      double res, double minx, double miny,
         5356  +				      double maxx, double maxy,
         5357  +				      unsigned int width, unsigned int height,
         5358  +				      int red_band, int nir_band,
         5359  +				      int is_centered, int decimal_digits)
  5430   5360   {
  5431   5361   /* exporting an ASCII Grid from the DBMS into the file-system */
  5432         -    return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path,
  5433         -					  cvg, 0, res, minx, miny, maxx, maxy,
  5434         -					  width, height, red_band, nir_band,
         5362  +    return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path, cvg,
         5363  +					  0, res, minx, miny, maxx, maxy, width,
         5364  +					  height, red_band, nir_band,
  5435   5365   					  is_centered, decimal_digits);
  5436   5366   }
  5437   5367   
  5438   5368   RL2_DECLARE int
  5439         -rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
  5440         -					      int max_threads,
         5369  +rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
  5441   5370   					      const char *dst_path,
  5442   5371   					      rl2CoveragePtr cvg,
  5443   5372   					      sqlite3_int64 section_id,
  5444   5373   					      double res, double minx,
  5445   5374   					      double miny, double maxx,
  5446   5375   					      double maxy, unsigned int width,
  5447         -					      unsigned int height,
  5448         -					      int red_band, int nir_band,
  5449         -					      int is_centered,
         5376  +					      unsigned int height, int red_band,
         5377  +					      int nir_band, int is_centered,
  5450   5378   					      int decimal_digits)
  5451   5379   {
  5452   5380   /* exporting an ASCII Grid - Section */
  5453         -    return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path,
  5454         -					  cvg, section_id, res, minx, miny,
  5455         -					  maxx, maxy, width, height, red_band,
         5381  +    return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path, cvg,
         5382  +					  section_id, res, minx, miny, maxx,
         5383  +					  maxy, width, height, red_band,
  5456   5384   					  nir_band, is_centered,
  5457   5385   					  decimal_digits);
  5458   5386   }
  5459   5387   
  5460   5388   static int
  5461   5389   export_jpeg_common (int by_section, sqlite3 * handle, int max_threads,
  5462   5390   		    const char *dst_path, rl2CoveragePtr cvg,
................................................................................
  5499   5427       else
  5500   5428   	goto error;
  5501   5429   
  5502   5430       if (by_section)
  5503   5431         {
  5504   5432   	  /* single Section */
  5505   5433   	  if (rl2_get_section_raw_raster_data
  5506         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  5507         -	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5434  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         5435  +	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5508   5436   	       pixel_type) != RL2_OK)
  5509   5437   	      goto error;
  5510   5438         }
  5511   5439       else
  5512   5440         {
  5513   5441   	  /* whole Coverage */
  5514   5442   	  if (rl2_get_raw_raster_data
  5515         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  5516         -	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5443  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         5444  +	       xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5517   5445   	       pixel_type) != RL2_OK)
  5518   5446   	      goto error;
  5519   5447         }
  5520   5448   
  5521   5449       raster =
  5522   5450   	rl2_create_raster (width, height, sample_type, pixel_type, num_bands,
  5523   5451   			   outbuf, outbuf_size, NULL, NULL, 0, NULL);
................................................................................
  5550   5478   	free (outbuf);
  5551   5479       return RL2_ERROR;
  5552   5480   }
  5553   5481   
  5554   5482   RL2_DECLARE int
  5555   5483   rl2_export_jpeg_from_dbms (sqlite3 * handle, int max_threads,
  5556   5484   			   const char *dst_path, rl2CoveragePtr cvg,
  5557         -			   double x_res, double y_res, double minx,
  5558         -			   double miny, double maxx, double maxy,
  5559         -			   unsigned int width, unsigned int height,
  5560         -			   int quality, int with_worldfile)
         5485  +			   double x_res, double y_res, double minx, double miny,
         5486  +			   double maxx, double maxy, unsigned int width,
         5487  +			   unsigned int height, int quality, int with_worldfile)
  5561   5488   {
  5562   5489   /* exporting a JPEG (with possible JGW) from the DBMS into the file-system */
  5563         -    return export_jpeg_common (0, handle, max_threads, dst_path, cvg, 0,
  5564         -			       x_res, y_res, minx, miny, maxx, maxy, width,
  5565         -			       height, quality, with_worldfile);
         5490  +    return export_jpeg_common (0, handle, max_threads, dst_path, cvg, 0, x_res,
         5491  +			       y_res, minx, miny, maxx, maxy, width, height,
         5492  +			       quality, with_worldfile);
  5566   5493   }
  5567   5494   
  5568   5495   RL2_DECLARE int
  5569   5496   rl2_export_section_jpeg_from_dbms (sqlite3 * handle, int max_threads,
  5570   5497   				   const char *dst_path, rl2CoveragePtr cvg,
  5571   5498   				   sqlite3_int64 section_id, double x_res,
  5572   5499   				   double y_res, double minx, double miny,
  5573         -				   double maxx, double maxy,
  5574         -				   unsigned int width, unsigned int height,
  5575         -				   int quality, int with_worldfile)
         5500  +				   double maxx, double maxy, unsigned int width,
         5501  +				   unsigned int height, int quality,
         5502  +				   int with_worldfile)
  5576   5503   {
  5577   5504   /* exporting a JPEG (with possible JGW) - Section */
  5578   5505       return export_jpeg_common (1, handle, max_threads, dst_path, cvg,
  5579         -			       section_id, x_res, y_res, minx, miny, maxx,
  5580         -			       maxy, width, height, quality, with_worldfile);
         5506  +			       section_id, x_res, y_res, minx, miny, maxx, maxy,
         5507  +			       width, height, quality, with_worldfile);
  5581   5508   }
  5582   5509   
  5583   5510   static int
  5584   5511   export_raw_pixels_common (int by_section, sqlite3 * handle, int max_threads,
  5585   5512   			  rl2CoveragePtr cvg, sqlite3_int64 section_id,
  5586         -			  double x_res, double y_res, double minx,
  5587         -			  double miny, double maxx, double maxy,
  5588         -			  unsigned int width, unsigned int height,
  5589         -			  int big_endian, unsigned char **blob, int *blob_size)
         5513  +			  double x_res, double y_res, double minx, double miny,
         5514  +			  double maxx, double maxy, unsigned int width,
         5515  +			  unsigned int height, int big_endian,
         5516  +			  unsigned char **blob, int *blob_size)
  5590   5517   {
  5591   5518   /* common implementation for Export RAW pixels */
  5592   5519       unsigned char level;
  5593   5520       unsigned char scale;
  5594   5521       double xx_res = x_res;
  5595   5522       double yy_res = y_res;
  5596   5523       unsigned char sample_type;
................................................................................
  5613   5540   	RL2_OK)
  5614   5541   	goto error;
  5615   5542   
  5616   5543       if (by_section)
  5617   5544         {
  5618   5545   	  /* single Section */
  5619   5546   	  if (rl2_get_section_raw_raster_data
  5620         -	      (handle, max_threads, cvg, section_id, width, height, minx,
  5621         -	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5547  +	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
         5548  +	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5622   5549   	       pixel_type) != RL2_OK)
  5623   5550   	      goto error;
  5624   5551         }
  5625   5552       else
  5626   5553         {
  5627   5554   	  /* whole Coverage */
  5628   5555   	  if (rl2_get_raw_raster_data
  5629         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
  5630         -	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5556  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
         5557  +	       xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5631   5558   	       pixel_type) != RL2_OK)
  5632   5559   	      goto error;
  5633   5560         }
  5634   5561       bufpix =
  5635   5562   	rl2_copy_endian_raw_pixels (outbuf, outbuf_size, width, height,
  5636   5563   				    sample_type, num_bands, big_endian);
  5637   5564       if (bufpix == NULL)
................................................................................
  5653   5580   				 double y_res, double minx, double miny,
  5654   5581   				 double maxx, double maxy,
  5655   5582   				 unsigned int width,
  5656   5583   				 unsigned int height, int big_endian,
  5657   5584   				 unsigned char **blob, int *blob_size)
  5658   5585   {
  5659   5586   /* exporting RAW pixel buffer and Transparency Mask from the DBMS */
  5660         -    return export_raw_pixels_common (0, handle, max_threads, coverage, 0,
  5661         -				     x_res, y_res, minx, miny, maxx, maxy,
  5662         -				     width, height, big_endian, blob,
  5663         -				     blob_size);
         5587  +    return export_raw_pixels_common (0, handle, max_threads, coverage, 0, x_res,
         5588  +				     y_res, minx, miny, maxx, maxy, width,
         5589  +				     height, big_endian, blob, blob_size);
  5664   5590   }
  5665   5591   
  5666   5592   RL2_DECLARE int
  5667   5593   rl2_export_section_raw_pixels_from_dbms (sqlite3 * handle, int max_threads,
  5668   5594   					 rl2CoveragePtr coverage,
  5669   5595   					 sqlite3_int64 section_id,
  5670   5596   					 double x_res, double y_res,
................................................................................
  5673   5599   					 unsigned int width,
  5674   5600   					 unsigned int height,
  5675   5601   					 int big_endian,
  5676   5602   					 unsigned char **blob, int *blob_size)
  5677   5603   {
  5678   5604   /* exporting RAW pixel buffer and Transparency Mask - Section */
  5679   5605       return export_raw_pixels_common (1, handle, max_threads, coverage,
  5680         -				     section_id, x_res, y_res, minx, miny,
  5681         -				     maxx, maxy, width, height, big_endian,
  5682         -				     blob, blob_size);
         5606  +				     section_id, x_res, y_res, minx, miny, maxx,
         5607  +				     maxy, width, height, big_endian, blob,
         5608  +				     blob_size);
  5683   5609   }
  5684   5610   
  5685   5611   RL2_DECLARE int
  5686   5612   rl2_load_raw_raster_into_dbms (sqlite3 * handle, int max_threads,
  5687   5613   			       rl2CoveragePtr cvg, const char *section,
  5688   5614   			       rl2RasterPtr rst, int pyramidize)
  5689   5615   {
................................................................................
  6079   6005       return RL2_OK;
  6080   6006   
  6081   6007     error:
  6082   6008       if (aux != NULL)
  6083   6009   	destroyAuxImporter (aux);
  6084   6010       if (thread_slots != NULL)
  6085   6011   	free (thread_slots);
  6086         -    if (stmt_upd_sect != NULL)
  6087         -	sqlite3_finalize (stmt_upd_sect);
  6088         -    if (stmt_sect != NULL)
  6089         -	sqlite3_finalize (stmt_sect);
  6090         -    if (stmt_levl != NULL)
  6091         -	sqlite3_finalize (stmt_levl);
  6092         -    if (stmt_tils != NULL)
  6093         -	sqlite3_finalize (stmt_tils);
  6094         -    if (stmt_data != NULL)
  6095         -	sqlite3_finalize (stmt_data);
  6096         -    return RL2_ERROR;
  6097         -}
  6098         -
  6099         -RL2_DECLARE int
  6100         -rl2_load_raw_tiles_into_dbms (sqlite3 * handle,
  6101         -			      rl2CoveragePtr cvg, const char *section,
  6102         -			      unsigned int sctn_width,
  6103         -			      unsigned int sctn_height,
  6104         -			      int sctn_srid,
  6105         -			      double sctn_minx,
  6106         -			      double sctn_miny,
  6107         -			      double sctn_maxx,
  6108         -			      double sctn_maxy,
  6109         -			      int (*getTile) (void *data, double tile_minx,
  6110         -					      double tile_miny,
  6111         -					      double tile_maxx,
  6112         -					      double tile_maxy,
  6113         -					      unsigned char *bufpix,
  6114         -					      rl2PalettePtr * palette),
  6115         -			      void *data, int pyramidize)
  6116         -{
  6117         -/* callback-based IMPORT Raster function */
  6118         -    rl2PrivCoveragePtr privcvg = (rl2PrivCoveragePtr) cvg;
  6119         -    int ret;
  6120         -    char *sql;
  6121         -    const char *coverage;
  6122         -    unsigned char sample_type;
  6123         -    unsigned char pixel_type;
  6124         -    unsigned char num_bands;
  6125         -    unsigned int tile_w;
  6126         -    unsigned int tile_h;
  6127         -    unsigned char compression;
  6128         -    int quality;
  6129         -    char *table;
  6130         -    char *xtable;
  6131         -    unsigned int tileWidth;
  6132         -    unsigned int tileHeight;
  6133         -    unsigned int width = sctn_width;
  6134         -    unsigned int height = sctn_height;
  6135         -    int srid;
  6136         -    double minx = sctn_minx;
  6137         -    double miny = sctn_miny;
  6138         -    double maxx = sctn_maxx;
  6139         -    double maxy = sctn_maxy;
  6140         -    double tile_minx;
  6141         -    double tile_miny;
  6142         -    double tile_maxx;
  6143         -    double tile_maxy;
  6144         -    rl2RasterStatisticsPtr section_stats = NULL;
  6145         -    rl2PixelPtr no_data = NULL;
  6146         -    rl2PalettePtr palette = NULL;
  6147         -    rl2PalettePtr aux_palette = NULL;
  6148         -    unsigned int row;
  6149         -    unsigned int col;
  6150         -    double res_x;
  6151         -    double res_y;
  6152         -    double hResolution;
  6153         -    double vResolution;
  6154         -    double base_res_x;
  6155         -    double base_res_y;
  6156         -    char *xml_summary = NULL;
  6157         -    sqlite3_stmt *stmt_data = NULL;
  6158         -    sqlite3_stmt *stmt_tils = NULL;
  6159         -    sqlite3_stmt *stmt_sect = NULL;
  6160         -    sqlite3_stmt *stmt_levl = NULL;
  6161         -    sqlite3_stmt *stmt_upd_sect = NULL;
  6162         -    sqlite3_int64 section_id;
  6163         -    int pixel_size;
  6164         -    int bufpix_sz;
  6165         -
  6166         -    if (cvg == NULL)
  6167         -	goto error;
  6168         -    if (section == NULL)
  6169         -	goto error;
  6170         -    if (width == 0 || height == 0)
  6171         -	goto error;
  6172         -    if (minx >= maxx || miny >= maxy)
  6173         -	goto error;
  6174         -    hResolution = (sctn_maxx - sctn_minx) / (double) sctn_width;
  6175         -    vResolution = (sctn_maxy - sctn_miny) / (double) sctn_height;
  6176         -
  6177         -    if (rl2_get_coverage_tile_size (cvg, &tileWidth, &tileHeight) != RL2_OK)
  6178         -	goto error;
  6179         -    if (rl2_get_coverage_srid (cvg, &srid) != RL2_OK)
  6180         -	goto error;
  6181         -    if (srid != sctn_srid)
  6182         -	goto error;
  6183         -    srid = sctn_srid;
  6184         -
  6185         -    tile_w = tileWidth;
  6186         -    tile_h = tileHeight;
  6187         -    rl2_get_coverage_compression (cvg, &compression, &quality);
  6188         -    rl2_get_coverage_type (cvg, &sample_type, &pixel_type, &num_bands);
  6189         -    coverage = rl2_get_coverage_name (cvg);
  6190         -    switch (sample_type)
  6191         -      {
  6192         -      case RL2_SAMPLE_INT16:
  6193         -      case RL2_SAMPLE_UINT16:
  6194         -	  pixel_size = 2;
  6195         -	  break;
  6196         -      case RL2_SAMPLE_INT32:
  6197         -      case RL2_SAMPLE_UINT32:
  6198         -      case RL2_SAMPLE_FLOAT:
  6199         -	  pixel_size = 4;
  6200         -	  break;
  6201         -      case RL2_SAMPLE_DOUBLE:
  6202         -	  pixel_size = 8;
  6203         -	  break;
  6204         -      default:
  6205         -	  pixel_size = 1;
  6206         -	  break;
  6207         -      };
  6208         -    pixel_size *= num_bands;
  6209         -    bufpix_sz = tile_w * tile_h * pixel_size;
  6210         -
  6211         -    table = sqlite3_mprintf ("%s_sections", coverage);
  6212         -    xtable = rl2_double_quoted_sql (table);
  6213         -    sqlite3_free (table);
  6214         -    sql =
  6215         -	sqlite3_mprintf
  6216         -	("INSERT INTO \"%s\" (section_id, section_name, file_path, "
  6217         -	 "md5_checksum, summary, width, height, geometry) "
  6218         -	 "VALUES (NULL, ?, ?, ?, XB_Create(?), ?, ?, ?)", xtable);
  6219         -    free (xtable);
  6220         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_sect, NULL);
  6221         -    sqlite3_free (sql);
  6222         -    if (ret != SQLITE_OK)
  6223         -      {
  6224         -	  printf ("INSERT INTO sections SQL error: %s\n",
  6225         -		  sqlite3_errmsg (handle));
  6226         -	  goto error;
  6227         -      }
  6228         -
  6229         -    table = sqlite3_mprintf ("%s_sections", coverage);
  6230         -    xtable = rl2_double_quoted_sql (table);
  6231         -    sqlite3_free (table);
  6232         -    sql =
  6233         -	sqlite3_mprintf
  6234         -	("UPDATE \"%s\" SET statistics = ? WHERE section_id = ?", xtable);
  6235         -    free (xtable);
  6236         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_upd_sect, NULL);
  6237         -    sqlite3_free (sql);
  6238         -    if (ret != SQLITE_OK)
  6239         -      {
  6240         -	  printf ("UPDATE sections SQL error: %s\n", sqlite3_errmsg (handle));
  6241         -	  goto error;
  6242         -      }
  6243         -
  6244         -    if (privcvg->mixedResolutions)
  6245         -      {
  6246         -	  /* mixed resolutions Coverage */
  6247         -	  table = sqlite3_mprintf ("%s_section_levels", coverage);
  6248         -	  xtable = rl2_double_quoted_sql (table);
  6249         -	  sqlite3_free (table);
  6250         -	  sql =
  6251         -	      sqlite3_mprintf
  6252         -	      ("INSERT OR IGNORE INTO \"%s\" (section_id, pyramid_level, "
  6253         -	       "x_resolution_1_1, y_resolution_1_1, "
  6254         -	       "x_resolution_1_2, y_resolution_1_2, x_resolution_1_4, "
  6255         -	       "y_resolution_1_4, x_resolution_1_8, y_resolution_1_8) "
  6256         -	       "VALUES (?, 0, ?, ?, ?, ?, ?, ?, ?, ?)", xtable);
  6257         -	  free (xtable);
  6258         -	  ret =
  6259         -	      sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_levl, NULL);
  6260         -	  sqlite3_free (sql);
  6261         -	  if (ret != SQLITE_OK)
  6262         -	    {
  6263         -		printf ("INSERT INTO section_levels SQL error: %s\n",
  6264         -			sqlite3_errmsg (handle));
  6265         -		goto error;
  6266         -	    }
  6267         -      }
  6268         -    else
  6269         -      {
  6270         -	  /* single resolution Coverage */
  6271         -	  table = sqlite3_mprintf ("%s_levels", coverage);
  6272         -	  xtable = rl2_double_quoted_sql (table);
  6273         -	  sqlite3_free (table);
  6274         -	  sql =
  6275         -	      sqlite3_mprintf
  6276         -	      ("INSERT OR IGNORE INTO \"%s\" (pyramid_level, "
  6277         -	       "x_resolution_1_1, y_resolution_1_1, "
  6278         -	       "x_resolution_1_2, y_resolution_1_2, x_resolution_1_4, "
  6279         -	       "y_resolution_1_4, x_resolution_1_8, y_resolution_1_8) "
  6280         -	       "VALUES (0, ?, ?, ?, ?, ?, ?, ?, ?)", xtable);
  6281         -	  free (xtable);
  6282         -	  ret =
  6283         -	      sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_levl, NULL);
  6284         -	  sqlite3_free (sql);
  6285         -	  if (ret != SQLITE_OK)
  6286         -	    {
  6287         -		printf ("INSERT INTO levels SQL error: %s\n",
  6288         -			sqlite3_errmsg (handle));
  6289         -		goto error;
  6290         -	    }
  6291         -      }
  6292         -
  6293         -    table = sqlite3_mprintf ("%s_tiles", coverage);
  6294         -    xtable = rl2_double_quoted_sql (table);
  6295         -    sqlite3_free (table);
  6296         -    sql =
  6297         -	sqlite3_mprintf
  6298         -	("INSERT INTO \"%s\" (tile_id, pyramid_level, section_id, geometry) "
  6299         -	 "VALUES (NULL, 0, ?, BuildMBR(?, ?, ?, ?, ?))", xtable);
  6300         -    free (xtable);
  6301         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tils, NULL);
  6302         -    sqlite3_free (sql);
  6303         -    if (ret != SQLITE_OK)
  6304         -      {
  6305         -	  printf ("INSERT INTO tiles SQL error: %s\n", sqlite3_errmsg (handle));
  6306         -	  goto error;
  6307         -      }
  6308         -
  6309         -    table = sqlite3_mprintf ("%s_tile_data", coverage);
  6310         -    xtable = rl2_double_quoted_sql (table);
  6311         -    sqlite3_free (table);
  6312         -    sql =
  6313         -	sqlite3_mprintf
  6314         -	("INSERT INTO \"%s\" (tile_id, tile_data_odd, tile_data_even) "
  6315         -	 "VALUES (?, ?, ?)", xtable);
  6316         -    free (xtable);
  6317         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_data, NULL);
  6318         -    sqlite3_free (sql);
  6319         -    if (ret != SQLITE_OK)
  6320         -      {
  6321         -	  printf ("INSERT INTO tile_data SQL error: %s\n",
  6322         -		  sqlite3_errmsg (handle));
  6323         -	  goto error;
  6324         -      }
  6325         -    res_x = hResolution;
  6326         -    res_y = vResolution;
  6327         -    base_res_x = privcvg->hResolution;
  6328         -    base_res_y = privcvg->vResolution;
  6329         -
  6330         -/* INSERTing the section */
  6331         -    if (!rl2_do_insert_section
  6332         -	(handle, "loaded from RAW pixels", section, srid, width, height, minx,
  6333         -	 miny, maxx, maxy, xml_summary, privcvg->sectionPaths,
  6334         -	 privcvg->sectionMD5, privcvg->sectionSummary, stmt_sect, &section_id))
  6335         -	goto error;
  6336         -    section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  6337         -    if (section_stats == NULL)
  6338         -	goto error;
  6339         -/* INSERTing the base-levels */
  6340         -    if (privcvg->mixedResolutions)
  6341         -      {
  6342         -	  /* multiple resolutions Coverage */
  6343         -	  if (!rl2_do_insert_section_levels
  6344         -	      (handle, section_id, res_x, res_y, 1.0, sample_type, stmt_levl))
  6345         -	      goto error;
  6346         -      }
  6347         -    else
  6348         -      {
  6349         -	  /* single resolution Coverage */
  6350         -	  if (!rl2_do_insert_levels
  6351         -	      (handle, base_res_x, base_res_y, 1.0, sample_type, stmt_levl))
  6352         -	      goto error;
  6353         -      }
  6354         -
  6355         -/* looping on tiles */
  6356         -    tile_maxy = maxy;
  6357         -    for (row = 0; row < height; row += tile_h)
  6358         -      {
  6359         -	  tile_miny = tile_maxy - ((double) tile_h * res_y);
  6360         -	  tile_minx = minx;
  6361         -	  for (col = 0; col < width; col += tile_w)
  6362         -	    {
  6363         -		/* requesting a Tile */
  6364         -		rl2RasterPtr tile;
  6365         -		unsigned char *blob_odd;
  6366         -		unsigned char *blob_even;
  6367         -		int blob_odd_sz;
  6368         -		int blob_even_sz;
  6369         -		unsigned char *bufpix = malloc (bufpix_sz);
  6370         -
  6371         -		if (pixel_type == RL2_PIXEL_PALETTE)
  6372         -		    rl2_prime_void_tile_palette (bufpix, tile_w, tile_h,
  6373         -						 no_data);
  6374         -		else
  6375         -		    rl2_prime_void_tile (bufpix, tile_w, tile_h,
  6376         -					 sample_type, num_bands, no_data);
  6377         -
  6378         -		tile_maxx = tile_minx + ((double) tile_w * res_x);
  6379         -		if (!getTile
  6380         -		    (data, tile_minx, tile_miny, tile_maxx, tile_maxy, bufpix,
  6381         -		     &palette))
  6382         -		  {
  6383         -		      if (bufpix != NULL)
  6384         -			  free (bufpix);
  6385         -		      goto error;
  6386         -		  }
  6387         -
  6388         -		/* building a raster Tile */
  6389         -		tile =
  6390         -		    rl2_create_raster (tile_w, tile_h, sample_type, pixel_type,
  6391         -				       num_bands, bufpix, bufpix_sz, palette,
  6392         -				       NULL, 0, no_data);
  6393         -		if (tile == NULL)
  6394         -		  {
  6395         -		      if (bufpix != NULL)
  6396         -			  free (bufpix);
  6397         -		      goto error;
  6398         -		  }
  6399         -
  6400         -		/* encoding the Tile */
  6401         -		if (rl2_raster_encode
  6402         -		    (tile, compression, &blob_odd, &blob_odd_sz, &blob_even,
  6403         -		     &blob_even_sz, quality, 1) != RL2_OK)
  6404         -		  {
  6405         -		      fprintf (stderr,
  6406         -			       "ERROR: unable to encode a tile [Row=%d Col=%d]\n",
  6407         -			       row, col);
  6408         -		      rl2_destroy_raster (tile);
  6409         -		      goto error;
  6410         -		  }
  6411         -		aux_palette = rl2_clone_palette (rl2_get_raster_palette (tile));
  6412         -		rl2_destroy_raster (tile);
  6413         -
  6414         -		/* INSERTing the tile */
  6415         -		if (!do_insert_tile
  6416         -		    (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  6417         -		     section_id, srid, tile_minx, tile_miny, tile_maxx,
  6418         -		     tile_maxy, aux_palette, no_data, stmt_tils, stmt_data,
  6419         -		     section_stats))
  6420         -		    goto error;
  6421         -
  6422         -		/* next tile */
  6423         -		tile_minx += (double) tile_w *res_x;
  6424         -	    }
  6425         -	  tile_maxy -= (double) tile_h *res_y;
  6426         -      }
  6427         -
  6428         -/* updating the Section's Statistics */
  6429         -    compute_aggregate_sq_diff (section_stats);
  6430         -    if (!rl2_do_insert_stats (handle, section_stats, section_id, stmt_upd_sect))
  6431         -	goto error;
  6432         -
  6433         -    rl2_destroy_raster_statistics (section_stats);
  6434         -    section_stats = NULL;
  6435         -
  6436         -    if (pyramidize)
  6437         -      {
  6438         -	  /* immediately building the Section's Pyramid */
  6439         -	  const char *coverage_name = rl2_get_coverage_name (cvg);
  6440         -	  if (coverage_name == NULL)
  6441         -	      goto error;
  6442         -	  if (rl2_build_section_pyramid
  6443         -	      (handle, 1, coverage_name, section_id, 1, 0) != RL2_OK)
  6444         -	    {
  6445         -		fprintf (stderr, "unable to build the Section's Pyramid\n");
  6446         -		goto error;
  6447         -	    }
  6448         -      }
  6449         -
  6450         -    sqlite3_finalize (stmt_upd_sect);
  6451         -    sqlite3_finalize (stmt_sect);
  6452         -    sqlite3_finalize (stmt_levl);
  6453         -    sqlite3_finalize (stmt_tils);
  6454         -    sqlite3_finalize (stmt_data);
  6455         -    stmt_upd_sect = NULL;
  6456         -    stmt_sect = NULL;
  6457         -    stmt_levl = NULL;
  6458         -    stmt_tils = NULL;
  6459         -    stmt_data = NULL;
  6460         -
  6461         -    if (rl2_update_dbms_coverage (handle, coverage) != RL2_OK)
  6462         -      {
  6463         -	  fprintf (stderr, "unable to update the Coverage\n");
  6464         -	  goto error;
  6465         -      }
  6466         -
  6467         -    return RL2_OK;
  6468         -
  6469         -  error:
  6470   6012       if (stmt_upd_sect != NULL)
  6471   6013   	sqlite3_finalize (stmt_upd_sect);
  6472   6014       if (stmt_sect != NULL)
  6473   6015   	sqlite3_finalize (stmt_sect);
  6474   6016       if (stmt_levl != NULL)
  6475   6017   	sqlite3_finalize (stmt_levl);
  6476   6018       if (stmt_tils != NULL)
  6477   6019   	sqlite3_finalize (stmt_tils);
  6478   6020       if (stmt_data != NULL)
  6479   6021   	sqlite3_finalize (stmt_data);
  6480   6022       return RL2_ERROR;
  6481   6023   }

Changes to src/rl2jpeg.c.

   226    226       /* The source object is made permanent so that a series of JPEG images
   227    227        * can be read from the same buffer by calling jpeg_mem_src only before
   228    228        * the first one.
   229    229        */
   230    230       if (cinfo->src == NULL)
   231    231         {				/* first time for this JPEG object? */
   232    232   	  cinfo->src = (struct jpeg_source_mgr *)
   233         -	      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
   234         -					  JPOOL_PERMANENT,
          233  +	      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
   235    234   					  sizeof (struct jpeg_source_mgr));
   236    235         }
   237    236   
   238    237       src = cinfo->src;
   239    238       src->init_source = init_mem_source;
   240    239       src->fill_input_buffer = fill_mem_input_buffer;
   241    240       src->skip_input_data = skip_input_data;
................................................................................
   262    261   
   263    262       /* The destination object is made permanent so that multiple JPEG images
   264    263        * can be written to the same buffer without re-executing jpeg_mem_dest.
   265    264        */
   266    265       if (cinfo->dest == NULL)
   267    266         {				/* first time for this JPEG object? */
   268    267   	  cinfo->dest = (struct jpeg_destination_mgr *)
   269         -	      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
   270         -					  JPOOL_PERMANENT,
          268  +	      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
   271    269   					  sizeof (jpeg_mem_destination_mgr));
   272    270   	  dest = (jpeg_mem_dest_ptr) cinfo->dest;
   273    271   	  dest->newbuffer = NULL;
   274    272         }
   275    273   
   276    274       dest = (jpeg_mem_dest_ptr) cinfo->dest;
   277    275       dest->pub.init_destination = init_mem_destination;
................................................................................
   755    753   /* creating a JPEG image from a raster */
   756    754       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
   757    755       unsigned char *blob;
   758    756       int blob_size;
   759    757   
   760    758       if (rst == NULL)
   761    759   	return RL2_ERROR;
   762         -    if (check_jpeg_compatibility
   763         -	(rst->sampleType, rst->pixelType, rst->nBands) != RL2_OK)
          760  +    if (check_jpeg_compatibility (rst->sampleType, rst->pixelType, rst->nBands)
          761  +	!= RL2_OK)
   764    762   	return RL2_ERROR;
   765    763       if (rl2_data_to_jpeg
   766    764   	(rst->rasterBuffer, rst->maskBuffer, (rl2PalettePtr) (rst->Palette),
   767    765   	 rst->width, rst->height, rst->sampleType, rst->pixelType, &blob,
   768    766   	 &blob_size, quality) != RL2_OK)
   769    767   	return RL2_ERROR;
   770    768       *jpeg = blob;
................................................................................
   780    778   /* creating a PNG image from an RGB buffer */
   781    779       unsigned char *blob;
   782    780       int blob_size;
   783    781       if (rgb == NULL)
   784    782   	return RL2_ERROR;
   785    783   
   786    784       if (rl2_data_to_jpeg
   787         -	(rgb, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_RGB,
   788         -	 &blob, &blob_size, quality) != RL2_OK)
          785  +	(rgb, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, &blob,
          786  +	 &blob_size, quality) != RL2_OK)
   789    787   	return RL2_ERROR;
   790    788       *jpeg = blob;
   791    789       *jpeg_size = blob_size;
   792    790       return RL2_OK;
   793    791   }
   794    792   
   795    793   RL2_DECLARE int
   796    794   rl2_gray_to_jpeg (unsigned int width, unsigned int height,
   797         -		  const unsigned char *gray, int quality,
   798         -		  unsigned char **jpeg, int *jpeg_size)
          795  +		  const unsigned char *gray, int quality, unsigned char **jpeg,
          796  +		  int *jpeg_size)
   799    797   {
   800    798   /* creating a PNG image from a Grayscale buffer */
   801    799       unsigned char *blob;
   802    800       int blob_size;
   803    801       if (gray == NULL)
   804    802   	return RL2_ERROR;
   805    803   
   806    804       if (rl2_data_to_jpeg
   807         -	(gray, NULL, NULL, width, height, RL2_SAMPLE_UINT8,
   808         -	 RL2_PIXEL_GRAYSCALE, &blob, &blob_size, quality) != RL2_OK)
          805  +	(gray, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE,
          806  +	 &blob, &blob_size, quality) != RL2_OK)
   809    807   	return RL2_ERROR;
   810    808       *jpeg = blob;
   811    809       *jpeg_size = blob_size;
   812    810       return RL2_OK;
   813    811   }
   814    812   
   815    813   RL2_PRIVATE int
................................................................................
   849    847       rst = rl2_raster_from_jpeg (blob, blob_size);
   850    848       free (blob);
   851    849       if (rst == NULL)
   852    850   	return NULL;
   853    851   
   854    852   /* creating the raster section */
   855    853       scn =
   856         -	rl2_create_section (path, RL2_COMPRESSION_JPEG,
   857         -			    RL2_TILESIZE_UNDEFINED, RL2_TILESIZE_UNDEFINED,
   858         -			    rst);
          854  +	rl2_create_section (path, RL2_COMPRESSION_JPEG, RL2_TILESIZE_UNDEFINED,
          855  +			    RL2_TILESIZE_UNDEFINED, rst);
   859    856       return scn;
   860    857   }
   861    858   
   862    859   RL2_DECLARE rl2RasterPtr
   863    860   rl2_raster_from_jpeg (const unsigned char *jpeg, int jpeg_size)
   864    861   {
   865    862   /* attempting to create a raster from a JPEG image */
................................................................................
   877    874   	goto error;
   878    875       nBands = 1;
   879    876       if (pixel_type == RL2_PIXEL_RGB)
   880    877   	nBands = 3;
   881    878   
   882    879   /* creating the raster */
   883    880       rst =
   884         -	rl2_create_raster (width, height, RL2_SAMPLE_UINT8, pixel_type,
   885         -			   nBands, data, data_size, NULL, NULL, 0, NULL);
          881  +	rl2_create_raster (width, height, RL2_SAMPLE_UINT8, pixel_type, nBands,
          882  +			   data, data_size, NULL, NULL, 0, NULL);
   886    883       if (rst == NULL)
   887    884   	goto error;
   888    885       return rst;
   889    886   
   890    887     error:
   891    888       if (rst != NULL)
   892    889   	rl2_destroy_raster (rst);
   893    890       if (data != NULL)
   894    891   	free (data);
   895    892       return NULL;
   896    893   }
   897    894   
   898    895   RL2_DECLARE int
   899         -rl2_get_jpeg_infos (const char *path, unsigned int *width,
   900         -		    unsigned int *height, unsigned char *pixel_type)
          896  +rl2_get_jpeg_infos (const char *path, unsigned int *width, unsigned int *height,
          897  +		    unsigned char *pixel_type)
   901    898   {
   902    899   /* attempting to retrieve basic infos from a JPEG image */
   903    900       int jpeg_size;
   904    901       unsigned char *jpeg = NULL;
   905    902       struct jpeg_decompress_struct cinfo;
   906    903       struct jpeg_error_mgr jerr;
   907    904       int row_stride;
................................................................................
  1063   1060   	  /* reading all decompressed scanlines */
  1064   1061   	  jpeg_read_scanlines (&cinfo, buffer, 1);
  1065   1062   	  if (cinfo.out_color_space == JCS_CMYK)
  1066   1063   	    {
  1067   1064   		JSAMPROW row = buffer[0];
  1068   1065   		for (i = 0; i < (int) (cinfo.output_width); i++)
  1069   1066   		  {
  1070         -		      CMYK2RGB (*(row + 0), *(row + 1), *(row + 2),
  1071         -				*(row + 3), inverted, p_data);
         1067  +		      CMYK2RGB (*(row + 0), *(row + 1), *(row + 2), *(row + 3),
         1068  +				inverted, p_data);
  1072   1069   		      row += 4;
  1073   1070   		      p_data += 3;
  1074   1071   		  }
  1075   1072   	    }
  1076   1073   	  else if (cinfo.out_color_space == JCS_GRAYSCALE)
  1077   1074   	    {
  1078   1075   		JSAMPROW row = buffer[0];
................................................................................
  1297   1294   				unsigned char forced_conversion, int verbose)
  1298   1295   {
  1299   1296   /* checking for strict compatibility */
  1300   1297       if (coverage->sampleType == RL2_SAMPLE_UINT8
  1301   1298   	&& coverage->pixelType == RL2_PIXEL_GRAYSCALE && coverage->nBands == 1)
  1302   1299         {
  1303   1300   	  if (raster->sampleType == RL2_SAMPLE_UINT8
  1304         -	      && raster->pixelType == RL2_PIXEL_GRAYSCALE
  1305         -	      && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO)
         1301  +	      && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1
         1302  +	      && forced_conversion == RL2_CONVERT_NO)
  1306   1303   	      return 1;
  1307   1304   	  if (raster->sampleType == RL2_SAMPLE_UINT8
  1308   1305   	      && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3
  1309   1306   	      && forced_conversion == RL2_CONVERT_RGB_TO_GRAYSCALE)
  1310   1307   	      return 1;
  1311   1308         }
  1312   1309       if (coverage->sampleType == RL2_SAMPLE_UINT8
................................................................................
  1313   1310   	&& coverage->pixelType == RL2_PIXEL_RGB && coverage->nBands == 3)
  1314   1311         {
  1315   1312   	  if (raster->sampleType == RL2_SAMPLE_UINT8
  1316   1313   	      && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3
  1317   1314   	      && forced_conversion == RL2_CONVERT_NO)
  1318   1315   	      return 1;
  1319   1316   	  if (raster->sampleType == RL2_SAMPLE_UINT8
  1320         -	      && raster->pixelType == RL2_PIXEL_GRAYSCALE
  1321         -	      && raster->nBands == 1
         1317  +	      && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1
  1322   1318   	      && forced_conversion == RL2_CONVERT_GRAYSCALE_TO_RGB)
  1323   1319   	      return 1;
  1324   1320         }
  1325   1321       if (verbose)
  1326   1322   	fprintf (stderr, "Mismatching JPEG colorspace !!!\n");
  1327   1323       return 0;
  1328   1324   }
................................................................................
  1532   1528   	  xml = sqlite3_mprintf ("%s</BoundingBox>", prev);
  1533   1529   	  sqlite3_free (prev);
  1534   1530   	  prev = xml;
  1535   1531   	  xml = sqlite3_mprintf ("%s<Extent>", prev);
  1536   1532   	  sqlite3_free (prev);
  1537   1533   	  prev = xml;
  1538   1534   	  xml =
  1539         -	      sqlite3_mprintf
  1540         -	      ("%s<HorizontalExtent>%1.10f</HorizontalExtent>", prev,
  1541         -	       maxx - minx);
         1535  +	      sqlite3_mprintf ("%s<HorizontalExtent>%1.10f</HorizontalExtent>",
         1536  +			       prev, maxx - minx);
  1542   1537   	  sqlite3_free (prev);
  1543   1538   	  prev = xml;
  1544   1539   	  xml =
  1545   1540   	      sqlite3_mprintf ("%s<VerticalExtent>%1.10f</VerticalExtent>",
  1546   1541   			       prev, maxy - miny);
  1547   1542   	  sqlite3_free (prev);
  1548   1543   	  prev = xml;

Changes to src/rl2openjpeg.c.

    56     56   #include "rasterlite2_private.h"
    57     57   
    58     58   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
    59     59   
    60     60   #ifdef HAVE_OPENJPEG_2_1_OPENJPEG_H
    61     61   #include <openjpeg-2.1/openjpeg.h>
    62     62   #else
    63         -#ifdef __ANDROID__		/* Android specific */
    64         -#include <openjpeg.h>
    65         -#else
    66     63   #include <openjpeg-2.0/openjpeg.h>
    67         -#endif
    68     64   #endif
    69     65   
    70     66   struct jp2_memfile
    71     67   {
    72     68   /* a struct emulating a file [memory mapped] */
    73     69       unsigned char *buffer;
    74     70       int malloc_block;
................................................................................
   692    688         }
   693    689   }
   694    690   
   695    691   RL2_PRIVATE int
   696    692   rl2_decode_jpeg2000_scaled (int scale, const unsigned char *jpeg2000,
   697    693   			    int jpeg2000_sz, unsigned int *xwidth,
   698    694   			    unsigned int *xheight, unsigned char xsample_type,
   699         -			    unsigned char xpixel_type,
   700         -			    unsigned char xnum_bands, unsigned char **pixels,
   701         -			    int *pixels_size)
          695  +			    unsigned char xpixel_type, unsigned char xnum_bands,
          696  +			    unsigned char **pixels, int *pixels_size)
   702    697   {
   703    698   /* attempting to create a raster from a Jpeg2000 image - supporting rescaled size */
   704    699       unsigned char *buf = NULL;
   705    700       int buf_size = 0;
   706    701       unsigned int width;
   707    702       unsigned int height;
   708    703       unsigned char sample_type = RL2_SAMPLE_UNKNOWN;
................................................................................
   859    854   		fprintf (stderr,
   860    855   			 "OpenJpeg Error: opj_decode_tile_data() failed\n");
   861    856   		goto error;
   862    857   	    }
   863    858   	  if (sample_type == RL2_SAMPLE_UINT16)
   864    859   	      save_tile_u16 ((unsigned short *) buf,
   865    860   			     (unsigned short *) jp2_data, tile_x0 / scale,
   866         -			     tile_y0 / scale, tile_x1 / scale,
   867         -			     tile_y1 / scale, num_bands, width / scale,
   868         -			     height / scale);
          861  +			     tile_y0 / scale, tile_x1 / scale, tile_y1 / scale,
          862  +			     num_bands, width / scale, height / scale);
   869    863   	  else
   870    864   	      save_tile_u8 ((unsigned char *) buf, (unsigned char *) jp2_data,
   871    865   			    tile_x0 / scale, tile_y0 / scale, tile_x1 / scale,
   872    866   			    tile_y1 / scale, num_bands, width / scale,
   873    867   			    height / scale);
   874    868   	  free (jp2_data);
   875    869   	  jp2_data = NULL;
................................................................................
   903    897   				    int verbose)
   904    898   {
   905    899   /* checking for strict compatibility */
   906    900       if (coverage->sampleType == RL2_SAMPLE_UINT8
   907    901   	&& coverage->pixelType == RL2_PIXEL_GRAYSCALE && coverage->nBands == 1)
   908    902         {
   909    903   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   910         -	      && raster->pixelType == RL2_PIXEL_GRAYSCALE
   911         -	      && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO)
          904  +	      && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1
          905  +	      && forced_conversion == RL2_CONVERT_NO)
   912    906   	      return 1;
   913    907   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   914    908   	      && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3
   915    909   	      && forced_conversion == RL2_CONVERT_RGB_TO_GRAYSCALE)
   916    910   	      return 1;
   917    911         }
   918    912       if (coverage->sampleType == RL2_SAMPLE_UINT8
................................................................................
   919    913   	&& coverage->pixelType == RL2_PIXEL_RGB && coverage->nBands == 3)
   920    914         {
   921    915   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   922    916   	      && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3
   923    917   	      && forced_conversion == RL2_CONVERT_NO)
   924    918   	      return 1;
   925    919   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   926         -	      && raster->pixelType == RL2_PIXEL_GRAYSCALE
   927         -	      && raster->nBands == 1
          920  +	      && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1
   928    921   	      && forced_conversion == RL2_CONVERT_GRAYSCALE_TO_RGB)
   929    922   	      return 1;
   930    923         }
   931    924       if (coverage->sampleType == RL2_SAMPLE_UINT8
   932    925   	&& coverage->pixelType == RL2_PIXEL_DATAGRID && coverage->nBands == 1)
   933    926         {
   934    927   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   935         -	      && raster->pixelType == RL2_PIXEL_DATAGRID
   936         -	      && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO)
          928  +	      && raster->pixelType == RL2_PIXEL_DATAGRID && raster->nBands == 1
          929  +	      && forced_conversion == RL2_CONVERT_NO)
   937    930   	      return 1;
   938    931         }
   939    932       if (coverage->sampleType == RL2_SAMPLE_UINT8
   940         -	&& coverage->pixelType == RL2_PIXEL_MULTIBAND
   941         -	&& (coverage->nBands == 3 || coverage->nBands == 4))
          933  +	&& coverage->pixelType == RL2_PIXEL_MULTIBAND && (coverage->nBands == 3
          934  +							  || coverage->nBands ==
          935  +							  4))
   942    936         {
   943    937   	  if (raster->sampleType == RL2_SAMPLE_UINT8
   944    938   	      && raster->pixelType == RL2_PIXEL_MULTIBAND
   945    939   	      && raster->nBands == coverage->nBands
   946    940   	      && forced_conversion == RL2_CONVERT_NO)
   947    941   	      return 1;
   948    942         }
   949    943       if (coverage->sampleType == RL2_SAMPLE_UINT16
   950    944   	&& coverage->pixelType == RL2_PIXEL_DATAGRID && coverage->nBands == 1)
   951    945         {
   952    946   	  if (raster->sampleType == RL2_SAMPLE_UINT16
   953         -	      && raster->pixelType == RL2_PIXEL_DATAGRID
   954         -	      && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO)
          947  +	      && raster->pixelType == RL2_PIXEL_DATAGRID && raster->nBands == 1
          948  +	      && forced_conversion == RL2_CONVERT_NO)
   955    949   	      return 1;
   956    950         }
   957    951       if (coverage->sampleType == RL2_SAMPLE_UINT16
   958    952   	&& coverage->pixelType == RL2_PIXEL_RGB && coverage->nBands == 3)
   959    953         {
   960    954   	  if (raster->sampleType == RL2_SAMPLE_UINT16
   961    955   	      && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3
   962    956   	      && forced_conversion == RL2_CONVERT_NO)
   963    957   	      return 1;
   964    958         }
   965    959       if (coverage->sampleType == RL2_SAMPLE_UINT16
   966         -	&& coverage->pixelType == RL2_PIXEL_MULTIBAND
   967         -	&& (coverage->nBands == 3 || coverage->nBands == 4))
          960  +	&& coverage->pixelType == RL2_PIXEL_MULTIBAND && (coverage->nBands == 3
          961  +							  || coverage->nBands ==
          962  +							  4))
   968    963         {
   969    964   	  if (raster->sampleType == RL2_SAMPLE_UINT16
   970    965   	      && raster->pixelType == RL2_PIXEL_MULTIBAND
   971    966   	      && raster->nBands == coverage->nBands
   972    967   	      && forced_conversion == RL2_CONVERT_NO)
   973    968   	      return 1;
   974    969         }
   975    970       if (verbose)
   976    971   	fprintf (stderr, "Mismatching Jpeg2000 colorspace !!!\n");
   977    972       return 0;
   978    973   }
   979    974   
   980    975   static int
   981         -read_jpeg2000_pixels_gray_to_rgb (rl2PrivRasterPtr origin,
   982         -				  unsigned short width, unsigned short height,
   983         -				  unsigned int startRow,
          976  +read_jpeg2000_pixels_gray_to_rgb (rl2PrivRasterPtr origin, unsigned short width,
          977  +				  unsigned short height, unsigned int startRow,
   984    978   				  unsigned int startCol, unsigned char *pixels)
   985    979   {
   986    980   /* Grayscale -> RGB */
   987    981       unsigned short x;
   988    982       unsigned short y;
   989    983       unsigned short row;
   990    984       unsigned short col;
................................................................................
  1004    998   		*p_out++ = value;	/* blue */
  1005    999   	    }
  1006   1000         }
  1007   1001       return 1;
  1008   1002   }
  1009   1003   
  1010   1004   static int
  1011         -read_jpeg2000_pixels_rgb_to_gray (rl2PrivRasterPtr origin,
  1012         -				  unsigned short width, unsigned short height,
  1013         -				  unsigned int startRow,
         1005  +read_jpeg2000_pixels_rgb_to_gray (rl2PrivRasterPtr origin, unsigned short width,
         1006  +				  unsigned short height, unsigned int startRow,
  1014   1007   				  unsigned int startCol, unsigned char *pixels)
  1015   1008   {
  1016   1009   /* RGB -> Grayscale */
  1017   1010       unsigned short x;
  1018   1011       unsigned short y;
  1019   1012       unsigned short row;
  1020   1013       unsigned short col;
................................................................................
  1193   1186       if (no_data != NULL)
  1194   1187   	rl2_destroy_pixel (no_data);
  1195   1188       return RL2_ERROR;
  1196   1189   }
  1197   1190   
  1198   1191   RL2_DECLARE rl2RasterPtr
  1199   1192   rl2_get_tile_from_jpeg2000_origin (rl2CoveragePtr cvg, rl2RasterPtr jpeg2000,
  1200         -				   unsigned int startRow,
  1201         -				   unsigned int startCol,
         1193  +				   unsigned int startRow, unsigned int startCol,
  1202   1194   				   unsigned char forced_conversion, int verbose)
  1203   1195   {
  1204   1196   /* attempting to create a Coverage-tile from a Jpeg2000 origin */
  1205   1197       unsigned int x;
  1206   1198       rl2PrivCoveragePtr coverage = (rl2PrivCoveragePtr) cvg;
  1207   1199       rl2PrivRasterPtr origin = (rl2PrivRasterPtr) jpeg2000;
  1208   1200       rl2RasterPtr raster = NULL;
................................................................................
  1608   1600   	  xml = sqlite3_mprintf ("%s</BoundingBox>", prev);
  1609   1601   	  sqlite3_free (prev);
  1610   1602   	  prev = xml;
  1611   1603   	  xml = sqlite3_mprintf ("%s<Extent>", prev);
  1612   1604   	  sqlite3_free (prev);
  1613   1605   	  prev = xml;
  1614   1606   	  xml =
  1615         -	      sqlite3_mprintf
  1616         -	      ("%s<HorizontalExtent>%1.10f</HorizontalExtent>", prev,
  1617         -	       maxx - minx);
         1607  +	      sqlite3_mprintf ("%s<HorizontalExtent>%1.10f</HorizontalExtent>",
         1608  +			       prev, maxx - minx);
  1618   1609   	  sqlite3_free (prev);
  1619   1610   	  prev = xml;
  1620   1611   	  xml =
  1621   1612   	      sqlite3_mprintf ("%s<VerticalExtent>%1.10f</VerticalExtent>",
  1622   1613   			       prev, maxy - miny);
  1623   1614   	  sqlite3_free (prev);
  1624   1615   	  prev = xml;

Changes to src/rl2paint.c.

   183    183       int height;
   184    184       unsigned char *rgba;
   185    185       cairo_surface_t *bitmap;
   186    186       cairo_pattern_t *pattern;
   187    187   } RL2GraphBitmap;
   188    188   typedef RL2GraphBitmap *RL2GraphBitmapPtr;
   189    189   
   190         -static unsigned char
   191         -unpremultiply (unsigned char c, unsigned char a)
   192         -{
   193         -/* Cairo has premultiplied alphas */
   194         -    double x = ((double) c * 255.0) / (double) a;
   195         -    if (a == 0)
   196         -	return 0;
   197         -    return (unsigned char) x;
   198         -}
   199         -
   200    190   RL2_DECLARE rl2GraphicsContextPtr
   201    191   rl2_graph_create_context (int width, int height)
   202    192   {
   203    193   /* creating a generic Graphics Context */
   204    194       RL2GraphContextPtr ctx;
   205    195   
   206    196       ctx = malloc (sizeof (RL2GraphContext));
................................................................................
   778    768   					 double height, unsigned char red1,
   779    769   					 unsigned char green1,
   780    770   					 unsigned char blue1,
   781    771   					 unsigned char alpha1,
   782    772   					 unsigned char red2,
   783    773   					 unsigned char green2,
   784    774   					 unsigned char blue2,
   785         -					 unsigned char alpha2,
   786         -					 double pen_width, int line_cap,
   787         -					 int line_join)
          775  +					 unsigned char alpha2, double pen_width,
          776  +					 int line_cap, int line_join)
   788    777   {
   789    778   /* setting up a Linear Gradient Pen - solid style */
   790    779       double d_red = (double) red1 / 255.0;
   791    780       double d_green = (double) green1 / 255.0;
   792    781       double d_blue = (double) blue1 / 255.0;
   793    782       double d_alpha = (double) alpha1 / 255.0;
   794    783       RL2GraphContextPtr ctx = (RL2GraphContextPtr) context;
................................................................................
  1054   1043       return 1;
  1055   1044   }
  1056   1045   
  1057   1046   RL2_DECLARE int
  1058   1047   rl2_graph_set_linear_gradient_brush (rl2GraphicsContextPtr context, double x,
  1059   1048   				     double y, double width, double height,
  1060   1049   				     unsigned char red1, unsigned char green1,
  1061         -				     unsigned char blue1,
  1062         -				     unsigned char alpha1, unsigned char red2,
  1063         -				     unsigned char green2,
         1050  +				     unsigned char blue1, unsigned char alpha1,
         1051  +				     unsigned char red2, unsigned char green2,
  1064   1052   				     unsigned char blue2, unsigned char alpha2)
  1065   1053   {
  1066   1054   /* setting up a Linear Gradient Brush */
  1067   1055       double d_red = (double) red1 / 255.0;
  1068   1056       double d_green = (double) green1 / 255.0;
  1069   1057       double d_blue = (double) blue1 / 255.0;
  1070   1058       double d_alpha = (double) alpha1 / 255.0;
................................................................................
  1176   1164   	      style = CAIRO_FONT_SLANT_ITALIC;
  1177   1165   	  if (fnt->style == RL2_FONTSTYLE_OBLIQUE)
  1178   1166   	      style = CAIRO_FONT_SLANT_OBLIQUE;
  1179   1167   	  if (fnt->weight == RL2_FONTWEIGHT_BOLD)
  1180   1168   	      weight = CAIRO_FONT_WEIGHT_BOLD;
  1181   1169   	  cairo_select_font_face (cairo, fnt->facename, style, weight);
  1182   1170   	  cairo_set_font_size (cairo, size);
  1183         -	  fnt->cairo_font = cairo_get_font_face (cairo);
  1184   1171         }
  1185   1172       else
  1186   1173         {
  1187   1174   	  /* using a TrueType font */
  1188   1175   	  cairo_font_options_t *font_options = cairo_font_options_create ();
  1189   1176   	  cairo_matrix_t ctm;
  1190   1177   	  cairo_matrix_t font_matrix;
................................................................................
  1567   1554       unsigned char red;
  1568   1555       unsigned char green;
  1569   1556       unsigned char blue;
  1570   1557       unsigned char alpha;
  1571   1558       unsigned char xred;
  1572   1559       unsigned char xgreen;
  1573   1560       unsigned char xblue;
  1574         -    unsigned char xalpha;
  1575   1561       int valid = 0;
  1576         -    int has_black = 0;
  1577   1562       unsigned char *bitmap;
  1578   1563       RL2PrivGraphPatternPtr pattern = (RL2PrivGraphPatternPtr) ptrn;
  1579   1564       if (pattern == NULL)
  1580   1565   	return RL2_ERROR;
  1581   1566   
  1582   1567       width = pattern->width;
  1583   1568       height = pattern->height;
................................................................................
  1586   1571       if (bitmap == NULL)
  1587   1572   	return RL2_ERROR;
  1588   1573   /* checking for a Monochrome Pattern */
  1589   1574       for (y = 0; y < height; y++)
  1590   1575         {
  1591   1576   	  for (x = 0; x < width; x++)
  1592   1577   	    {
  1593         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
  1594         -				       &blue, &alpha);
         1578  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
         1579  +				       &alpha);
  1595   1580   		if (alpha != 0)
  1596   1581   		  {
  1597         -		      if (red < 64 && green < 64 && blue < 64)
  1598         -			  has_black++;
  1599   1582   		      if (valid)
  1600   1583   			{
  1601         -			    if (xred == red && xgreen == green
  1602         -				&& xblue == blue && alpha == xalpha)
         1584  +			    if (xred == red && xgreen == green && xblue == blue)
  1603   1585   				;
  1604   1586   			    else
  1605         -				goto not_mono;
         1587  +				return RL2_ERROR;
  1606   1588   			}
  1607   1589   		      else
  1608   1590   			{
  1609   1591   			    xred = red;
  1610   1592   			    xgreen = green;
  1611   1593   			    xblue = blue;
  1612         -			    xalpha = alpha;
  1613   1594   			    valid = 1;
  1614   1595   			}
  1615   1596   		  }
  1616   1597   	    }
  1617   1598         }
  1618   1599   /* all right, applying the new color */
  1619   1600       for (y = 0; y < height; y++)
  1620   1601         {
  1621   1602   	  for (x = 0; x < width; x++)
  1622   1603   	    {
  1623         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
  1624         -				       &blue, &alpha);
         1604  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
         1605  +				       &alpha);
  1625   1606   		if (alpha != 0)
  1626   1607   		    aux_pattern_set_pixel (x, y, width, bitmap, r, g, b, alpha);
  1627   1608   	    }
  1628   1609         }
  1629   1610       cairo_surface_mark_dirty (pattern->bitmap);
  1630   1611       return RL2_OK;
  1631         -
  1632         -  not_mono:
  1633         -    if (has_black)
  1634         -      {
  1635         -	  /* recoloring only the black pixels */
  1636         -	  for (y = 0; y < height; y++)
  1637         -	    {
  1638         -		for (x = 0; x < width; x++)
  1639         -		  {
  1640         -		      aux_pattern_get_pixel (x, y, width, bitmap, &red,
  1641         -					     &green, &blue, &alpha);
  1642         -		      if (red < 64 && green < 64 && blue < 64)
  1643         -			  aux_pattern_set_pixel (x, y, width, bitmap, r, g, b,
  1644         -						 alpha);
  1645         -		  }
  1646         -	    }
  1647         -	  cairo_surface_mark_dirty (pattern->bitmap);
  1648         -	  return RL2_OK;
  1649         -      }
  1650         -    return RL2_ERROR;
  1651   1612   }
  1652   1613   
  1653   1614   RL2_DECLARE int
  1654   1615   rl2_graph_pattern_transparency (rl2GraphicsPatternPtr ptrn, unsigned char aleph)
  1655   1616   {
  1656   1617   /* changing the Pattern's transparency */
  1657   1618       int x;
................................................................................
  1674   1635       if (bitmap == NULL)
  1675   1636   	return RL2_ERROR;
  1676   1637   /* applying the new transparency */
  1677   1638       for (y = 0; y < height; y++)
  1678   1639         {
  1679   1640   	  for (x = 0; x < width; x++)
  1680   1641   	    {
  1681         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
  1682         -				       &blue, &alpha);
         1642  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
         1643  +				       &alpha);
  1683   1644   		if (alpha != 0)
  1684   1645   		    aux_pattern_set_pixel (x, y, width, bitmap, red, green,
  1685   1646   					   blue, aleph);
  1686   1647   	    }
  1687   1648         }
  1688   1649       cairo_surface_mark_dirty (pattern->bitmap);
  1689   1650       return RL2_OK;
................................................................................
  1804   1765         }
  1805   1766   
  1806   1767   /* destroying the cached font */
  1807   1768       rl2_destroy_private_tt_font (font);
  1808   1769   }
  1809   1770   
  1810   1771   RL2_DECLARE rl2GraphicsFontPtr
  1811         -rl2_graph_create_TrueType_font (const void *priv_data,
  1812         -				const unsigned char *ttf, int ttf_bytes,
  1813         -				double size)
         1772  +rl2_graph_create_TrueType_font (const void *priv_data, const unsigned char *ttf,
         1773  +				int ttf_bytes, double size)
  1814   1774   {
  1815   1775   /* creating a TrueType font */
  1816   1776       RL2GraphFontPtr fnt;
  1817   1777       char *facename;
  1818   1778       int is_bold;
  1819   1779       int is_italic;
  1820   1780       unsigned char *font = NULL;
................................................................................
  1948   1908   }
  1949   1909   
  1950   1910   RL2_DECLARE void
  1951   1911   rl2_graph_destroy_font (rl2GraphicsFontPtr font)
  1952   1912   {
  1953   1913   /* destroying a font */
  1954   1914       RL2GraphFontPtr fnt = (RL2GraphFontPtr) font;
         1915  +
  1955   1916       if (fnt == NULL)
  1956   1917   	return;
  1957   1918       if (fnt->toy_font == 0)
  1958   1919         {
  1959   1920   	  if (fnt->cairo_scaled_font != NULL)
  1960   1921   	      cairo_scaled_font_destroy (fnt->cairo_scaled_font);
         1922  +	  if (fnt->cairo_font != NULL)
         1923  +	      cairo_font_face_destroy (fnt->cairo_font);
  1961   1924         }
  1962   1925       else
  1963   1926         {
  1964   1927   	  if (fnt->facename != NULL)
  1965   1928   	      free (fnt->facename);
         1929  +	  free (fnt);
  1966   1930         }
  1967         -    if (fnt->cairo_font != NULL)
  1968         -      {
  1969         -	  if (cairo_font_face_get_reference_count (fnt->cairo_font) > 0)
  1970         -	      cairo_font_face_destroy (fnt->cairo_font);
  1971         -      }
  1972         -    free (fnt);
  1973   1931   }
  1974   1932   
  1975   1933   RL2_DECLARE int
  1976   1934   rl2_graph_font_set_color (rl2GraphicsFontPtr font, unsigned char red,
  1977   1935   			  unsigned char green, unsigned char blue,
  1978   1936   			  unsigned char alpha)
  1979   1937   {
................................................................................
  2304   2262       set_current_pen (ctx);
  2305   2263       cairo_stroke (cairo);
  2306   2264       return 1;
  2307   2265   }
  2308   2266   
  2309   2267   RL2_DECLARE int
  2310   2268   rl2_graph_draw_circle_sector (rl2GraphicsContextPtr context, double center_x,
  2311         -			      double center_y, double radius,
  2312         -			      double from_angle, double to_angle)
         2269  +			      double center_y, double radius, double from_angle,
         2270  +			      double to_angle)
  2313   2271   {
  2314   2272   /* drawing a filled circular sector */
  2315   2273       cairo_t *cairo;
  2316   2274       RL2GraphContextPtr ctx = (RL2GraphContextPtr) context;
  2317   2275       if (ctx == NULL)
  2318   2276   	return 0;
  2319   2277       if (ctx->type == RL2_SURFACE_PDF)
................................................................................
  2469   2427       *height = extents.height;
  2470   2428       *post_x = extents.x_advance;
  2471   2429       *post_y = extents.y_advance;
  2472   2430       return 1;
  2473   2431   }
  2474   2432   
  2475   2433   RL2_DECLARE int
  2476         -rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text,
  2477         -		     double x, double y, double angle, double anchor_point_x,
         2434  +rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text, double x,
         2435  +		     double y, double angle, double anchor_point_x,
  2478   2436   		     double anchor_point_y)
  2479   2437   {
  2480   2438   /* drawing a text string (using the current font) */
  2481   2439       double rads;
  2482   2440       double pre_x;
  2483   2441       double pre_y;
  2484   2442       double width;
................................................................................
  2618   2576   			  rl2_geometry_from_blob (blob3, size3);
  2619   2577   		      if (result == NULL)
  2620   2578   			  break;
  2621   2579   		      if (result->first_point == NULL)
  2622   2580   			  break;
  2623   2581   		      *x = result->first_point->x;
  2624   2582   		      *y = result->first_point->y;
  2625         -		      rl2_destroy_geometry (result);
  2626   2583   		      ok = 1;
  2627   2584   		  }
  2628   2585   	    }
  2629   2586   	  else
  2630   2587   	      goto error;
  2631   2588         }
  2632   2589       if (ok == 0)
................................................................................
  2652   2609       rl2GetPoint (ln->coords, ln->points - 1, &xx, &yy);
  2653   2610       if (xx == x && yy == y)
  2654   2611   	return 1;
  2655   2612       return 0;
  2656   2613   }
  2657   2614   
  2658   2615   static rl2GeometryPtr
  2659         -aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom,
  2660         -		  rl2GeometryPtr circle, double x, double y)
         2616  +aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom, rl2GeometryPtr circle,
         2617  +		  double x, double y)
  2661   2618   {
  2662   2619   /* reducing a Curve by discarding the alreasdy processed portion */
  2663   2620       sqlite3_stmt *stmt = NULL;
  2664   2621       const char *sql;
  2665   2622       int ret;
  2666   2623       unsigned char *blob1;
  2667   2624       int size1;
  2668   2625       unsigned char *blob2;
  2669   2626       int size2;
  2670   2627       rl2GeometryPtr out = NULL;
  2671   2628       rl2LinestringPtr ln;
         2629  +    rl2LinestringPtr save_ln = NULL;
  2672   2630       int count = 0;
  2673   2631   
  2674   2632       rl2_serialize_linestring (geom->first_linestring, &blob1, &size1);
  2675   2633       rl2_serialize_linestring (circle->first_linestring, &blob2, &size2);
  2676   2634   
  2677   2635   /* preparing the SQL query statement */
  2678   2636       sql = "SELECT ST_Split(?, ?)";
................................................................................
  2702   2660   		      ln = result->first_linestring;
  2703   2661   		      while (ln != NULL)
  2704   2662   			{
  2705   2663   			    if (aux_is_discarded_portion (ln, x, y))
  2706   2664   				;
  2707   2665   			    else
  2708   2666   			      {
  2709         -				  if (out != NULL)
  2710         -				      rl2_destroy_geometry (out);
  2711         -				  out = rl2_clone_linestring (ln);
         2667  +				  save_ln = ln;
  2712   2668   				  count++;
  2713   2669   			      }
  2714   2670   			    ln = ln->next;
  2715   2671   			}
  2716         -		      rl2_destroy_geometry (result);
  2717   2672   		  }
  2718   2673   	    }
  2719   2674   	  else
  2720   2675   	      goto error;
  2721   2676         }
  2722         -    if (out == NULL || count != 1)
         2677  +    if (save_ln == NULL || count != 1)
  2723   2678   	goto error;
         2679  +    out = rl2_clone_linestring (save_ln);
  2724   2680       sqlite3_finalize (stmt);
  2725   2681       return out;
  2726   2682   
  2727   2683     error:
  2728   2684       if (stmt != NULL)
  2729   2685   	sqlite3_finalize (stmt);
  2730         -    if (out != NULL)
  2731         -	rl2_destroy_geometry (out);
  2732   2686       return NULL;
  2733   2687   }
  2734   2688   
  2735         -static int
  2736         -check_reverse (rl2GeometryPtr geom)
  2737         -{
  2738         -/* testing for an inverse label */
  2739         -    rl2LinestringPtr ln;
  2740         -    double x0;
  2741         -    double y0;
  2742         -    double x1;
  2743         -    double y1;
  2744         -    double width;
  2745         -    double height;
  2746         -    int last;
  2747         -
  2748         -    if (geom == NULL)
  2749         -	return 0;
  2750         -    ln = geom->first_linestring;
  2751         -    if (ln == NULL)
  2752         -	return 0;
  2753         -    if (ln->points < 2)
  2754         -	return 0;
  2755         -    last = ln->points - 1;
  2756         -
  2757         -    rl2GetPoint (ln->coords, 0, &x0, &y0);
  2758         -    rl2GetPoint (ln->coords, last, &x1, &y1);
  2759         -    width = fabs (x0 - x1);
  2760         -    height = fabs (y0 - y1);
  2761         -    if (width > 3.0)
  2762         -      {
  2763         -	  if (x0 > x1)
  2764         -	      return 1;
  2765         -      }
  2766         -    else
  2767         -      {
  2768         -	  if (y0 > y1)
  2769         -	      return 1;
  2770         -      }
  2771         -    return 0;
  2772         -}
  2773         -
  2774         -static void
  2775         -reverse_text (const char *in, char *dest, int len)
  2776         -{
  2777         -/* reversing a text string */
  2778         -    char *out;
  2779         -    int n = 1;
  2780         -    while (*in != '\0')
  2781         -      {
  2782         -	  out = dest + len - n;
  2783         -	  *out = *in++;
  2784         -	  n++;
  2785         -      }
  2786         -    *(dest + len) = '\0';
  2787         -}
  2788         -
  2789   2689   static rl2GeometryPtr
  2790   2690   rl2_draw_wrapped_label (sqlite3 * handle, rl2GraphicsContextPtr context,
  2791   2691   			cairo_t * cairo, const char *text, rl2GeometryPtr geom)
  2792   2692   {
  2793   2693   /* placing each character along the modelling line */
  2794   2694       double x0;
  2795   2695       double y0;
................................................................................
  2799   2699       double m;
  2800   2700       double rads;
  2801   2701       double angle;
  2802   2702       char buf[2];
  2803   2703       rl2GeometryPtr g2;
  2804   2704       rl2GeometryPtr g = rl2_clone_curve (geom);
  2805   2705       rl2GeometryPtr circle;
  2806         -    char *rev_text = NULL;
  2807   2706       const char *c = text;
  2808   2707       cairo_font_extents_t extents;
  2809   2708   
  2810   2709       cairo_font_extents (cairo, &extents);
  2811   2710       radius =
  2812   2711   	sqrt ((extents.max_x_advance * extents.max_x_advance) +
  2813   2712   	      (extents.height * extents.height)) / 2.0;
  2814         -    if (check_reverse (g))
  2815         -      {
  2816         -	  /* reverse text */
  2817         -	  int len = strlen (text);
  2818         -	  rev_text = malloc (len + 1);
  2819         -	  reverse_text (text, rev_text, len);
  2820         -	  c = rev_text;
  2821         -      }
  2822   2713       while (*c != '\0' && g != NULL)
  2823   2714         {
  2824   2715   	  buf[0] = *c;
  2825   2716   	  buf[1] = '\0';
  2826   2717   	  get_aux_start_point (g, &x0, &y0);
  2827   2718   	  circle = rl2_build_circle (x0, y0, radius);
  2828   2719   	  if (!get_aux_interception_point (handle, g, circle, &x1, &y1))
................................................................................
  2831   2722   		rl2_destroy_geometry (g);
  2832   2723   		g = NULL;
  2833   2724   		break;
  2834   2725   	    }
  2835   2726   	  m = (y1 - y0) / (x1 - x0);
  2836   2727   	  rads = atan (m);
  2837   2728   	  angle = rads / .0174532925199432958;
  2838         -	  if (x1 < x0 && rev_text == NULL)
         2729  +	  if (x1 < x0)
  2839   2730   	      angle += 180.0;
  2840   2731   	  rl2_graph_draw_text (context, buf, x0, y0, angle, 0.5, 0.5);
  2841   2732   	  c++;
  2842   2733   	  g2 = aux_reduce_curve (handle, g, circle, x0, y0);
  2843   2734   	  rl2_destroy_geometry (circle);
  2844   2735   	  rl2_destroy_geometry (g);
  2845   2736   	  g = g2;
  2846   2737         }
  2847         -    if (rev_text)
  2848         -	free (rev_text);
  2849   2738       return g;
  2850   2739   }
  2851   2740   
  2852   2741   RL2_DECLARE int
  2853   2742   rl2_graph_draw_warped_text (sqlite3 * handle, rl2GraphicsContextPtr context,
  2854         -			    const char *text, int points, double *x,
  2855         -			    double *y, double initial_gap, double gap,
  2856         -			    int repeated)
         2743  +			    const char *text, int points, double *x, double *y,
         2744  +			    double initial_gap, double gap, int repeated)
  2857   2745   {
  2858   2746   /* drawing a text string warped along a modelling curve (using the current font) */
  2859   2747       double curve_len;
  2860   2748       double text_len;
  2861   2749       double extra_len;
  2862   2750       double start;
  2863   2751       double from;
  2864   2752       rl2GeometryPtr geom = NULL;
  2865   2753       rl2GeometryPtr geom2 = NULL;
  2866         -    rl2GeometryPtr geom3 = NULL;
  2867   2754       cairo_t *cairo;
  2868   2755       RL2GraphContextPtr ctx = (RL2GraphContextPtr) context;
  2869   2756   
  2870   2757       if (ctx == NULL)
  2871   2758   	return 0;
  2872   2759       if (text == NULL)
  2873   2760   	return 0;
................................................................................
  2878   2765   
  2879   2766       geom = rl2_curve_from_XY (points, x, y);
  2880   2767       if (geom == NULL)
  2881   2768   	return 0;
  2882   2769   
  2883   2770       curve_len = rl2_compute_curve_length (geom);
  2884   2771       do_estimate_text_length (cairo, text, &text_len, &extra_len);
  2885         -    if ((initial_gap + text_len + (2.0 * extra_len)) > curve_len)
         2772  +    if ((text_len + (2.0 * extra_len)) > curve_len)
  2886   2773   	return 0;		/* not enough room to place the label */
  2887   2774   
  2888   2775       if (repeated)
  2889   2776         {
  2890   2777   	  /* repeated labels */
  2891   2778   	  int first = 1;
  2892         -	  geom3 = rl2_clone_linestring (geom->first_linestring);
         2779  +	  rl2GeometryPtr geom3 = rl2_clone_linestring (geom->first_linestring);
  2893   2780   	  while (geom3 != NULL)
  2894   2781   	    {
  2895   2782   		if (first)
  2896   2783   		  {
  2897   2784   		      start = initial_gap + extra_len;
  2898   2785   		      first = 0;
  2899   2786   		  }
  2900   2787   		else
  2901   2788   		    start = gap + extra_len;
  2902   2789   		curve_len = rl2_compute_curve_length (geom3);
  2903         -		if ((start + text_len + extra_len) > curve_len)
  2904         -		    break;	/* not enough room to place the label */
  2905   2790   		from = start / curve_len;
  2906   2791   		/* extracting the sub-path modelling the label */
  2907   2792   		geom2 = rl2_curve_substring (handle, geom3, from, 1.0);
  2908   2793   		rl2_destroy_geometry (geom3);
  2909   2794   		if (geom2 == NULL)
  2910   2795   		    goto error;
  2911   2796   		geom3 =
................................................................................
  2919   2804   	  /* single label */
  2920   2805   	  start = (curve_len - text_len) / 2.0;
  2921   2806   	  from = start / curve_len;
  2922   2807   	  /* extracting the sub-path modelling the label */
  2923   2808   	  geom2 = rl2_curve_substring (handle, geom, from, 1.0);
  2924   2809   	  if (geom2 == NULL)
  2925   2810   	      goto error;
  2926         -	  geom3 = rl2_draw_wrapped_label (handle, context, cairo, text, geom2);
         2811  +	  rl2_draw_wrapped_label (handle, context, cairo, text, geom2);
  2927   2812   	  rl2_destroy_geometry (geom2);
  2928         -	  rl2_destroy_geometry (geom3);
  2929   2813         }
  2930   2814   
  2931   2815       rl2_destroy_geometry (geom);
  2932   2816       return 1;
  2933   2817   
  2934   2818     error:
  2935   2819       rl2_destroy_geometry (geom);
................................................................................
  3004   2888       cairo_set_source (cairo, bmp->pattern);
  3005   2889       cairo_paint (cairo);
  3006   2890       cairo_restore (cairo);
  3007   2891       cairo_surface_flush (surface);
  3008   2892       return 1;
  3009   2893   }
  3010   2894   
  3011         -RL2_DECLARE int
  3012         -rl2_rescale_pixbuf (const unsigned char *inbuf, unsigned int inwidth,
  3013         -		    unsigned int inheight, unsigned char pixtype,
  3014         -		    const unsigned char *outbuf, unsigned int outwidth,
  3015         -		    unsigned int outheight)
  3016         -{
  3017         -/* drawing a rescaled pixbufx (RGB or GRAYSCALE) */
  3018         -    unsigned char *pixbuf = NULL;
  3019         -    int bufsz;
  3020         -    const unsigned char *p_in;
  3021         -    unsigned char *p_out;
  3022         -    unsigned int x;
  3023         -    unsigned int y;
  3024         -    int stride;
  3025         -    double scale_x = (double) outwidth / (double) inwidth;
  3026         -    double scale_y = (double) outheight / (double) inheight;
  3027         -    int little_endian = rl2cr_endian_arch ();
  3028         -    cairo_t *cairo;
  3029         -    cairo_surface_t *surface;
  3030         -    cairo_surface_t *bitmap;
  3031         -    cairo_pattern_t *pattern;
  3032         -    if (pixtype != RL2_PIXEL_RGB && pixtype != RL2_PIXEL_GRAYSCALE)
  3033         -	return 0;
  3034         -
  3035         -/* creating a Cairo context */
  3036         -    surface =
  3037         -	cairo_image_surface_create (CAIRO_FORMAT_ARGB32, outwidth, outheight);
  3038         -    if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS)
  3039         -	;
  3040         -    else
  3041         -	goto error1;
  3042         -    cairo = cairo_create (surface);
  3043         -    if (cairo_status (cairo) == CAIRO_STATUS_NO_MEMORY)
  3044         -	goto error2;
  3045         -
  3046         -/* allocating and populating data for Cairo */
  3047         -    stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, inwidth);
  3048         -    bufsz = stride * inheight;
  3049         -    pixbuf = malloc (bufsz);
  3050         -    if (pixbuf == NULL)
  3051         -      {
  3052         -	  goto error2;
  3053         -      }
  3054         -    p_in = inbuf;
  3055         -    p_out = pixbuf;
  3056         -    for (y = 0; y < inheight; y++)
  3057         -      {
  3058         -	  for (x = 0; x < inwidth; x++)
  3059         -	    {
  3060         -		unsigned char r;
  3061         -		unsigned char g;
  3062         -		unsigned char b;
  3063         -		if (pixtype == RL2_PIXEL_RGB)
  3064         -		  {
  3065         -		      r = *p_in++;
  3066         -		      g = *p_in++;
  3067         -		      b = *p_in++;
  3068         -		  }
  3069         -		else
  3070         -		  {
  3071         -		      r = *p_in++;
  3072         -		      g = r;
  3073         -		      b = r;
  3074         -		  }
  3075         -		if (little_endian)
  3076         -		  {
  3077         -		      *p_out++ = b;
  3078         -		      *p_out++ = g;
  3079         -		      *p_out++ = r;
  3080         -		      *p_out++ = 0xff;
  3081         -		  }
  3082         -		else
  3083         -		  {
  3084         -		      *p_out++ = 0xff;
  3085         -		      *p_out++ = r;
  3086         -		      *p_out++ = g;
  3087         -		      *p_out++ = b;
  3088         -		  }
  3089         -	    }
  3090         -      }
  3091         -
  3092         -/* creating the input pattern */
  3093         -    bitmap =
  3094         -	cairo_image_surface_create_for_data (pixbuf, CAIRO_FORMAT_ARGB32,
  3095         -					     inwidth, inheight, stride);
  3096         -    pattern = cairo_pattern_create_for_surface (bitmap);
  3097         -    cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
  3098         -
  3099         -/* rescaling the image */
  3100         -    cairo_save (cairo);
  3101         -    cairo_scale (cairo, scale_x, scale_y);
  3102         -    cairo_set_source (cairo, pattern);
  3103         -    cairo_paint (cairo);
  3104         -    cairo_restore (cairo);
  3105         -    cairo_surface_flush (surface);
  3106         -
  3107         -/* cleaning up the input pattern */
  3108         -    cairo_pattern_destroy (pattern);
  3109         -    cairo_surface_destroy (bitmap);
  3110         -    free (pixbuf);
  3111         -
  3112         -/* exporting the rescaled image */
  3113         -    p_in = cairo_image_surface_get_data (surface);
  3114         -    p_out = (unsigned char *) outbuf;
  3115         -    for (y = 0; y < outheight; y++)
  3116         -      {
  3117         -	  for (x = 0; x < outwidth; x++)
  3118         -	    {
  3119         -		unsigned char r;
  3120         -		unsigned char g;
  3121         -		unsigned char b;
  3122         -		unsigned char a;
  3123         -		if (little_endian)
  3124         -		  {
  3125         -		      b = *p_in++;
  3126         -		      g = *p_in++;
  3127         -		      r = *p_in++;
  3128         -		      a = *p_in++;
  3129         -		  }
  3130         -		else
  3131         -		  {
  3132         -		      a = *p_in++;
  3133         -		      r = *p_in++;
  3134         -		      g = *p_in++;
  3135         -		      b = *p_in++;
  3136         -		  }
  3137         -		if (pixtype == RL2_PIXEL_RGB)
  3138         -		  {
  3139         -		      *p_out++ = unpremultiply (r, a);
  3140         -		      *p_out++ = unpremultiply (g, a);
  3141         -		      *p_out++ = unpremultiply (b, a);
  3142         -
  3143         -		  }
  3144         -		else
  3145         -		    *p_out++ = unpremultiply (r, a);
  3146         -	    }
  3147         -      }
  3148         -
  3149         -/* destroying the Cairo context */
  3150         -    cairo_destroy (cairo);
  3151         -    cairo_surface_destroy (surface);
  3152         -    return 1;
  3153         -
  3154         -  error2:
  3155         -    if (pixbuf != NULL)
  3156         -	free (pixbuf);
  3157         -    cairo_destroy (cairo);
  3158         -    cairo_surface_destroy (surface);
  3159         -    return 0;
  3160         -  error1:
  3161         -    cairo_surface_destroy (surface);
  3162         -    return 0;
  3163         -}
  3164         -
  3165   2895   RL2_DECLARE int
  3166   2896   rl2_graph_draw_graphic_symbol (rl2GraphicsContextPtr context,
  3167   2897   			       rl2GraphicsPatternPtr symbol, double width,
  3168   2898   			       double height, double x,
  3169   2899   			       double y, double angle,
  3170   2900   			       double anchor_point_x, double anchor_point_y)
  3171   2901   {
................................................................................
  3388   3118   	  rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH);
  3389   3119         }
  3390   3120       cairo_restore (cairo);
  3391   3121       cairo_surface_flush (surface);
  3392   3122   
  3393   3123       return 1;
  3394   3124   }
         3125  +
         3126  +static unsigned char
         3127  +unpremultiply (unsigned char c, unsigned char a)
         3128  +{
         3129  +/* Cairo has premultiplied alphas */
         3130  +    double x = ((double) c * 255.0) / (double) a;
         3131  +    if (a == 0)
         3132  +	return 0;
         3133  +    return (unsigned char) x;
         3134  +}
  3395   3135   
  3396   3136   RL2_DECLARE unsigned char *
  3397   3137   rl2_graph_get_context_rgb_array (rl2GraphicsContextPtr context)
  3398   3138   {
  3399   3139   /* creating an RGB buffer from the given Context */
  3400   3140       int width;
  3401   3141       int height;

Changes to src/rl2png.c.

   224    224   	rl2_free (green);
   225    225       if (blue != NULL)
   226    226   	rl2_free (blue);
   227    227       return RL2_ERROR;
   228    228   }
   229    229   
   230    230   static int
   231         -compress_grayscale_png8 (const unsigned char *pixels,
   232         -			 const unsigned char *mask, double opacity,
   233         -			 unsigned int width, unsigned int height,
   234         -			 unsigned char sample_type, unsigned char pixel_type,
   235         -			 unsigned char **png, int *png_size)
          231  +compress_grayscale_png8 (const unsigned char *pixels, const unsigned char *mask,
          232  +			 double opacity, unsigned int width,
          233  +			 unsigned int height, unsigned char sample_type,
          234  +			 unsigned char pixel_type, unsigned char **png,
          235  +			 int *png_size)
   236    236   {
   237    237   /* compressing a PNG image of the GRAYSCALE type - 8 bits */
   238    238       png_structp png_ptr;
   239    239       png_infop info_ptr;
   240    240       int bit_depth;
   241    241       png_bytep *row_pointers = NULL;
   242    242       png_bytep p_out;
................................................................................
  1080   1080       *png = blob;
  1081   1081       *png_size = blob_size;
  1082   1082       return RL2_OK;
  1083   1083   }
  1084   1084   
  1085   1085   RL2_DECLARE int
  1086   1086   rl2_rgb_real_alpha_to_png (unsigned int width, unsigned int height,
  1087         -			   const unsigned char *rgb,
  1088         -			   const unsigned char *alpha, unsigned char **png,
  1089         -			   int *png_size)
         1087  +			   const unsigned char *rgb, const unsigned char *alpha,
         1088  +			   unsigned char **png, int *png_size)
  1090   1089   {
  1091   1090   /* creating a PNG image from two distinct RGB + Alpha buffer */
  1092   1091       unsigned char *blob;
  1093   1092       int blob_size;
  1094   1093       if (rgb == NULL || alpha == NULL)
  1095   1094   	return RL2_ERROR;
  1096   1095   
................................................................................
  1172   1171         case RL2_PIXEL_DATAGRID:
  1173   1172   	  if (sample_type == RL2_SAMPLE_UINT16)
  1174   1173   	      ret =
  1175   1174   		  compress_grayscale_png16 (pixels, width, height,
  1176   1175   					    sample_type, &blob, &blob_size);
  1177   1176   	  else
  1178   1177   	      ret =
  1179         -		  compress_grayscale_png8 (pixels, mask, opacity, width,
  1180         -					   height, sample_type, pixel_type,
  1181         -					   &blob, &blob_size);
         1178  +		  compress_grayscale_png8 (pixels, mask, opacity, width, height,
         1179  +					   sample_type, pixel_type, &blob,
         1180  +					   &blob_size);
  1182   1181   	  break;
  1183   1182         case RL2_PIXEL_RGB:
  1184   1183   	  if (sample_type == RL2_SAMPLE_UINT8)
  1185   1184   	      ret =
  1186   1185   		  compress_rgb_png8 (pixels, mask, opacity, width, height,
  1187   1186   				     &blob, &blob_size);
  1188   1187   	  else if (sample_type == RL2_SAMPLE_UINT16)
................................................................................
  1190   1189   		  compress_rgb_png16 (pixels, width, height, &blob, &blob_size);
  1191   1190   	  break;
  1192   1191         case RL2_PIXEL_MULTIBAND:
  1193   1192   	  if (sample_type == RL2_SAMPLE_UINT8)
  1194   1193   	    {
  1195   1194   		if (num_bands == 3)
  1196   1195   		    ret =
  1197         -			compress_rgb_png8 (pixels, mask, opacity, width,
  1198         -					   height, &blob, &blob_size);
         1196  +			compress_rgb_png8 (pixels, mask, opacity, width, height,
         1197  +					   &blob, &blob_size);
  1199   1198   		else if (num_bands == 4)
  1200   1199   		    ret =
  1201   1200   			compress_4bands_png8 (pixels, width, height, &blob,
  1202   1201   					      &blob_size);
  1203   1202   	    }
  1204   1203   	  else if (sample_type == RL2_SAMPLE_UINT16)
  1205   1204   	    {
................................................................................
  1412   1411   	  if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
  1413   1412   	      nBands = 4;
  1414   1413         }
  1415   1414       if (*xpixel_type == RL2_PIXEL_DATAGRID)
  1416   1415   	pixel_type = RL2_PIXEL_DATAGRID;
  1417   1416       if (pixel_type == RL2_PIXEL_PALETTE)
  1418   1417         {
  1419         -	  if (png_get_tRNS
  1420         -	      (png_ptr, info_ptr, &transp, &nTransp,
  1421         -	       &transpValues) == PNG_INFO_tRNS)
         1418  +	  if (png_get_tRNS (png_ptr, info_ptr, &transp, &nTransp, &transpValues)
         1419  +	      == PNG_INFO_tRNS)
  1422   1420   	    {
  1423   1421   		/* a Transparency palette is defined */
  1424   1422   		int i;
  1425   1423   		for (i = 0; i < nTransp; i++)
  1426   1424   		    *(alpha + i) = *(transp + i);
  1427   1425   		has_alpha = 1;
  1428   1426   	    }

Changes to src/rl2pyramid.c.

   255    255   #endif
   256    256   
   257    257       table = sqlite3_mprintf ("%s_tiles", coverage);
   258    258       xtable = rl2_double_quoted_sql (table);
   259    259       sqlite3_free (table);
   260    260       sql =
   261    261   	sqlite3_mprintf ("SELECT Count(*) FROM \"%s\" "
   262         -			 "WHERE section_id = %s AND pyramid_level > 0",
   263         -			 xtable, sect_id);
          262  +			 "WHERE section_id = %s AND pyramid_level > 0", xtable,
          263  +			 sect_id);
   264    264       free (xtable);
   265    265       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
   266    266       sqlite3_free (sql);
   267    267       if (ret != SQLITE_OK)
   268    268   	return 1;
   269    269       while (1)
   270    270         {
................................................................................
   347    347         }
   348    348       sqlite3_finalize (stmt);
   349    349       stmt = NULL;
   350    350       if (!ok)
   351    351   	goto error;
   352    352   
   353    353   /* Coverage's palette and no-data */
   354         -    sql =
   355         -	sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages "
   356         -			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
          354  +    sql = sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages "
          355  +			   "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
   357    356       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
   358    357       sqlite3_free (sql);
   359    358       if (ret != SQLITE_OK)
   360    359         {
   361    360   	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
   362    361   	  goto error;
   363    362         }
................................................................................
   488    487   	  free (tile_in);
   489    488   	  tile_in = tile_in_n;
   490    489         }
   491    490       free (pyr);
   492    491   }
   493    492   
   494    493   static int
   495         -insert_tile_into_section_pyramid (SectionPyramidPtr pyr,
   496         -				  sqlite3_int64 tile_id, double minx,
   497         -				  double miny, double maxx, double maxy)
          494  +insert_tile_into_section_pyramid (SectionPyramidPtr pyr, sqlite3_int64 tile_id,
          495  +				  double minx, double miny, double maxx,
          496  +				  double maxy)
   498    497   {
   499    498   /* inserting a base tile into the Pyramid level */
   500    499       SectionPyramidTileInPtr tile;
   501    500       if (pyr == NULL)
   502    501   	return 0;
   503    502       tile = alloc_section_pyramid_tile (tile_id, minx, miny, maxx, maxy);
   504    503       if (tile == NULL)
................................................................................
   573    572         {
   574    573   	  if (tile->cx > minx && tile->cx < maxx && tile->cy > miny
   575    574   	      && tile->cy < maxy)
   576    575   	    {
   577    576   		if (first)
   578    577   		  {
   579    578   		      out =
   580         -			  add_pyramid_out_tile (pyr, row, col, minx, miny,
   581         -						maxx, maxy);
          579  +			  add_pyramid_out_tile (pyr, row, col, minx, miny, maxx,
          580  +						maxy);
   582    581   		      first = 0;
   583    582   		  }
   584    583   		if (out != NULL)
   585    584   		    add_pyramid_sub_tile (out, tile);
   586    585   	    }
   587    586   	  tile = tile->next;
   588    587         }
................................................................................
   764    763   	  for (col = 0; col < (unsigned int) tic_x; col++)
   765    764   	    {
   766    765   		unsigned int xx = col + x;
   767    766   		char *p_out = p_out_base + xx;
   768    767   		if (xx >= tileWidth)
   769    768   		    break;
   770    769   		*p_out =
   771         -		    rescale_pixel_int8 (buf_in, tileWidth, tileHeight,
   772         -					col * 8, row * 8, nd);
          770  +		    rescale_pixel_int8 (buf_in, tileWidth, tileHeight, col * 8,
          771  +					row * 8, nd);
   773    772   	    }
   774    773         }
   775    774   }
   776    775   
   777    776   static double
   778    777   rescale_pixel_uint8 (const unsigned char *buf_in, unsigned int tileWidth,
   779    778   		     unsigned int tileHeight, int x, int y, unsigned char nd)
................................................................................
   844    843   	  for (col = 0; col < (unsigned int) tic_x; col++)
   845    844   	    {
   846    845   		unsigned int xx = col + x;
   847    846   		unsigned char *p_out = p_out_base + xx;
   848    847   		if (xx >= tileWidth)
   849    848   		    break;
   850    849   		*p_out =
   851         -		    rescale_pixel_uint8 (buf_in, tileWidth, tileHeight,
   852         -					 col * 8, row * 8, nd);
          850  +		    rescale_pixel_uint8 (buf_in, tileWidth, tileHeight, col * 8,
          851  +					 row * 8, nd);
   853    852   	    }
   854    853         }
   855    854   }
   856    855   
   857    856   static double
   858    857   rescale_pixel_int16 (const short *buf_in, unsigned int tileWidth,
   859    858   		     unsigned int tileHeight, int x, int y, short nd)
................................................................................
   924    923   	  for (col = 0; col < (unsigned int) tic_x; col++)
   925    924   	    {
   926    925   		unsigned int xx = col + x;
   927    926   		short *p_out = p_out_base + xx;
   928    927   		if (xx >= tileWidth)
   929    928   		    break;
   930    929   		*p_out =
   931         -		    rescale_pixel_int16 (buf_in, tileWidth, tileHeight,
   932         -					 col * 8, row * 8, nd);
          930  +		    rescale_pixel_int16 (buf_in, tileWidth, tileHeight, col * 8,
          931  +					 row * 8, nd);
   933    932   	    }
   934    933         }
   935    934   }
   936    935   
   937    936   static double
   938    937   rescale_pixel_uint16 (const unsigned short *buf_in, unsigned int tileWidth,
   939    938   		      unsigned int tileHeight, int x, int y, unsigned short nd)
................................................................................
  1084   1083   	  for (col = 0; col < (unsigned int) tic_x; col++)
  1085   1084   	    {
  1086   1085   		unsigned int xx = col + x;
  1087   1086   		int *p_out = p_out_base + xx;
  1088   1087   		if (xx >= tileWidth)
  1089   1088   		    break;
  1090   1089   		*p_out =
  1091         -		    rescale_pixel_int32 (buf_in, tileWidth, tileHeight,
  1092         -					 col * 8, row * 8, nd);
         1090  +		    rescale_pixel_int32 (buf_in, tileWidth, tileHeight, col * 8,
         1091  +					 row * 8, nd);
  1093   1092   	    }
  1094   1093         }
  1095   1094   }
  1096   1095   
  1097   1096   static double
  1098   1097   rescale_pixel_uint32 (const unsigned int *buf_in, unsigned int tileWidth,
  1099   1098   		      unsigned int tileHeight, int x, int y, unsigned int nd)
................................................................................
  1244   1243   	  for (col = 0; col < (unsigned int) tic_x; col++)
  1245   1244   	    {
  1246   1245   		unsigned int xx = col + x;
  1247   1246   		float *p_out = p_out_base + xx;
  1248   1247   		if (xx >= tileWidth)
  1249   1248   		    break;
  1250   1249   		*p_out =
  1251         -		    rescale_pixel_float (buf_in, tileWidth, tileHeight,
  1252         -					 col * 8, row * 8, nd);
         1250  +		    rescale_pixel_float (buf_in, tileWidth, tileHeight, col * 8,
         1251  +					 row * 8, nd);
  1253   1252   	    }
  1254   1253         }
  1255   1254   }
  1256   1255   
  1257   1256   static double
  1258   1257   rescale_pixel_double (const double *buf_in, unsigned int tileWidth,
  1259   1258   		      unsigned int tileHeight, int x, int y, double nd)
................................................................................
  1345   1344         {
  1346   1345         case RL2_SAMPLE_INT8:
  1347   1346   	  rescale_grid_int8 ((char *) buf_out, tileWidth, tileHeight,
  1348   1347   			     (const char *) buf_in, x, y, tic_x, tic_y,
  1349   1348   			     no_data);
  1350   1349   	  break;
  1351   1350         case RL2_SAMPLE_UINT8:
  1352         -	  rescale_grid_uint8 ((unsigned char *) buf_out, tileWidth,
  1353         -			      tileHeight, (const unsigned char *) buf_in, x,
  1354         -			      y, tic_x, tic_y, no_data);
         1351  +	  rescale_grid_uint8 ((unsigned char *) buf_out, tileWidth, tileHeight,
         1352  +			      (const unsigned char *) buf_in, x, y, tic_x,
         1353  +			      tic_y, no_data);
  1355   1354   	  break;
  1356   1355         case RL2_SAMPLE_INT16:
  1357   1356   	  rescale_grid_int16 ((short *) buf_out, tileWidth, tileHeight,
  1358   1357   			      (const short *) buf_in, x, y, tic_x, tic_y,
  1359   1358   			      no_data);
  1360   1359   	  break;
  1361   1360         case RL2_SAMPLE_UINT16:
................................................................................
  1365   1364   	  break;
  1366   1365         case RL2_SAMPLE_INT32:
  1367   1366   	  rescale_grid_int32 ((int *) buf_out, tileWidth, tileHeight,
  1368   1367   			      (const int *) buf_in, x, y, tic_x, tic_y,
  1369   1368   			      no_data);
  1370   1369   	  break;
  1371   1370         case RL2_SAMPLE_UINT32:
  1372         -	  rescale_grid_uint32 ((unsigned int *) buf_out, tileWidth,
  1373         -			       tileHeight, (const unsigned int *) buf_in, x,
  1374         -			       y, tic_x, tic_y, no_data);
         1371  +	  rescale_grid_uint32 ((unsigned int *) buf_out, tileWidth, tileHeight,
         1372  +			       (const unsigned int *) buf_in, x, y, tic_x,
         1373  +			       tic_y, no_data);
  1375   1374   	  break;
  1376   1375         case RL2_SAMPLE_FLOAT:
  1377   1376   	  rescale_grid_float ((float *) buf_out, tileWidth, tileHeight,
  1378   1377   			      (const float *) buf_in, x, y, tic_x, tic_y,
  1379   1378   			      no_data);
  1380   1379   	  break;
  1381   1380         case RL2_SAMPLE_DOUBLE:
................................................................................
  1516   1515   				  break;
  1517   1516   			      }
  1518   1517   			    pos_x += geo_x;
  1519   1518   			}
  1520   1519   		      pos_y -= geo_y;
  1521   1520   		  }
  1522   1521   		rst = (rl2PrivRasterPtr) raster_in;
  1523         -		rescale_grid (buf_out, tileWidth, tileHeight,
  1524         -			      rst->rasterBuffer, sample_type, x, y, tic_x,
  1525         -			      tic_y, no_data);
         1522  +		rescale_grid (buf_out, tileWidth, tileHeight, rst->rasterBuffer,
         1523  +			      sample_type, x, y, tic_x, tic_y, no_data);
  1526   1524   		rl2_destroy_raster (raster_in);
  1527   1525   		raster_in = NULL;
  1528   1526   		tile_in = tile_in->next;
  1529   1527   	    }
  1530   1528   
  1531   1529   	  raster_out = NULL;
  1532   1530   	  raster_out =
................................................................................
  1548   1546   		goto error;
  1549   1547   	    }
  1550   1548   	  rl2_destroy_raster (raster_out);
  1551   1549   	  raster_out = NULL;
  1552   1550   
  1553   1551   	  /* INSERTing the tile */
  1554   1552   	  if (!do_insert_pyramid_tile
  1555         -	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  1556         -	       id_level, pyr->section_id, pyr->srid, tile_out->minx,
  1557         -	       tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils,
  1558         -	       stmt_data))
         1553  +	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level,
         1554  +	       pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny,
         1555  +	       tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data))
  1559   1556   	      goto error;
  1560   1557   
  1561   1558   	  tile_out = tile_out->next;
  1562   1559         }
  1563   1560   
  1564   1561       return 1;
  1565   1562   
................................................................................
  1573   1570       if (mask != NULL)
  1574   1571   	free (mask);
  1575   1572       return 0;
  1576   1573   }
  1577   1574   
  1578   1575   static double
  1579   1576   rescale_mb_pixel_uint8 (const unsigned char *buf_in, unsigned int tileWidth,
  1580         -			unsigned int tileHeight, unsigned int x,
  1581         -			unsigned int y, unsigned char nd, unsigned char nb,
         1577  +			unsigned int tileHeight, unsigned int x, unsigned int y,
         1578  +			unsigned char nd, unsigned char nb,
  1582   1579   			unsigned char num_bands)
  1583   1580   {
  1584   1581   /* rescaling a MultiBand pixel sample (8x8) - UINT8 */
  1585   1582       unsigned int row;
  1586   1583       unsigned int col;
  1587   1584       int nodata = 0;
  1588   1585       int valid = 0;
................................................................................
  1651   1648   				&& pxl->nBands == num_bands)
  1652   1649   			      {
  1653   1650   				  rl2PrivSamplePtr sample = pxl->Samples + nb;
  1654   1651   				  nd = sample->uint8;
  1655   1652   			      }
  1656   1653   			}
  1657   1654   		      *(p_out + nb) =
  1658         -			  rescale_mb_pixel_uint8 (buf_in, tileWidth,
  1659         -						  tileHeight, col * 8,
  1660         -						  row * 8, nd, nb, num_bands);
         1655  +			  rescale_mb_pixel_uint8 (buf_in, tileWidth, tileHeight,
         1656  +						  col * 8, row * 8, nd, nb,
         1657  +						  num_bands);
  1661   1658   		  }
  1662   1659   	    }
  1663   1660         }
  1664   1661   }
  1665   1662   
  1666   1663   static double
  1667   1664   rescale_mb_pixel_uint16 (const unsigned short *buf_in, unsigned int tileWidth,
................................................................................
  1741   1738   			      {
  1742   1739   				  rl2PrivSamplePtr sample = pxl->Samples + nb;
  1743   1740   				  nd = sample->uint16;
  1744   1741   			      }
  1745   1742   			}
  1746   1743   		      *(p_out + nb) =
  1747   1744   			  rescale_mb_pixel_uint16 (buf_in, tileWidth,
  1748         -						   tileHeight, col * 8,
  1749         -						   row * 8, nd, nb, num_bands);
         1745  +						   tileHeight, col * 8, row * 8,
         1746  +						   nd, nb, num_bands);
  1750   1747   		  }
  1751   1748   	    }
  1752   1749         }
  1753   1750   }
  1754   1751   
  1755   1752   static void
  1756   1753   rescale_multiband (void *buf_out, unsigned int tileWidth,
................................................................................
  1765   1762         case RL2_SAMPLE_UINT8:
  1766   1763   	  rescale_multiband_uint8 ((unsigned char *) buf_out, tileWidth,
  1767   1764   				   tileHeight, (const unsigned char *) buf_in,
  1768   1765   				   x, y, tic_x, tic_y, num_bands, no_data);
  1769   1766   	  break;
  1770   1767         case RL2_SAMPLE_UINT16:
  1771   1768   	  rescale_multiband_uint16 ((unsigned short *) buf_out, tileWidth,
  1772         -				    tileHeight,
  1773         -				    (const unsigned short *) buf_in, x, y,
  1774         -				    tic_x, tic_y, num_bands, no_data);
         1769  +				    tileHeight, (const unsigned short *) buf_in,
         1770  +				    x, y, tic_x, tic_y, num_bands, no_data);
  1775   1771   	  break;
  1776   1772         };
  1777   1773   }
  1778   1774   
  1779   1775   static int
  1780   1776   update_sect_pyramid_multiband (sqlite3 * handle, sqlite3_stmt * stmt_rd,
  1781   1777   			       sqlite3_stmt * stmt_tils,
................................................................................
  1900   1896   			      }
  1901   1897   			    pos_x += geo_x;
  1902   1898   			}
  1903   1899   		      pos_y -= geo_y;
  1904   1900   		  }
  1905   1901   		rst = (rl2PrivRasterPtr) raster_in;
  1906   1902   		rescale_multiband (buf_out, tileWidth, tileHeight,
  1907         -				   rst->rasterBuffer, sample_type, num_bands,
  1908         -				   x, y, tic_x, tic_y, no_data);
         1903  +				   rst->rasterBuffer, sample_type, num_bands, x,
         1904  +				   y, tic_x, tic_y, no_data);
  1909   1905   		rl2_destroy_raster (raster_in);
  1910   1906   		raster_in = NULL;
  1911   1907   		tile_in = tile_in->next;
  1912   1908   	    }
  1913   1909   
  1914   1910   	  raster_out = NULL;
  1915   1911   	  raster_out =
................................................................................
  1931   1927   		goto error;
  1932   1928   	    }
  1933   1929   	  rl2_destroy_raster (raster_out);
  1934   1930   	  raster_out = NULL;
  1935   1931   
  1936   1932   	  /* INSERTing the tile */
  1937   1933   	  if (!do_insert_pyramid_tile
  1938         -	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  1939         -	       id_level, pyr->section_id, pyr->srid, tile_out->minx,
  1940         -	       tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils,
  1941         -	       stmt_data))
         1934  +	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level,
         1935  +	       pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny,
         1936  +	       tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data))
  1942   1937   	      goto error;
  1943   1938   
  1944   1939   	  tile_out = tile_out->next;
  1945   1940         }
  1946   1941   
  1947   1942       return 1;
  1948   1943   
................................................................................
  2123   2118   							    0);
  2124   2119   			}
  2125   2120   		      compression = RL2_COMPRESSION_PNG;
  2126   2121   		  }
  2127   2122   		else
  2128   2123   		    nd = rl2_clone_pixel (no_data);
  2129   2124   		raster =
  2130         -		    rl2_create_raster (tileWidth, tileHeight,
  2131         -				       RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE,
  2132         -				       1, gray, tileWidth * tileHeight, NULL,
  2133         -				       alpha, tileWidth * tileHeight, nd);
         2125  +		    rl2_create_raster (tileWidth, tileHeight, RL2_SAMPLE_UINT8,
         2126  +				       RL2_PIXEL_GRAYSCALE, 1, gray,
         2127  +				       tileWidth * tileHeight, NULL, alpha,
         2128  +				       tileWidth * tileHeight, nd);
  2134   2129   	    }
  2135   2130   	  else if (pyr->pixel_type == RL2_PIXEL_RGB)
  2136   2131   	    {
  2137   2132   		/* RGB Pyramid */
  2138   2133   		nd = rl2_clone_pixel (no_data);
  2139   2134   		raster =
  2140         -		    rl2_create_raster (tileWidth, tileHeight,
  2141         -				       RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, 3,
  2142         -				       rgb, tileWidth * tileHeight * 3, NULL,
  2143         -				       alpha, tileWidth * tileHeight, nd);
         2135  +		    rl2_create_raster (tileWidth, tileHeight, RL2_SAMPLE_UINT8,
         2136  +				       RL2_PIXEL_RGB, 3, rgb,
         2137  +				       tileWidth * tileHeight * 3, NULL, alpha,
         2138  +				       tileWidth * tileHeight, nd);
  2144   2139   	    }
  2145   2140   	  if (raster == NULL)
  2146   2141   	    {
  2147   2142   		fprintf (stderr, "ERROR: unable to create a Pyramid Tile\n");
  2148   2143   		goto error;
  2149   2144   	    }
  2150   2145   	  if (rl2_raster_encode
................................................................................
  2157   2152   	  rl2_destroy_raster (raster);
  2158   2153   	  raster = NULL;
  2159   2154   	  rl2_graph_destroy_context (ctx);
  2160   2155   	  ctx = NULL;
  2161   2156   
  2162   2157   	  /* INSERTing the tile */
  2163   2158   	  if (!do_insert_pyramid_tile
  2164         -	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  2165         -	       id_level, pyr->section_id, pyr->srid, tile_out->minx,
  2166         -	       tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils,
  2167         -	       stmt_data))
         2159  +	      (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level,
         2160  +	       pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny,
         2161  +	       tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data))
  2168   2162   	      goto error;
  2169   2163   
  2170   2164   	  tile_out = tile_out->next;
  2171   2165         }
  2172   2166   
  2173   2167       return 1;
  2174   2168   
................................................................................
  2346   2340   	rl2_graph_destroy_context (ctx);
  2347   2341       return 0;
  2348   2342   }
  2349   2343   
  2350   2344   #define floor2(exp) ((long) exp)
  2351   2345   
  2352   2346   static rl2RasterPtr
  2353         -create_124_rescaled_raster (const unsigned char *rgba,
  2354         -			    unsigned char pixel_type, unsigned int tileWidth,
  2355         -			    unsigned int tileHeight, int scale)
         2347  +create_124_rescaled_raster (const unsigned char *rgba, unsigned char pixel_type,
         2348  +			    unsigned int tileWidth, unsigned int tileHeight,
         2349  +			    int scale)
  2356   2350   {
  2357   2351   /* creating a rescaled raster (1,2 or 4 bit pyramids) 
  2358   2352   /
  2359   2353   / this function builds an high quality rescaled sub-image by applying pixel interpolation
  2360   2354   /
  2361   2355   / this code is widely inspired by the original GD gdImageCopyResampled() function
  2362   2356   */
................................................................................
  2535   2529   			    *p_msk = 1;
  2536   2530   			}
  2537   2531   		  }
  2538   2532   	    }
  2539   2533         }
  2540   2534   
  2541   2535       raster =
  2542         -	rl2_create_raster (out_width, out_height, RL2_SAMPLE_UINT8,
  2543         -			   pixel_type, num_bands, rgb, rgb_sz, NULL, mask,
  2544         -			   mask_sz, NULL);
         2536  +	rl2_create_raster (out_width, out_height, RL2_SAMPLE_UINT8, pixel_type,
         2537  +			   num_bands, rgb, rgb_sz, NULL, mask, mask_sz, NULL);
  2545   2538       return raster;
  2546   2539   }
  2547   2540   
  2548   2541   static void
  2549   2542   copy_124_rescaled (rl2RasterPtr raster_out, rl2RasterPtr raster_in,
  2550   2543   		   unsigned int base_x, unsigned int base_y)
  2551   2544   {
................................................................................
  2747   2740   		double tile_x = sqlite3_column_double (stmt_geo, 1);
  2748   2741   		double tile_y = sqlite3_column_double (stmt_geo, 2);
  2749   2742   
  2750   2743   		rgba = load_tile_base (stmt_data, tile_id, palette, no_data);
  2751   2744   		if (rgba == NULL)
  2752   2745   		    goto error;
  2753   2746   		base_tile =
  2754         -		    create_124_rescaled_raster (rgba, out_pixel_type,
  2755         -						tileWidth, tileHeight, factor);
         2747  +		    create_124_rescaled_raster (rgba, out_pixel_type, tileWidth,
         2748  +						tileHeight, factor);
  2756   2749   		free (rgba);
  2757   2750   		if (base_tile == NULL)
  2758   2751   		    goto error;
  2759   2752   		shift_x = tile_x - minx;
  2760   2753   		shift_y = maxy - tile_y;
  2761   2754   		x = (int) (shift_x / res_x);
  2762   2755   		y = (int) (shift_y / res_y);
................................................................................
  3122   3115       for (ib = 0; ib < num_bands; ib++)
  3123   3116   	*p_out++ = (unsigned char) (*(sum + ib) / (double) valid);
  3124   3117       free (sum);
  3125   3118       *p_msk = 1;
  3126   3119   }
  3127   3120   
  3128   3121   static void
  3129         -mb_prime_nodata_u8 (unsigned char *buf, unsigned int width,
  3130         -		    unsigned int height, unsigned char num_bands,
  3131         -		    rl2PixelPtr no_data)
         3122  +mb_prime_nodata_u8 (unsigned char *buf, unsigned int width, unsigned int height,
         3123  +		    unsigned char num_bands, rl2PixelPtr no_data)
  3132   3124   {
  3133   3125   /* priming a void buffer */
  3134   3126       rl2PrivPixelPtr nd = (rl2PrivPixelPtr) no_data;
  3135   3127       unsigned int x;
  3136   3128       unsigned int y;
  3137   3129       unsigned char ib;
  3138   3130       unsigned char *p = buf;
................................................................................
  3252   3244   					    (unsigned char *) buf_in, mask_in,
  3253   3245   					    (unsigned char *) buf, mask, x, y,
  3254   3246   					    ox, oy, no_data);
  3255   3247   		      break;
  3256   3248   		  case RL2_SAMPLE_UINT16:
  3257   3249   		      rescale_multiband_u16 (tileWidth, tileHeight, num_bands,
  3258   3250   					     out_width, out_height, factor,
  3259         -					     (unsigned short *) buf_in,
  3260         -					     mask_in, (unsigned short *) buf,
  3261         -					     mask, x, y, ox, oy, no_data);
         3251  +					     (unsigned short *) buf_in, mask_in,
         3252  +					     (unsigned short *) buf, mask, x, y,
         3253  +					     ox, oy, no_data);
  3262   3254   		      break;
  3263   3255   		  };
  3264   3256   		ox++;
  3265   3257   	    }
  3266   3258   	  oy++;
  3267   3259         }
  3268   3260   
................................................................................
  4044   4036   					   out_height, factor,
  4045   4037   					   (unsigned char *) buf_in,
  4046   4038   					   (unsigned char *) buf, mask, x, y,
  4047   4039   					   ox, oy, no_data_u8);
  4048   4040   		      break;
  4049   4041   		  case RL2_SAMPLE_INT16:
  4050   4042   		      rescale_datagrid_16 (tileWidth, tileHeight, out_width,
  4051         -					   out_height, factor,
  4052         -					   (short *) buf_in, (short *) buf,
  4053         -					   mask, x, y, ox, oy, no_data_16);
         4043  +					   out_height, factor, (short *) buf_in,
         4044  +					   (short *) buf, mask, x, y, ox, oy,
         4045  +					   no_data_16);
  4054   4046   		      break;
  4055   4047   		  case RL2_SAMPLE_UINT16:
  4056   4048   		      rescale_datagrid_u16 (tileWidth, tileHeight, out_width,
  4057   4049   					    out_height, factor,
  4058   4050   					    (unsigned short *) buf_in,
  4059         -					    (unsigned short *) buf, mask, x,
  4060         -					    y, ox, oy, no_data_u16);
         4051  +					    (unsigned short *) buf, mask, x, y,
         4052  +					    ox, oy, no_data_u16);
  4061   4053   		      break;
  4062   4054   		  case RL2_SAMPLE_INT32:
  4063   4055   		      rescale_datagrid_32 (tileWidth, tileHeight, out_width,
  4064   4056   					   out_height, factor, (int *) buf_in,
  4065   4057   					   (int *) buf, mask, x, y, ox, oy,
  4066   4058   					   no_data_32);
  4067   4059   		      break;
................................................................................
  4097   4089       return raster;
  4098   4090   }
  4099   4091   
  4100   4092   static int
  4101   4093   rescale_monolithic_multiband (int id_level,
  4102   4094   			      unsigned int tileWidth, unsigned int tileHeight,
  4103   4095   			      unsigned char sample_type,
  4104         -			      unsigned char num_bands, int factor,
  4105         -			      double res_x, double res_y, double minx,
  4106         -			      double miny, double maxx, double maxy,
  4107         -			      unsigned char *buffer, int buf_size,
  4108         -			      unsigned char *mask, int *mask_size,
         4096  +			      unsigned char num_bands, int factor, double res_x,
         4097  +			      double res_y, double minx, double miny,
         4098  +			      double maxx, double maxy, unsigned char *buffer,
         4099  +			      int buf_size, unsigned char *mask, int *mask_size,
  4109   4100   			      rl2PixelPtr no_data, sqlite3_stmt * stmt_geo,
  4110   4101   			      sqlite3_stmt * stmt_data)
  4111   4102   {
  4112   4103   /* rescaling monolithic MultiBand */
  4113   4104       rl2RasterPtr raster = NULL;
  4114   4105       rl2RasterPtr base_tile = NULL;
  4115   4106       rl2PrivRasterPtr rst;
................................................................................
  4127   4118       p_out = mask;
  4128   4119       for (y = 0; y < tileHeight; y++)
  4129   4120         {
  4130   4121   	  /* priming full transparency */
  4131   4122   	  for (x = 0; x < tileWidth; x++)
  4132   4123   	      *p_out++ = 0;
  4133   4124         }
  4134         -    rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type,
  4135         -			 num_bands, no_data);
         4125  +    rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type, num_bands,
         4126  +			 no_data);
  4136   4127   /* creating the output raster */
  4137   4128       raster =
  4138   4129   	rl2_create_raster (tileWidth, tileHeight, sample_type,
  4139   4130   			   RL2_PIXEL_MULTIBAND, num_bands, buffer, buf_size,
  4140   4131   			   NULL, mask, *mask_size, nd);
  4141   4132       if (raster == NULL)
  4142   4133   	goto error;
................................................................................
  4338   4329   	  rl2_destroy_raster (raster);
  4339   4330         }
  4340   4331       return 0;
  4341   4332   }
  4342   4333   
  4343   4334   static int
  4344   4335   prepare_section_pyramid_stmts (sqlite3 * handle, const char *coverage,
  4345         -			       int mixed_resolutions,
  4346         -			       sqlite3_stmt ** xstmt_rd,
         4336  +			       int mixed_resolutions, sqlite3_stmt ** xstmt_rd,
  4347   4337   			       sqlite3_stmt ** xstmt_levl,
  4348   4338   			       sqlite3_stmt ** xstmt_tils,
  4349   4339   			       sqlite3_stmt ** xstmt_data)
  4350   4340   {
  4351   4341   /* preparing the section pyramid related SQL statements */
  4352   4342       char *table_tile_data;
  4353   4343       char *xtable_tile_data;
................................................................................
  4510   4500   
  4511   4501       if (!get_section_infos
  4512   4502   	(handle, coverage, section_id, &sect_width, &sect_height, &minx,
  4513   4503   	 &miny, &maxx, &maxy, &palette, &no_data))
  4514   4504   	goto error;
  4515   4505   
  4516   4506       if (!prepare_section_pyramid_stmts
  4517         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
  4518         -	 &stmt_tils, &stmt_data))
         4507  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
         4508  +	 &stmt_data))
  4519   4509   	goto error;
  4520   4510   
  4521   4511       while (1)
  4522   4512         {
  4523   4513   	  /* looping on pyramid levels */
  4524   4514   	  if (mixed_resolutions)
  4525   4515   	      table_levels = sqlite3_mprintf ("%s_section_levels", coverage);
................................................................................
  4590   4580   		      scale = 8;
  4591   4581   		      if (first)
  4592   4582   			{
  4593   4583   			    pyr =
  4594   4584   				alloc_sect_pyramid (section_id, sect_width,
  4595   4585   						    sect_height, sample_type,
  4596   4586   						    pixel_type, num_samples,
  4597         -						    compression, quality,
  4598         -						    srid, new_res_x,
  4599         -						    new_res_y,
         4587  +						    compression, quality, srid,
         4588  +						    new_res_x, new_res_y,
  4600   4589   						    (double) tileWidth *
  4601   4590   						    new_res_x,
  4602   4591   						    (double) tileHeight *
  4603         -						    new_res_y, minx, miny,
  4604         -						    maxx, maxy, scale);
         4592  +						    new_res_y, minx, miny, maxx,
         4593  +						    maxy, scale);
  4605   4594   			    first = 0;
  4606   4595   			    if (pyr == NULL)
  4607   4596   				goto error;
  4608   4597   			}
  4609   4598   		      if (!insert_tile_into_section_pyramid
  4610   4599   			  (pyr, tile_id, tminx, tminy, tmaxx, tmaxy))
  4611   4600   			  goto error;
................................................................................
  4623   4612   	  if (pyr == NULL)
  4624   4613   	      goto error;
  4625   4614   
  4626   4615   	  out_maxy = maxy;
  4627   4616   	  for (row = 0; row < pyr->scaled_height; row += tileHeight)
  4628   4617   	    {
  4629   4618   		out_miny = out_maxy - pyr->tile_height;
  4630         -		if (out_miny < miny)
  4631         -		    out_miny = miny;
  4632   4619   		out_minx = minx;
  4633   4620   		for (col = 0; col < pyr->scaled_width; col += tileWidth)
  4634   4621   		  {
  4635   4622   		      out_maxx = out_minx + pyr->tile_width;
  4636         -		      if (out_maxx > maxx)
  4637         -			  out_maxx = maxx;
  4638   4623   		      set_pyramid_tile_destination (pyr, out_minx, out_miny,
  4639   4624   						    out_maxx, out_maxy, row,
  4640   4625   						    col);
  4641   4626   		      out_minx += pyr->tile_width;
  4642   4627   		  }
  4643   4628   		out_maxy -= pyr->tile_height;
  4644   4629   	    }
................................................................................
  4969   4954   }
  4970   4955   
  4971   4956   static int
  4972   4957   get_section_raw_raster_data (sqlite3 * handle, int max_threads,
  4973   4958   			     const char *coverage, sqlite3_int64 sect_id,
  4974   4959   			     unsigned int width, unsigned int height,
  4975   4960   			     unsigned char sample_type,
  4976         -			     unsigned char pixel_type,
  4977         -			     unsigned char num_bands, double minx, double miny,
  4978         -			     double maxx, double maxy, double x_res,
         4961  +			     unsigned char pixel_type, unsigned char num_bands,
         4962  +			     double minx, double maxy, double x_res,
  4979   4963   			     double y_res, unsigned char **buffer,
  4980   4964   			     int *buf_size, rl2PalettePtr palette,
  4981   4965   			     rl2PixelPtr no_data)
  4982   4966   {
  4983   4967   /* attempting to return a buffer containing raw pixels from the whole DBMS Section */
  4984   4968       unsigned char *bufpix = NULL;
  4985   4969       int bufpix_size;
................................................................................
  5018   5002   
  5019   5003   /* preparing the "tiles" SQL query */
  5020   5004       xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  5021   5005       xxtiles = rl2_double_quoted_sql (xtiles);
  5022   5006       sql =
  5023   5007   	sqlite3_mprintf ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  5024   5008   			 "FROM \"%s\" "
  5025         -			 "WHERE section_id = ? AND pyramid_level = ? AND ROWID IN ( "
  5026         -			 "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
  5027         -			 "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles,
  5028         -			 xtiles);
         5009  +			 "WHERE pyramid_level = 0 AND section_id = ?", xxtiles);
  5029   5010       sqlite3_free (xtiles);
  5030   5011       free (xxtiles);
  5031   5012       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL);
  5032   5013       sqlite3_free (sql);
  5033   5014       if (ret != SQLITE_OK)
  5034   5015         {
  5035   5016   	  printf ("SELECT section raw tiles SQL error: %s\n",
................................................................................
  5057   5038       if (pixel_type == RL2_PIXEL_PALETTE)
  5058   5039   	void_raw_buffer_palette (bufpix, width, height, no_data);
  5059   5040       else
  5060   5041   	void_raw_buffer (bufpix, width, height, sample_type, num_bands,
  5061   5042   			 no_data);
  5062   5043       if (!rl2_load_dbms_tiles_section
  5063   5044   	(handle, max_threads, sect_id, stmt_tiles, stmt_data, bufpix, width,
  5064         -	 height, sample_type, num_bands, 0, 0, 0, x_res, y_res, minx, miny,
  5065         -	 maxx, maxy, 0, RL2_SCALE_1, palette, no_data))
         5045  +	 height, sample_type, num_bands, 0, 0, 0, x_res, y_res, minx, maxy,
         5046  +	 RL2_SCALE_1, palette, no_data))
  5066   5047   	goto error;
  5067   5048       sqlite3_finalize (stmt_tiles);
  5068   5049       sqlite3_finalize (stmt_data);
  5069   5050       *buffer = bufpix;
  5070   5051       *buf_size = bufpix_size;
  5071   5052       return 1;
  5072   5053   
................................................................................
  5078   5059       if (bufpix != NULL)
  5079   5060   	free (bufpix);
  5080   5061       return 0;
  5081   5062   }
  5082   5063   
  5083   5064   static void
  5084   5065   raster_tile_124_rescaled (unsigned char *outbuf,
  5085         -			  unsigned char pixel_type,
  5086         -			  const unsigned char *inbuf,
         5066  +			  unsigned char pixel_type, const unsigned char *inbuf,
  5087   5067   			  unsigned int section_width,
  5088   5068   			  unsigned int section_height, unsigned int out_width,
  5089   5069   			  unsigned int out_height, rl2PalettePtr palette)
  5090   5070   {
  5091   5071   /* 
  5092   5072   / this function builds an high quality rescaled sub-image by applying pixel interpolation
  5093   5073   /
................................................................................
  5377   5357   do_build_124_bit_section_pyramid (sqlite3 * handle, int max_threads,
  5378   5358   				  const char *coverage, int mixed_resolutions,
  5379   5359   				  sqlite3_int64 section_id,
  5380   5360   				  unsigned char sample_type,
  5381   5361   				  unsigned char pixel_type,
  5382   5362   				  unsigned char num_samples, int srid,
  5383   5363   				  unsigned int tileWidth,
  5384         -				  unsigned int tileHeight,
  5385         -				  unsigned char bgRed, unsigned char bgGreen,
  5386         -				  unsigned char bgBlue)
         5364  +				  unsigned int tileHeight, unsigned char bgRed,
         5365  +				  unsigned char bgGreen, unsigned char bgBlue)
  5387   5366   {
  5388   5367   /* attempting to (re)build a 1,2,4-bit section pyramid from scratch */
  5389   5368       double base_res_x;
  5390   5369       double base_res_y;
  5391   5370       unsigned int sect_width;
  5392   5371       unsigned int sect_height;
  5393   5372       int id_level = 0;
................................................................................
  5441   5420         {
  5442   5421   	  if (!find_base_resolution
  5443   5422   	      (handle, coverage, &base_res_x, &base_res_y))
  5444   5423   	      goto error;
  5445   5424         }
  5446   5425       if (!get_section_raw_raster_data
  5447   5426   	(handle, max_threads, coverage, section_id, sect_width, sect_height,
  5448         -	 sample_type, pixel_type, num_samples, minx, miny, maxx, maxy,
  5449         -	 base_res_x, base_res_y, &inbuf, &inbuf_size, palette, no_data))
         5427  +	 sample_type, pixel_type, num_samples, minx, maxy, base_res_x,
         5428  +	 base_res_y, &inbuf, &inbuf_size, palette, no_data))
  5450   5429   	goto error;
  5451   5430   
  5452   5431       if (!prepare_section_pyramid_stmts
  5453         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
  5454         -	 &stmt_tils, &stmt_data))
         5432  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
         5433  +	 &stmt_data))
  5455   5434   	goto error;
  5456   5435   
  5457   5436       id_level = 1;
  5458   5437       scale = 2;
  5459   5438       x_res = base_res_x * 2.0;
  5460   5439       y_res = base_res_y * 2.0;
  5461   5440       while (1)
................................................................................
  5523   5502   		    goto error;
  5524   5503   	    }
  5525   5504   
  5526   5505   	  for (row = 0; row < out_height; row += tileHeight)
  5527   5506   	    {
  5528   5507   		t_minx = minx;
  5529   5508   		t_miny = t_maxy - (tileHeight * y_res);
  5530         -		if (t_miny < miny)
  5531         -		    t_miny = miny;
  5532   5509   		for (col = 0; col < out_width; col += tileWidth)
  5533   5510   		  {
  5534   5511   		      if (pixel_type == RL2_PIXEL_MONOCHROME)
  5535   5512   			{
  5536   5513   			    if (no_data == NULL)
  5537   5514   				nd = NULL;
  5538   5515   			    else
................................................................................
  5551   5528   			    if (no_data == NULL)
  5552   5529   				nd = NULL;
  5553   5530   			    else
  5554   5531   			      {
  5555   5532   				  /* converting the NO-DATA pixel */
  5556   5533   				  nd = rl2_create_pixel (RL2_SAMPLE_UINT8,
  5557   5534   							 RL2_PIXEL_RGB, 3);
  5558         -				  rl2_set_pixel_sample_uint8 (nd,
  5559         -							      RL2_RED_BAND,
         5535  +				  rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND,
  5560   5536   							      bgRed);
  5561   5537   				  rl2_set_pixel_sample_uint8 (nd,
  5562   5538   							      RL2_GREEN_BAND,
  5563   5539   							      bgGreen);
  5564         -				  rl2_set_pixel_sample_uint8 (nd,
  5565         -							      RL2_BLUE_BAND,
         5540  +				  rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
  5566   5541   							      bgBlue);
  5567   5542   			      }
  5568   5543   			}
  5569   5544   		      t_maxx = t_minx + (tileWidth * x_res);
  5570         -		      if (t_maxx > maxx)
  5571         -			  t_maxx = maxx;
  5572   5545   		      if (!copy_124_tile
  5573   5546   			  (out_pixel_type, outbuf, &tilebuf,
  5574   5547   			   &tilebuf_sz, &tilemask, &tilemask_sz, row, col,
  5575   5548   			   out_width, out_height, tileWidth, tileHeight,
  5576   5549   			   no_data))
  5577   5550   			{
  5578   5551   			    fprintf (stderr,
................................................................................
  5590   5563   		      if (raster == NULL)
  5591   5564   			{
  5592   5565   			    fprintf (stderr,
  5593   5566   				     "ERROR: unable to create a Pyramid Tile\n");
  5594   5567   			    goto error;
  5595   5568   			}
  5596   5569   		      if (rl2_raster_encode
  5597         -			  (raster, RL2_COMPRESSION_PNG, &blob_odd,
  5598         -			   &blob_odd_sz, &blob_even, &blob_even_sz, 100,
  5599         -			   1) != RL2_OK)
         5570  +			  (raster, RL2_COMPRESSION_PNG, &blob_odd, &blob_odd_sz,
         5571  +			   &blob_even, &blob_even_sz, 100, 1) != RL2_OK)
  5600   5572   			{
  5601   5573   			    fprintf (stderr,
  5602   5574   				     "ERROR: unable to encode a Pyramid tile\n");
  5603   5575   			    goto error;
  5604   5576   			}
  5605   5577   
  5606   5578   		      /* INSERTing the tile */
................................................................................
  5662   5634   }
  5663   5635   
  5664   5636   static int
  5665   5637   do_build_palette_section_pyramid (sqlite3 * handle, int max_threads,
  5666   5638   				  const char *coverage, int mixed_resolutions,
  5667   5639   				  sqlite3_int64 section_id, int srid,
  5668   5640   				  unsigned int tileWidth,
  5669         -				  unsigned int tileHeight,
  5670         -				  unsigned char bgRed, unsigned char bgGreen,
  5671         -				  unsigned char bgBlue)
         5641  +				  unsigned int tileHeight, unsigned char bgRed,
         5642  +				  unsigned char bgGreen, unsigned char bgBlue)
  5672   5643   {
  5673   5644   /* attempting to (re)build a Palette section pyramid from scratch */
  5674   5645       double base_res_x;
  5675   5646       double base_res_y;
  5676   5647       unsigned int sect_width;
  5677   5648       unsigned int sect_height;
  5678   5649       int id_level = 0;
................................................................................
  5728   5699         {
  5729   5700   	  if (!find_base_resolution
  5730   5701   	      (handle, coverage, &base_res_x, &base_res_y))
  5731   5702   	      goto error;
  5732   5703         }
  5733   5704       if (!get_section_raw_raster_data
  5734   5705   	(handle, max_threads, coverage, section_id, sect_width, sect_height,
  5735         -	 RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE, 1, minx, miny, maxx, maxy,
  5736         -	 base_res_x, base_res_y, &inbuf, &inbuf_size, palette, no_data))
         5706  +	 RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE, 1, minx, maxy, base_res_x,
         5707  +	 base_res_y, &inbuf, &inbuf_size, palette, no_data))
  5737   5708   	goto error;
  5738   5709   
  5739   5710       if (!prepare_section_pyramid_stmts
  5740         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
  5741         -	 &stmt_tils, &stmt_data))
         5711  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
         5712  +	 &stmt_data))
  5742   5713   	goto error;
  5743   5714   
  5744   5715       id_level = 1;
  5745   5716       scale = 2;
  5746   5717       x_res = base_res_x * 2.0;
  5747   5718       y_res = base_res_y * 2.0;
  5748   5719       while (1)
................................................................................
  5790   5761   		    goto error;
  5791   5762   	    }
  5792   5763   
  5793   5764   	  for (row = 0; row < out_height; row += tileHeight)
  5794   5765   	    {
  5795   5766   		t_minx = minx;
  5796   5767   		t_miny = t_maxy - (tileHeight * y_res);
  5797         -		if (t_miny < miny)
  5798         -		    t_miny = miny;
  5799   5768   		for (col = 0; col < out_width; col += tileWidth)
  5800   5769   		  {
  5801   5770   		      if (no_data == NULL)
  5802   5771   			  nd = NULL;
  5803   5772   		      else
  5804   5773   			{
  5805   5774   			    /* converting the NO-DATA pixel */
................................................................................
  5810   5779   			    rl2_set_pixel_sample_uint8 (nd,
  5811   5780   							RL2_GREEN_BAND,
  5812   5781   							bgGreen);
  5813   5782   			    rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
  5814   5783   							bgBlue);
  5815   5784   			}
  5816   5785   		      t_maxx = t_minx + (tileWidth * x_res);
  5817         -		      if (t_maxx > maxx)
  5818         -			  t_maxx = maxx;
  5819   5786   		      if (!copy_124_tile (out_pixel_type, outbuf, &tilebuf,
  5820         -					  &tilebuf_sz, &tilemask,
  5821         -					  &tilemask_sz, row, col, out_width,
  5822         -					  out_height, tileWidth, tileHeight,
  5823         -					  no_data))
         5787  +					  &tilebuf_sz, &tilemask, &tilemask_sz,
         5788  +					  row, col, out_width, out_height,
         5789  +					  tileWidth, tileHeight, no_data))
  5824   5790   			{
  5825   5791   			    fprintf (stderr,
  5826   5792   				     "ERROR: unable to extract a Pyramid Tile\n");
  5827   5793   			    goto error;
  5828   5794   			}
  5829   5795   
  5830   5796   		      raster =
................................................................................
  6083   6049   		    goto error;
  6084   6050   	    }
  6085   6051   	  else
  6086   6052   	    {
  6087   6053   		/* ordinary RGB, Grayscale, MultiBand or DataGrid Pyramid */
  6088   6054   		if (!do_build_section_pyramid
  6089   6055   		    (handle, coverage, section_id, sample_type, pixel_type,
  6090         -		     num_bands, compression, ptrcvg->mixedResolutions,
  6091         -		     quality, srid, tileWidth, tileHeight))
         6056  +		     num_bands, compression, ptrcvg->mixedResolutions, quality,
         6057  +		     srid, tileWidth, tileHeight))
  6092   6058   		    goto error;
  6093   6059   	    }
  6094   6060   	  if (verbose)
  6095   6061   	    {
  6096   6062   		printf ("  ----------\n");
  6097   6063   #if defined(_WIN32) && !defined(__MINGW32__)
  6098   6064   		printf
................................................................................
  6141   6107   	  ret = sqlite3_step (stmt);
  6142   6108   	  if (ret == SQLITE_DONE)
  6143   6109   	      break;
  6144   6110   	  if (ret == SQLITE_ROW)
  6145   6111   	    {
  6146   6112   		sqlite3_int64 section_id = sqlite3_column_int64 (stmt, 0);
  6147   6113   		if (rl2_build_section_pyramid
  6148         -		    (handle, max_threads, coverage, section_id,
  6149         -		     forced_rebuild, verbose) != RL2_OK)
         6114  +		    (handle, max_threads, coverage, section_id, forced_rebuild,
         6115  +		     verbose) != RL2_OK)
  6150   6116   		    goto error;
  6151   6117   	    }
  6152   6118   	  else
  6153   6119   	    {
  6154   6120   		fprintf (stderr,
  6155   6121   			 "SELECT section_id; sqlite3_step() error: %s\n",
  6156   6122   			 sqlite3_errmsg (handle));
................................................................................
  6315   6281   	  out_sample_type = RL2_SAMPLE_UINT8;
  6316   6282   	  out_pixel_type = RL2_PIXEL_RGB;
  6317   6283   	  out_num_bands = 3;
  6318   6284   	  out_compression = RL2_COMPRESSION_PNG;
  6319   6285   	  out_quality = 100;
  6320   6286   	  virt_levels = 1;
  6321   6287         }
  6322         -    else if (sample_type == RL2_SAMPLE_UINT8
  6323         -	     && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1)
         6288  +    else if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE
         6289  +	     && num_bands == 1)
  6324   6290         {
  6325   6291   	  /* palette 8: output colorspace is RGB compression PNG */
  6326   6292   	  out_sample_type = RL2_SAMPLE_UINT8;
  6327   6293   	  out_pixel_type = RL2_PIXEL_RGB;
  6328   6294   	  out_num_bands = 3;
  6329   6295   	  out_compression = RL2_COMPRESSION_PNG;
  6330   6296   	  out_quality = 100;
................................................................................
  6437   6403   		      if (tile_miny < miny)
  6438   6404   			  end_y = miny;
  6439   6405   
  6440   6406   		      if ((sample_type == RL2_SAMPLE_UINT8
  6441   6407   			   && pixel_type == RL2_PIXEL_GRAYSCALE
  6442   6408   			   && num_bands == 1)
  6443   6409   			  || (sample_type == RL2_SAMPLE_UINT8
  6444         -			      && pixel_type == RL2_PIXEL_RGB
  6445         -			      && num_bands == 3)
         6410  +			      && pixel_type == RL2_PIXEL_RGB && num_bands == 3)
  6446   6411   			  || (sample_type == RL2_SAMPLE_UINT8
  6447   6412   			      && pixel_type == RL2_PIXEL_PALETTE
  6448   6413   			      && num_bands == 1))
  6449   6414   			{
  6450   6415   			    /* RGB, PALETTE or GRAYSCALE datasource (UINT8) */
  6451   6416   			    if (!rescale_monolithic_rgba
  6452         -				(id_level, tileWidth, tileHeight,
  6453         -				 resize_factor, res_x, res_y, tile_minx,
  6454         -				 tile_miny, tile_maxx, tile_maxy, buffer,
  6455         -				 buf_size, mask, &mask_size, palette, no_data,
  6456         -				 stmt_geo, stmt_rd))
         6417  +				(id_level, tileWidth, tileHeight, resize_factor,
         6418  +				 res_x, res_y, tile_minx, tile_miny,
         6419  +				 tile_maxx, tile_maxy, buffer, buf_size, mask,
         6420  +				 &mask_size, palette, no_data, stmt_geo,
         6421  +				 stmt_rd))
  6457   6422   				goto error;
  6458   6423   			    if (mask_size == 0)
  6459   6424   				mask = NULL;
  6460   6425   			}
  6461   6426   		      else if (((sample_type == RL2_SAMPLE_1_BIT
  6462   6427   				 || sample_type == RL2_SAMPLE_2_BIT
  6463   6428   				 || sample_type == RL2_SAMPLE_4_BIT)
................................................................................
  6495   6460   		      else if (pixel_type == RL2_PIXEL_DATAGRID)
  6496   6461   			{
  6497   6462   			    /* DataGrid */
  6498   6463   			    if (!rescale_monolithic_datagrid
  6499   6464   				(id_level, tileWidth, tileHeight, sample_type,
  6500   6465   				 resize_factor, res_x, res_y, tile_minx,
  6501   6466   				 tile_miny, tile_maxx, tile_maxy, buffer,
  6502         -				 buf_size, mask, &mask_size, no_data,
  6503         -				 stmt_geo, stmt_rd))
         6467  +				 buf_size, mask, &mask_size, no_data, stmt_geo,
         6468  +				 stmt_rd))
  6504   6469   				goto error;
  6505   6470   			    if (mask_size == 0)
  6506   6471   				mask = NULL;
  6507   6472   			}
  6508   6473   		      else
  6509   6474   			{
  6510   6475   			    /* unknown */
................................................................................
  6548   6513   			{
  6549   6514   			    if (no_data == NULL)
  6550   6515   				nd = NULL;
  6551   6516   			    else
  6552   6517   			      {
  6553   6518   				  nd = rl2_create_pixel (RL2_SAMPLE_UINT8,
  6554   6519   							 RL2_PIXEL_RGB, 3);
  6555         -				  rl2_set_pixel_sample_uint8 (nd,
  6556         -							      RL2_RED_BAND,
         6520  +				  rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND,
  6557   6521   							      255);
  6558   6522   				  rl2_set_pixel_sample_uint8 (nd,
  6559   6523   							      RL2_GREEN_BAND,
  6560   6524   							      255);
  6561         -				  rl2_set_pixel_sample_uint8 (nd,
  6562         -							      RL2_BLUE_BAND,
         6525  +				  rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
  6563   6526   							      255);
  6564   6527   			      }
  6565   6528   			}
  6566   6529   		      else
  6567   6530   			  nd = rl2_clone_pixel (no_data);
  6568   6531   
  6569   6532   		      raster =
................................................................................
  6643   6606       sqlite3_finalize (stmt_rd);
  6644   6607       sqlite3_finalize (stmt_levl);
  6645   6608       sqlite3_finalize (stmt_tils);
  6646   6609       sqlite3_finalize (stmt_data);
  6647   6610       if (verbose)
  6648   6611         {
  6649   6612   	  printf ("  ----------\n");
  6650         -	  printf
  6651         -	      ("    Monolithic Pyramid levels successfully built for: %s\n",
  6652         -	       coverage);
         6613  +	  printf ("    Monolithic Pyramid levels successfully built for: %s\n",
         6614  +		  coverage);
  6653   6615         }
  6654   6616       free (buffer);
  6655   6617       free (mask);
  6656   6618       rl2_destroy_coverage (cvg);
  6657   6619   
  6658   6620       return RL2_OK;
  6659   6621   

Changes to src/rl2rastersym.c.

   690    690   			    for (ib = 0; ib < out_num_bands; ib++)
   691    691   				p_out++;
   692    692   			}
   693    693   		      else
   694    694   			{
   695    695   			    /* opaque pixel */
   696    696   			    p_out =
   697         -				mono_int8_pixel_handler (p_in, p_out,
   698         -							 mono_band,
          697  +				mono_int8_pixel_handler (p_in, p_out, mono_band,
   699    698   							 mono_handling);
   700    699   			}
   701    700   		  }
   702    701   		else
   703    702   		  {
   704    703   		      /* testing for NO-DATA values */
   705    704   		      int match = 0;
................................................................................
   708    707   		      rl2_get_pixel_sample_int8 (no_data, &sample);
   709    708   		      if (sample == *p_save++)
   710    709   			  match++;
   711    710   		      if (match != 1)
   712    711   			{
   713    712   			    /* opaque pixel */
   714    713   			    p_out =
   715         -				mono_int8_pixel_handler (p_in, p_out,
   716         -							 mono_band,
          714  +				mono_int8_pixel_handler (p_in, p_out, mono_band,
   717    715   							 mono_handling);
   718    716   			}
   719    717   		      else
   720    718   			{
   721    719   			    /* NO-DATA pixel */
   722    720   			    for (ib = 0; ib < out_num_bands; ib++)
   723    721   				p_out++;
................................................................................
   731    729   static void
   732    730   copy_uint8_raw_pixels (const unsigned char *buffer, const unsigned char *mask,
   733    731   		       unsigned char *outbuf, unsigned short width,
   734    732   		       unsigned short height, unsigned char num_bands,
   735    733   		       double x_res, double y_res, double minx, double maxy,
   736    734   		       double tile_minx, double tile_maxy,
   737    735   		       unsigned short tile_width, unsigned short tile_height,
   738         -		       rl2PixelPtr no_data, unsigned char raster_type)
          736  +		       rl2PixelPtr no_data)
   739    737   {
   740    738   /* copying UINT8 raw pixels from the DBMS tile into the output image */
   741    739       int x;
   742    740       int y;
   743    741       int b;
   744    742       int out_x;
   745    743       int out_y;
................................................................................
   760    758         {
   761    759   	  ignore_no_data = 0;
   762    760   	  if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands)
   763    761   	      != RL2_OK)
   764    762   	      ignore_no_data = 1;
   765    763   	  if (nbands != num_bands)
   766    764   	      ignore_no_data = 1;
   767         -	  if (sample_type == RL2_SAMPLE_1_BIT
   768         -	      || sample_type == RL2_SAMPLE_2_BIT
          765  +	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
   769    766   	      || sample_type == RL2_SAMPLE_4_BIT
   770    767   	      || sample_type == RL2_SAMPLE_UINT8)
   771    768   	      ;
   772    769   	  else
   773    770   	      ignore_no_data = 1;
   774    771         }
          772  +
   775    773       geo_y = tile_maxy + y_res2;
   776    774       for (y = 0; y < tile_height; y++)
   777    775         {
   778    776   	  geo_y -= y_res;
   779    777   	  out_y = (maxy - geo_y) / y_res;
   780    778   	  if (out_y < 0 || out_y >= height)
   781    779   	    {
................................................................................
   820    818   			}
   821    819   		  }
   822    820   		else
   823    821   		  {
   824    822   		      /* testing for NO-DATA values */
   825    823   		      int match = 0;
   826    824   		      const unsigned char *p_save = p_in;
   827         -		      if (raster_type == RL2_SAMPLE_1_BIT && num_bands == 1)
          825  +		      for (b = 0; b < num_bands; b++)
   828    826   			{
   829         -			    /* special case: MONOCHROME */
   830         -			    if (*p_in++ == 1)
   831         -				*p_out++ = 0;
   832         -			    else
   833         -				p_out++;
   834         -			    match++;
   835         -			}
   836         -		      else
   837         -			{
   838         -			    for (b = 0; b < num_bands; b++)
          827  +			    unsigned char sample = 0;
          828  +			    switch (sample_type)
   839    829   			      {
   840         -				  unsigned char sample = 0;
   841         -				  switch (sample_type)
   842         -				    {
   843         -				    case RL2_SAMPLE_1_BIT:
   844         -					rl2_get_pixel_sample_1bit (no_data,
   845         -								   &sample);
   846         -					break;
   847         -				    case RL2_SAMPLE_2_BIT:
   848         -					rl2_get_pixel_sample_2bit (no_data,
   849         -								   &sample);
   850         -					break;
   851         -				    case RL2_SAMPLE_4_BIT:
   852         -					rl2_get_pixel_sample_4bit (no_data,
   853         -								   &sample);
   854         -					break;
   855         -				    case RL2_SAMPLE_UINT8:
   856         -					rl2_get_pixel_sample_uint8 (no_data, b,
   857         -								    &sample);
   858         -					break;
   859         -				    };
   860         -				  if (sample == *p_in++)
   861         -				      match++;
   862         -			      }
   863         -			    if (match != num_bands)
   864         -			      {
   865         -				  /* opaque pixel */
   866         -				  p_in = p_save;
   867         -				  for (b = 0; b < num_bands; b++)
   868         -				      *p_out++ = *p_in++;
   869         -			      }
   870         -			    else
   871         -			      {
   872         -				  /* NO-DATA pixel */
   873         -				  for (b = 0; b < num_bands; b++)
   874         -				      p_out++;
   875         -			      }
          830  +			      case RL2_SAMPLE_1_BIT:
          831  +				  rl2_get_pixel_sample_1bit (no_data, &sample);
          832  +				  break;
          833  +			      case RL2_SAMPLE_2_BIT:
          834  +				  rl2_get_pixel_sample_2bit (no_data, &sample);
          835  +				  break;
          836  +			      case RL2_SAMPLE_4_BIT:
          837  +				  rl2_get_pixel_sample_4bit (no_data, &sample);
          838  +				  break;
          839  +			      case RL2_SAMPLE_UINT8:
          840  +				  rl2_get_pixel_sample_uint8 (no_data, b,
          841  +							      &sample);
          842  +				  break;
          843  +			      };
          844  +			    if (sample == *p_in++)
          845  +				match++;
          846  +			}
          847  +		      if (match != num_bands)
          848  +			{
          849  +			    /* opaque pixel */
          850  +			    p_in = p_save;
          851  +			    for (b = 0; b < num_bands; b++)
          852  +				*p_out++ = *p_in++;
          853  +			}
          854  +		      else
          855  +			{
          856  +			    /* NO-DATA pixel */
          857  +			    for (b = 0; b < num_bands; b++)
          858  +				p_out++;
   876    859   			}
   877    860   		  }
   878    861   	    }
   879    862         }
   880    863   }
   881    864   
   882    865   static unsigned char *
................................................................................
   894    877       return apply_contrast_enhancement ((double) mono, p_out, mono_handling);
   895    878   }
   896    879   
   897    880   static void
   898    881   copy_uint8_raw_selected_pixels (const unsigned char *buffer,
   899    882   				const unsigned char *mask,
   900    883   				unsigned char *outbuf, unsigned short width,
   901         -				unsigned short height,
   902         -				unsigned char num_bands, double x_res,
   903         -				double y_res, double minx, double maxy,
   904         -				double tile_minx, double tile_maxy,
          884  +				unsigned short height, unsigned char num_bands,
          885  +				double x_res, double y_res, double minx,
          886  +				double maxy, double tile_minx, double tile_maxy,
   905    887   				unsigned short tile_width,
   906         -				unsigned short tile_height,
   907         -				rl2PixelPtr no_data, unsigned char red_band,
          888  +				unsigned short tile_height, rl2PixelPtr no_data,
          889  +				unsigned char red_band,
   908    890   				unsigned char green_band,
   909    891   				unsigned char blue_band,
   910    892   				rl2BandHandlingPtr red_handling,
   911    893   				rl2BandHandlingPtr green_handling,
   912    894   				rl2BandHandlingPtr blue_handling)
   913    895   {
   914    896   /* copying UINT8 raw pixels from the DBMS tile into the output image */
................................................................................
   983    965   			    /* skipping a transparent pixel */
   984    966   			    p_out += 3;
   985    967   			}
   986    968   		      else
   987    969   			{
   988    970   			    /* opaque pixel */
   989    971   			    p_out =
   990         -				mono_uint8_pixel_handler (p_in, p_out,
   991         -							  red_band,
          972  +				mono_uint8_pixel_handler (p_in, p_out, red_band,
   992    973   							  red_handling);
   993    974   			    p_out =
   994    975   				mono_uint8_pixel_handler (p_in, p_out,
   995    976   							  green_band,
   996    977   							  green_handling);
   997    978   			    p_out =
   998    979   				mono_uint8_pixel_handler (p_in, p_out,
................................................................................
  1012    993   			    if (sample == *p_save++)
  1013    994   				match++;
  1014    995   			}
  1015    996   		      if (match != num_bands)
  1016    997   			{
  1017    998   			    /* opaque pixel */
  1018    999   			    p_out =
  1019         -				mono_uint8_pixel_handler (p_in, p_out,
  1020         -							  red_band,
         1000  +				mono_uint8_pixel_handler (p_in, p_out, red_band,
  1021   1001   							  red_handling);
  1022   1002   			    p_out =
  1023   1003   				mono_uint8_pixel_handler (p_in, p_out,
  1024   1004   							  green_band,
  1025   1005   							  green_handling);
  1026   1006   			    p_out =
  1027   1007   				mono_uint8_pixel_handler (p_in, p_out,
................................................................................
  1040   1020   }
  1041   1021   
  1042   1022   static void
  1043   1023   copy_uint8_raw_mono_pixels (const unsigned char *buffer,
  1044   1024   			    const unsigned char *mask, unsigned char *outbuf,
  1045   1025   			    unsigned short width, unsigned short height,
  1046   1026   			    unsigned char out_num_bands,
  1047         -			    unsigned char num_bands, double x_res,
  1048         -			    double y_res, double minx, double maxy,
  1049         -			    double tile_minx, double tile_maxy,
  1050         -			    unsigned short tile_width,
         1027  +			    unsigned char num_bands, double x_res, double y_res,
         1028  +			    double minx, double maxy, double tile_minx,
         1029  +			    double tile_maxy, unsigned short tile_width,
  1051   1030   			    unsigned short tile_height, rl2PixelPtr no_data,
  1052   1031   			    unsigned char mono_band,
  1053   1032   			    rl2BandHandlingPtr mono_handling)
  1054   1033   {
  1055   1034   /* copying UINT8 raw pixels from the DBMS tile into the output image */
  1056   1035       int x;
  1057   1036       int y;
................................................................................
  1414   1393   		  }
  1415   1394   		p_in++;
  1416   1395   	    }
  1417   1396         }
  1418   1397   }
  1419   1398   
  1420   1399   static void
  1421         -copy_uint16_raw_pixels (const unsigned short *buffer,
  1422         -			const unsigned char *mask, unsigned short *outbuf,
  1423         -			unsigned short width, unsigned short height,
  1424         -			unsigned char num_bands, double x_res, double y_res,
  1425         -			double minx, double maxy, double tile_minx,
  1426         -			double tile_maxy, unsigned short tile_width,
  1427         -			unsigned short tile_height, rl2PixelPtr no_data)
         1400  +copy_uint16_raw_pixels (const unsigned short *buffer, const unsigned char *mask,
         1401  +			unsigned short *outbuf, unsigned short width,
         1402  +			unsigned short height, unsigned char num_bands,
         1403  +			double x_res, double y_res, double minx, double maxy,
         1404  +			double tile_minx, double tile_maxy,
         1405  +			unsigned short tile_width, unsigned short tile_height,
         1406  +			rl2PixelPtr no_data)
  1428   1407   {
  1429   1408   /* copying UINT16 raw pixels from the DBMS tile into the output image */
  1430   1409       int x;
  1431   1410       int y;
  1432   1411       int b;
  1433   1412       int out_x;
  1434   1413       int out_y;
................................................................................
  1551   1530       return apply_contrast_enhancement ((double) mono, p_out, mono_handling);
  1552   1531   }
  1553   1532   
  1554   1533   static void
  1555   1534   copy_uint16_raw_selected_pixels (const unsigned short *buffer,
  1556   1535   				 const unsigned char *mask,
  1557   1536   				 unsigned char *outbuf, unsigned short width,
  1558         -				 unsigned short height,
  1559         -				 unsigned char num_bands, double x_res,
  1560         -				 double y_res, double minx, double maxy,
  1561         -				 double tile_minx, double tile_maxy,
  1562         -				 unsigned short tile_width,
         1537  +				 unsigned short height, unsigned char num_bands,
         1538  +				 double x_res, double y_res, double minx,
         1539  +				 double maxy, double tile_minx,
         1540  +				 double tile_maxy, unsigned short tile_width,
  1563   1541   				 unsigned short tile_height,
  1564   1542   				 rl2PixelPtr no_data, unsigned char red_band,
  1565   1543   				 unsigned char green_band,
  1566   1544   				 unsigned char blue_band,
  1567   1545   				 rl2BandHandlingPtr red_handling,
  1568   1546   				 rl2BandHandlingPtr green_handling,
  1569   1547   				 rl2BandHandlingPtr blue_handling)
................................................................................
  3097   3075   		if (style->contrastEnhancement ==
  3098   3076   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3099   3077   		  {
  3100   3078   		      r = malloc (sizeof (rl2BandHandling));
  3101   3079   		      r->colorMap = NULL;
  3102   3080   		      r->contrastEnhancement =
  3103   3081   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3104         -		      compute_stretching (band, &(r->minValue),
  3105         -					  &(r->maxValue), &(r->scaleFactor));
         3082  +		      compute_stretching (band, &(r->minValue), &(r->maxValue),
         3083  +					  &(r->scaleFactor));
  3106   3084   		  }
  3107   3085   		else if (style->contrastEnhancement ==
  3108   3086   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3109   3087   		  {
  3110   3088   		      r = malloc (sizeof (rl2BandHandling));
  3111   3089   		      r->colorMap = NULL;
  3112   3090   		      r->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3183   3161   		if (style->contrastEnhancement ==
  3184   3162   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3185   3163   		  {
  3186   3164   		      g = malloc (sizeof (rl2BandHandling));
  3187   3165   		      g->colorMap = NULL;
  3188   3166   		      g->contrastEnhancement =
  3189   3167   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3190         -		      compute_stretching (band, &(g->minValue),
  3191         -					  &(g->maxValue), &(g->scaleFactor));
         3168  +		      compute_stretching (band, &(g->minValue), &(g->maxValue),
         3169  +					  &(g->scaleFactor));
  3192   3170   		  }
  3193   3171   		else if (style->contrastEnhancement ==
  3194   3172   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3195   3173   		  {
  3196   3174   		      g = malloc (sizeof (rl2BandHandling));
  3197   3175   		      g->colorMap = NULL;
  3198   3176   		      g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3269   3247   		if (style->contrastEnhancement ==
  3270   3248   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3271   3249   		  {
  3272   3250   		      b = malloc (sizeof (rl2BandHandling));
  3273   3251   		      b->colorMap = NULL;
  3274   3252   		      b->contrastEnhancement =
  3275   3253   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3276         -		      compute_stretching (band, &(b->minValue),
  3277         -					  &(b->maxValue), &(b->scaleFactor));
         3254  +		      compute_stretching (band, &(b->minValue), &(b->maxValue),
         3255  +					  &(b->scaleFactor));
  3278   3256   		  }
  3279   3257   		else if (style->contrastEnhancement ==
  3280   3258   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3281   3259   		  {
  3282   3260   		      b = malloc (sizeof (rl2BandHandling));
  3283   3261   		      b->colorMap = NULL;
  3284   3262   		      b->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3621   3599   		if (style->contrastEnhancement ==
  3622   3600   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3623   3601   		  {
  3624   3602   		      g = malloc (sizeof (rl2BandHandling));
  3625   3603   		      g->colorMap = NULL;
  3626   3604   		      g->contrastEnhancement =
  3627   3605   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3628         -		      compute_stretching (band, &(g->minValue),
  3629         -					  &(g->maxValue), &(g->scaleFactor));
         3606  +		      compute_stretching (band, &(g->minValue), &(g->maxValue),
         3607  +					  &(g->scaleFactor));
  3630   3608   		  }
  3631   3609   		else if (style->contrastEnhancement ==
  3632   3610   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3633   3611   		  {
  3634   3612   		      g = malloc (sizeof (rl2BandHandling));
  3635   3613   		      g->colorMap = NULL;
  3636   3614   		      g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3915   3893   }
  3916   3894   
  3917   3895   static int
  3918   3896   do_copy_raw_selected_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf,
  3919   3897   			     unsigned int width, unsigned int height,
  3920   3898   			     double x_res, double y_res, double minx,
  3921   3899   			     double maxy, double tile_minx, double tile_maxy,
  3922         -			     unsigned int tile_width,
  3923         -			     unsigned int tile_height, rl2PixelPtr no_data,
  3924         -			     unsigned char red_band, unsigned char green_band,
  3925         -			     unsigned char blue_band,
         3900  +			     unsigned int tile_width, unsigned int tile_height,
         3901  +			     rl2PixelPtr no_data, unsigned char red_band,
         3902  +			     unsigned char green_band, unsigned char blue_band,
  3926   3903   			     rl2BandHandlingPtr red_handling,
  3927   3904   			     rl2BandHandlingPtr green_handling,
  3928   3905   			     rl2BandHandlingPtr blue_handling)
  3929   3906   {
  3930   3907       switch (rst->sampleType)
  3931   3908         {
  3932   3909         case RL2_SAMPLE_UINT8:
................................................................................
  4180   4157         };
  4181   4158       return 0;
  4182   4159   }
  4183   4160   
  4184   4161   static int
  4185   4162   do_copy_raw_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf,
  4186   4163   		    unsigned int width, unsigned int height,
  4187         -		    unsigned char raster_type, unsigned char sample_type,
  4188         -		    unsigned char num_bands, double x_res, double y_res,
  4189         -		    double minx, double maxy, double tile_minx,
  4190         -		    double tile_maxy, unsigned int tile_width,
         4164  +		    unsigned char sample_type, unsigned char num_bands,
         4165  +		    double x_res, double y_res, double minx, double maxy,
         4166  +		    double tile_minx, double tile_maxy, unsigned int tile_width,
  4191   4167   		    unsigned int tile_height, rl2PixelPtr no_data)
  4192   4168   {
         4169  +
         4170  +
  4193   4171       switch (sample_type)
  4194   4172         {
  4195   4173         case RL2_SAMPLE_INT8:
  4196   4174   	  copy_int8_raw_pixels ((const char *) (rst->rasterBuffer),
  4197   4175   				(const unsigned char *) (rst->maskBuffer),
  4198   4176   				(char *) outbuf, width, height,
  4199   4177   				x_res, y_res, minx, maxy, tile_minx,
................................................................................
  4203   4181   	  copy_int16_raw_pixels ((const short *) (rst->rasterBuffer),
  4204   4182   				 (const unsigned char *) (rst->maskBuffer),
  4205   4183   				 (short *) outbuf, width, height,
  4206   4184   				 x_res, y_res, minx, maxy, tile_minx,
  4207   4185   				 tile_maxy, tile_width, tile_height, no_data);
  4208   4186   	  return 1;
  4209   4187         case RL2_SAMPLE_UINT16:
  4210         -	  copy_uint16_raw_pixels ((const unsigned short
  4211         -				   *) (rst->rasterBuffer),
         4188  +	  copy_uint16_raw_pixels ((const unsigned short *) (rst->rasterBuffer),
  4212   4189   				  (const unsigned char *) (rst->maskBuffer),
  4213   4190   				  (unsigned short *) outbuf, width, height,
  4214   4191   				  num_bands, x_res, y_res, minx, maxy,
  4215   4192   				  tile_minx, tile_maxy, tile_width,
  4216   4193   				  tile_height, no_data);
  4217   4194   	  return 1;
  4218   4195         case RL2_SAMPLE_INT32:
................................................................................
  4245   4222   				  tile_minx, tile_maxy, tile_width,
  4246   4223   				  tile_height, no_data);
  4247   4224   	  return 1;
  4248   4225         default:
  4249   4226   	  copy_uint8_raw_pixels ((const unsigned char *) (rst->rasterBuffer),
  4250   4227   				 (const unsigned char *) (rst->maskBuffer),
  4251   4228   				 (unsigned char *) outbuf, width, height,
  4252         -				 num_bands, x_res, y_res, minx, maxy,
  4253         -				 tile_minx, tile_maxy, tile_width,
  4254         -				 tile_height, no_data, raster_type);
         4229  +				 num_bands, x_res, y_res, minx, maxy, tile_minx,
         4230  +				 tile_maxy, tile_width, tile_height, no_data);
  4255   4231   	  return 1;
  4256   4232         };
  4257   4233       return 0;
  4258   4234   }
  4259   4235   
  4260   4236   RL2_PRIVATE int
  4261   4237   rl2_copy_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf,
  4262   4238   		     unsigned int width,
  4263   4239   		     unsigned int height, unsigned char sample_type,
  4264   4240   		     unsigned char num_bands, unsigned char auto_ndvi,
  4265         -		     unsigned char red_band_index,
  4266         -		     unsigned char nir_band_index, double x_res, double y_res,
  4267         -		     double minx, double maxy, double tile_minx,
  4268         -		     double tile_maxy, rl2PixelPtr no_data,
         4241  +		     unsigned char red_band_index, unsigned char nir_band_index,
         4242  +		     double x_res, double y_res, double minx, double maxy,
         4243  +		     double tile_minx, double tile_maxy, rl2PixelPtr no_data,
  4269   4244   		     rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats)
  4270   4245   {
  4271   4246   /* copying raw pixels into the output buffer */
  4272   4247       unsigned int tile_width;
  4273   4248       unsigned int tile_height;
  4274   4249       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
  4275   4250   
................................................................................
  4277   4252   	return 0;
  4278   4253       if (style != NULL && stats != NULL)
  4279   4254         {
  4280   4255   	  /* attempting to apply a RasterSymbolizer */
  4281   4256   	  int yes_no;
  4282   4257   	  int categorize;
  4283   4258   	  int interpolate;
  4284         -	  if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no)
  4285         -	      == RL2_OK)
         4259  +	  if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no) ==
         4260  +	      RL2_OK)
  4286   4261   	    {
  4287   4262   		if ((rst->sampleType == RL2_SAMPLE_UINT8
  4288   4263   		     || rst->sampleType == RL2_SAMPLE_UINT16)
  4289   4264   		    && (rst->pixelType == RL2_PIXEL_RGB
  4290   4265   			|| rst->pixelType == RL2_PIXEL_MULTIBAND) && yes_no)
  4291   4266   		  {
  4292   4267   		      /* triple band selection - false color RGB */
................................................................................
  4312   4287   						  blue_band, &red_handling,
  4313   4288   						  &green_handling,
  4314   4289   						  &blue_handling);
  4315   4290   		      if (red_handling == NULL || green_handling == NULL
  4316   4291   			  || blue_handling == NULL)
  4317   4292   			  return 0;
  4318   4293   		      if (do_copy_raw_selected_pixels
  4319         -			  (rst, outbuf, width, height, x_res, y_res, minx,
  4320         -			   maxy, tile_minx, tile_maxy, tile_width,
  4321         -			   tile_height, no_data, red_band, green_band,
  4322         -			   blue_band, red_handling, green_handling,
  4323         -			   blue_handling))
         4294  +			  (rst, outbuf, width, height, x_res, y_res, minx, maxy,
         4295  +			   tile_minx, tile_maxy, tile_width, tile_height,
         4296  +			   no_data, red_band, green_band, blue_band,
         4297  +			   red_handling, green_handling, blue_handling))
  4324   4298   			  return 1;
  4325   4299   		      if (red_handling != NULL)
  4326   4300   			  free (red_handling);
  4327   4301   		      if (green_handling != NULL)
  4328   4302   			  free (green_handling);
  4329   4303   		      if (blue_handling != NULL)
  4330   4304   			  free (blue_handling);
................................................................................
  4342   4316   		      /* applying Auto NDVI */
  4343   4317   		      rl2BandHandlingPtr ndvi_handling = NULL;
  4344   4318   		      build_ndvi_handling ((rl2PrivRasterSymbolizerPtr)
  4345   4319   					   style, &ndvi_handling);
  4346   4320   		      if (ndvi_handling == NULL)
  4347   4321   			  return 0;
  4348   4322   		      if (do_auto_ndvi_pixels
  4349         -			  (rst, outbuf, width, height, num_bands, x_res,
  4350         -			   y_res, minx, maxy, tile_minx, tile_maxy,
  4351         -			   tile_width, tile_height, no_data, red_band_index,
  4352         -			   nir_band_index, ndvi_handling))
         4323  +			  (rst, outbuf, width, height, num_bands, x_res, y_res,
         4324  +			   minx, maxy, tile_minx, tile_maxy, tile_width,
         4325  +			   tile_height, no_data, red_band_index, nir_band_index,
         4326  +			   ndvi_handling))
  4353   4327   			  return 1;
  4354   4328   		      if (ndvi_handling != NULL)
  4355   4329   			  destroy_ndvi_handling (ndvi_handling);
  4356   4330   		  }
  4357   4331   		if (((rst->sampleType == RL2_SAMPLE_UINT8
  4358   4332   		      || rst->sampleType == RL2_SAMPLE_UINT16)
  4359   4333   		     || rst->pixelType == RL2_PIXEL_DATAGRID) && yes_no)
................................................................................
  4370   4344   						style,
  4371   4345   						(rl2PrivRasterStatisticsPtr)
  4372   4346   						stats, mono_band,
  4373   4347   						&mono_handling);
  4374   4348   		      if (mono_handling == NULL)
  4375   4349   			  return 0;
  4376   4350   		      if (do_copy_raw_mono_pixels
  4377         -			  (rst, outbuf, width, height, num_bands, x_res,
  4378         -			   y_res, minx, maxy, tile_minx, tile_maxy,
  4379         -			   tile_width, tile_height, no_data, mono_band,
  4380         -			   mono_handling))
         4351  +			  (rst, outbuf, width, height, num_bands, x_res, y_res,
         4352  +			   minx, maxy, tile_minx, tile_maxy, tile_width,
         4353  +			   tile_height, no_data, mono_band, mono_handling))
  4381   4354   			  return 1;
  4382   4355   		      if (mono_handling != NULL)
  4383   4356   			  destroy_mono_handling (mono_handling);
  4384   4357   		  }
  4385   4358   	    }
  4386   4359         }
  4387   4360   
  4388   4361       if (do_copy_raw_pixels
  4389         -	(rst, outbuf, width, height, rst->sampleType, sample_type, num_bands,
  4390         -	 x_res, y_res, minx, maxy, tile_minx, tile_maxy, tile_width,
  4391         -	 tile_height, no_data))
         4362  +	(rst, outbuf, width, height, sample_type, num_bands, x_res, y_res, minx,
         4363  +	 maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data))
  4392   4364   	return 1;
  4393   4365   
  4394   4366       return 0;
  4395   4367   }
  4396   4368   
  4397         -static void
  4398         -do_copy_raw_mask (rl2PrivRasterPtr rst, unsigned char *maskbuf,
  4399         -		  unsigned int width, unsigned int height, double x_res,
  4400         -		  double y_res, double minx, double maxy, double tile_minx,
  4401         -		  double tile_maxy, unsigned int tile_width,
  4402         -		  unsigned int tile_height)
  4403         -{
  4404         -/* copying mask pixels from the DBMS tile into the output mask */
  4405         -    unsigned int x;
  4406         -    unsigned int y;
  4407         -    int out_x;
  4408         -    int out_y;
  4409         -    double geo_x;
  4410         -    double geo_y;
  4411         -    const unsigned char *p_in = rst->maskBuffer;
  4412         -    unsigned char *p_out;
  4413         -    double y_res2 = y_res / 2.0;
  4414         -    double x_res2 = x_res / 2.0;
  4415         -
  4416         -    geo_y = tile_maxy + y_res2;
  4417         -    for (y = 0; y < tile_height; y++)
  4418         -      {
  4419         -	  geo_y -= y_res;
  4420         -	  out_y = (maxy - geo_y) / y_res;
  4421         -	  if (out_y < 0 || out_y >= (int) height)
  4422         -	    {
  4423         -		p_in += tile_width;
  4424         -		continue;
  4425         -	    }
  4426         -	  geo_x = tile_minx - x_res2;
  4427         -	  for (x = 0; x < tile_width; x++)
  4428         -	    {
  4429         -		geo_x += x_res;
  4430         -		out_x = (geo_x - minx) / x_res;
  4431         -		if (out_x < 0 || out_x >= (int) width)
  4432         -		  {
  4433         -		      p_in++;
  4434         -		      continue;
  4435         -		  }
  4436         -		p_out = maskbuf + (out_y * width) + out_x;
  4437         -		if (*p_in++ == 0)
  4438         -		    *p_out++ = 255;
  4439         -	    }
  4440         -      }
  4441         -}
  4442         -
  4443         -RL2_PRIVATE int
  4444         -rl2_copy_raw_mask (rl2RasterPtr raster, unsigned char *maskbuf,
  4445         -		   unsigned int width,
  4446         -		   unsigned int height, double x_res, double y_res,
  4447         -		   double minx, double maxy, double tile_minx, double tile_maxy)
  4448         -{
  4449         -/* copying a raw transparency mask into the output buffer */
  4450         -    unsigned int tile_width;
  4451         -    unsigned int tile_height;
  4452         -    rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
  4453         -
  4454         -    if (rl2_get_raster_size (raster, &tile_width, &tile_height) != RL2_OK)
  4455         -	return 0;
  4456         -
  4457         -    if (rst->maskBuffer == NULL)
  4458         -      {
  4459         -	  /* tile without mask - ok */
  4460         -	  return 1;
  4461         -      }
  4462         -    do_copy_raw_mask (rst, maskbuf, width, height, x_res, y_res, minx, maxy,
  4463         -		      tile_minx, tile_maxy, tile_width, tile_height);
  4464         -    return 1;
  4465         -}
  4466         -
  4467   4369   static void
  4468   4370   get_int8_ennuple (const char *rawbuf, unsigned short row, unsigned short col,
  4469   4371   		  unsigned short row_stride, rl2PixelPtr no_data,
  4470   4372   		  double ennuple[], int *has_no_data)
  4471   4373   {
  4472   4374   /* extracting a 3x3 "super-pixel" - INT8 */
  4473   4375       const char *p_in;
................................................................................
  4549   4451   	  /* checking for NoData values */
  4550   4452   	  if (ennuple[i] == nd_val)
  4551   4453   	      *has_no_data = 1;
  4552   4454         }
  4553   4455   }
  4554   4456   
  4555   4457   static void
  4556         -get_int16_ennuple (const short *rawbuf, unsigned short row,
  4557         -		   unsigned short col, unsigned short row_stride,
  4558         -		   rl2PixelPtr no_data, double ennuple[], int *has_no_data)
         4458  +get_int16_ennuple (const short *rawbuf, unsigned short row, unsigned short col,
         4459  +		   unsigned short row_stride, rl2PixelPtr no_data,
         4460  +		   double ennuple[], int *has_no_data)
  4559   4461   {
  4560   4462   /* extracting a 3x3 "super-pixel" - INT16 */
  4561   4463       const short *p_in;
  4562   4464       short nd_val = 0;
  4563   4465       int i;
  4564   4466   
  4565   4467       if (no_data != NULL)
................................................................................
  4725   4627   	  /* checking for NoData values */
  4726   4628   	  if (ennuple[i] == nd_val)
  4727   4629   	      *has_no_data = 1;
  4728   4630         }
  4729   4631   }
  4730   4632   
  4731   4633   static void
  4732         -get_float_ennuple (const float *rawbuf, unsigned short row,
  4733         -		   unsigned short col, unsigned short row_stride,
  4734         -		   rl2PixelPtr no_data, double ennuple[], int *has_no_data)
         4634  +get_float_ennuple (const float *rawbuf, unsigned short row, unsigned short col,
         4635  +		   unsigned short row_stride, rl2PixelPtr no_data,
         4636  +		   double ennuple[], int *has_no_data)
  4735   4637   {
  4736   4638   /* extracting a 3x3 "super-pixel" - FLOAT */
  4737   4639       const float *p_in;
  4738   4640       float nd_val = 0.0;
  4739   4641       int i;
  4740   4642   
  4741   4643       if (no_data != NULL)
................................................................................
  5035   4937   	      free (shadower->opaque_thread_id);
  5036   4938   	  shadower->opaque_thread_id = NULL;
  5037   4939         }
  5038   4940   }
  5039   4941   
  5040   4942   RL2_PRIVATE int
  5041   4943   rl2_build_shaded_relief_mask (sqlite3 * handle, int max_threads,
  5042         -			      rl2CoveragePtr cvg,
  5043         -			      int by_section, sqlite3_int64 section_id,
  5044         -			      double relief_factor, double scale_factor,
  5045         -			      unsigned int width, unsigned int height,
  5046         -			      double minx, double miny, double maxx,
  5047         -			      double maxy, double x_res, double y_res,
  5048         -			      float **shaded_relief, int *shaded_relief_sz)
         4944  +			      rl2CoveragePtr cvg, double relief_factor,
         4945  +			      double scale_factor, unsigned int width,
         4946  +			      unsigned int height, double minx, double miny,
         4947  +			      double maxx, double maxy, double x_res,
         4948  +			      double y_res, float **shaded_relief,
         4949  +			      int *shaded_relief_sz)
  5049   4950   {
  5050   4951   /* attempting to return a Shaded Relief mask from the DBMS Coverage */
  5051   4952       rl2PixelPtr no_data = NULL;
  5052   4953       const char *coverage;
  5053   4954       unsigned char level;
  5054   4955       unsigned char scale;
  5055   4956       double xx_res = x_res;
................................................................................
  5080   4981   
  5081   4982       if (cvg == NULL || handle == NULL)
  5082   4983   	goto error;
  5083   4984       coverage = rl2_get_coverage_name (cvg);
  5084   4985       if (coverage == NULL)
  5085   4986   	goto error;
  5086   4987       if (rl2_find_matching_resolution
  5087         -	(handle, cvg, by_section, section_id, &xx_res, &yy_res, &level,
  5088         -	 &scale) != RL2_OK)
         4988  +	(handle, cvg, 0, 0, &xx_res, &yy_res, &level, &scale) != RL2_OK)
  5089   4989   	goto error;
  5090   4990       if (rl2_get_coverage_type (cvg, &sample_type, &pixel_type, &num_bands) !=
  5091   4991   	RL2_OK)
  5092   4992   	goto error;
  5093   4993       if (pixel_type != RL2_PIXEL_DATAGRID && num_bands != 1)
  5094   4994   	goto error;
  5095   4995       no_data = rl2_get_coverage_no_data (cvg);
................................................................................
  5096   4996       if (no_data == NULL)
  5097   4997   	goto error;
  5098   4998   
  5099   4999   /* preparing the "tiles" SQL query */
  5100   5000       xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  5101   5001       xxtiles = rl2_double_quoted_sql (xtiles);
  5102   5002       sql =
  5103         -	sqlite3_mprintf
  5104         -	("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  5105         -	 "FROM \"%s\" " "WHERE pyramid_level = ? AND ROWID IN ( "
  5106         -	 "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
  5107         -	 "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles);
         5003  +	sqlite3_mprintf ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
         5004  +			 "FROM \"%s\" "
         5005  +			 "WHERE pyramid_level = ? AND ROWID IN ( "
         5006  +			 "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
         5007  +			 "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles,
         5008  +			 xtiles);
  5108   5009       sqlite3_free (xtiles);
  5109   5010       free (xxtiles);
  5110   5011       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL);
  5111   5012       sqlite3_free (sql);
  5112   5013       if (ret != SQLITE_OK)
  5113   5014         {
  5114   5015   	  printf ("SELECT shadedRelief tiles SQL error: %s\n",
................................................................................
  5211   5112   	  /* executing in a single thread */
  5212   5113   	  p_out = sr_mask;
  5213   5114   	  for (row = 0; row < height; row++)
  5214   5115   	    {
  5215   5116   		for (col = 0; col < width; col++)
  5216   5117   		    *p_out++ =
  5217   5118   			shaded_relief_value (relief_factor, scale_factor,
  5218         -					     altRadians, azRadians, rawbuf,
  5219         -					     row, col, row_stride,
  5220         -					     sample_type, no_data);
         5119  +					     altRadians, azRadians, rawbuf, row,
         5120  +					     col, row_stride, sample_type,
         5121  +					     no_data);
  5221   5122   	    }
  5222   5123         }
  5223   5124       else
  5224   5125         {
  5225   5126   	  /* executing as many concurrent threads */
  5226   5127   	  rl2AuxShadowerPtr aux = NULL;
  5227   5128   	  rl2AuxShadowerPtr shadower;

Changes to src/rl2raw.c.

   367    367   		  }
   368    368   		break;
   369    369   	    case RL2_PIXEL_GRAYSCALE:
   370    370   		grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8,
   371    371   				  &transpR, &transpG, &transpB);
   372    372   		break;
   373    373   	    case RL2_PIXEL_RGB:
   374         -		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   375         -					    RL2_RED_BAND, &transpR);
          374  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND,
          375  +					    &transpR);
   376    376   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   377    377   					    RL2_GREEN_BAND, &transpG);
   378    378   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   379    379   					    RL2_BLUE_BAND, &transpB);
   380    380   		break;
   381    381   	    };
   382    382         }
................................................................................
   601    601   		  }
   602    602   		break;
   603    603   	    case RL2_PIXEL_GRAYSCALE:
   604    604   		grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8,
   605    605   				  &transpR, &transpG, &transpB);
   606    606   		break;
   607    607   	    case RL2_PIXEL_RGB:
   608         -		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   609         -					    RL2_RED_BAND, &transpR);
          608  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND,
          609  +					    &transpR);
   610    610   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   611    611   					    RL2_GREEN_BAND, &transpG);
   612    612   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   613    613   					    RL2_BLUE_BAND, &transpB);
   614    614   		break;
   615    615   	    };
   616    616         }
................................................................................
   889    889   		  }
   890    890   		break;
   891    891   	    case RL2_PIXEL_GRAYSCALE:
   892    892   		grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8,
   893    893   				  &transpR, &transpG, &transpB);
   894    894   		break;
   895    895   	    case RL2_PIXEL_RGB:
   896         -		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   897         -					    RL2_RED_BAND, &transpR);
          896  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND,
          897  +					    &transpR);
   898    898   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   899    899   					    RL2_GREEN_BAND, &transpG);
   900    900   		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
   901    901   					    RL2_BLUE_BAND, &transpB);
   902    902   		break;
   903    903   	    };
   904    904         }
................................................................................
  1506   1506   
  1507   1507       *buffer = buf;
  1508   1508       *buf_size = sz;
  1509   1509       return RL2_OK;
  1510   1510   }
  1511   1511   
  1512   1512   RL2_DECLARE int
  1513         -rl2_raster_band_to_uint16 (rl2RasterPtr ptr, int band,
  1514         -			   unsigned short **buffer, int *buf_size)
         1513  +rl2_raster_band_to_uint16 (rl2RasterPtr ptr, int band, unsigned short **buffer,
         1514  +			   int *buf_size)
  1515   1515   {
  1516   1516   /* attempting to export Raster BAND data as a UINT-16 array */
  1517   1517       unsigned short *buf;
  1518   1518       int sz;
  1519   1519       unsigned int row;
  1520   1520       unsigned int col;
  1521   1521       int nBand;
................................................................................
  1971   1971   	    }
  1972   1972         }
  1973   1973   }
  1974   1974   
  1975   1975   RL2_PRIVATE unsigned char *
  1976   1976   rl2_copy_endian_raw_pixels (const unsigned char *pixels, int pixels_sz,
  1977   1977   			    unsigned int width, unsigned int height,
  1978         -			    unsigned char sample_type,
  1979         -			    unsigned char num_bands, int big_endian)
         1978  +			    unsigned char sample_type, unsigned char num_bands,
         1979  +			    int big_endian)
  1980   1980   {
  1981   1981   /* copying RAW pixels (in endian safe mode) */
  1982   1982       int sample_bytes = 0;
  1983   1983       int outsize = width * height * num_bands;
  1984   1984       unsigned char *outbuf = NULL;
  1985   1985   
  1986   1986       switch (sample_type)
................................................................................
  2022   2022   	  copy_endian_raw_u8 (outbuf, pixels, width, height, num_bands);
  2023   2023   	  break;
  2024   2024         case RL2_SAMPLE_INT8:
  2025   2025   	  copy_endian_raw_i8 ((char *) outbuf, (const char *) pixels, width,
  2026   2026   			      height, num_bands);
  2027   2027   	  break;
  2028   2028         case RL2_SAMPLE_INT16:
  2029         -	  copy_endian_raw_i16 ((short *) outbuf, (const short *) pixels,
  2030         -			       width, height, num_bands, big_endian);
         2029  +	  copy_endian_raw_i16 ((short *) outbuf, (const short *) pixels, width,
         2030  +			       height, num_bands, big_endian);
  2031   2031   	  break;
  2032   2032         case RL2_SAMPLE_UINT16:
  2033   2033   	  copy_endian_raw_u16 ((unsigned short *) outbuf,
  2034   2034   			       (const unsigned short *) pixels, width, height,
  2035   2035   			       num_bands, big_endian);
  2036   2036   	  break;
  2037   2037         case RL2_SAMPLE_INT32:
................................................................................
  2040   2040   	  break;
  2041   2041         case RL2_SAMPLE_UINT32:
  2042   2042   	  copy_endian_raw_u32 ((unsigned int *) outbuf,
  2043   2043   			       (const unsigned int *) pixels, width, height,
  2044   2044   			       num_bands, big_endian);
  2045   2045   	  break;
  2046   2046         case RL2_SAMPLE_FLOAT:
  2047         -	  copy_endian_raw_flt ((float *) outbuf, (const float *) pixels,
  2048         -			       width, height, num_bands, big_endian);
         2047  +	  copy_endian_raw_flt ((float *) outbuf, (const float *) pixels, width,
         2048  +			       height, num_bands, big_endian);
  2049   2049   	  break;
  2050   2050         case RL2_SAMPLE_DOUBLE:
  2051   2051   	  copy_endian_raw_dbl ((double *) outbuf, (const double *) pixels,
  2052   2052   			       width, height, num_bands, big_endian);
  2053   2053   	  break;
  2054   2054         };
  2055   2055       return outbuf;
................................................................................
  2065   2065   	&& coverage->nBands == raster->nBands)
  2066   2066   	return 1;
  2067   2067       fprintf (stderr, "Mismatching RAW pixels !!!\n");
  2068   2068       return 0;
  2069   2069   }
  2070   2070   
  2071   2071   static void
  2072         -copy_tile_raw_i8 (const char *in, unsigned int in_width,
  2073         -		  unsigned int in_height, unsigned int startRow,
  2074         -		  unsigned int startCol, char *out, unsigned int tileWidth,
  2075         -		  unsigned int tileHeight, unsigned char num_bands)
         2072  +copy_tile_raw_i8 (const char *in, unsigned int in_width, unsigned int in_height,
         2073  +		  unsigned int startRow, unsigned int startCol, char *out,
         2074  +		  unsigned int tileWidth, unsigned int tileHeight,
         2075  +		  unsigned char num_bands)
  2076   2076   {
  2077   2077   /* signed int8 */
  2078   2078       unsigned int x;
  2079   2079       unsigned int y;
  2080   2080       unsigned char b;
  2081   2081       for (y = 0; y < tileHeight; y++)
  2082   2082         {
................................................................................
  2187   2187   		for (b = 0; b < num_bands; b++)
  2188   2188   		    *p_out++ = *p_in++;
  2189   2189   	    }
  2190   2190         }
  2191   2191   }
  2192   2192   
  2193   2193   static void
  2194         -copy_tile_raw_i32 (const int *in, unsigned int in_width,
  2195         -		   unsigned int in_height, unsigned int startRow,
  2196         -		   unsigned int startCol, int *out, unsigned int tileWidth,
  2197         -		   unsigned int tileHeight, unsigned char num_bands)
         2194  +copy_tile_raw_i32 (const int *in, unsigned int in_width, unsigned int in_height,
         2195  +		   unsigned int startRow, unsigned int startCol, int *out,
         2196  +		   unsigned int tileWidth, unsigned int tileHeight,
         2197  +		   unsigned char num_bands)
  2198   2198   {
  2199   2199   /* signed int32 */
  2200   2200       unsigned int x;
  2201   2201       unsigned int y;
  2202   2202       unsigned char b;
  2203   2203       for (y = 0; y < tileHeight; y++)
  2204   2204         {
................................................................................
  2309   2309   		    *p_out++ = *p_in++;
  2310   2310   	    }
  2311   2311         }
  2312   2312   }
  2313   2313   
  2314   2314   static int
  2315   2315   build_tile_from_raw_pixels (rl2PrivRasterPtr origin, unsigned int tileWidth,
  2316         -			    unsigned int tileHeight,
  2317         -			    unsigned char sample_type,
         2316  +			    unsigned int tileHeight, unsigned char sample_type,
  2318   2317   			    unsigned char num_bands, unsigned int startRow,
  2319   2318   			    unsigned int startCol, rl2PixelPtr no_data,
  2320   2319   			    unsigned char **pixels, int *pixels_sz)
  2321   2320   {
  2322   2321   /* extracting a Tile from the RAW buffer */
  2323   2322       unsigned char *out;
  2324   2323       int outsz = tileWidth * tileHeight * num_bands;
................................................................................
  2350   2349         case RL2_SAMPLE_INT8:
  2351   2350   	  copy_tile_raw_i8 ((const char *) (origin->rasterBuffer),
  2352   2351   			    origin->width, origin->height, startRow, startCol,
  2353   2352   			    (char *) out, tileWidth, tileHeight, num_bands);
  2354   2353   	  break;
  2355   2354         case RL2_SAMPLE_INT16:
  2356   2355   	  copy_tile_raw_i16 ((const short *) (origin->rasterBuffer),
  2357         -			     origin->width, origin->height, startRow,
  2358         -			     startCol, (short *) out, tileWidth, tileHeight,
  2359         -			     num_bands);
         2356  +			     origin->width, origin->height, startRow, startCol,
         2357  +			     (short *) out, tileWidth, tileHeight, num_bands);
  2360   2358   	  break;
  2361   2359         case RL2_SAMPLE_UINT16:
  2362   2360   	  copy_tile_raw_u16 ((const unsigned short *) (origin->rasterBuffer),
  2363         -			     origin->width, origin->height, startRow,
  2364         -			     startCol, (unsigned short *) out, tileWidth,
  2365         -			     tileHeight, num_bands);
         2361  +			     origin->width, origin->height, startRow, startCol,
         2362  +			     (unsigned short *) out, tileWidth, tileHeight,
         2363  +			     num_bands);
  2366   2364   	  break;
  2367   2365         case RL2_SAMPLE_INT32:
  2368   2366   	  copy_tile_raw_i32 ((const int *) (origin->rasterBuffer),
  2369         -			     origin->width, origin->height, startRow,
  2370         -			     startCol, (int *) out, tileWidth, tileHeight,
  2371         -			     num_bands);
         2367  +			     origin->width, origin->height, startRow, startCol,
         2368  +			     (int *) out, tileWidth, tileHeight, num_bands);
  2372   2369   	  break;
  2373   2370         case RL2_SAMPLE_UINT32:
  2374   2371   	  copy_tile_raw_u32 ((const unsigned int *) (origin->rasterBuffer),
  2375         -			     origin->width, origin->height, startRow,
  2376         -			     startCol, (unsigned int *) out, tileWidth,
  2377         -			     tileHeight, num_bands);
         2372  +			     origin->width, origin->height, startRow, startCol,
         2373  +			     (unsigned int *) out, tileWidth, tileHeight,
         2374  +			     num_bands);
  2378   2375   	  break;
  2379   2376         case RL2_SAMPLE_FLOAT:
  2380   2377   	  copy_tile_raw_flt ((const float *) (origin->rasterBuffer),
  2381         -			     origin->width, origin->height, startRow,
  2382         -			     startCol, (float *) out, tileWidth, tileHeight,
  2383         -			     num_bands);
         2378  +			     origin->width, origin->height, startRow, startCol,
         2379  +			     (float *) out, tileWidth, tileHeight, num_bands);
  2384   2380   	  break;
  2385   2381         case RL2_SAMPLE_DOUBLE:
  2386   2382   	  copy_tile_raw_dbl ((const double *) (origin->rasterBuffer),
  2387         -			     origin->width, origin->height, startRow,
  2388         -			     startCol, (double *) out, tileWidth, tileHeight,
  2389         -			     num_bands);
         2383  +			     origin->width, origin->height, startRow, startCol,
         2384  +			     (double *) out, tileWidth, tileHeight, num_bands);
  2390   2385   	  break;
  2391   2386         default:
  2392   2387   	  copy_tile_raw_u8 ((const unsigned char *) (origin->rasterBuffer),
  2393   2388   			    origin->width, origin->height, startRow, startCol,
  2394   2389   			    (unsigned char *) out, tileWidth, tileHeight,
  2395   2390   			    num_bands);
  2396   2391   	  break;

Changes to src/rl2sql.c.

   657    657       else
   658    658         {
   659    659   	  blob_even = sqlite3_value_blob (argv[3]);
   660    660   	  blob_even_sz = sqlite3_value_bytes (argv[3]);
   661    661         }
   662    662   
   663    663       if (!get_coverage_defs
   664         -	(sqlite, coverage, &tile_width, &tile_height, &sample_type,
   665         -	 &pixel_type, &num_bands, &compression))
          664  +	(sqlite, coverage, &tile_width, &tile_height, &sample_type, &pixel_type,
          665  +	 &num_bands, &compression))
   666    666         {
   667    667   	  sqlite3_result_int (context, -1);
   668    668   	  return;
   669    669         }
   670    670       ret =
   671         -	rl2_is_valid_dbms_raster_tile (level, tile_width, tile_height,
   672         -				       blob_odd, blob_odd_sz, blob_even,
   673         -				       blob_even_sz, sample_type, pixel_type,
   674         -				       num_bands, compression);
          671  +	rl2_is_valid_dbms_raster_tile (level, tile_width, tile_height, blob_odd,
          672  +				       blob_odd_sz, blob_even, blob_even_sz,
          673  +				       sample_type, pixel_type, num_bands,
          674  +				       compression);
   675    675       if (ret == RL2_OK)
   676    676   	sqlite3_result_int (context, 1);
   677    677       else
   678    678   	sqlite3_result_int (context, 0);
   679    679   }
   680    680   
   681    681   static void
................................................................................
  1533   1533       if (pxl1 != NULL)
  1534   1534   	rl2_destroy_pixel (pxl1);
  1535   1535       if (pxl2 != NULL)
  1536   1536   	rl2_destroy_pixel (pxl2);
  1537   1537   }
  1538   1538   
  1539   1539   static void
  1540         -fnct_GetRasterStatistics_NoDataPixelsCount (sqlite3_context * context,
  1541         -					    int argc, sqlite3_value ** argv)
         1540  +fnct_GetRasterStatistics_NoDataPixelsCount (sqlite3_context * context, int argc,
         1541  +					    sqlite3_value ** argv)
  1542   1542   {
  1543   1543   /* SQL function:
  1544   1544   / GetRasterStatistics_NoDataPixelsCount(BLOBencoded statistics)
  1545   1545   /
  1546   1546   / will return the total count of NoData pixels
  1547   1547   / or NULL (INVALID ARGS)
  1548   1548   /
................................................................................
  1568   1568         }
  1569   1569       st = (rl2PrivRasterStatisticsPtr) stats;
  1570   1570       sqlite3_result_int64 (context, st->no_data);
  1571   1571       rl2_destroy_raster_statistics (stats);
  1572   1572   }
  1573   1573   
  1574   1574   static void
  1575         -fnct_GetRasterStatistics_ValidPixelsCount (sqlite3_context * context,
  1576         -					   int argc, sqlite3_value ** argv)
         1575  +fnct_GetRasterStatistics_ValidPixelsCount (sqlite3_context * context, int argc,
         1576  +					   sqlite3_value ** argv)
  1577   1577   {
  1578   1578   /* SQL function:
  1579   1579   / GetRasterStatistics_ValidPixelsCount(BLOBencoded statistics)
  1580   1580   /
  1581   1581   / will return the total count of valid pixels
  1582   1582   / or NULL (INVALID ARGS)
  1583   1583   /
................................................................................
  3883   3883   	  return;
  3884   3884         }
  3885   3885       if (rl2_get_coverage_srid (coverage, &srid) != RL2_OK)
  3886   3886         {
  3887   3887   	  sqlite3_result_int (context, -1);
  3888   3888   	  return;
  3889   3889         }
  3890         -    if (rl2_get_coverage_type
  3891         -	(coverage, &sample_type, &pixel_type, &num_bands) != RL2_OK)
         3890  +    if (rl2_get_coverage_type (coverage, &sample_type, &pixel_type, &num_bands)
         3891  +	!= RL2_OK)
  3892   3892         {
  3893   3893   	  sqlite3_result_int (context, -1);
  3894   3894   	  return;
  3895   3895         }
  3896   3896       no_data = rl2_get_coverage_no_data (coverage);
  3897   3897       if (rl2_get_coverage_compression (coverage, &compression, &quality)
  3898   3898   	!= RL2_OK)
................................................................................
  4047   4047       cvg = (rl2PrivCoveragePtr) coverage;
  4048   4048       for (y = maxy; y > miny; y -= tileh)
  4049   4049         {
  4050   4050   	  for (x = minx; x < maxx; x += tilew)
  4051   4051   	    {
  4052   4052   		char *err_msg = NULL;
  4053   4053   		unsigned char *rgba_tile =
  4054         -		    do_wms_GetMap_get (NULL, url, proxy, wms_version,
  4055         -				       wms_layer,
         4054  +		    do_wms_GetMap_get (NULL, url, proxy, wms_version, wms_layer,
  4056   4055   				       wms_crs, swap_xy, x, y - tileh,
  4057   4056   				       x + tilew, y, tile_width, tile_height,
  4058   4057   				       wms_style, wms_format, opaque, 0,
  4059   4058   				       &err_msg);
  4060   4059   		if (rgba_tile == NULL)
  4061   4060   		  {
  4062   4061   		      add_retry (retry_list, x, y - tileh, x + tilew, y);
................................................................................
  4110   4109   		if (retry->done)
  4111   4110   		  {
  4112   4111   		      retry = retry->next;
  4113   4112   		      continue;
  4114   4113   		  }
  4115   4114   		retry->count += 1;
  4116   4115   		rgba_tile =
  4117         -		    do_wms_GetMap_get (NULL, url, proxy, wms_version,
  4118         -				       wms_layer, wms_crs, swap_xy,
  4119         -				       retry->minx, retry->miny, retry->maxx,
  4120         -				       retry->maxy, tile_width, tile_height,
  4121         -				       wms_style, wms_format, opaque, 0,
  4122         -				       &err_msg);
         4116  +		    do_wms_GetMap_get (NULL, url, proxy, wms_version, wms_layer,
         4117  +				       wms_crs, swap_xy, retry->minx,
         4118  +				       retry->miny, retry->maxx, retry->maxy,
         4119  +				       tile_width, tile_height, wms_style,
         4120  +				       wms_format, opaque, 0, &err_msg);
  4123   4121   		if (rgba_tile == NULL)
  4124   4122   		  {
  4125   4123   		      retry = retry->next;
  4126   4124   		      continue;
  4127   4125   		  }
  4128   4126   
  4129   4127   		params.sqlite = sqlite;
................................................................................
  4487   4485   	  double ext_x = (double) width * horz_res;
  4488   4486   	  double ext_y = (double) height * vert_res;
  4489   4487   	  minx = pt_x - ext_x / 2.0;
  4490   4488   	  maxx = minx + ext_x;
  4491   4489   	  miny = pt_y - ext_y / 2.0;
  4492   4490   	  maxy = miny + ext_y;
  4493   4491         }
  4494         -    else if (rl2_parse_bbox
  4495         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         4492  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         4493  +	     != RL2_OK)
  4496   4494         {
  4497   4495   	  errcode = -1;
  4498   4496   	  goto error;
  4499   4497         }
  4500   4498   
  4501   4499   /* attempting to load the Coverage definitions from the DBMS */
  4502   4500       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  4517   4515   						    height, compression,
  4518   4516   						    tile_sz, worldfile);
  4519   4517         }
  4520   4518       else
  4521   4519         {
  4522   4520   	  /* whole Coverage */
  4523   4521   	  ret =
  4524         -	      rl2_export_geotiff_from_dbms (sqlite, max_threads, path,
  4525         -					    coverage, horz_res, vert_res,
  4526         -					    minx, miny, maxx, maxy, width,
  4527         -					    height, compression, tile_sz,
  4528         -					    worldfile);
         4522  +	      rl2_export_geotiff_from_dbms (sqlite, max_threads, path, coverage,
         4523  +					    horz_res, vert_res, minx, miny,
         4524  +					    maxx, maxy, width, height,
         4525  +					    compression, tile_sz, worldfile);
  4529   4526         }
  4530   4527       if (ret != RL2_OK)
  4531   4528         {
  4532   4529   	  errcode = 0;
  4533   4530   	  goto error;
  4534   4531         }
  4535   4532       rl2_destroy_coverage (coverage);
................................................................................
  4867   4864   	  double ext_x = (double) width * horz_res;
  4868   4865   	  double ext_y = (double) height * vert_res;
  4869   4866   	  minx = pt_x - ext_x / 2.0;
  4870   4867   	  maxx = minx + ext_x;
  4871   4868   	  miny = pt_y - ext_y / 2.0;
  4872   4869   	  maxy = miny + ext_y;
  4873   4870         }
  4874         -    else if (rl2_parse_bbox
  4875         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         4871  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         4872  +	     != RL2_OK)
  4876   4873         {
  4877   4874   	  errcode = -1;
  4878   4875   	  goto error;
  4879   4876         }
  4880   4877   
  4881   4878   /* attempting to load the Coverage definitions from the DBMS */
  4882   4879       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  4890   4887         {
  4891   4888   	  /* single Section */
  4892   4889   	  ret =
  4893   4890   	      rl2_export_section_triple_band_geotiff_from_dbms (sqlite, path,
  4894   4891   								coverage,
  4895   4892   								section_id,
  4896   4893   								horz_res,
  4897         -								vert_res,
  4898         -								minx, miny,
  4899         -								maxx, maxy,
  4900         -								width, height,
         4894  +								vert_res, minx,
         4895  +								miny, maxx,
         4896  +								maxy, width,
         4897  +								height,
  4901   4898   								red_band,
  4902   4899   								green_band,
  4903   4900   								blue_band,
  4904   4901   								compression,
  4905   4902   								tile_sz,
  4906   4903   								worldfile);
  4907   4904         }
  4908   4905       else
  4909   4906         {
  4910   4907   	  /* whole Coverage */
  4911   4908   
  4912   4909   	  ret =
  4913         -	      rl2_export_triple_band_geotiff_from_dbms (sqlite, path,
  4914         -							coverage, horz_res,
  4915         -							vert_res, minx, miny,
  4916         -							maxx, maxy, width,
  4917         -							height, red_band,
         4910  +	      rl2_export_triple_band_geotiff_from_dbms (sqlite, path, coverage,
         4911  +							horz_res, vert_res,
         4912  +							minx, miny, maxx, maxy,
         4913  +							width, height, red_band,
  4918   4914   							green_band, blue_band,
  4919   4915   							compression, tile_sz,
  4920   4916   							worldfile);
  4921   4917         }
  4922   4918       if (ret != RL2_OK)
  4923   4919         {
  4924   4920   	  errcode = 0;
................................................................................
  5248   5244   	  double ext_x = (double) width * horz_res;
  5249   5245   	  double ext_y = (double) height * vert_res;
  5250   5246   	  minx = pt_x - ext_x / 2.0;
  5251   5247   	  maxx = minx + ext_x;
  5252   5248   	  miny = pt_y - ext_y / 2.0;
  5253   5249   	  maxy = miny + ext_y;
  5254   5250         }
  5255         -    else if (rl2_parse_bbox
  5256         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         5251  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         5252  +	     != RL2_OK)
  5257   5253         {
  5258   5254   	  errcode = -1;
  5259   5255   	  goto error;
  5260   5256         }
  5261   5257   
  5262   5258   /* attempting to load the Coverage definitions from the DBMS */
  5263   5259       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5272   5268   	  /* single Section */
  5273   5269   	  ret =
  5274   5270   	      rl2_export_section_mono_band_geotiff_from_dbms (sqlite, path,
  5275   5271   							      coverage,
  5276   5272   							      section_id,
  5277   5273   							      horz_res,
  5278   5274   							      vert_res, minx,
  5279         -							      miny, maxx,
  5280         -							      maxy, width,
  5281         -							      height,
         5275  +							      miny, maxx, maxy,
         5276  +							      width, height,
  5282   5277   							      mono_band,
  5283   5278   							      compression,
  5284   5279   							      tile_sz,
  5285   5280   							      worldfile);
  5286   5281         }
  5287   5282       else
  5288   5283         {
  5289   5284   	  /* whole Coverage */
  5290   5285   	  ret =
  5291   5286   	      rl2_export_mono_band_geotiff_from_dbms (sqlite, path, coverage,
  5292         -						      horz_res, vert_res,
  5293         -						      minx, miny, maxx, maxy,
  5294         -						      width, height,
  5295         -						      mono_band, compression,
  5296         -						      tile_sz, worldfile);
         5287  +						      horz_res, vert_res, minx,
         5288  +						      miny, maxx, maxy, width,
         5289  +						      height, mono_band,
         5290  +						      compression, tile_sz,
         5291  +						      worldfile);
  5297   5292         }
  5298   5293   
  5299   5294       if (ret != RL2_OK)
  5300   5295         {
  5301   5296   	  errcode = 0;
  5302   5297   	  goto error;
  5303   5298         }
................................................................................
  5603   5598   	  double ext_x = (double) width * horz_res;
  5604   5599   	  double ext_y = (double) height * vert_res;
  5605   5600   	  minx = pt_x - ext_x / 2.0;
  5606   5601   	  maxx = minx + ext_x;
  5607   5602   	  miny = pt_y - ext_y / 2.0;
  5608   5603   	  maxy = miny + ext_y;
  5609   5604         }
  5610         -    else if (rl2_parse_bbox
  5611         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         5605  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         5606  +	     != RL2_OK)
  5612   5607         {
  5613   5608   	  errcode = -1;
  5614   5609   	  goto error;
  5615   5610         }
  5616   5611   
  5617   5612   /* attempting to load the Coverage definitions from the DBMS */
  5618   5613       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5626   5621   	  /* only a single Section */
  5627   5622   	  if (with_worldfile)
  5628   5623   	    {
  5629   5624   		/* TIFF + Worldfile */
  5630   5625   		ret =
  5631   5626   		    rl2_export_section_tiff_worldfile_from_dbms (sqlite,
  5632   5627   								 max_threads,
  5633         -								 path,
  5634         -								 coverage,
         5628  +								 path, coverage,
  5635   5629   								 section_id,
  5636   5630   								 horz_res,
  5637         -								 vert_res,
  5638         -								 minx, miny,
  5639         -								 maxx, maxy,
  5640         -								 width,
         5631  +								 vert_res, minx,
         5632  +								 miny, maxx,
         5633  +								 maxy, width,
  5641   5634   								 height,
  5642   5635   								 compression,
  5643   5636   								 tile_sz);
  5644   5637   	    }
  5645   5638   	  else
  5646   5639   	    {
  5647   5640   		/* plain TIFF, no Worldfile */
................................................................................
  5661   5654   	  if (with_worldfile)
  5662   5655   	    {
  5663   5656   		/* TIFF + Worldfile */
  5664   5657   		ret =
  5665   5658   		    rl2_export_tiff_worldfile_from_dbms (sqlite, max_threads,
  5666   5659   							 path, coverage,
  5667   5660   							 horz_res, vert_res,
  5668         -							 minx, miny, maxx,
  5669         -							 maxy, width, height,
         5661  +							 minx, miny, maxx, maxy,
         5662  +							 width, height,
  5670   5663   							 compression, tile_sz);
  5671   5664   	    }
  5672   5665   	  else
  5673   5666   	    {
  5674   5667   		/* plain TIFF, no Worldfile */
  5675   5668   		ret =
  5676   5669   		    rl2_export_tiff_from_dbms (sqlite, max_threads, path,
................................................................................
  5976   5969   	  double ext_x = (double) width * horz_res;
  5977   5970   	  double ext_y = (double) height * vert_res;
  5978   5971   	  minx = pt_x - ext_x / 2.0;
  5979   5972   	  maxx = minx + ext_x;
  5980   5973   	  miny = pt_y - ext_y / 2.0;
  5981   5974   	  maxy = miny + ext_y;
  5982   5975         }
  5983         -    else if (rl2_parse_bbox
  5984         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         5976  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         5977  +	     != RL2_OK)
  5985   5978         {
  5986   5979   	  errcode = -1;
  5987   5980   	  goto error;
  5988   5981         }
  5989   5982   
  5990   5983   /* attempting to load the Coverage definitions from the DBMS */
  5991   5984       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5996   5989         }
  5997   5990   
  5998   5991       if (by_section)
  5999   5992         {
  6000   5993   	  /* single Section */
  6001   5994   	  ret =
  6002   5995   	      rl2_export_section_jpeg_from_dbms (sqlite, max_threads, path,
  6003         -						 coverage, section_id,
  6004         -						 horz_res, vert_res, minx,
  6005         -						 miny, maxx, maxy, width,
  6006         -						 height, quality,
         5996  +						 coverage, section_id, horz_res,
         5997  +						 vert_res, minx, miny, maxx,
         5998  +						 maxy, width, height, quality,
  6007   5999   						 with_worldfile);
  6008   6000         }
  6009   6001       else
  6010   6002         {
  6011   6003   	  /* whole Coverage */
  6012   6004   	  ret =
  6013   6005   	      rl2_export_jpeg_from_dbms (sqlite, max_threads, path, coverage,
................................................................................
  6374   6366   	  double ext_x = (double) width * horz_res;
  6375   6367   	  double ext_y = (double) height * vert_res;
  6376   6368   	  minx = pt_x - ext_x / 2.0;
  6377   6369   	  maxx = minx + ext_x;
  6378   6370   	  miny = pt_y - ext_y / 2.0;
  6379   6371   	  maxy = miny + ext_y;
  6380   6372         }
  6381         -    else if (rl2_parse_bbox
  6382         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         6373  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         6374  +	     != RL2_OK)
  6383   6375         {
  6384   6376   	  errcode = -1;
  6385   6377   	  goto error;
  6386   6378         }
  6387   6379   
  6388   6380   /* attempting to load the Coverage definitions from the DBMS */
  6389   6381       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  6405   6397   		     minx, miny, maxx, maxy, width, height, red_band,
  6406   6398   		     green_band, blue_band, compression, tile_sz);
  6407   6399   	    }
  6408   6400   	  else
  6409   6401   	    {
  6410   6402   		/* plain TIFF, no Worldfile */
  6411   6403   		ret =
  6412         -		    rl2_export_section_triple_band_tiff_from_dbms (sqlite,
  6413         -								   path,
         6404  +		    rl2_export_section_triple_band_tiff_from_dbms (sqlite, path,
  6414   6405   								   coverage,
  6415   6406   								   section_id,
  6416   6407   								   horz_res,
  6417   6408   								   vert_res,
  6418   6409   								   minx, miny,
  6419   6410   								   maxx, maxy,
  6420   6411   								   width,
................................................................................
  6434   6425   		/* TIFF + Worldfile */
  6435   6426   		ret =
  6436   6427   		    rl2_export_triple_band_tiff_worldfile_from_dbms (sqlite,
  6437   6428   								     path,
  6438   6429   								     coverage,
  6439   6430   								     horz_res,
  6440   6431   								     vert_res,
  6441         -								     minx,
  6442         -								     miny,
  6443         -								     maxx,
  6444         -								     maxy,
         6432  +								     minx, miny,
         6433  +								     maxx, maxy,
  6445   6434   								     width,
  6446   6435   								     height,
  6447   6436   								     red_band,
  6448   6437   								     green_band,
  6449   6438   								     blue_band,
  6450   6439   								     compression,
  6451   6440   								     tile_sz);
................................................................................
  6452   6441   	    }
  6453   6442   	  else
  6454   6443   	    {
  6455   6444   		/* plain TIFF, no Worldfile */
  6456   6445   		ret =
  6457   6446   		    rl2_export_triple_band_tiff_from_dbms (sqlite, path,
  6458   6447   							   coverage, horz_res,
  6459         -							   vert_res, minx,
  6460         -							   miny, maxx, maxy,
  6461         -							   width, height,
  6462         -							   red_band,
         6448  +							   vert_res, minx, miny,
         6449  +							   maxx, maxy, width,
         6450  +							   height, red_band,
  6463   6451   							   green_band,
  6464   6452   							   blue_band,
  6465   6453   							   compression,
  6466   6454   							   tile_sz);
  6467   6455   	    }
  6468   6456         }
  6469   6457       if (ret != RL2_OK)
................................................................................
  6827   6815   	  double ext_x = (double) width * horz_res;
  6828   6816   	  double ext_y = (double) height * vert_res;
  6829   6817   	  minx = pt_x - ext_x / 2.0;
  6830   6818   	  maxx = minx + ext_x;
  6831   6819   	  miny = pt_y - ext_y / 2.0;
  6832   6820   	  maxy = miny + ext_y;
  6833   6821         }
  6834         -    else if (rl2_parse_bbox
  6835         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         6822  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         6823  +	     != RL2_OK)
  6836   6824         {
  6837   6825   	  errcode = -1;
  6838   6826   	  goto error;
  6839   6827         }
  6840   6828   
  6841   6829   /* attempting to load the Coverage definitions from the DBMS */
  6842   6830       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  6862   6850   	    {
  6863   6851   		/* plain TIFF, no Worldfile */
  6864   6852   		ret =
  6865   6853   		    rl2_export_section_mono_band_tiff_from_dbms (sqlite, path,
  6866   6854   								 coverage,
  6867   6855   								 section_id,
  6868   6856   								 horz_res,
  6869         -								 vert_res,
  6870         -								 minx, miny,
  6871         -								 maxx, maxy,
  6872         -								 width,
         6857  +								 vert_res, minx,
         6858  +								 miny, maxx,
         6859  +								 maxy, width,
  6873   6860   								 height,
  6874   6861   								 mono_band,
  6875   6862   								 compression,
  6876   6863   								 tile_sz);
  6877   6864   	    }
  6878   6865         }
  6879   6866       else
  6880   6867         {
  6881   6868   	  /* whole Coverage */
  6882   6869   	  if (with_worldfile)
  6883   6870   	    {
  6884   6871   		/* TIFF + Worldfile */
  6885   6872   		ret =
  6886         -		    rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite,
  6887         -								   path,
         6873  +		    rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite, path,
  6888   6874   								   coverage,
  6889   6875   								   horz_res,
  6890   6876   								   vert_res,
  6891   6877   								   minx, miny,
  6892   6878   								   maxx, maxy,
  6893   6879   								   width,
  6894   6880   								   height,
................................................................................
  6896   6882   								   compression,
  6897   6883   								   tile_sz);
  6898   6884   	    }
  6899   6885   	  else
  6900   6886   	    {
  6901   6887   		/* plain TIFF, no Worldfile */
  6902   6888   		ret =
  6903         -		    rl2_export_mono_band_tiff_from_dbms (sqlite, path,
  6904         -							 coverage, horz_res,
  6905         -							 vert_res, minx, miny,
  6906         -							 maxx, maxy, width,
  6907         -							 height, mono_band,
  6908         -							 compression, tile_sz);
         6889  +		    rl2_export_mono_band_tiff_from_dbms (sqlite, path, coverage,
         6890  +							 horz_res, vert_res,
         6891  +							 minx, miny, maxx, maxy,
         6892  +							 width, height,
         6893  +							 mono_band, compression,
         6894  +							 tile_sz);
  6909   6895   	    }
  6910   6896         }
  6911   6897       if (ret != RL2_OK)
  6912   6898         {
  6913   6899   	  errcode = 0;
  6914   6900   	  goto error;
  6915   6901         }
................................................................................
  7202   7188   	  double ext_x = (double) width * resolution;
  7203   7189   	  double ext_y = (double) height * resolution;
  7204   7190   	  minx = pt_x - ext_x / 2.0;
  7205   7191   	  maxx = minx + ext_x;
  7206   7192   	  miny = pt_y - ext_y / 2.0;
  7207   7193   	  maxy = miny + ext_y;
  7208   7194         }
  7209         -    else if (rl2_parse_bbox
  7210         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         7195  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         7196  +	     != RL2_OK)
  7211   7197         {
  7212   7198   	  errcode = -1;
  7213   7199   	  goto error;
  7214   7200         }
  7215   7201   
  7216   7202   /* attempting to load the Coverage definitions from the DBMS */
  7217   7203       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  7234   7220   						       decimal_digits);
  7235   7221         }
  7236   7222       else
  7237   7223         {
  7238   7224   	  /* whole Coverage */
  7239   7225   	  ret =
  7240   7226   	      rl2_export_ascii_grid_from_dbms (sqlite, max_threads, path,
  7241         -					       coverage, resolution, minx,
  7242         -					       miny, maxx, maxy, width,
  7243         -					       height, is_centered,
  7244         -					       decimal_digits);
         7227  +					       coverage, resolution, minx, miny,
         7228  +					       maxx, maxy, width, height,
         7229  +					       is_centered, decimal_digits);
  7245   7230         }
  7246   7231       if (ret != RL2_OK)
  7247   7232         {
  7248   7233   	  errcode = 0;
  7249   7234   	  goto error;
  7250   7235         }
  7251   7236       rl2_destroy_coverage (coverage);
................................................................................
  7492   7477   	  double ext_x = (double) width * resolution;
  7493   7478   	  double ext_y = (double) height * resolution;
  7494   7479   	  minx = pt_x - ext_x / 2.0;
  7495   7480   	  maxx = minx + ext_x;
  7496   7481   	  miny = pt_y - ext_y / 2.0;
  7497   7482   	  maxy = miny + ext_y;
  7498   7483         }
  7499         -    else if (rl2_parse_bbox
  7500         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         7484  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         7485  +	     != RL2_OK)
  7501   7486         {
  7502   7487   	  errcode = -1;
  7503   7488   	  goto error;
  7504   7489         }
  7505   7490   
  7506   7491   /* attempting to load the Coverage definitions from the DBMS */
  7507   7492       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  7511   7496   	  return;
  7512   7497         }
  7513   7498   
  7514   7499       if (by_section)
  7515   7500         {
  7516   7501   	  /* single Section */
  7517   7502   	  ret =
  7518         -	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite,
  7519         -							    max_threads, path,
  7520         -							    coverage,
         7503  +	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite, max_threads,
         7504  +							    path, coverage,
  7521   7505   							    section_id,
  7522   7506   							    resolution, minx,
  7523   7507   							    miny, maxx, maxy,
  7524   7508   							    width, height,
  7525         -							    red_band,
  7526         -							    nir_band,
         7509  +							    red_band, nir_band,
  7527   7510   							    is_centered,
  7528   7511   							    decimal_digits);
  7529   7512         }
  7530   7513       else
  7531   7514         {
  7532   7515   	  /* whole Coverage */
  7533   7516   	  ret =
  7534   7517   	      rl2_export_ndvi_ascii_grid_from_dbms (sqlite, max_threads, path,
  7535         -						    coverage, resolution,
  7536         -						    minx, miny, maxx, maxy,
  7537         -						    width, height, red_band,
  7538         -						    nir_band, is_centered,
         7518  +						    coverage, resolution, minx,
         7519  +						    miny, maxx, maxy, width,
         7520  +						    height, red_band, nir_band,
         7521  +						    is_centered,
  7539   7522   						    decimal_digits);
  7540   7523         }
  7541   7524       if (ret != RL2_OK)
  7542   7525         {
  7543   7526   	  errcode = 0;
  7544   7527   	  goto error;
  7545   7528         }
................................................................................
  7597   7580   / will return 1 (TRUE, success) or 0 (FALSE, failure)
  7598   7581   / or -1 (INVALID ARGS)
  7599   7582   /
  7600   7583   */
  7601   7584       common_write_ndvi_ascii_grid (1, context, argc, argv);
  7602   7585   }
  7603   7586   
  7604         -static int
  7605         -test_geographic_srid (sqlite3 * handle, int srid)
  7606         -{
  7607         -/* testing if some SRID is of the Geographic type */
  7608         -    int ret;
  7609         -    int is_geographic = 0;
  7610         -    sqlite3_stmt *stmt = NULL;
  7611         -    const char *sql;
  7612         -
  7613         -    sql = "SELECT SridIsGeographic(?)";
  7614         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  7615         -    if (ret != SQLITE_OK)
  7616         -	return 0;
  7617         -
  7618         -    sqlite3_reset (stmt);
  7619         -    sqlite3_clear_bindings (stmt);
  7620         -    sqlite3_bind_int (stmt, 1, srid);
  7621         -    while (1)
  7622         -      {
  7623         -	  /* scrolling the result set rows */
  7624         -	  ret = sqlite3_step (stmt);
  7625         -	  if (ret == SQLITE_DONE)
  7626         -	      break;		/* end of result set */
  7627         -	  if (ret == SQLITE_ROW)
  7628         -	      is_geographic = sqlite3_column_int (stmt, 0);
  7629         -      }
  7630         -    sqlite3_finalize (stmt);
  7631         -    return is_geographic;
  7632         -}
  7633         -
  7634         -static double
  7635         -standard_scale (sqlite3 * handle, int srid, int width, int height,
  7636         -		double ext_x, double ext_y)
  7637         -{
  7638         -/* computing the standard (normalized) scale */
  7639         -    double linear_res;
  7640         -    double factor;
  7641         -    int is_geographic = test_geographic_srid (handle, srid);
  7642         -    if (is_geographic)
  7643         -      {
  7644         -	  /* geographic (long/lat) CRS */
  7645         -	  double metres = ext_x * (6378137.0 * 2.0 * 3.141592653589793) / 360.0;
  7646         -	  linear_res = metres / (double) width;
  7647         -      }
  7648         -    else
  7649         -      {
  7650         -	  /* planar (projected) CRS */
  7651         -	  double x_res = ext_x / (double) width;
  7652         -	  double y_res = ext_y / (double) height;
  7653         -	  linear_res = sqrt (x_res * y_res);
  7654         -      }
  7655         -    factor = linear_res / 0.000254;
  7656         -    return factor * (0.28 / 0.254);
  7657         -}
  7658         -
  7659   7587   static void
  7660   7588   fnct_GetMapImageFromRaster (sqlite3_context * context, int argc,
  7661   7589   			    sqlite3_value ** argv)
  7662   7590   {
  7663   7591   /* SQL function:
  7664   7592   / GetMapImageFromRaster(text coverage, BLOB geom, int width, int height)
  7665   7593   / GetMapImageFromRaster(text coverage, BLOB geom, int width, int height,
................................................................................
  7713   7641       double ext_y;
  7714   7642       double x_res;
  7715   7643       double y_res;
  7716   7644       int srid;
  7717   7645       int level_id;
  7718   7646       int scale;
  7719   7647       int xscale;
  7720         -    double map_scale;
  7721   7648       double xx_res;
  7722   7649       double yy_res;
  7723   7650       double aspect_org;
  7724   7651       double aspect_dst;
  7725   7652       int ok_style;
  7726   7653       int ok_format;
  7727   7654       unsigned char *outbuf = NULL;
................................................................................
  7863   7790   	  aux.reaspect = reaspect;
  7864   7791   	  rl2_aux_group_renderer (&aux);
  7865   7792   	  return;
  7866   7793         }
  7867   7794   
  7868   7795       x_res = ext_x / (double) width;
  7869   7796       y_res = ext_y / (double) height;
  7870         -    map_scale = standard_scale (sqlite, out_srid, width, height, ext_x, ext_y);
  7871   7797   /* validating the style */
  7872   7798       ok_style = 0;
  7873   7799       if (strcasecmp (style, "default") == 0)
  7874   7800   	ok_style = 1;
  7875   7801       else
  7876   7802         {
  7877   7803   	  /* attempting to get a Coverage Style */
  7878   7804   	  cvg_stl =
  7879   7805   	      rl2_create_coverage_style_from_dbms (sqlite, cvg_name, style);
  7880   7806   	  if (cvg_stl == NULL)
  7881   7807   	      goto error;
  7882         -	  symbolizer =
  7883         -	      rl2_get_symbolizer_from_coverage_style (cvg_stl, map_scale);
         7808  +	  symbolizer = rl2_get_symbolizer_from_coverage_style (cvg_stl, 1.0);
  7884   7809   	  if (symbolizer == NULL)
  7885         -	    {
  7886         -		/* invisible at the currect scale */
  7887         -		if (!rl2_aux_default_image
  7888         -		    (width, height, bg_red, bg_green, bg_blue, format_id,
  7889         -		     transparent, quality, &image, &image_size))
  7890         -		    goto error;
  7891         -		goto done;
  7892         -	    }
         7810  +	      goto error;
  7893   7811   	  stats = rl2_create_raster_statistics_from_dbms (sqlite, cvg_name);
  7894   7812   	  if (stats == NULL)
  7895   7813   	      goto error;
  7896   7814   	  ok_style = 1;
  7897   7815         }
  7898   7816       if (!ok_style)
  7899   7817   	goto error;
................................................................................
  8058   7976         }
  8059   7977       else
  8060   7978         {
  8061   7979   	  /* ordinary Coverage */
  8062   7980   	  by_section = 0;
  8063   7981   	  /* retrieving the optimal resolution level */
  8064   7982   	  if (!rl2_find_best_resolution_level
  8065         -	      (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale,
  8066         -	       &xscale, &xx_res, &yy_res))
         7983  +	      (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale, &xscale,
         7984  +	       &xx_res, &yy_res))
  8067   7985   	      goto error;
  8068   7986         }
  8069   7987       base_width = (int) (ext_x / xx_res);
  8070   7988       base_height = (int) (ext_y / yy_res);
  8071   7989       if ((base_width <= 0 && base_width >= USHRT_MAX)
  8072   7990   	|| (base_height <= 0 && base_height >= USHRT_MAX))
  8073   7991   	goto error;
................................................................................
  8178   8096       aux.symbolizer = symbolizer;
  8179   8097       aux.stats = stats;
  8180   8098       aux.outbuf = outbuf;
  8181   8099       aux.palette = palette;
  8182   8100       aux.out_pixel = out_pixel;
  8183   8101       if (!rl2_aux_render_image (&aux, &image, &image_size))
  8184   8102   	goto error;
  8185         -
  8186         -  done:
  8187   8103       sqlite3_result_blob (context, image, image_size, free);
  8188   8104       rl2_destroy_coverage (coverage);
  8189   8105       if (palette != NULL)
  8190   8106   	rl2_destroy_palette (palette);
  8191   8107       if (cvg_stl != NULL)
  8192   8108   	rl2_destroy_coverage_style (cvg_stl);
  8193   8109       if (stats != NULL)
................................................................................
  8201   8117   	rl2_destroy_palette (palette);
  8202   8118       if (cvg_stl != NULL)
  8203   8119   	rl2_destroy_coverage_style (cvg_stl);
  8204   8120       if (stats != NULL)
  8205   8121   	rl2_destroy_raster_statistics (stats);
  8206   8122       sqlite3_result_null (context);
  8207   8123   }
         8124  +
         8125  +static int
         8126  +test_geographic_srid (sqlite3 * handle, int srid)
         8127  +{
         8128  +/* testing if some SRID is of the Geographic type */
         8129  +    int ret;
         8130  +    int is_geographic = 0;
         8131  +    sqlite3_stmt *stmt = NULL;
         8132  +    const char *sql;
         8133  +
         8134  +    sql = "SELECT SridIsGeographic(?)";
         8135  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         8136  +    if (ret != SQLITE_OK)
         8137  +	return 0;
         8138  +
         8139  +    sqlite3_reset (stmt);
         8140  +    sqlite3_clear_bindings (stmt);
         8141  +    sqlite3_bind_int (stmt, 1, srid);
         8142  +    while (1)
         8143  +      {
         8144  +	  /* scrolling the result set rows */
         8145  +	  ret = sqlite3_step (stmt);
         8146  +	  if (ret == SQLITE_DONE)
         8147  +	      break;		/* end of result set */
         8148  +	  if (ret == SQLITE_ROW)
         8149  +	      is_geographic = sqlite3_column_int (stmt, 0);
         8150  +      }
         8151  +    sqlite3_finalize (stmt);
         8152  +    return is_geographic;
         8153  +}
         8154  +
         8155  +static double
         8156  +standard_scale (sqlite3 * handle, int srid, int width, int height, double ext_x,
         8157  +		double ext_y)
         8158  +{
         8159  +/* computing the standard (normalized) scale */
         8160  +    double linear_res;
         8161  +    double factor;
         8162  +    int is_geographic = test_geographic_srid (handle, srid);
         8163  +    if (is_geographic)
         8164  +      {
         8165  +	  /* geographic (long/lat) CRS */
         8166  +	  double metres = ext_x * (6378137.0 * 2.0 * 3.141592653589793) / 360.0;
         8167  +	  linear_res = metres / (double) width;
         8168  +      }
         8169  +    else
         8170  +      {
         8171  +	  /* planar (projected) CRS */
         8172  +	  double x_res = ext_x / (double) width;
         8173  +	  double y_res = ext_y / (double) height;
         8174  +	  linear_res = sqrt (x_res * y_res);
         8175  +      }
         8176  +    factor = linear_res / 0.000254;
         8177  +    return factor * (0.28 / 0.254);
         8178  +}
  8208   8179   
  8209   8180   static void
  8210   8181   fnct_GetMapImageFromVector (sqlite3_context * context, int argc,
  8211   8182   			    sqlite3_value ** argv)
  8212   8183   {
  8213   8184   /* SQL function:
  8214   8185   / GetMapImageFromVector(text coverage, BLOB geom, int width, int height)
................................................................................
  8248   8219       unsigned char bg_green;
  8249   8220       unsigned char bg_blue;
  8250   8221       int transparent = 0;
  8251   8222       int quality = 80;
  8252   8223       int reaspect = 0;
  8253   8224       sqlite3 *sqlite;
  8254   8225       sqlite3_stmt *stmt = NULL;
  8255         -    const void *data;
  8256   8226       double minx;
  8257   8227       double maxx;
  8258   8228       double miny;
  8259   8229       double maxy;
  8260   8230       double ext_x;
  8261   8231       double ext_y;
  8262   8232       double x_res;
................................................................................
  8330   8300       if (argc > 8)
  8331   8301   	quality = sqlite3_value_int (argv[8]);
  8332   8302       if (argc > 9)
  8333   8303   	reaspect = sqlite3_value_int (argv[9]);
  8334   8304   
  8335   8305   /* coarse args validation */
  8336   8306       sqlite = sqlite3_context_db_handle (context);
  8337         -    data = sqlite3_user_data (context);
  8338   8307       if (width < 64)
  8339   8308   	goto error;
  8340   8309       if (height < 64)
  8341   8310   	goto error;
  8342   8311   /* validating the format */
  8343   8312       ok_format = 0;
  8344   8313       if (strcmp (format, "image/png") == 0)
................................................................................
  8532   8501   			      {
  8533   8502   			      case SQLITE_INTEGER:
  8534   8503   				  rl2_set_variant_int (variant, i, col_name,
  8535   8504   						       sqlite3_column_int64
  8536   8505   						       (stmt, i + 1));
  8537   8506   				  break;
  8538   8507   			      case SQLITE_FLOAT:
  8539         -				  rl2_set_variant_double (variant, i,
  8540         -							  col_name,
         8508  +				  rl2_set_variant_double (variant, i, col_name,
  8541   8509   							  sqlite3_column_double
  8542   8510   							  (stmt, i + 1));
  8543   8511   				  break;
  8544   8512   			      case SQLITE_TEXT:
  8545   8513   				  rl2_set_variant_text (variant, i, col_name,
  8546   8514   							(const char *)
  8547   8515   							sqlite3_column_text
................................................................................
  8561   8529   				  break;
  8562   8530   			      };
  8563   8531   			}
  8564   8532   		  }
  8565   8533   		if (geom != NULL)
  8566   8534   		  {
  8567   8535   		      /* drawing a styled Feature */
  8568         -		      int scale_forbidden = 0;
         8536  +		      int scale_forbidden;
  8569   8537   		      symbolizer = NULL;
  8570   8538   		      if (lyr_stl != NULL)
  8571   8539   			  symbolizer =
  8572   8540   			      rl2_get_symbolizer_from_feature_type_style
  8573   8541   			      (lyr_stl, scale, variant, &scale_forbidden);
  8574   8542   		      if (!scale_forbidden)
  8575         -			  rl2_draw_vector_feature (ctx, sqlite, data,
  8576         -						   symbolizer, height, minx,
  8577         -						   miny, maxx, maxy, x_res,
         8543  +			  rl2_draw_vector_feature (ctx, sqlite, symbolizer,
         8544  +						   height, minx, miny, x_res,
  8578   8545   						   y_res, geom, variant);
  8579   8546   		      rl2_destroy_geometry (geom);
  8580   8547   		  }
  8581   8548   	    }
  8582   8549         }
  8583   8550       sqlite3_finalize (stmt);
  8584   8551   
................................................................................
  8838   8805   			    *p_rgba++ = 0;	/* transparent */
  8839   8806   			}
  8840   8807   		  }
  8841   8808   		switch (pixel_type)
  8842   8809   		  {
  8843   8810   		  case RL2_PIXEL_MONOCHROME:
  8844   8811   		      ret =
  8845         -			  get_rgba_from_monochrome_mask (width, height,
  8846         -							 buffer, mask,
  8847         -							 no_data, rgba);
         8812  +			  get_rgba_from_monochrome_mask (width, height, buffer,
         8813  +							 mask, no_data, rgba);
  8848   8814   		      buffer = NULL;
  8849   8815   		      mask = NULL;
  8850   8816   		      if (!ret)
  8851   8817   			  goto error;
  8852   8818   		      if (!build_rgb_alpha
  8853         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  8854         -			   bg_green, bg_blue))
         8819  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         8820  +			   bg_blue))
  8855   8821   			  goto error;
  8856   8822   		      free (rgba);
  8857   8823   		      rgba = NULL;
  8858   8824   		      if (transparent)
  8859   8825   			{
  8860   8826   			    if (!get_payload_from_gray_rgba_transparent
  8861   8827   				(width, height, rgb, alpha,
................................................................................
  8881   8847   						      mask, palette, no_data,
  8882   8848   						      rgba);
  8883   8849   		      buffer = NULL;
  8884   8850   		      mask = NULL;
  8885   8851   		      if (!ret)
  8886   8852   			  goto error;
  8887   8853   		      if (!build_rgb_alpha
  8888         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  8889         -			   bg_green, bg_blue))
         8854  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         8855  +			   bg_blue))
  8890   8856   			  goto error;
  8891   8857   		      free (rgba);
  8892   8858   		      rgba = NULL;
  8893   8859   		      if (transparent)
  8894   8860   			{
  8895   8861   			    if (!get_payload_from_rgb_rgba_transparent
  8896   8862   				(width, height, rgb, alpha,
................................................................................
  8915   8881   			  get_rgba_from_grayscale_mask (width, height, buffer,
  8916   8882   							mask, no_data, rgba);
  8917   8883   		      buffer = NULL;
  8918   8884   		      mask = NULL;
  8919   8885   		      if (!ret)
  8920   8886   			  goto error;
  8921   8887   		      if (!build_rgb_alpha
  8922         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  8923         -			   bg_green, bg_blue))
         8888  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         8889  +			   bg_blue))
  8924   8890   			  goto error;
  8925   8891   		      free (rgba);
  8926   8892   		      rgba = NULL;
  8927   8893   		      if (transparent)
  8928   8894   			{
  8929   8895   			    if (!get_payload_from_gray_rgba_transparent
  8930   8896   				(width, height, rgb, alpha,
................................................................................
  8950   8916   						       sample_type, buffer,
  8951   8917   						       mask, no_data, rgba);
  8952   8918   		      buffer = NULL;
  8953   8919   		      mask = NULL;
  8954   8920   		      if (!ret)
  8955   8921   			  goto error;
  8956   8922   		      if (!build_rgb_alpha
  8957         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  8958         -			   bg_green, bg_blue))
         8923  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         8924  +			   bg_blue))
  8959   8925   			  goto error;
  8960   8926   		      free (rgba);
  8961   8927   		      rgba = NULL;
  8962   8928   		      if (transparent)
  8963   8929   			{
  8964   8930   			    if (!get_payload_from_gray_rgba_transparent
  8965   8931   				(width, height, rgb, alpha,
................................................................................
  8979   8945   			}
  8980   8946   		      sqlite3_result_blob (context, image, image_size, free);
  8981   8947   		      break;
  8982   8948   		  case RL2_PIXEL_RGB:
  8983   8949   		      if (sample_type == RL2_SAMPLE_UINT16)
  8984   8950   			{
  8985   8951   			    ret =
  8986         -				get_rgba_from_multiband16 (width, height, 0,
  8987         -							   1, 2, 3,
         8952  +				get_rgba_from_multiband16 (width, height, 0, 1,
         8953  +							   2, 3,
  8988   8954   							   (unsigned short *)
  8989   8955   							   buffer, mask,
  8990   8956   							   no_data, rgba);
  8991   8957   			}
  8992   8958   		      else
  8993   8959   			{
  8994   8960   			    ret =
................................................................................
  8996   8962   							mask, no_data, rgba);
  8997   8963   			}
  8998   8964   		      buffer = NULL;
  8999   8965   		      mask = NULL;
  9000   8966   		      if (!ret)
  9001   8967   			  goto error;
  9002   8968   		      if (!build_rgb_alpha
  9003         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  9004         -			   bg_green, bg_blue))
         8969  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         8970  +			   bg_blue))
  9005   8971   			  goto error;
  9006   8972   		      free (rgba);
  9007   8973   		      rgba = NULL;
  9008   8974   		      if (transparent)
  9009   8975   			{
  9010   8976   			    if (!get_payload_from_rgb_rgba_transparent
  9011   8977   				(width, height, rgb, alpha,
................................................................................
  9024   8990   				goto error;
  9025   8991   			}
  9026   8992   		      sqlite3_result_blob (context, image, image_size, free);
  9027   8993   		      break;
  9028   8994   		  case RL2_PIXEL_MULTIBAND:
  9029   8995   		      ret =
  9030   8996   			  get_rgba_from_multiband_mask (width, height,
  9031         -							sample_type,
  9032         -							num_bands, buffer,
  9033         -							mask, no_data, rgba);
         8997  +							sample_type, num_bands,
         8998  +							buffer, mask, no_data,
         8999  +							rgba);
  9034   9000   		      buffer = NULL;
  9035   9001   		      mask = NULL;
  9036   9002   		      if (!ret)
  9037   9003   			  goto error;
  9038   9004   		      if (!build_rgb_alpha
  9039         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  9040         -			   bg_green, bg_blue))
         9005  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         9006  +			   bg_blue))
  9041   9007   			  goto error;
  9042   9008   		      free (rgba);
  9043   9009   		      rgba = NULL;
  9044   9010   		      if (transparent)
  9045   9011   			{
  9046   9012   			    if (!get_payload_from_gray_rgba_transparent
  9047   9013   				(width, height, rgb, alpha,
................................................................................
  9272   9238   						    num_bands, buffer, mask,
  9273   9239   						    no_data, rgba);
  9274   9240   		      buffer = NULL;
  9275   9241   		      mask = NULL;
  9276   9242   		      if (!ret)
  9277   9243   			  goto error;
  9278   9244   		      if (!build_rgb_alpha
  9279         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  9280         -			   bg_green, bg_blue))
         9245  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         9246  +			   bg_blue))
  9281   9247   			  goto error;
  9282   9248   		      free (rgba);
  9283   9249   		      rgba = NULL;
  9284   9250   		      if (transparent)
  9285   9251   			{
  9286   9252   			    if (!get_payload_from_rgb_rgba_transparent
  9287   9253   				(width, height, rgb, alpha,
................................................................................
  9302   9268   		      sqlite3_result_blob (context, image, image_size, free);
  9303   9269   		      break;
  9304   9270   		  case RL2_SAMPLE_UINT16:
  9305   9271   		      ret =
  9306   9272   			  get_rgba_from_multiband16 (width, height, red_band,
  9307   9273   						     green_band, blue_band,
  9308   9274   						     num_bands,
  9309         -						     (unsigned short *)
  9310         -						     buffer, mask, no_data,
  9311         -						     rgba);
         9275  +						     (unsigned short *) buffer,
         9276  +						     mask, no_data, rgba);
  9312   9277   		      if (!build_rgb_alpha
  9313         -			  (width, height, rgba, &rgb, &alpha, bg_red,
  9314         -			   bg_green, bg_blue))
         9278  +			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
         9279  +			   bg_blue))
  9315   9280   			  goto error;
  9316   9281   		      free (rgba);
  9317   9282   		      rgba = NULL;
  9318   9283   		      if (transparent)
  9319   9284   			{
  9320   9285   			    if (!get_payload_from_rgb_rgba_transparent
  9321   9286   				(width, height, rgb, alpha,
................................................................................
  9696   9661   	  double ext_x = (double) width * horz_res;
  9697   9662   	  double ext_y = (double) height * vert_res;
  9698   9663   	  minx = pt_x - ext_x / 2.0;
  9699   9664   	  maxx = minx + ext_x;
  9700   9665   	  miny = pt_y - ext_y / 2.0;
  9701   9666   	  maxy = miny + ext_y;
  9702   9667         }
  9703         -    else if (rl2_parse_bbox
  9704         -	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
         9668  +    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
         9669  +	     != RL2_OK)
  9705   9670   	goto error;
  9706   9671   
  9707   9672   /* attempting to load the Coverage definitions from the DBMS */
  9708   9673       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
  9709   9674       if (coverage == NULL)
  9710   9675   	goto error;
  9711   9676       if (by_section)
  9712   9677         {
  9713   9678   	  /* only a single Section */
  9714   9679   	  ret =
  9715   9680   	      rl2_export_section_raw_pixels_from_dbms (sqlite, max_threads,
  9716   9681   						       coverage, section_id,
  9717         -						       horz_res, vert_res,
  9718         -						       minx, miny, maxx, maxy,
  9719         -						       width, height,
  9720         -						       big_endian, &xblob,
  9721         -						       &xblob_sz);
         9682  +						       horz_res, vert_res, minx,
         9683  +						       miny, maxx, maxy, width,
         9684  +						       height, big_endian,
         9685  +						       &xblob, &xblob_sz);
  9722   9686         }
  9723   9687       else
  9724   9688         {
  9725   9689   	  /* whole Coverage */
  9726   9690   	  ret =
  9727   9691   	      rl2_export_raw_pixels_from_dbms (sqlite, max_threads, coverage,
  9728   9692   					       horz_res, vert_res, minx, miny,
................................................................................
  9914   9878       if (rl2_parse_bbox_srid
  9915   9879   	(sqlite, blob, blob_sz, &srid, &minx, &miny, &maxx, &maxy) != RL2_OK)
  9916   9880         {
  9917   9881   	  errcode = -1;
  9918   9882   	  goto error;
  9919   9883         }
  9920   9884   
  9921         -    if (rl2_get_coverage_type
  9922         -	(coverage, &sample_type, &pixel_type, &num_bands) != RL2_OK)
         9885  +    if (rl2_get_coverage_type (coverage, &sample_type, &pixel_type, &num_bands)
         9886  +	!= RL2_OK)
  9923   9887         {
  9924   9888   	  errcode = -1;
  9925   9889   	  goto error;
  9926   9890         }
  9927   9891       if (rl2_get_coverage_srid (coverage, &cov_srid) != RL2_OK)
  9928   9892         {
  9929   9893   	  errcode = -1;
................................................................................
  9983   9947       no_data = NULL;
  9984   9948       if (raster == NULL)
  9985   9949         {
  9986   9950   	  errcode = -1;
  9987   9951   	  goto error;
  9988   9952         }
  9989   9953   /* georeferencing the raster */
  9990         -    if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy)
  9991         -	!= RL2_OK)
         9954  +    if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy) !=
         9955  +	RL2_OK)
  9992   9956         {
  9993   9957   	  errcode = -1;
  9994   9958   	  goto error;
  9995   9959         }
  9996   9960   
  9997   9961   /* attempting to load the Raster into the DBMS */
  9998   9962       if (transaction)
................................................................................
 10003   9967   	    {
 10004   9968   		rl2_destroy_coverage (coverage);
 10005   9969   		sqlite3_result_int (context, -1);
 10006   9970   		return;
 10007   9971   	    }
 10008   9972         }
 10009   9973       ret =
 10010         -	rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage,
 10011         -				       sctn_name, raster, pyramidize);
         9974  +	rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage, sctn_name,
         9975  +				       raster, pyramidize);
 10012   9976       rl2_destroy_coverage (coverage);
 10013   9977       rl2_destroy_raster (raster);
 10014   9978       if (ret != RL2_OK)
 10015   9979         {
 10016   9980   	  if (transaction)
 10017   9981   	    {
 10018   9982   		/* invalidating the pending transaction */
................................................................................
 10173  10137   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10174  10138       sqlite3_create_function (db, "DropRasterCoverage", 2,
 10175  10139   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10176  10140       sqlite3_create_function (db, "RL2_DropRasterCoverage", 2,
 10177  10141   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10178  10142       sqlite3_create_function (db, "SetRasterCoverageInfos", 3,
 10179  10143   			     SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0);
 10180         -    sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3, SQLITE_UTF8,
 10181         -			     0, fnct_SetRasterCoverageInfos, 0, 0);
        10144  +    sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3,
        10145  +			     SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0);
 10182  10146       sqlite3_create_function (db, "SetRasterCoverageDefaultBands", 5,
 10183         -			     SQLITE_UTF8, 0,
 10184         -			     fnct_SetRasterCoverageDefaultBands, 0, 0);
        10147  +			     SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands,
        10148  +			     0, 0);
 10185  10149       sqlite3_create_function (db, "RL2_SetRasterCoverageDefaultBands", 5,
 10186         -			     SQLITE_UTF8, 0,
 10187         -			     fnct_SetRasterCoverageDefaultBands, 0, 0);
        10150  +			     SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands,
        10151  +			     0, 0);
 10188  10152       sqlite3_create_function (db, "EnableRasterCoverageAutoNDVI", 2,
 10189         -			     SQLITE_UTF8, 0,
 10190         -			     fnct_EnableRasterCoverageAutoNDVI, 0, 0);
        10153  +			     SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI,
        10154  +			     0, 0);
 10191  10155       sqlite3_create_function (db, "RL2_EnableRasterCoverageAutoNDVI", 2,
 10192         -			     SQLITE_UTF8, 0,
 10193         -			     fnct_EnableRasterCoverageAutoNDVI, 0, 0);
        10156  +			     SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI,
        10157  +			     0, 0);
 10194  10158       sqlite3_create_function (db, "IsRasterCoverageAutoNdviEnabled", 1,
 10195  10159   			     SQLITE_UTF8, 0,
 10196  10160   			     fnct_IsRasterCoverageAutoNdviEnabled, 0, 0);
 10197  10161       sqlite3_create_function (db, "RL2_IsRasterCoverageAutoNdviEnabled", 1,
 10198  10162   			     SQLITE_UTF8, 0,
 10199  10163   			     fnct_IsRasterCoverageAutoNdviEnabled, 0, 0);
 10200  10164       sqlite3_create_function (db, "GetPaletteNumEntries", 1,
................................................................................
 10322  10286   			     fnct_IsFontItalic, 0, 0);
 10323  10287       sqlite3_create_function (db, "RL2_IsFontItalic", 1,
 10324  10288   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10325  10289   			     fnct_IsFontItalic, 0, 0);
 10326  10290       sqlite3_create_function (db, "GetRasterStatistics_NoDataPixelsCount", 1,
 10327  10291   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10328  10292   			     fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0);
 10329         -    sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount",
 10330         -			     1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10293  +    sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount", 1,
        10294  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10331  10295   			     fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0);
 10332  10296       sqlite3_create_function (db, "GetRasterStatistics_ValidPixelsCount", 1,
 10333  10297   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10334  10298   			     fnct_GetRasterStatistics_ValidPixelsCount, 0, 0);
 10335         -    sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount",
 10336         -			     1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10299  +    sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount", 1,
        10300  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10337  10301   			     fnct_GetRasterStatistics_ValidPixelsCount, 0, 0);
 10338  10302       sqlite3_create_function (db, "GetRasterStatistics_SampleType", 1,
 10339  10303   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10340  10304   			     fnct_GetRasterStatistics_SampleType, 0, 0);
 10341  10305       sqlite3_create_function (db, "RL2_GetRasterStatistics_SampleType", 1,
 10342  10306   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10343  10307   			     fnct_GetRasterStatistics_SampleType, 0, 0);
................................................................................
 10404  10368   			     fnct_Pyramidize, 0, 0);
 10405  10369       sqlite3_create_function (db, "Pyramidize", 4, SQLITE_UTF8, priv_data,
 10406  10370   			     fnct_Pyramidize, 0, 0);
 10407  10371       sqlite3_create_function (db, "RL2_Pyramidize", 4, SQLITE_UTF8, priv_data,
 10408  10372   			     fnct_Pyramidize, 0, 0);
 10409  10373       sqlite3_create_function (db, "PyramidizeMonolithic", 1, SQLITE_UTF8, 0,
 10410  10374   			     fnct_PyramidizeMonolithic, 0, 0);
 10411         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8,
 10412         -			     0, fnct_PyramidizeMonolithic, 0, 0);
        10375  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8, 0,
        10376  +			     fnct_PyramidizeMonolithic, 0, 0);
 10413  10377       sqlite3_create_function (db, "PyramidizeMonolithic", 2, SQLITE_UTF8, 0,
 10414  10378   			     fnct_PyramidizeMonolithic, 0, 0);
 10415         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8,
 10416         -			     0, fnct_PyramidizeMonolithic, 0, 0);
        10379  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8, 0,
        10380  +			     fnct_PyramidizeMonolithic, 0, 0);
 10417  10381       sqlite3_create_function (db, "PyramidizeMonolithic", 3, SQLITE_UTF8, 0,
 10418  10382   			     fnct_PyramidizeMonolithic, 0, 0);
 10419         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8,
 10420         -			     0, fnct_PyramidizeMonolithic, 0, 0);
        10383  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8, 0,
        10384  +			     fnct_PyramidizeMonolithic, 0, 0);
 10421  10385       sqlite3_create_function (db, "DePyramidize", 1, SQLITE_UTF8, 0,
 10422  10386   			     fnct_DePyramidize, 0, 0);
 10423  10387       sqlite3_create_function (db, "RL2_DePyramidize", 1, SQLITE_UTF8, 0,
 10424  10388   			     fnct_DePyramidize, 0, 0);
 10425  10389       sqlite3_create_function (db, "DePyramidize", 2, SQLITE_UTF8, 0,
 10426  10390   			     fnct_DePyramidize, 0, 0);
 10427  10391       sqlite3_create_function (db, "RL2_DePyramidize", 2, SQLITE_UTF8, 0,
................................................................................
 10475  10439       sqlite3_create_function (db, "GetMapImageFromRaster", 11,
 10476  10440   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10477  10441   			     fnct_GetMapImageFromRaster, 0, 0);
 10478  10442       sqlite3_create_function (db, "RL2_GetMapImageFromRaster", 11,
 10479  10443   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10480  10444   			     fnct_GetMapImageFromRaster, 0, 0);
 10481  10445       sqlite3_create_function (db, "GetMapImageFromVector", 4,
 10482         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10446  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10483  10447   			     fnct_GetMapImageFromVector, 0, 0);
 10484  10448       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 4,
 10485         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10449  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10486  10450   			     fnct_GetMapImageFromVector, 0, 0);
 10487  10451       sqlite3_create_function (db, "GetMapImageFromVector", 5,
 10488         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10452  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10489  10453   			     fnct_GetMapImageFromVector, 0, 0);
 10490  10454       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 5,
 10491         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10455  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10492  10456   			     fnct_GetMapImageFromVector, 0, 0);
 10493  10457       sqlite3_create_function (db, "GetMapImageFromVector", 6,
 10494         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10458  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10495  10459   			     fnct_GetMapImageFromVector, 0, 0);
 10496  10460       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 6,
 10497         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10461  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10498  10462   			     fnct_GetMapImageFromVector, 0, 0);
 10499  10463       sqlite3_create_function (db, "GetMapImageFromVector", 7,
 10500         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10464  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10501  10465   			     fnct_GetMapImageFromVector, 0, 0);
 10502  10466       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 7,
 10503         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10467  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10504  10468   			     fnct_GetMapImageFromVector, 0, 0);
 10505  10469       sqlite3_create_function (db, "GetMapImageFromVector", 8,
 10506         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10470  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10507  10471   			     fnct_GetMapImageFromVector, 0, 0);
 10508  10472       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 8,
 10509         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10473  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10510  10474   			     fnct_GetMapImageFromVector, 0, 0);
 10511  10475       sqlite3_create_function (db, "GetMapImageFromVector", 9,
 10512         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10476  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10513  10477   			     fnct_GetMapImageFromVector, 0, 0);
 10514  10478       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 9,
 10515         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10479  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10516  10480   			     fnct_GetMapImageFromVector, 0, 0);
 10517  10481       sqlite3_create_function (db, "GetMapImageFromVector", 10,
 10518         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10482  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10519  10483   			     fnct_GetMapImageFromVector, 0, 0);
 10520  10484       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 10,
 10521         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10485  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10522  10486   			     fnct_GetMapImageFromVector, 0, 0);
 10523  10487       sqlite3_create_function (db, "GetMapImageFromVector", 11,
 10524         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10488  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10525  10489   			     fnct_GetMapImageFromVector, 0, 0);
 10526  10490       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 11,
 10527         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
        10491  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10528  10492   			     fnct_GetMapImageFromVector, 0, 0);
 10529  10493       sqlite3_create_function (db, "GetTileImage", 2,
 10530  10494   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10531  10495   			     fnct_GetTileImage, 0, 0);
 10532  10496       sqlite3_create_function (db, "RL2_GetTileImage", 2,
 10533  10497   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10534  10498   			     fnct_GetTileImage, 0, 0);
................................................................................
 10671  10635   				   fnct_LoadFontFromFile, 0, 0);
 10672  10636   	  sqlite3_create_function (db, "RL2_LoadFontFromFile", 1, SQLITE_UTF8,
 10673  10637   				   0, fnct_LoadFontFromFile, 0, 0);
 10674  10638   	  sqlite3_create_function (db, "ExportFontToFile", 2, SQLITE_UTF8, 0,
 10675  10639   				   fnct_ExportFontToFile, 0, 0);
 10676  10640   	  sqlite3_create_function (db, "RL2_ExportFontToFile", 2, SQLITE_UTF8,
 10677  10641   				   0, fnct_ExportFontToFile, 0, 0);
 10678         -	  sqlite3_create_function (db, "LoadRaster", 2, SQLITE_UTF8,
 10679         -				   priv_data, fnct_LoadRaster, 0, 0);
 10680         -	  sqlite3_create_function (db, "LoadRaster", 3, SQLITE_UTF8,
 10681         -				   priv_data, fnct_LoadRaster, 0, 0);
 10682         -	  sqlite3_create_function (db, "LoadRaster", 4, SQLITE_UTF8,
 10683         -				   priv_data, fnct_LoadRaster, 0, 0);
 10684         -	  sqlite3_create_function (db, "LoadRaster", 5, SQLITE_UTF8,
 10685         -				   priv_data, fnct_LoadRaster, 0, 0);
 10686         -	  sqlite3_create_function (db, "LoadRaster", 6, SQLITE_UTF8,
 10687         -				   priv_data, fnct_LoadRaster, 0, 0);
        10642  +	  sqlite3_create_function (db, "LoadRaster", 2, SQLITE_UTF8, priv_data,
        10643  +				   fnct_LoadRaster, 0, 0);
        10644  +	  sqlite3_create_function (db, "LoadRaster", 3, SQLITE_UTF8, priv_data,
        10645  +				   fnct_LoadRaster, 0, 0);
        10646  +	  sqlite3_create_function (db, "LoadRaster", 4, SQLITE_UTF8, priv_data,
        10647  +				   fnct_LoadRaster, 0, 0);
        10648  +	  sqlite3_create_function (db, "LoadRaster", 5, SQLITE_UTF8, priv_data,
        10649  +				   fnct_LoadRaster, 0, 0);
        10650  +	  sqlite3_create_function (db, "LoadRaster", 6, SQLITE_UTF8, priv_data,
        10651  +				   fnct_LoadRaster, 0, 0);
 10688  10652   	  sqlite3_create_function (db, "RL2_LoadRaster", 2, SQLITE_UTF8,
 10689  10653   				   priv_data, fnct_LoadRaster, 0, 0);
 10690  10654   	  sqlite3_create_function (db, "RL2_LoadRaster", 3, SQLITE_UTF8,
 10691  10655   				   priv_data, fnct_LoadRaster, 0, 0);
 10692  10656   	  sqlite3_create_function (db, "RL2_LoadRaster", 4, SQLITE_UTF8,
 10693  10657   				   priv_data, fnct_LoadRaster, 0, 0);
 10694  10658   	  sqlite3_create_function (db, "RL2_LoadRaster", 5, SQLITE_UTF8,
................................................................................
 10703  10667   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10704  10668   	  sqlite3_create_function (db, "LoadRastersFromDir", 5, SQLITE_UTF8,
 10705  10669   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10706  10670   	  sqlite3_create_function (db, "LoadRastersFromDir", 6, SQLITE_UTF8,
 10707  10671   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10708  10672   	  sqlite3_create_function (db, "LoadRastersFromDir", 7, SQLITE_UTF8,
 10709  10673   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10710         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 2,
 10711         -				   SQLITE_UTF8, priv_data,
 10712         -				   fnct_LoadRastersFromDir, 0, 0);
 10713         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 3,
 10714         -				   SQLITE_UTF8, priv_data,
 10715         -				   fnct_LoadRastersFromDir, 0, 0);
 10716         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 4,
 10717         -				   SQLITE_UTF8, priv_data,
 10718         -				   fnct_LoadRastersFromDir, 0, 0);
 10719         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 5,
 10720         -				   SQLITE_UTF8, priv_data,
 10721         -				   fnct_LoadRastersFromDir, 0, 0);
 10722         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 6,
 10723         -				   SQLITE_UTF8, priv_data,
 10724         -				   fnct_LoadRastersFromDir, 0, 0);
 10725         -	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 7,
 10726         -				   SQLITE_UTF8, priv_data,
 10727         -				   fnct_LoadRastersFromDir, 0, 0);
        10674  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 2, SQLITE_UTF8,
        10675  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
        10676  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 3, SQLITE_UTF8,
        10677  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
        10678  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 4, SQLITE_UTF8,
        10679  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
        10680  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 5, SQLITE_UTF8,
        10681  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
        10682  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 6, SQLITE_UTF8,
        10683  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
        10684  +	  sqlite3_create_function (db, "RL2_LoadRastersFromDir", 7, SQLITE_UTF8,
        10685  +				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10728  10686   	  sqlite3_create_function (db, "LoadRasterFromWMS", 9, SQLITE_UTF8,
 10729  10687   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10730         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9,
 10731         -				   SQLITE_UTF8, priv_data,
 10732         -				   fnct_LoadRasterFromWMS, 0, 0);
        10688  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9, SQLITE_UTF8,
        10689  +				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10733  10690   	  sqlite3_create_function (db, "LoadRasterFromWMS", 10, SQLITE_UTF8,
 10734  10691   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10735         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10,
 10736         -				   SQLITE_UTF8, priv_data,
 10737         -				   fnct_LoadRasterFromWMS, 0, 0);
        10692  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10, SQLITE_UTF8,
        10693  +				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10738  10694   	  sqlite3_create_function (db, "LoadRasterFromWMS", 11, SQLITE_UTF8,
 10739  10695   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10740         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11,
 10741         -				   SQLITE_UTF8, priv_data,
 10742         -				   fnct_LoadRasterFromWMS, 0, 0);
        10696  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11, SQLITE_UTF8,
        10697  +				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10743  10698   	  sqlite3_create_function (db, "LoadRasterFromWMS", 12, SQLITE_UTF8,
 10744  10699   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10745         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12,
 10746         -				   SQLITE_UTF8, priv_data,
 10747         -				   fnct_LoadRasterFromWMS, 0, 0);
        10700  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12, SQLITE_UTF8,
        10701  +				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10748  10702   	  sqlite3_create_function (db, "LoadRasterFromWMS", 13, SQLITE_UTF8,
 10749  10703   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10750         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13,
 10751         -				   SQLITE_UTF8, priv_data,
 10752         -				   fnct_LoadRasterFromWMS, 0, 0);
        10704  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13, SQLITE_UTF8,
        10705  +				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10753  10706   	  sqlite3_create_function (db, "LoadRasterFromWMS", 14, SQLITE_UTF8,
 10754  10707   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10755         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14,
 10756         -				   SQLITE_UTF8, 0, fnct_LoadRasterFromWMS, 0,
 10757         -				   0);
        10708  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14, SQLITE_UTF8,
        10709  +				   0, fnct_LoadRasterFromWMS, 0, 0);
 10758  10710   	  sqlite3_create_function (db, "WriteGeoTiff", 6, SQLITE_UTF8,
 10759  10711   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10760  10712   	  sqlite3_create_function (db, "RL2_WriteGeoTiff", 6, SQLITE_UTF8,
 10761  10713   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10762  10714   	  sqlite3_create_function (db, "WriteGeoTiff", 7, SQLITE_UTF8,
 10763  10715   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10764  10716   	  sqlite3_create_function (db, "RL2_WriteGeoTiff", 7, SQLITE_UTF8,
................................................................................
 10861  10813   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10862  10814   	  sqlite3_create_function (db, "WriteSectionTiff", 9, SQLITE_UTF8,
 10863  10815   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10864  10816   	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 9, SQLITE_UTF8,
 10865  10817   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10866  10818   	  sqlite3_create_function (db, "WriteSectionTiff", 10, SQLITE_UTF8,
 10867  10819   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10868         -	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 10,
 10869         -				   SQLITE_UTF8, priv_data,
 10870         -				   fnct_WriteSectionTiff, 0, 0);
        10820  +	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 10, SQLITE_UTF8,
        10821  +				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10871  10822   	  sqlite3_create_function (db, "WriteJpegJgw", 6, SQLITE_UTF8,
 10872  10823   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10873  10824   	  sqlite3_create_function (db, "RL2_WriteJpegJgw", 6, SQLITE_UTF8,
 10874  10825   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10875  10826   	  sqlite3_create_function (db, "WriteJpegJgw", 7, SQLITE_UTF8,
 10876  10827   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10877  10828   	  sqlite3_create_function (db, "RL2_WriteJpegJgw", 7, SQLITE_UTF8,
................................................................................
 10915  10866   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10916  10867   	  sqlite3_create_function (db, "RL2_WriteSectionJpeg", 8, SQLITE_UTF8,
 10917  10868   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10918  10869   	  sqlite3_create_function (db, "WriteSectionJpeg", 9, SQLITE_UTF8,
 10919  10870   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10920  10871   	  sqlite3_create_function (db, "RL2_WriteSectionJpeg", 9, SQLITE_UTF8,
 10921  10872   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10922         -	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9,
 10923         -				   SQLITE_UTF8, priv_data,
 10924         -				   fnct_WriteTripleBandGeoTiff, 0, 0);
        10873  +	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9, SQLITE_UTF8,
        10874  +				   priv_data, fnct_WriteTripleBandGeoTiff, 0,
        10875  +				   0);
 10925  10876   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 9,
 10926  10877   				   SQLITE_UTF8, priv_data,
 10927  10878   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10928  10879   	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 10,
 10929  10880   				   SQLITE_UTF8, priv_data,
 10930  10881   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10931  10882   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 10,
................................................................................
 10948  10899   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10949  10900   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 13,
 10950  10901   				   SQLITE_UTF8, priv_data,
 10951  10902   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10952  10903   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 10,
 10953  10904   				   SQLITE_UTF8, 0,
 10954  10905   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10955         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
 10956         -				   10, SQLITE_UTF8, priv_data,
        10906  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 10,
        10907  +				   SQLITE_UTF8, priv_data,
 10957  10908   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10958  10909   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 11,
 10959  10910   				   SQLITE_UTF8, priv_data,
 10960  10911   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10961         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
 10962         -				   11, SQLITE_UTF8, priv_data,
        10912  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 11,
        10913  +				   SQLITE_UTF8, priv_data,
 10963  10914   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10964  10915   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 12,
 10965  10916   				   SQLITE_UTF8, priv_data,
 10966  10917   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10967         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
 10968         -				   12, SQLITE_UTF8, priv_data,
        10918  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 12,
        10919  +				   SQLITE_UTF8, priv_data,
 10969  10920   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10970  10921   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 13,
 10971  10922   				   SQLITE_UTF8, priv_data,
 10972  10923   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10973         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
 10974         -				   13, SQLITE_UTF8, priv_data,
        10924  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 13,
        10925  +				   SQLITE_UTF8, priv_data,
 10975  10926   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10976  10927   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 14,
 10977  10928   				   SQLITE_UTF8, priv_data,
 10978  10929   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10979         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
 10980         -				   14, SQLITE_UTF8, priv_data,
        10930  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 14,
        10931  +				   SQLITE_UTF8, priv_data,
 10981  10932   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10982  10933   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 7, SQLITE_UTF8,
 10983  10934   				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 10984  10935   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 7,
 10985  10936   				   SQLITE_UTF8, priv_data,
 10986  10937   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10987  10938   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 8, SQLITE_UTF8,
................................................................................
 10990  10941   				   SQLITE_UTF8, priv_data,
 10991  10942   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10992  10943   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 9, SQLITE_UTF8,
 10993  10944   				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 10994  10945   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 9,
 10995  10946   				   SQLITE_UTF8, priv_data,
 10996  10947   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10997         -	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10,
 10998         -				   SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff,
 10999         -				   0, 0);
        10948  +	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10, SQLITE_UTF8,
        10949  +				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 11000  10950   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 10,
 11001  10951   				   SQLITE_UTF8, priv_data,
 11002  10952   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 11003         -	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11,
 11004         -				   SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff,
 11005         -				   0, 0);
        10953  +	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11, SQLITE_UTF8,
        10954  +				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 11006  10955   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 11,
 11007  10956   				   SQLITE_UTF8, priv_data,
 11008  10957   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 11009  10958   	  sqlite3_create_function (db, "WriteSectionMonoBandGeoTiff", 8,
 11010  10959   				   SQLITE_UTF8, priv_data,
 11011  10960   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 11012  10961   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandGeoTiff", 8,
................................................................................
 11032  10981   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 11033  10982   	  sqlite3_create_function (db, "WriteSectionMonoBandGeoTiff", 12,
 11034  10983   				   SQLITE_UTF8, priv_data,
 11035  10984   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 11036  10985   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandGeoTiff", 12,
 11037  10986   				   SQLITE_UTF8, priv_data,
 11038  10987   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 11039         -	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9,
 11040         -				   SQLITE_UTF8, priv_data,
 11041         -				   fnct_WriteTripleBandTiffTfw, 0, 0);
        10988  +	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9, SQLITE_UTF8,
        10989  +				   priv_data, fnct_WriteTripleBandTiffTfw, 0,
        10990  +				   0);
 11042  10991   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 9,
 11043  10992   				   SQLITE_UTF8, priv_data,
 11044  10993   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11045  10994   	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 10,
 11046  10995   				   SQLITE_UTF8, priv_data,
 11047  10996   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11048  10997   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 10,
................................................................................
 11059  11008   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11060  11009   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 12,
 11061  11010   				   SQLITE_UTF8, priv_data,
 11062  11011   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11063  11012   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 10,
 11064  11013   				   SQLITE_UTF8, priv_data,
 11065  11014   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11066         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
 11067         -				   10, SQLITE_UTF8, priv_data,
        11015  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 10,
        11016  +				   SQLITE_UTF8, priv_data,
 11068  11017   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11069  11018   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 11,
 11070  11019   				   SQLITE_UTF8, priv_data,
 11071  11020   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11072         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
 11073         -				   11, SQLITE_UTF8, priv_data,
        11021  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 11,
        11022  +				   SQLITE_UTF8, priv_data,
 11074  11023   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11075  11024   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 12,
 11076  11025   				   SQLITE_UTF8, priv_data,
 11077  11026   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11078         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
 11079         -				   12, SQLITE_UTF8, priv_data,
        11027  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 12,
        11028  +				   SQLITE_UTF8, priv_data,
 11080  11029   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11081  11030   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 13,
 11082  11031   				   SQLITE_UTF8, priv_data,
 11083  11032   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11084         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
 11085         -				   13, SQLITE_UTF8, priv_data,
        11033  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 13,
        11034  +				   SQLITE_UTF8, priv_data,
 11086  11035   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11087  11036   	  sqlite3_create_function (db, "WriteSectionMonoBandTiffTfw", 8,
 11088  11037   				   SQLITE_UTF8, priv_data,
 11089  11038   				   fnct_WriteSectionMonoBandTiffTfw, 0, 0);
 11090  11039   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiffTfw", 8,
 11091  11040   				   SQLITE_UTF8, priv_data,
 11092  11041   				   fnct_WriteSectionMonoBandTiffTfw, 0, 0);
................................................................................
 11119  11068   				   SQLITE_UTF8, priv_data,
 11120  11069   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11121  11070   	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 9, SQLITE_UTF8,
 11122  11071   				   priv_data, fnct_WriteMonoBandTiffTfw, 0, 0);
 11123  11072   	  sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 9,
 11124  11073   				   SQLITE_UTF8, priv_data,
 11125  11074   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11126         -	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10,
 11127         -				   SQLITE_UTF8, priv_data,
 11128         -				   fnct_WriteMonoBandTiffTfw, 0, 0);
        11075  +	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10, SQLITE_UTF8,
        11076  +				   priv_data, fnct_WriteMonoBandTiffTfw, 0, 0);
 11129  11077   	  sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 10,
 11130  11078   				   SQLITE_UTF8, priv_data,
 11131  11079   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11132         -	  sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8,
 11133         -				   0, fnct_WriteTripleBandTiff, 0, 0);
        11080  +	  sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8, 0,
        11081  +				   fnct_WriteTripleBandTiff, 0, 0);
 11134  11082   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiff", 9,
 11135  11083   				   SQLITE_UTF8, priv_data,
 11136  11084   				   fnct_WriteTripleBandTiff, 0, 0);
 11137  11085   	  sqlite3_create_function (db, "WriteTripleBandTiff", 10, SQLITE_UTF8,
 11138  11086   				   0, fnct_WriteTripleBandTiff, 0, 0);
 11139  11087   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiff", 10,
 11140  11088   				   SQLITE_UTF8, priv_data,
................................................................................
 11171  11119   				   SQLITE_UTF8, priv_data,
 11172  11120   				   fnct_WriteSectionTripleBandTiff, 0, 0);
 11173  11121   	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiff", 13,
 11174  11122   				   SQLITE_UTF8, priv_data,
 11175  11123   				   fnct_WriteSectionTripleBandTiff, 0, 0);
 11176  11124   	  sqlite3_create_function (db, "WriteMonoBandTiff", 7, SQLITE_UTF8, 0,
 11177  11125   				   fnct_WriteMonoBandTiff, 0, 0);
 11178         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7,
 11179         -				   SQLITE_UTF8, priv_data,
 11180         -				   fnct_WriteMonoBandTiff, 0, 0);
        11126  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7, SQLITE_UTF8,
        11127  +				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11181  11128   	  sqlite3_create_function (db, "WriteMonoBandTiff", 8, SQLITE_UTF8, 0,
 11182  11129   				   fnct_WriteMonoBandTiff, 0, 0);
 11183         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8,
 11184         -				   SQLITE_UTF8, priv_data,
 11185         -				   fnct_WriteMonoBandTiff, 0, 0);
        11130  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8, SQLITE_UTF8,
        11131  +				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11186  11132   	  sqlite3_create_function (db, "WriteMonoBandTiff", 9, SQLITE_UTF8,
 11187  11133   				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11188         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9,
 11189         -				   SQLITE_UTF8, priv_data,
 11190         -				   fnct_WriteMonoBandTiff, 0, 0);
        11134  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9, SQLITE_UTF8,
        11135  +				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11191  11136   	  sqlite3_create_function (db, "WriteMonoBandTiff", 10, SQLITE_UTF8,
 11192  11137   				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11193         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10,
 11194         -				   SQLITE_UTF8, priv_data,
 11195         -				   fnct_WriteMonoBandTiff, 0, 0);
        11138  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10, SQLITE_UTF8,
        11139  +				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11196  11140   	  sqlite3_create_function (db, "WriteSectionMonoBandTiff", 8,
 11197  11141   				   SQLITE_UTF8, priv_data,
 11198  11142   				   fnct_WriteSectionMonoBandTiff, 0, 0);
 11199  11143   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiff", 8,
 11200  11144   				   SQLITE_UTF8, priv_data,
 11201  11145   				   fnct_WriteSectionMonoBandTiff, 0, 0);
 11202  11146   	  sqlite3_create_function (db, "WriteSectionMonoBandTiff", 9,
................................................................................
 11225  11169   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11226  11170   	  sqlite3_create_function (db, "RL2_WriteAsciiGrid", 7, SQLITE_UTF8,
 11227  11171   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11228  11172   	  sqlite3_create_function (db, "WriteAsciiGrid", 8, SQLITE_UTF8,
 11229  11173   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11230  11174   	  sqlite3_create_function (db, "RL2_WriteAsciiGrid", 8, SQLITE_UTF8,
 11231  11175   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11232         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 7,
 11233         -				   SQLITE_UTF8, priv_data,
 11234         -				   fnct_WriteSectionAsciiGrid, 0, 0);
        11176  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 7, SQLITE_UTF8,
        11177  +				   priv_data, fnct_WriteSectionAsciiGrid, 0, 0);
 11235  11178   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 7,
 11236  11179   				   SQLITE_UTF8, priv_data,
 11237  11180   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11238         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 8,
 11239         -				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
 11240         -				   0, 0);
        11181  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 8, SQLITE_UTF8,
        11182  +				   0, fnct_WriteSectionAsciiGrid, 0, 0);
 11241  11183   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 8,
 11242  11184   				   SQLITE_UTF8, priv_data,
 11243  11185   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11244         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 9,
 11245         -				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
 11246         -				   0, 0);
        11186  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 9, SQLITE_UTF8,
        11187  +				   0, fnct_WriteSectionAsciiGrid, 0, 0);
 11247  11188   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 9,
 11248  11189   				   SQLITE_UTF8, priv_data,
 11249  11190   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11250  11191   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 8, SQLITE_UTF8,
 11251  11192   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11252         -	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8,
 11253         -				   SQLITE_UTF8, priv_data,
 11254         -				   fnct_WriteNdviAsciiGrid, 0, 0);
        11193  +	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8, SQLITE_UTF8,
        11194  +				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11255  11195   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 9, SQLITE_UTF8,
 11256  11196   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11257         -	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9,
 11258         -				   SQLITE_UTF8, priv_data,
 11259         -				   fnct_WriteNdviAsciiGrid, 0, 0);
        11197  +	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9, SQLITE_UTF8,
        11198  +				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11260  11199   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 10, SQLITE_UTF8,
 11261  11200   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11262  11201   	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 10,
 11263  11202   				   SQLITE_UTF8, priv_data,
 11264  11203   				   fnct_WriteNdviAsciiGrid, 0, 0);
 11265  11204   	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 9,
 11266  11205   				   SQLITE_UTF8, priv_data,

Changes to src/rl2sqlaux.c.

    81     81       int ret;
    82     82       const char *sample;
    83     83       int bands;
    84     84       unsigned char xsample_type = RL2_SAMPLE_UNKNOWN;
    85     85       unsigned char xnum_bands = RL2_BANDS_UNKNOWN;
    86     86   
    87     87       sql =
    88         -	sqlite3_mprintf
    89         -	("SELECT sample_type, num_bands FROM raster_coverages "
    90         -	 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
           88  +	sqlite3_mprintf ("SELECT sample_type, num_bands FROM raster_coverages "
           89  +			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
    91     90       ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL);
    92     91       sqlite3_free (sql);
    93     92       if (ret != SQLITE_OK)
    94     93   	return 0;
    95     94       if (rows < 1)
    96     95   	;
    97     96       else
................................................................................
   735    734     error:
   736    735       if (stmt != NULL)
   737    736   	sqlite3_finalize (stmt);
   738    737       return RL2_ERROR;
   739    738   }
   740    739   
   741    740   static int
   742         -do_insert_wms_tile (sqlite3 * handle, unsigned char *blob_odd,
   743         -		    int blob_odd_sz, unsigned char *blob_even,
   744         -		    int blob_even_sz, sqlite3_int64 section_id, int srid,
   745         -		    double res_x, double res_y, unsigned int tile_w,
   746         -		    unsigned int tile_h, double miny, double maxx,
   747         -		    double tile_minx, double tile_miny, double tile_maxx,
   748         -		    double tile_maxy, rl2PalettePtr aux_palette,
   749         -		    rl2PixelPtr no_data, sqlite3_stmt * stmt_tils,
   750         -		    sqlite3_stmt * stmt_data,
          741  +do_insert_wms_tile (sqlite3 * handle, unsigned char *blob_odd, int blob_odd_sz,
          742  +		    unsigned char *blob_even, int blob_even_sz,
          743  +		    sqlite3_int64 section_id, int srid, double res_x,
          744  +		    double res_y, unsigned int tile_w, unsigned int tile_h,
          745  +		    double miny, double maxx, double tile_minx,
          746  +		    double tile_miny, double tile_maxx, double tile_maxy,
          747  +		    rl2PalettePtr aux_palette, rl2PixelPtr no_data,
          748  +		    sqlite3_stmt * stmt_tils, sqlite3_stmt * stmt_data,
   751    749   		    rl2RasterStatisticsPtr section_stats)
   752    750   {
   753    751   /* INSERTing the tile */
   754    752       int ret;
   755    753       sqlite3_int64 tile_id;
   756    754       rl2RasterStatisticsPtr stats = NULL;
   757    755   
................................................................................
  1001    999   }
  1002   1000   
  1003   1001   RL2_PRIVATE int
  1004   1002   rl2_do_insert_section (sqlite3 * handle, const char *src_path,
  1005   1003   		       const char *section, int srid, unsigned int width,
  1006   1004   		       unsigned int height, double minx, double miny,
  1007   1005   		       double maxx, double maxy, char *xml_summary,
  1008         -		       int section_paths, int section_md5,
  1009         -		       int section_summary, sqlite3_stmt * stmt_sect,
  1010         -		       sqlite3_int64 * id)
         1006  +		       int section_paths, int section_md5, int section_summary,
         1007  +		       sqlite3_stmt * stmt_sect, sqlite3_int64 * id)
  1011   1008   {
  1012   1009   /* INSERTing the section */
  1013   1010       int ret;
  1014   1011       unsigned char *blob;
  1015   1012       int blob_size;
  1016   1013       sqlite3_int64 section_id;
  1017   1014   
................................................................................
  1054   1051         {
  1055   1052   	  sqlite3_bind_null (stmt_sect, 4);
  1056   1053   	  if (xml_summary != NULL)
  1057   1054   	      free (xml_summary);
  1058   1055         }
  1059   1056       sqlite3_bind_int (stmt_sect, 5, width);
  1060   1057       sqlite3_bind_int (stmt_sect, 6, height);
  1061         -    if (rl2_build_bbox
  1062         -	(handle, srid, minx, miny, maxx, maxy, &blob, &blob_size) != RL2_OK)
         1058  +    if (rl2_build_bbox (handle, srid, minx, miny, maxx, maxy, &blob, &blob_size)
         1059  +	!= RL2_OK)
  1063   1060   	goto error;
  1064   1061       sqlite3_bind_blob (stmt_sect, 7, blob, blob_size, free);
  1065   1062       ret = sqlite3_step (stmt_sect);
  1066   1063       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1067   1064   	section_id = sqlite3_last_insert_rowid (handle);
  1068   1065       else
  1069   1066         {
................................................................................
  1216   1213       int blob_odd_sz;
  1217   1214       unsigned char *blob_even;
  1218   1215       int blob_even_sz;
  1219   1216       rl2RasterPtr raster = NULL;
  1220   1217       double base_res_x;
  1221   1218       double base_res_y;
  1222   1219   
  1223         -    if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y)
  1224         -	!= RL2_OK)
         1220  +    if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y) !=
         1221  +	RL2_OK)
  1225   1222   	goto error;
  1226   1223       if (*first)
  1227   1224         {
  1228   1225   	  /* INSERTing the section */
  1229   1226   	  *first = 0;
  1230   1227   	  if (!rl2_do_insert_section
  1231   1228   	      (ptr->sqlite, "WMS Service", ptr->sect_name, ptr->srid,
  1232   1229   	       ptr->width, ptr->height, ptr->minx, ptr->miny, ptr->maxx,
  1233         -	       ptr->maxy, ptr->xml_summary, ptr->sectionPaths,
  1234         -	       ptr->sectionMD5, ptr->sectionSummary, ptr->stmt_sect,
  1235         -	       section_id))
         1230  +	       ptr->maxy, ptr->xml_summary, ptr->sectionPaths, ptr->sectionMD5,
         1231  +	       ptr->sectionSummary, ptr->stmt_sect, section_id))
  1236   1232   	      goto error;
  1237   1233   	  *section_stats =
  1238   1234   	      rl2_create_raster_statistics (ptr->sample_type, ptr->num_bands);
  1239   1235   	  if (*section_stats == NULL)
  1240   1236   	      goto error;
  1241   1237   	  /* INSERTing the base-levels */
  1242   1238   	  if (ptr->mixedResolutions)
................................................................................
  1275   1271       /* INSERTing the tile */
  1276   1272       tile_minx = ptr->x;
  1277   1273       tile_maxx = tile_minx + ptr->tilew;
  1278   1274       tile_maxy = ptr->y;
  1279   1275       tile_miny = tile_maxy - ptr->tileh;
  1280   1276       if (!do_insert_wms_tile
  1281   1277   	(ptr->sqlite, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  1282         -	 *section_id, ptr->srid, ptr->horz_res, ptr->vert_res,
  1283         -	 ptr->tile_width, ptr->tile_height, ptr->miny, ptr->maxx, tile_minx,
  1284         -	 tile_miny, tile_maxx, tile_maxy, NULL, ptr->no_data, ptr->stmt_tils,
         1278  +	 *section_id, ptr->srid, ptr->horz_res, ptr->vert_res, ptr->tile_width,
         1279  +	 ptr->tile_height, ptr->miny, ptr->maxx, tile_minx, tile_miny,
         1280  +	 tile_maxx, tile_maxy, NULL, ptr->no_data, ptr->stmt_tils,
  1285   1281   	 ptr->stmt_data, *section_stats))
  1286   1282   	goto error;
  1287   1283       blob_odd = NULL;
  1288   1284       blob_even = NULL;
  1289   1285       rl2_destroy_raster (raster);
  1290   1286       free (ptr->rgba_tile);
  1291   1287       ptr->rgba_tile = NULL;
................................................................................
  1405   1401   	  xxcoverage = rl2_double_quoted_sql (xcoverage);
  1406   1402   	  sqlite3_free (xcoverage);
  1407   1403   	  sql =
  1408   1404   	      sqlite3_mprintf
  1409   1405   	      ("SELECT pyramid_level, x_resolution_1_8, y_resolution_1_8, "
  1410   1406   	       "x_resolution_1_4, y_resolution_1_4, x_resolution_1_2, y_resolution_1_2, "
  1411   1407   	       "x_resolution_1_1, y_resolution_1_1 FROM \"%s\" "
  1412         -	       "WHERE section_id = %s ORDER BY pyramid_level DESC",
  1413         -	       xxcoverage, sctn);
         1408  +	       "WHERE section_id = %s ORDER BY pyramid_level DESC", xxcoverage,
         1409  +	       sctn);
  1414   1410         }
  1415   1411       else
  1416   1412         {
  1417   1413   	  /* ordinary Coverage */
  1418   1414   	  xcoverage = sqlite3_mprintf ("%s_levels", coverage);
  1419   1415   	  xxcoverage = rl2_double_quoted_sql (xcoverage);
  1420   1416   	  sqlite3_free (xcoverage);
................................................................................
  1616   1612   	    }
  1617   1613         }
  1618   1614       return rgba;
  1619   1615   }
  1620   1616   
  1621   1617   RL2_PRIVATE int
  1622   1618   get_payload_from_monochrome_opaque (unsigned int width, unsigned int height,
  1623         -				    sqlite3 * handle, double minx,
  1624         -				    double miny, double maxx, double maxy,
  1625         -				    int srid, unsigned char *pixels,
  1626         -				    unsigned char format, int quality,
  1627         -				    unsigned char **image, int *image_sz)
         1619  +				    sqlite3 * handle, double minx, double miny,
         1620  +				    double maxx, double maxy, int srid,
         1621  +				    unsigned char *pixels, unsigned char format,
         1622  +				    int quality, unsigned char **image,
         1623  +				    int *image_sz)
  1628   1624   {
  1629   1625   /* input: Monochrome    output: Grayscale */
  1630   1626       int ret;
  1631   1627       unsigned char *p_in;
  1632   1628       unsigned char *p_out;
  1633   1629       unsigned char *gray = NULL;
  1634   1630       unsigned int row;
................................................................................
  1664   1660   	      goto error;
  1665   1661         }
  1666   1662       else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1667   1663         {
  1668   1664   	  if (srid > 0)
  1669   1665   	    {
  1670   1666   		if (rl2_gray_to_geotiff
  1671         -		    (width, height, handle, minx, miny, maxx, maxy, srid,
  1672         -		     gray, image, image_sz) != RL2_OK)
         1667  +		    (width, height, handle, minx, miny, maxx, maxy, srid, gray,
         1668  +		     image, image_sz) != RL2_OK)
  1673   1669   		    goto error;
  1674   1670   	    }
  1675   1671   	  else
  1676   1672   	    {
  1677   1673   		if (rl2_gray_to_tiff (width, height, gray, image, image_sz) !=
  1678   1674   		    RL2_OK)
  1679   1675   		    goto error;
................................................................................
  1833   1829   		    goto error;
  1834   1830   	    }
  1835   1831   	  else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1836   1832   	    {
  1837   1833   		if (srid > 0)
  1838   1834   		  {
  1839   1835   		      if (rl2_rgb_to_geotiff
  1840         -			  (width, height, handle, minx, miny, maxx, maxy,
  1841         -			   srid, rgb, image, image_sz) != RL2_OK)
         1836  +			  (width, height, handle, minx, miny, maxx, maxy, srid,
         1837  +			   rgb, image, image_sz) != RL2_OK)
  1842   1838   			  goto error;
  1843   1839   		  }
  1844   1840   		else
  1845   1841   		  {
  1846         -		      if (rl2_rgb_to_tiff
  1847         -			  (width, height, rgb, image, image_sz) != RL2_OK)
         1842  +		      if (rl2_rgb_to_tiff (width, height, rgb, image, image_sz)
         1843  +			  != RL2_OK)
  1848   1844   			  goto error;
  1849   1845   		  }
  1850   1846   	    }
  1851   1847   	  else if (format == RL2_OUTPUT_FORMAT_PDF)
  1852   1848   	    {
  1853   1849   		rgba = rgb_to_rgba (width, height, rgb);
  1854   1850   		if (rgba == NULL)
................................................................................
  1896   1892   		    goto error;
  1897   1893   	    }
  1898   1894   	  else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1899   1895   	    {
  1900   1896   		if (srid > 0)
  1901   1897   		  {
  1902   1898   		      if (rl2_gray_to_geotiff
  1903         -			  (width, height, handle, minx, miny, maxx, maxy,
  1904         -			   srid, gray, image, image_sz) != RL2_OK)
         1899  +			  (width, height, handle, minx, miny, maxx, maxy, srid,
         1900  +			   gray, image, image_sz) != RL2_OK)
  1905   1901   			  goto error;
  1906   1902   		  }
  1907   1903   		else
  1908   1904   		  {
  1909   1905   		      if (rl2_gray_to_tiff
  1910   1906   			  (width, height, gray, image, image_sz) != RL2_OK)
  1911   1907   			  goto error;
................................................................................
  2074   2070       return 0;
  2075   2071   }
  2076   2072   
  2077   2073   RL2_PRIVATE int
  2078   2074   get_payload_from_grayscale_opaque (unsigned int width, unsigned int height,
  2079   2075   				   sqlite3 * handle, double minx, double miny,
  2080   2076   				   double maxx, double maxy, int srid,
  2081         -				   unsigned char *pixels,
  2082         -				   unsigned char format, int quality,
  2083         -				   unsigned char **image, int *image_sz)
         2077  +				   unsigned char *pixels, unsigned char format,
         2078  +				   int quality, unsigned char **image,
         2079  +				   int *image_sz)
  2084   2080   {
  2085   2081   /* input: Grayscale    output: Grayscale */
  2086   2082       int ret;
  2087   2083       unsigned char *rgba = NULL;
  2088   2084   
  2089   2085       if (format == RL2_OUTPUT_FORMAT_JPEG)
  2090   2086         {
  2091         -	  if (rl2_gray_to_jpeg
  2092         -	      (width, height, pixels, quality, image, image_sz) != RL2_OK)
         2087  +	  if (rl2_gray_to_jpeg (width, height, pixels, quality, image, image_sz)
         2088  +	      != RL2_OK)
  2093   2089   	      goto error;
  2094   2090         }
  2095   2091       else if (format == RL2_OUTPUT_FORMAT_PNG)
  2096   2092         {
  2097   2093   	  if (rl2_gray_to_png (width, height, pixels, image, image_sz) !=
  2098   2094   	      RL2_OK)
  2099   2095   	      goto error;
................................................................................
  2105   2101   		if (rl2_gray_to_geotiff
  2106   2102   		    (width, height, handle, minx, miny, maxx, maxy, srid,
  2107   2103   		     pixels, image, image_sz) != RL2_OK)
  2108   2104   		    goto error;
  2109   2105   	    }
  2110   2106   	  else
  2111   2107   	    {
  2112         -		if (rl2_gray_to_tiff (width, height, pixels, image, image_sz)
  2113         -		    != RL2_OK)
         2108  +		if (rl2_gray_to_tiff (width, height, pixels, image, image_sz) !=
         2109  +		    RL2_OK)
  2114   2110   		    goto error;
  2115   2111   	    }
  2116   2112         }
  2117   2113       else if (format == RL2_OUTPUT_FORMAT_PDF)
  2118   2114         {
  2119   2115   	  rgba = gray_to_rgba (width, height, pixels);
  2120   2116   	  if (rgba == NULL)
................................................................................
  2196   2192   {
  2197   2193   /* input: RGB    output: RGB */
  2198   2194       int ret;
  2199   2195       unsigned char *rgba = NULL;
  2200   2196   
  2201   2197       if (format == RL2_OUTPUT_FORMAT_JPEG)
  2202   2198         {
  2203         -	  if (rl2_rgb_to_jpeg
  2204         -	      (width, height, pixels, quality, image, image_sz) != RL2_OK)
         2199  +	  if (rl2_rgb_to_jpeg (width, height, pixels, quality, image, image_sz)
         2200  +	      != RL2_OK)
  2205   2201   	      goto error;
  2206   2202         }
  2207   2203       else if (format == RL2_OUTPUT_FORMAT_PNG)
  2208   2204         {
  2209   2205   	  if (rl2_rgb_to_png (width, height, pixels, image, image_sz) != RL2_OK)
  2210   2206   	      goto error;
  2211   2207         }
................................................................................
  2216   2212   		if (rl2_rgb_to_geotiff
  2217   2213   		    (width, height, handle, minx, miny, maxx, maxy, srid,
  2218   2214   		     pixels, image, image_sz) != RL2_OK)
  2219   2215   		    goto error;
  2220   2216   	    }
  2221   2217   	  else
  2222   2218   	    {
  2223         -		if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz)
  2224         -		    != RL2_OK)
         2219  +		if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz) !=
         2220  +		    RL2_OK)
  2225   2221   		    goto error;
  2226   2222   	    }
  2227   2223         }
  2228   2224       else if (format == RL2_OUTPUT_FORMAT_PDF)
  2229   2225         {
  2230   2226   	  rgba = rgb_to_rgba (width, height, pixels);
  2231   2227   	  if (rgba == NULL)
................................................................................
  2248   2244   }
  2249   2245   
  2250   2246   RL2_PRIVATE int
  2251   2247   get_payload_from_rgb_transparent (unsigned int width, unsigned int height,
  2252   2248   				  unsigned char *pixels, unsigned char format,
  2253   2249   				  int quality, unsigned char **image,
  2254   2250   				  int *image_sz, unsigned char bg_red,
  2255         -				  unsigned char bg_green,
  2256         -				  unsigned char bg_blue, double opacity)
         2251  +				  unsigned char bg_green, unsigned char bg_blue,
         2252  +				  double opacity)
  2257   2253   {
  2258   2254   /* input: RGB    output: RGB */
  2259   2255       unsigned char *p_in;
  2260   2256       unsigned char *p_msk;
  2261   2257       unsigned char *mask = NULL;
  2262   2258       unsigned int row;
  2263   2259       unsigned int col;
................................................................................
  2525   2521   				 unsigned char *pixels, unsigned char *rgba)
  2526   2522   {
  2527   2523   /* input: Monochrome    output: Grayscale */
  2528   2524       unsigned char *p_in;
  2529   2525       unsigned char *p_out;
  2530   2526       unsigned int row;
  2531   2527       unsigned int col;
  2532         -
  2533   2528       p_in = pixels;
  2534   2529       p_out = rgba;
  2535   2530       for (row = 0; row < height; row++)
  2536   2531         {
  2537   2532   	  for (col = 0; col < width; col++)
  2538   2533   	    {
  2539         -		if (*p_in++ == 0)
         2534  +		if (*p_in++ == 1)
  2540   2535   		  {
  2541   2536   		      *p_out++ = 0;	/* Black */
  2542   2537   		      *p_out++ = 0;
  2543   2538   		      *p_out++ = 0;
  2544   2539   		      *p_out++ = 255;	/* alpha */
  2545   2540   		  }
  2546   2541   		else
................................................................................
  2570   2565   
  2571   2566       p_in = pixels;
  2572   2567       p_out = rgba;
  2573   2568       for (row = 0; row < height; row++)
  2574   2569         {
  2575   2570   	  for (col = 0; col < width; col++)
  2576   2571   	    {
  2577         -		if (*p_in++ == 0)
         2572  +		if (*p_in++ == 1)
  2578   2573   		  {
  2579   2574   		      *p_out++ = 0;	/* Black */
  2580   2575   		      *p_out++ = 0;
  2581   2576   		      *p_out++ = 0;
  2582   2577   		      *p_out++ = 255;	/* alpha */
  2583   2578   		  }
  2584   2579   		else
................................................................................
  2773   2768     error:
  2774   2769       free (pixels);
  2775   2770       return 0;
  2776   2771   }
  2777   2772   
  2778   2773   RL2_PRIVATE int
  2779   2774   get_rgba_from_palette_transparent (unsigned int width, unsigned int height,
  2780         -				   unsigned char *pixels,
  2781         -				   rl2PalettePtr palette, unsigned char *rgba,
  2782         -				   unsigned char bg_red,
         2775  +				   unsigned char *pixels, rl2PalettePtr palette,
         2776  +				   unsigned char *rgba, unsigned char bg_red,
  2783   2777   				   unsigned char bg_green,
  2784   2778   				   unsigned char bg_blue)
  2785   2779   {
  2786   2780   /* input: Palette    output: Grayscale or RGB */
  2787   2781       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette;
  2788   2782       unsigned char *p_in;
  2789   2783       unsigned char *p_out;
................................................................................
  2931   2925       free (pixels);
  2932   2926       return 1;
  2933   2927   }
  2934   2928   
  2935   2929   RL2_PRIVATE int
  2936   2930   get_rgba_from_grayscale_transparent (unsigned int width,
  2937   2931   				     unsigned int height,
  2938         -				     unsigned char *pixels,
  2939         -				     unsigned char *rgba, unsigned char bg_gray)
         2932  +				     unsigned char *pixels, unsigned char *rgba,
         2933  +				     unsigned char bg_gray)
  2940   2934   {
  2941   2935   /* input: Grayscale    output: Grayscale */
  2942   2936       unsigned char *p_in;
  2943   2937       unsigned char *p_out;
  2944   2938       unsigned int row;
  2945   2939       unsigned int col;
  2946   2940   
................................................................................
  3894   3888       if (mask != NULL)
  3895   3889   	free (mask);
  3896   3890       return 1;
  3897   3891   }
  3898   3892   
  3899   3893   RL2_PRIVATE int
  3900   3894   rgba_from_double (unsigned int width, unsigned int height,
  3901         -		  double *pixels, unsigned char *mask,
  3902         -		  rl2PrivPixelPtr no_data, unsigned char *rgba)
         3895  +		  double *pixels, unsigned char *mask, rl2PrivPixelPtr no_data,
         3896  +		  unsigned char *rgba)
  3903   3897   {
  3904   3898   /* input: DataGrid DOUBLE   output: Grayscale */
  3905   3899       double *p_in;
  3906   3900       unsigned char *p_out;
  3907   3901       unsigned char *p_msk;
  3908   3902       unsigned int row;
  3909   3903       unsigned int col;
................................................................................
  4065   4059         case RL2_SAMPLE_INT16:
  4066   4060   	  ret =
  4067   4061   	      rgba_from_int16 (width, height, (short *) pixels, mask, no_data,
  4068   4062   			       rgba);
  4069   4063   	  break;
  4070   4064         case RL2_SAMPLE_UINT16:
  4071   4065   	  ret =
  4072         -	      rgba_from_uint16 (width, height, (unsigned short *) pixels,
  4073         -				mask, no_data, rgba);
         4066  +	      rgba_from_uint16 (width, height, (unsigned short *) pixels, mask,
         4067  +				no_data, rgba);
  4074   4068   	  break;
  4075   4069         case RL2_SAMPLE_INT32:
  4076   4070   	  ret =
  4077   4071   	      rgba_from_int32 (width, height, (int *) pixels, mask, no_data,
  4078   4072   			       rgba);
  4079   4073   	  break;
  4080   4074         case RL2_SAMPLE_UINT32:
................................................................................
  4085   4079         case RL2_SAMPLE_FLOAT:
  4086   4080   	  ret =
  4087   4081   	      rgba_from_float (width, height, (float *) pixels, mask, no_data,
  4088   4082   			       rgba);
  4089   4083   	  break;
  4090   4084         case RL2_SAMPLE_DOUBLE:
  4091   4085   	  ret =
  4092         -	      rgba_from_double (width, height, (double *) pixels, mask,
  4093         -				no_data, rgba);
         4086  +	      rgba_from_double (width, height, (double *) pixels, mask, no_data,
         4087  +				rgba);
  4094   4088   	  break;
  4095   4089         };
  4096   4090       return ret;
  4097   4091   }
  4098   4092   
  4099   4093   RL2_PRIVATE int
  4100   4094   rgba_from_multi_uint8 (unsigned int width, unsigned int height,
................................................................................
  4311   4305   	      rgba_from_multi_uint8 (width, height, num_bands,
  4312   4306   				     (unsigned char *) pixels, mask, no_data,
  4313   4307   				     rgba);
  4314   4308   	  break;
  4315   4309         case RL2_SAMPLE_UINT16:
  4316   4310   	  ret =
  4317   4311   	      rgba_from_multi_uint16 (width, height, num_bands,
  4318         -				      (unsigned short *) pixels, mask,
  4319         -				      no_data, rgba);
         4312  +				      (unsigned short *) pixels, mask, no_data,
         4313  +				      rgba);
  4320   4314   	  break;
  4321   4315         };
  4322   4316       return ret;
  4323   4317   }
  4324   4318   
  4325   4319   RL2_PRIVATE int
  4326   4320   get_payload_from_gray_rgba_opaque (unsigned int width, unsigned int height,
................................................................................
  4363   4357   	      goto error;
  4364   4358         }
  4365   4359       else if (format == RL2_OUTPUT_FORMAT_TIFF)
  4366   4360         {
  4367   4361   	  if (srid > 0)
  4368   4362   	    {
  4369   4363   		if (rl2_gray_to_geotiff
  4370         -		    (width, height, handle, minx, miny, maxx, maxy, srid,
  4371         -		     gray, image, image_sz) != RL2_OK)
         4364  +		    (width, height, handle, minx, miny, maxx, maxy, srid, gray,
         4365  +		     image, image_sz) != RL2_OK)
  4372   4366   		    goto error;
  4373   4367   	    }
  4374   4368   	  else
  4375   4369   	    {
  4376   4370   		if (rl2_gray_to_tiff (width, height, gray, image, image_sz) !=
  4377   4371   		    RL2_OK)
  4378   4372   		    goto error;
................................................................................
  4470   4464   {
  4471   4465   /* RGB, Opaque */
  4472   4466       int ret;
  4473   4467       unsigned char *rgba = NULL;
  4474   4468   
  4475   4469       if (format == RL2_OUTPUT_FORMAT_JPEG)
  4476   4470         {
  4477         -	  if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz)
  4478         -	      != RL2_OK)
         4471  +	  if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz) !=
         4472  +	      RL2_OK)
  4479   4473   	      goto error;
  4480   4474         }
  4481   4475       else if (format == RL2_OUTPUT_FORMAT_PNG)
  4482   4476         {
  4483   4477   	  if (rl2_rgb_to_png (width, height, rgb, image, image_sz) != RL2_OK)
  4484   4478   	      goto error;
  4485   4479         }
................................................................................
  4517   4511   	free (rgba);
  4518   4512       return 0;
  4519   4513   }
  4520   4514   
  4521   4515   RL2_PRIVATE int
  4522   4516   get_payload_from_rgb_rgba_transparent (unsigned int width,
  4523   4517   				       unsigned int height,
  4524         -				       unsigned char *rgb,
  4525         -				       unsigned char *alpha,
         4518  +				       unsigned char *rgb, unsigned char *alpha,
  4526   4519   				       unsigned char format, int quality,
  4527   4520   				       unsigned char **image, int *image_sz,
  4528   4521   				       double opacity, int half_transparency)
  4529   4522   {
  4530   4523   /* RGB, Transparent */
  4531   4524       int ret;
  4532   4525       unsigned char *p_msk;

Changes to src/rl2svg.c.

   227    227   		pattern =
   228    228   		    cairo_pattern_create_linear (grad->x1, grad->y1, grad->x2,
   229    229   						 grad->y2);
   230    230   		svg_apply_gradient_transformations (pattern, grad);
   231    231   		stop = grad->first_stop;
   232    232   		while (stop)
   233    233   		  {
   234         -		      cairo_pattern_add_color_stop_rgba (pattern,
   235         -							 stop->offset,
   236         -							 stop->red,
   237         -							 stop->green,
          234  +		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
          235  +							 stop->red, stop->green,
   238    236   							 stop->blue,
   239    237   							 stop->opacity *
   240    238   							 style->opacity);
   241    239   		      stop = stop->next;
   242    240   		  }
   243    241   		cairo_set_source (cairo, pattern);
   244    242   		cairo_set_line_cap (cairo, style->stroke_linecap);
................................................................................
   259    257   		pattern =
   260    258   		    cairo_pattern_create_radial (grad->cx, grad->cy, 0.0,
   261    259   						 grad->fx, grad->fy, grad->r);
   262    260   		svg_apply_gradient_transformations (pattern, grad);
   263    261   		stop = grad->first_stop;
   264    262   		while (stop)
   265    263   		  {
   266         -		      cairo_pattern_add_color_stop_rgba (pattern,
   267         -							 stop->offset,
   268         -							 stop->red,
   269         -							 stop->green,
          264  +		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
          265  +							 stop->red, stop->green,
   270    266   							 stop->blue,
   271    267   							 stop->opacity *
   272    268   							 style->opacity);
   273    269   		      stop = stop->next;
   274    270   		  }
   275    271   		cairo_set_source (cairo, pattern);
   276    272   		cairo_set_line_cap (cairo, style->stroke_linecap);
................................................................................
   292    288   			   style->stroke_opacity * style->opacity);
   293    289       cairo_set_line_cap (cairo, style->stroke_linecap);
   294    290       cairo_set_line_join (cairo, style->stroke_linejoin);
   295    291       cairo_set_miter_limit (cairo, style->stroke_miterlimit);
   296    292       if (style->stroke_dashitems == 0 || style->stroke_dasharray == NULL)
   297    293   	cairo_set_dash (cairo, lengths, 0, 0.0);
   298    294       else
   299         -	cairo_set_dash (cairo, style->stroke_dasharray,
   300         -			style->stroke_dashitems, style->stroke_dashoffset);
          295  +	cairo_set_dash (cairo, style->stroke_dasharray, style->stroke_dashitems,
          296  +			style->stroke_dashoffset);
   301    297   }
   302    298   
   303    299   static void
   304    300   svg_set_brush (cairo_t * cairo, rl2PrivSvgStylePtr style)
   305    301   {
   306    302   /* setting up a Brush for Cairo */
   307    303       cairo_pattern_t *pattern;
................................................................................
   314    310   		pattern =
   315    311   		    cairo_pattern_create_linear (grad->x1, grad->y1, grad->x2,
   316    312   						 grad->y2);
   317    313   		svg_apply_gradient_transformations (pattern, grad);
   318    314   		stop = grad->first_stop;
   319    315   		while (stop)
   320    316   		  {
   321         -		      cairo_pattern_add_color_stop_rgba (pattern,
   322         -							 stop->offset,
   323         -							 stop->red,
   324         -							 stop->green,
          317  +		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
          318  +							 stop->red, stop->green,
   325    319   							 stop->blue,
   326    320   							 stop->opacity *
   327    321   							 style->opacity);
   328    322   		      stop = stop->next;
   329    323   		  }
   330    324   		cairo_set_source (cairo, pattern);
   331    325   		cairo_pattern_destroy (pattern);
................................................................................
   336    330   		pattern =
   337    331   		    cairo_pattern_create_radial (grad->cx, grad->cy, 0.0,
   338    332   						 grad->fx, grad->fy, grad->r);
   339    333   		svg_apply_gradient_transformations (pattern, grad);
   340    334   		stop = grad->first_stop;
   341    335   		while (stop)
   342    336   		  {
   343         -		      cairo_pattern_add_color_stop_rgba (pattern,
   344         -							 stop->offset,
   345         -							 stop->red,
   346         -							 stop->green,
          337  +		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
          338  +							 stop->red, stop->green,
   347    339   							 stop->blue,
   348    340   							 stop->opacity *
   349    341   							 style->opacity);
   350    342   		      stop = stop->next;
   351    343   		  }
   352    344   		cairo_set_source (cairo, pattern);
   353    345   		cairo_pattern_destroy (pattern);
................................................................................
   854    846   		bezier = item->data;
   855    847   		cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2,
   856    848   				bezier->y2, bezier->x, bezier->y);
   857    849   		break;
   858    850   	    case RL2_SVG_CURVE_4:
   859    851   		bezier = item->data;
   860    852   		cairo_get_current_point (cairo, &x0, &y0);
   861         -		cairo_curve_to (cairo,
   862         -				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
          853  +		cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
   863    854   				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0,
   864         -				2.0 / 3.0 * bezier->x1 +
   865         -				1.0 / 3.0 * bezier->x2,
   866         -				2.0 / 3.0 * bezier->y1 +
   867         -				1.0 / 3.0 * bezier->y2, bezier->y1, bezier->y2);
          855  +				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2,
          856  +				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2,
          857  +				bezier->y1, bezier->y2);
   868    858   		break;
   869    859   	    case RL2_SVG_ELLIPT_ARC:
   870    860   		arc = item->data;
   871    861   		cairo_get_current_point (cairo, &x0, &y0);
   872    862   		svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation,
   873    863   				  &radii_ratio, &angle1, &angle2);
   874    864   		cairo_save (cairo);
................................................................................
   953    943   		bezier = item->data;
   954    944   		cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2,
   955    945   				bezier->y2, bezier->x, bezier->y);
   956    946   		break;
   957    947   	    case RL2_SVG_CURVE_4:
   958    948   		bezier = item->data;
   959    949   		cairo_get_current_point (cairo, &x0, &y0);
   960         -		cairo_curve_to (cairo,
   961         -				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
          950  +		cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
   962    951   				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0,
   963         -				2.0 / 3.0 * bezier->x1 +
   964         -				1.0 / 3.0 * bezier->x2,
   965         -				2.0 / 3.0 * bezier->y1 +
   966         -				1.0 / 3.0 * bezier->y2, bezier->y1, bezier->y2);
          952  +				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2,
          953  +				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2,
          954  +				bezier->y1, bezier->y2);
   967    955   		break;
   968    956   	    case RL2_SVG_ELLIPT_ARC:
   969    957   		arc = item->data;
   970    958   		cairo_get_current_point (cairo, &x0, &y0);
   971    959   		svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation,
   972    960   				  &radii_ratio, &angle1, &angle2);
   973    961   		cairo_save (cairo);

Changes to src/rl2symbaux.c.

   782    782   
   783    783   static int
   784    784   eval_filter (rl2PrivStyleRulePtr rule, rl2VariantArrayPtr variant)
   785    785   {
   786    786   /* evaluating a Rule Filter */
   787    787       int i;
   788    788       rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant;
   789         -    if (rule->column_name == NULL)
   790         -	return 1;		/* there is no comparison: surely true */
   791         -    if (var == NULL)
   792         -	return 0;
          789  +    if (rule == NULL || var == NULL)
          790  +	return 1;
   793    791       for (i = 0; i < var->count; i++)
   794    792         {
   795    793   	  rl2PrivVariantValuePtr val = *(var->array + i);
   796    794   	  if (val == NULL)
   797    795   	      return 0;
   798         -	  if (val->column_name == NULL)
          796  +	  if (rule->column_name == NULL || val->column_name == NULL)
   799    797   	      return 0;
   800    798   	  if (strcasecmp (rule->column_name, val->column_name) != 0)
   801    799   	      continue;
   802    800   	  switch (rule->comparison_op)
   803    801   	    {
   804    802   	    case RL2_COMPARISON_EQ:
   805    803   		return eval_filter_eq (rule, val);
................................................................................
   826    824         }
   827    825       return 0;
   828    826   }
   829    827   
   830    828   RL2_DECLARE rl2VectorSymbolizerPtr
   831    829   rl2_get_symbolizer_from_feature_type_style (rl2FeatureTypeStylePtr style,
   832    830   					    double scale,
   833         -					    rl2VariantArrayPtr variant,
   834         -					    int *scale_forbidden)
          831  +					    rl2VariantArrayPtr variant, int *scale_forbidden)
   835    832   {
   836    833   /* return the VectorSymbolizer matching a given scale/filter from a FeatureTypeStyle */
   837    834       rl2PrivVectorSymbolizerPtr symbolizer = NULL;
   838    835       rl2PrivStyleRulePtr pR;
   839    836       rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style;
   840    837       *scale_forbidden = 0;
   841    838       if (stl == NULL)
................................................................................
   848    845   	      ;
   849    846   	  else
   850    847   	    {
   851    848   		/* skipping any invalid rule */
   852    849   		pR = pR->next;
   853    850   		continue;
   854    851   	    }
   855         -
   856    852   	  if (eval_filter (pR, variant))
   857    853   	    {
   858         -		*scale_forbidden = 0;
   859    854   		if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX)
   860    855   		  {
   861    856   		      if (scale >= pR->min_scale && scale < pR->max_scale)
   862    857   			  symbolizer = pR->style;
   863    858   		  }
   864    859   		else if (pR->min_scale != DBL_MAX)
   865    860   		  {
................................................................................
   869    864   		else if (pR->max_scale != DBL_MAX)
   870    865   		  {
   871    866   		      if (scale < pR->max_scale)
   872    867   			  symbolizer = pR->style;
   873    868   		  }
   874    869   		else
   875    870   		    symbolizer = pR->style;
   876         -		if (symbolizer == NULL)
          871  +		    if (symbolizer == NULL)
   877    872   		    *scale_forbidden = 1;
   878         -		else
   879         -		    return (rl2VectorSymbolizerPtr) symbolizer;
          873  +		return (rl2VectorSymbolizerPtr) symbolizer;
   880    874   	    }
   881    875   	  pR = pR->next;
   882    876         }
   883    877       if (stl->else_rule != NULL)
   884    878         {
   885    879   	  /* applyhing the ELSE rule */
   886         -	  *scale_forbidden = 0;
   887    880   	  pR = stl->else_rule;
   888    881   	  if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX)
   889    882   	    {
   890    883   		if (scale >= pR->min_scale && scale < pR->max_scale)
   891    884   		    symbolizer = pR->style;
   892    885   	    }
   893    886   	  else if (pR->min_scale != DBL_MAX)
................................................................................
   898    891   	  else if (pR->max_scale != DBL_MAX)
   899    892   	    {
   900    893   		if (scale < pR->max_scale)
   901    894   		    symbolizer = pR->style;
   902    895   	    }
   903    896   	  else
   904    897   	      symbolizer = pR->style;
   905         -	  if (symbolizer == NULL)
   906         -	      *scale_forbidden = 1;
          898  +		    if (symbolizer == NULL)
          899  +		    *scale_forbidden = 1;
   907    900         }
   908    901       return (rl2VectorSymbolizerPtr) symbolizer;
   909    902   }
   910    903   
   911    904   RL2_DECLARE int
   912    905   rl2_is_visible_style (rl2FeatureTypeStylePtr style, double scale)
   913    906   {
................................................................................
   914    907   /* test visibility at a given scale/filter from a FeatureTypeStyle */
   915    908       int count = 0;
   916    909       int visible;
   917    910       rl2PrivStyleRulePtr pR;
   918    911       rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style;
   919    912       if (stl == NULL)
   920    913   	return 0;
   921         -    if (stl->first_rule == NULL)
   922         -      {
   923         -	  /* there are no rules: unconditional visibility */
   924         -	  return 1;
   925         -      }
   926    914   
   927    915       pR = stl->first_rule;
   928    916       while (pR != NULL)
   929    917         {
   930    918   	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
   931    919   	      ;
   932    920   	  else
................................................................................
  1114   1102   	    {
  1115   1103   		/* Interpolate Color Map */
  1116   1104   		*selected = 1;
  1117   1105   		*categorize = 0;
  1118   1106   		*interpolate = 1;
  1119   1107   		return RL2_OK;
  1120   1108   	    }
  1121         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
  1122         -	      || stl->contrastEnhancement ==
  1123         -	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
  1124         -	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1109  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
         1110  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
         1111  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1125   1112   	    {
  1126   1113   		/* Contrast Enhancement */
  1127   1114   		*selected = 1;
  1128   1115   		*categorize = 0;
  1129   1116   		*interpolate = 0;
  1130   1117   		return RL2_OK;
  1131   1118   	    }
................................................................................
  1184   1171   {
  1185   1172   /* return if the RasterSymbolizer has a TripleBand selection */
  1186   1173       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1187   1174       if (stl == NULL)
  1188   1175   	return RL2_ERROR;
  1189   1176       if (stl->bandSelection == NULL)
  1190   1177         {
  1191         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
  1192         -	      || stl->contrastEnhancement ==
  1193         -	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
  1194         -	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1178  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
         1179  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
         1180  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1195   1181   	    {
  1196   1182   		/* Contrast Enhancement */
  1197   1183   		*selected = 1;
  1198   1184   		return RL2_OK;
  1199   1185   	    }
  1200   1186         }
  1201   1187       if (stl->bandSelection == NULL)
................................................................................
  1215   1201   {
  1216   1202   /* return the RasterSymbolizer TripleBand selection */
  1217   1203       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1218   1204       if (stl == NULL)
  1219   1205   	return RL2_ERROR;
  1220   1206       if (stl->bandSelection == NULL)
  1221   1207         {
  1222         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
  1223         -	      || stl->contrastEnhancement ==
  1224         -	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
  1225         -	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1208  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
         1209  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
         1210  +	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1226   1211   	    {
  1227   1212   		/* Contrast Enhancement */
  1228   1213   		*red_band = 0;
  1229   1214   		*green_band = 1;
  1230   1215   		*blue_band = 2;
  1231   1216   		return RL2_OK;
  1232   1217   	    }
................................................................................
  1257   1242   	return RL2_ERROR;
  1258   1243       *contrast_enhancement = stl->contrastEnhancement;
  1259   1244       *gamma_value = stl->gammaValue;
  1260   1245       return RL2_OK;
  1261   1246   }
  1262   1247   
  1263   1248   RL2_DECLARE int
  1264         -    rl2_get_raster_symbolizer_red_band_contrast_enhancement
  1265         -    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
  1266         -     double *gamma_value)
         1249  +rl2_get_raster_symbolizer_red_band_contrast_enhancement (rl2RasterSymbolizerPtr
         1250  +							 style,
         1251  +							 unsigned char
         1252  +							 *contrast_enhancement,
         1253  +							 double *gamma_value)
  1267   1254   {
  1268   1255   /* return the RasterSymbolizer RedBand ContrastEnhancement */
  1269   1256       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1270   1257       if (stl == NULL)
  1271   1258   	return RL2_ERROR;
  1272   1259       if (stl->bandSelection == NULL)
  1273   1260   	return RL2_ERROR;
................................................................................
  1297   1284   	  *gamma_value = stl->bandSelection->greenGamma;
  1298   1285   	  return RL2_OK;
  1299   1286         }
  1300   1287       return RL2_ERROR;
  1301   1288   }
  1302   1289   
  1303   1290   RL2_DECLARE int
  1304         -    rl2_get_raster_symbolizer_blue_band_contrast_enhancement
  1305         -    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
  1306         -     double *gamma_value)
         1291  +rl2_get_raster_symbolizer_blue_band_contrast_enhancement (rl2RasterSymbolizerPtr
         1292  +							  style,
         1293  +							  unsigned char
         1294  +							  *contrast_enhancement,
         1295  +							  double *gamma_value)
  1307   1296   {
  1308   1297   /* return the RasterSymbolizer BlueBand ContrastEnhancement */
  1309   1298       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1310   1299       if (stl == NULL)
  1311   1300   	return RL2_ERROR;
  1312   1301       if (stl->bandSelection == NULL)
  1313   1302   	return RL2_ERROR;
................................................................................
  1317   1306   	  *gamma_value = stl->bandSelection->blueGamma;
  1318   1307   	  return RL2_OK;
  1319   1308         }
  1320   1309       return RL2_ERROR;
  1321   1310   }
  1322   1311   
  1323   1312   RL2_DECLARE int
  1324         -    rl2_get_raster_symbolizer_gray_band_contrast_enhancement
  1325         -    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
  1326         -     double *gamma_value)
         1313  +rl2_get_raster_symbolizer_gray_band_contrast_enhancement (rl2RasterSymbolizerPtr
         1314  +							  style,
         1315  +							  unsigned char
         1316  +							  *contrast_enhancement,
         1317  +							  double *gamma_value)
  1327   1318   {
  1328   1319   /* return the RasterSymbolizer GrayBand ContrastEnhancement */
  1329   1320       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1330   1321       if (stl == NULL)
  1331   1322   	return RL2_ERROR;
  1332   1323       if (stl->bandSelection == NULL)
  1333   1324   	return RL2_ERROR;
................................................................................
  1367   1358   	  *relief_factor = stl->reliefFactor;
  1368   1359   	  return RL2_OK;
  1369   1360         }
  1370   1361       return RL2_ERROR;
  1371   1362   }
  1372   1363   
  1373   1364   RL2_DECLARE int
  1374         -rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr
  1375         -						  style, int *interpolated)
         1365  +rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr style,
         1366  +						  int *interpolated)
  1376   1367   {
  1377   1368   /* return if the RasterSymbolizer has an Interpolated ColorMap */
  1378   1369       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1379   1370       if (stl == NULL)
  1380   1371   	return RL2_ERROR;
  1381   1372       if (stl->interpolate != NULL)
  1382   1373   	*interpolated = 1;
................................................................................
  1424   1415   	  *blue = stl->categorize->dfltBlue;
  1425   1416   	  return RL2_OK;
  1426   1417         }
  1427   1418       return RL2_ERROR;
  1428   1419   }
  1429   1420   
  1430   1421   RL2_DECLARE int
  1431         -rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr
  1432         -						   style, unsigned char *red,
         1422  +rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr style,
         1423  +						   unsigned char *red,
  1433   1424   						   unsigned char *green,
  1434   1425   						   unsigned char *blue)
  1435   1426   {
  1436   1427   /* return the RasterSymbolizer ColorMap Category base-color */
  1437   1428       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1438   1429       if (stl == NULL)
  1439   1430   	return RL2_ERROR;
................................................................................
  1586   1577   /* creating a default Graphic object) */
  1587   1578       rl2PrivGraphicPtr graphic = malloc (sizeof (rl2PrivGraphic));
  1588   1579       graphic->first = NULL;
  1589   1580       graphic->last = NULL;
  1590   1581       graphic->opacity = 1.0;
  1591   1582       graphic->size = 10.0;
  1592   1583       graphic->rotation = 0.0;
  1593         -    graphic->anchor_point_x = 0.5;
  1594         -    graphic->anchor_point_y = 0.5;
         1584  +    graphic->anchor_point_x = 0.0;
         1585  +    graphic->anchor_point_y = 0.0;
  1595   1586       graphic->displacement_x = 0.0;
  1596   1587       graphic->displacement_y = 0.0;
  1597   1588       return graphic;
  1598   1589   }
  1599   1590   
  1600   1591   RL2_PRIVATE rl2PrivStrokePtr
  1601   1592   rl2_create_default_stroke ()
................................................................................
  1617   1608   }
  1618   1609   
  1619   1610   RL2_PRIVATE rl2PrivPointPlacementPtr
  1620   1611   rl2_create_default_point_placement ()
  1621   1612   {
  1622   1613   /* creating a default PointPlacement object */
  1623   1614       rl2PrivPointPlacementPtr place = malloc (sizeof (rl2PrivPointPlacement));
  1624         -    place->anchor_point_x = 0.5;
  1625         -    place->anchor_point_y = 0.5;
         1615  +    place->anchor_point_x = 0.0;
         1616  +    place->anchor_point_y = 0.0;
  1626   1617       place->displacement_x = 0.0;
  1627   1618       place->displacement_y = 0.0;
  1628   1619       place->rotation = 0.0;
  1629   1620       return place;
  1630   1621   }
  1631   1622   
  1632   1623   RL2_PRIVATE rl2PrivLinePlacementPtr
................................................................................
  2272   2263       if (sym->stroke->graphic->first->type != RL2_EXTERNAL_GRAPHIC)
  2273   2264   	return NULL;
  2274   2265       ext = (rl2PrivExternalGraphicPtr) (sym->stroke->graphic->first->item);
  2275   2266       return ext->xlink_href;
  2276   2267   }
  2277   2268   
  2278   2269   RL2_DECLARE int
  2279         -    rl2_polygon_symbolizer_get_graphic_stroke_recode_count
  2280         -    (rl2PolygonSymbolizerPtr symbolizer, int *count)
         2270  +rl2_polygon_symbolizer_get_graphic_stroke_recode_count (rl2PolygonSymbolizerPtr
         2271  +							symbolizer, int *count)
  2281   2272   {
  2282   2273   /* return how many ColorReplacement items are in a Graphic Stroke (PolygonSymbolizer) */
  2283   2274       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2284   2275       if (sym == NULL)
  2285   2276   	return RL2_ERROR;
  2286   2277       *count = 0;
  2287   2278       if (sym->stroke != NULL)
................................................................................
  2310   2301   		  }
  2311   2302   	    }
  2312   2303         }
  2313   2304       return RL2_OK;
  2314   2305   }
  2315   2306   
  2316   2307   RL2_DECLARE int
  2317         -    rl2_polygon_symbolizer_get_graphic_stroke_recode_color
  2318         -    (rl2PolygonSymbolizerPtr symbolizer, int index, int *color_index,
  2319         -     unsigned char *red, unsigned char *green, unsigned char *blue)
         2308  +rl2_polygon_symbolizer_get_graphic_stroke_recode_color (rl2PolygonSymbolizerPtr
         2309  +							symbolizer, int index,
         2310  +							int *color_index,
         2311  +							unsigned char *red,
         2312  +							unsigned char *green,
         2313  +							unsigned char *blue)
  2320   2314   {
  2321   2315   /* return a ColorReplacement item from a Graphic Stroke (PolygonSymbolizer) */
  2322   2316       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2323   2317       if (sym == NULL)
  2324   2318   	return RL2_ERROR;
  2325   2319       if (sym->stroke != NULL)
  2326   2320         {
................................................................................
  2401   2395       if (sym->stroke == NULL)
  2402   2396   	return RL2_ERROR;
  2403   2397       *width = sym->stroke->width;
  2404   2398       return RL2_OK;
  2405   2399   }
  2406   2400   
  2407   2401   RL2_DECLARE int
  2408         -rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr
  2409         -					    symbolizer, unsigned char *linejoin)
         2402  +rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr symbolizer,
         2403  +					    unsigned char *linejoin)
  2410   2404   {
  2411   2405   /* return the Polygon Symbolizer Stroke Linejoin mode */
  2412   2406       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2413   2407       if (sym == NULL)
  2414   2408   	return RL2_ERROR;
  2415   2409       if (sym->stroke == NULL)
  2416   2410   	return RL2_ERROR;
................................................................................
  2443   2437       if (sym->stroke == NULL)
  2444   2438   	return RL2_ERROR;
  2445   2439       *count = sym->stroke->dash_count;
  2446   2440       return RL2_OK;
  2447   2441   }
  2448   2442   
  2449   2443   RL2_DECLARE int
  2450         -rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr
  2451         -					     symbolizer, int index,
  2452         -					     double *item)
         2444  +rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr symbolizer,
         2445  +					     int index, double *item)
  2453   2446   {
  2454   2447   /* return a Polygon Symbolizer Stroke Dash item */
  2455   2448       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2456   2449       if (sym == NULL)
  2457   2450   	return RL2_ERROR;
  2458   2451       if (sym->stroke == NULL)
  2459   2452   	return RL2_ERROR;
................................................................................
  3118   3111         }
  3119   3112       return NULL;
  3120   3113   }
  3121   3114   
  3122   3115   RL2_DECLARE int
  3123   3116   rl2_point_symbolizer_get_graphic_recode_color (rl2PointSymbolizerPtr
  3124   3117   					       symbolizer, int index,
  3125         -					       int repl_index,
  3126         -					       int *color_index,
         3118  +					       int repl_index, int *color_index,
  3127   3119   					       unsigned char *red,
  3128   3120   					       unsigned char *green,
  3129   3121   					       unsigned char *blue)
  3130   3122   {
  3131   3123   /* return a ColorReplacement item from an External Graphic (PointSymbolizer) */
  3132   3124       int count = 0;
  3133   3125       rl2PrivExternalGraphicPtr ext;
................................................................................
  3196   3188   	  count++;
  3197   3189   	  item = item->next;
  3198   3190         }
  3199   3191       return RL2_ERROR;
  3200   3192   }
  3201   3193   
  3202   3194   RL2_DECLARE int
  3203         -rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr
  3204         -					       symbolizer, int index,
  3205         -					       unsigned char *type)
         3195  +rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr symbolizer,
         3196  +					       int index, unsigned char *type)
  3206   3197   {
  3207   3198   /* return the Point Symbolizer Mark WellKnownType */
  3208   3199       int count = 0;
  3209   3200       rl2PrivMarkPtr mark;
  3210   3201       rl2PrivGraphicItemPtr item;
  3211   3202       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3212   3203       if (sym == NULL)
................................................................................
  3345   3336   	  count++;
  3346   3337   	  item = item->next;
  3347   3338         }
  3348   3339       return RL2_ERROR;
  3349   3340   }
  3350   3341   
  3351   3342   RL2_DECLARE int
  3352         -rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr
  3353         -					       symbolizer, int index,
         3343  +rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr symbolizer,
         3344  +					       int index,
  3354   3345   					       unsigned char *linejoin)
  3355   3346   {
  3356   3347   /* return the Point Symbolizer Mark Stroke Linejoin mode */
  3357   3348       int count = 0;
  3358   3349       rl2PrivMarkPtr mark;
  3359   3350       rl2PrivGraphicItemPtr item;
  3360   3351       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
................................................................................
  3379   3370   	  count++;
  3380   3371   	  item = item->next;
  3381   3372         }
  3382   3373       return RL2_ERROR;
  3383   3374   }
  3384   3375   
  3385   3376   RL2_DECLARE int
  3386         -rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr
  3387         -					      symbolizer, int index,
  3388         -					      unsigned char *linecap)
         3377  +rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr symbolizer,
         3378  +					      int index, unsigned char *linecap)
  3389   3379   {
  3390   3380   /* return the Point Symbolizer Stroke Mark Linecap mode */
  3391   3381       int count = 0;
  3392   3382       rl2PrivMarkPtr mark;
  3393   3383       rl2PrivGraphicItemPtr item;
  3394   3384       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3395   3385       if (sym == NULL)
................................................................................
  3521   3511   	  count++;
  3522   3512   	  itm = itm->next;
  3523   3513         }
  3524   3514       return RL2_ERROR;
  3525   3515   }
  3526   3516   
  3527   3517   RL2_DECLARE int
  3528         -rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer,
  3529         -				    int index, int *fill)
         3518  +rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer, int index,
         3519  +				    int *fill)
  3530   3520   {
  3531   3521   /* checks if a Point Symbolizer Mark has a Fill */
  3532   3522       int count = 0;
  3533   3523       rl2PrivMarkPtr mark;
  3534   3524       rl2PrivGraphicItemPtr item;
  3535   3525       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3536   3526       if (sym == NULL)
................................................................................
  4204   4194       if (*(var->array + index) != NULL)
  4205   4195   	rl2_destroy_variant_value (*(var->array + index));
  4206   4196       *(var->array + index) = val;
  4207   4197       return RL2_OK;
  4208   4198   }
  4209   4199   
  4210   4200   RL2_DECLARE int
  4211         -rl2_set_variant_double (rl2VariantArrayPtr variant, int index,
  4212         -			const char *name, double value)
         4201  +rl2_set_variant_double (rl2VariantArrayPtr variant, int index, const char *name,
         4202  +			double value)
  4213   4203   {
  4214   4204   /* setting a DOUBLE VariantValue into a VariantArray object */
  4215   4205       rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant;
  4216   4206       rl2PrivVariantValuePtr val;
  4217   4207       if (var == NULL)
  4218   4208   	return RL2_ERROR;
  4219   4209       if (index >= 0 && index < var->count)

Changes to src/rl2symbolizer.c.

   540    540   	  break;
   541    541         };
   542    542       *val = value;
   543    543       return 1;
   544    544   }
   545    545   
   546    546   static int
   547         -parse_sld_se_color (const char *color, unsigned char *red,
   548         -		    unsigned char *green, unsigned char *blue)
          547  +parse_sld_se_color (const char *color, unsigned char *red, unsigned char *green,
          548  +		    unsigned char *blue)
   549    549   {
   550    550   /* attempting to parse a #RRGGBB hexadecimal color */
   551    551       unsigned char r;
   552    552       unsigned char g;
   553    553       unsigned char b;
   554    554       if (strlen (color) != 7)
   555    555   	return 0;
................................................................................
   660    660   					    (color, &red, &green, &blue))
   661    661   					  {
   662    662   					      if (style->categorize->last ==
   663    663   						  NULL)
   664    664   						{
   665    665   						    style->categorize->baseRed =
   666    666   							red;
   667         -						    style->categorize->baseGreen
   668         -							= green;
          667  +						    style->
          668  +							categorize->baseGreen =
          669  +							green;
   669    670   						    style->
   670    671   							categorize->baseBlue =
   671    672   							blue;
   672    673   						}
   673    674   					      else
   674    675   						{
   675    676   						    style->categorize->
................................................................................
   975    976   					  {
   976    977   					      if (text->type == XML_TEXT_NODE)
   977    978   						{
   978    979   						    const char *value =
   979    980   							(const char
   980    981   							 *) (text->content);
   981    982   						    if (value != NULL)
   982         -							style->brightnessOnly
   983         -							    = atoi (value);
          983  +							style->brightnessOnly =
          984  +							    atoi (value);
   984    985   						}
   985    986   					      text = text->next;
   986    987   					  }
   987    988   				    }
   988    989   				  if (strcmp (xmode, "ReliefFactor") == 0)
   989    990   				    {
   990    991   					text = child->children;
................................................................................
  1055   1056   			    if (child->type == XML_ELEMENT_NODE)
  1056   1057   			      {
  1057   1058   				  name = (const char *) (child->name);
  1058   1059   				  if (strcmp (name, "RasterSymbolizer") == 0)
  1059   1060   				    {
  1060   1061   					rl2PrivStyleRulePtr rule =
  1061   1062   					    rl2_create_default_style_rule ();
  1062         -					rl2PrivRasterSymbolizerPtr symbolizer
  1063         -					    =
         1063  +					rl2PrivRasterSymbolizerPtr symbolizer =
  1064   1064   					    rl2_create_default_raster_symbolizer
  1065   1065   					    ();
  1066   1066   					if (symbolizer == NULL || rule == NULL)
  1067   1067   					  {
  1068   1068   					      if (symbolizer != NULL)
  1069   1069   						  rl2_destroy_raster_symbolizer
  1070   1070   						      (symbolizer);
................................................................................
  1372   1372   		      if (child->type == XML_TEXT_NODE
  1373   1373   			  && child->content != NULL)
  1374   1374   			{
  1375   1375   			    unsigned char red;
  1376   1376   			    unsigned char green;
  1377   1377   			    unsigned char blue;
  1378   1378   			    if (parse_sld_se_color
  1379         -				((const char *) (child->content), &red,
  1380         -				 &green, &blue))
         1379  +				((const char *) (child->content), &red, &green,
         1380  +				 &blue))
  1381   1381   			      {
  1382   1382   				  repl->red = red;
  1383   1383   				  repl->green = green;
  1384   1384   				  repl->blue = blue;
  1385   1385   			      }
  1386   1386   			    ok_value = 1;
  1387   1387   			}
................................................................................
  1546   1546   						   &blue))
  1547   1547   						{
  1548   1548   						    mark->stroke->red = red;
  1549   1549   						    mark->stroke->green = green;
  1550   1550   						    mark->stroke->blue = blue;
  1551   1551   						}
  1552   1552   					  }
  1553         -					if (strcmp (svg_name, "stroke-width")
  1554         -					    == 0)
         1553  +					if (strcmp (svg_name, "stroke-width") ==
         1554  +					    0)
  1555   1555   					    mark->stroke->width =
  1556   1556   						atof ((const char *) svg_value);
  1557         -					if (strcmp
  1558         -					    (svg_name, "stroke-linejoin") == 0)
         1557  +					if (strcmp (svg_name, "stroke-linejoin")
         1558  +					    == 0)
  1559   1559   					  {
  1560         -					      if (strcmp (svg_value, "mitre")
  1561         -						  == 0)
         1560  +					      if (strcmp (svg_value, "mitre") ==
         1561  +						  0)
  1562   1562   						  mark->stroke->linejoin =
  1563   1563   						      RL2_STROKE_LINEJOIN_MITRE;
  1564         -					      if (strcmp (svg_value, "round")
  1565         -						  == 0)
         1564  +					      if (strcmp (svg_value, "round") ==
         1565  +						  0)
  1566   1566   						  mark->stroke->linejoin =
  1567   1567   						      RL2_STROKE_LINEJOIN_ROUND;
  1568         -					      if (strcmp (svg_value, "bevel")
  1569         -						  == 0)
         1568  +					      if (strcmp (svg_value, "bevel") ==
         1569  +						  0)
  1570   1570   						  mark->stroke->linejoin =
  1571   1571   						      RL2_STROKE_LINEJOIN_BEVEL;
  1572   1572   					  }
  1573         -					if (strcmp
  1574         -					    (svg_name, "stroke-linecap") == 0)
         1573  +					if (strcmp (svg_name, "stroke-linecap")
         1574  +					    == 0)
  1575   1575   					  {
  1576         -					      if (strcmp (svg_value, "butt")
  1577         -						  == 0)
         1576  +					      if (strcmp (svg_value, "butt") ==
         1577  +						  0)
  1578   1578   						  mark->stroke->linecap =
  1579   1579   						      RL2_STROKE_LINECAP_BUTT;
  1580         -					      if (strcmp (svg_value, "round")
  1581         -						  == 0)
         1580  +					      if (strcmp (svg_value, "round") ==
         1581  +						  0)
  1582   1582   						  mark->stroke->linecap =
  1583   1583   						      RL2_STROKE_LINECAP_ROUND;
  1584   1584   					      if (strcmp (svg_value, "square")
  1585   1585   						  == 0)
  1586   1586   						  mark->stroke->linecap =
  1587   1587   						      RL2_STROKE_LINECAP_SQUARE;
  1588   1588   					  }
................................................................................
  1825   1825   						   &blue))
  1826   1826   						{
  1827   1827   						    sym->stroke->red = red;
  1828   1828   						    sym->stroke->green = green;
  1829   1829   						    sym->stroke->blue = blue;
  1830   1830   						}
  1831   1831   					  }
  1832         -					if (strcmp
  1833         -					    (svg_name, "stroke-opacity") == 0)
         1832  +					if (strcmp (svg_name, "stroke-opacity")
         1833  +					    == 0)
  1834   1834   					    sym->stroke->opacity =
  1835   1835   						atof ((const char *) svg_value);
  1836         -					if (strcmp (svg_name, "stroke-width")
  1837         -					    == 0)
         1836  +					if (strcmp (svg_name, "stroke-width") ==
         1837  +					    0)
  1838   1838   					    sym->stroke->width =
  1839   1839   						atof ((const char *) svg_value);
  1840         -					if (strcmp
  1841         -					    (svg_name, "stroke-linejoin") == 0)
         1840  +					if (strcmp (svg_name, "stroke-linejoin")
         1841  +					    == 0)
  1842   1842   					  {
  1843         -					      if (strcmp (svg_value, "mitre")
  1844         -						  == 0)
         1843  +					      if (strcmp (svg_value, "mitre") ==
         1844  +						  0)
  1845   1845   						  sym->stroke->linejoin =
  1846   1846   						      RL2_STROKE_LINEJOIN_MITRE;
  1847         -					      if (strcmp (svg_value, "round")
  1848         -						  == 0)
         1847  +					      if (strcmp (svg_value, "round") ==
         1848  +						  0)
  1849   1849   						  sym->stroke->linejoin =
  1850   1850   						      RL2_STROKE_LINEJOIN_ROUND;
  1851         -					      if (strcmp (svg_value, "bevel")
  1852         -						  == 0)
         1851  +					      if (strcmp (svg_value, "bevel") ==
         1852  +						  0)
  1853   1853   						  sym->stroke->linejoin =
  1854   1854   						      RL2_STROKE_LINEJOIN_BEVEL;
  1855   1855   					  }
  1856         -					if (strcmp
  1857         -					    (svg_name, "stroke-linecap") == 0)
         1856  +					if (strcmp (svg_name, "stroke-linecap")
         1857  +					    == 0)
  1858   1858   					  {
  1859         -					      if (strcmp (svg_value, "butt")
  1860         -						  == 0)
         1859  +					      if (strcmp (svg_value, "butt") ==
         1860  +						  0)
  1861   1861   						  sym->stroke->linecap =
  1862   1862   						      RL2_STROKE_LINECAP_BUTT;
  1863         -					      if (strcmp (svg_value, "round")
  1864         -						  == 0)
         1863  +					      if (strcmp (svg_value, "round") ==
         1864  +						  0)
  1865   1865   						  sym->stroke->linecap =
  1866   1866   						      RL2_STROKE_LINECAP_ROUND;
  1867   1867   					      if (strcmp (svg_value, "square")
  1868   1868   						  == 0)
  1869   1869   						  sym->stroke->linecap =
  1870   1870   						      RL2_STROKE_LINECAP_SQUARE;
  1871   1871   					  }
................................................................................
  2024   2024   						   &blue))
  2025   2025   						{
  2026   2026   						    sym->stroke->red = red;
  2027   2027   						    sym->stroke->green = green;
  2028   2028   						    sym->stroke->blue = blue;
  2029   2029   						}
  2030   2030   					  }
  2031         -					if (strcmp
  2032         -					    (svg_name, "stroke-opacity") == 0)
         2031  +					if (strcmp (svg_name, "stroke-opacity")
         2032  +					    == 0)
  2033   2033   					    sym->stroke->opacity =
  2034   2034   						atof ((const char *) svg_value);
  2035         -					if (strcmp (svg_name, "stroke-width")
  2036         -					    == 0)
         2035  +					if (strcmp (svg_name, "stroke-width") ==
         2036  +					    0)
  2037   2037   					    sym->stroke->width =
  2038   2038   						atof ((const char *) svg_value);
  2039         -					if (strcmp
  2040         -					    (svg_name, "stroke-linejoin") == 0)
         2039  +					if (strcmp (svg_name, "stroke-linejoin")
         2040  +					    == 0)
  2041   2041   					  {
  2042         -					      if (strcmp (svg_value, "mitre")
  2043         -						  == 0)
         2042  +					      if (strcmp (svg_value, "mitre") ==
         2043  +						  0)
  2044   2044   						  sym->stroke->linejoin =
  2045   2045   						      RL2_STROKE_LINEJOIN_MITRE;
  2046         -					      if (strcmp (svg_value, "round")
  2047         -						  == 0)
         2046  +					      if (strcmp (svg_value, "round") ==
         2047  +						  0)
  2048   2048   						  sym->stroke->linejoin =
  2049   2049   						      RL2_STROKE_LINEJOIN_ROUND;
  2050         -					      if (strcmp (svg_value, "bevel")
  2051         -						  == 0)
         2050  +					      if (strcmp (svg_value, "bevel") ==
         2051  +						  0)
  2052   2052   						  sym->stroke->linejoin =
  2053   2053   						      RL2_STROKE_LINEJOIN_BEVEL;
  2054   2054   					  }
  2055         -					if (strcmp
  2056         -					    (svg_name, "stroke-linecap") == 0)
         2055  +					if (strcmp (svg_name, "stroke-linecap")
         2056  +					    == 0)
  2057   2057   					  {
  2058         -					      if (strcmp (svg_value, "butt")
  2059         -						  == 0)
         2058  +					      if (strcmp (svg_value, "butt") ==
         2059  +						  0)
  2060   2060   						  sym->stroke->linecap =
  2061   2061   						      RL2_STROKE_LINECAP_BUTT;
  2062         -					      if (strcmp (svg_value, "round")
  2063         -						  == 0)
         2062  +					      if (strcmp (svg_value, "round") ==
         2063  +						  0)
  2064   2064   						  sym->stroke->linecap =
  2065   2065   						      RL2_STROKE_LINECAP_ROUND;
  2066   2066   					      if (strcmp (svg_value, "square")
  2067   2067   						  == 0)
  2068   2068   						  sym->stroke->linecap =
  2069   2069   						      RL2_STROKE_LINECAP_SQUARE;
  2070   2070   					  }
................................................................................
  2166   2166   						   &blue))
  2167   2167   						{
  2168   2168   						    sym->fill->red = red;
  2169   2169   						    sym->fill->green = green;
  2170   2170   						    sym->fill->blue = blue;
  2171   2171   						}
  2172   2172   					  }
  2173         -					if (strcmp (svg_name, "fill-opacity")
  2174         -					    == 0)
         2173  +					if (strcmp (svg_name, "fill-opacity") ==
         2174  +					    0)
  2175   2175   					    sym->fill->opacity =
  2176   2176   						atof (svg_value);
  2177   2177   				    }
  2178   2178   			      }
  2179   2179   			    child = child->next;
  2180   2180   			}
  2181   2181   		  }
................................................................................
  2617   2617   					const char *svg_value;
  2618   2618   					if (!svg_parameter_name
  2619   2619   					    (child, &svg_name, &svg_value))
  2620   2620   					  {
  2621   2621   					      child = child->next;
  2622   2622   					      continue;
  2623   2623   					  }
  2624         -					if (strcmp (svg_name, "font-family")
  2625         -					    == 0)
         2624  +					if (strcmp (svg_name, "font-family") ==
         2625  +					    0)
  2626   2626   					  {
  2627   2627   					      if (sym->font_families_count <
  2628   2628   						  RL2_MAX_FONT_FAMILIES)
  2629   2629   						{
  2630   2630   						    int idx =
  2631   2631   							sym->font_families_count++;
  2632   2632   						    int len =
................................................................................
  2650   2650   						  sym->font_style =
  2651   2651   						      RL2_FONT_STYLE_ITALIC;
  2652   2652   					      if (strcasecmp
  2653   2653   						  (svg_value, "oblique") == 0)
  2654   2654   						  sym->font_style =
  2655   2655   						      RL2_FONT_STYLE_OBLIQUE;
  2656   2656   					  }
  2657         -					if (strcmp (svg_name, "font-weight")
  2658         -					    == 0)
         2657  +					if (strcmp (svg_name, "font-weight") ==
         2658  +					    0)
  2659   2659   					  {
  2660   2660   					      if (strcasecmp
  2661   2661   						  (svg_value, "normal") == 0)
  2662   2662   						  sym->font_weight =
  2663   2663   						      RL2_FONT_WEIGHT_NORMAL;
  2664         -					      if (strcasecmp
  2665         -						  (svg_value, "bold") == 0)
         2664  +					      if (strcasecmp (svg_value, "bold")
         2665  +						  == 0)
  2666   2666   						  sym->font_weight =
  2667   2667   						      RL2_FONT_WEIGHT_BOLD;
  2668   2668   					  }
  2669   2669   					if (strcmp (svg_name, "font-size") == 0)
  2670   2670   					    sym->font_size = atof (svg_value);
  2671   2671   				    }
  2672   2672   			      }
................................................................................
  3016   3016         {
  3017   3017   	  if (node->type == XML_ELEMENT_NODE)
  3018   3018   	    {
  3019   3019   		const char *name = (const char *) (node->name);
  3020   3020   		if (strcmp (name, "LabelPlacement") == 0)
  3021   3021   		  {
  3022   3022   		      xmlNodePtr child = node->children;
  3023         -		      if (sym->label_placement_type ==
  3024         -			  RL2_LABEL_PLACEMENT_POINT
         3023  +		      if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT
  3025   3024   			  && sym->label_placement != NULL)
  3026   3025   			  rl2_destroy_point_placement ((rl2PrivPointPlacementPtr) (sym->label_placement));
  3027         -		      if (sym->label_placement_type ==
  3028         -			  RL2_LABEL_PLACEMENT_LINE
         3026  +		      if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE
  3029   3027   			  && sym->label_placement != NULL)
  3030   3028   			  rl2_destroy_line_placement ((rl2PrivLinePlacementPtr)
  3031   3029   						      (sym->label_placement));
  3032   3030   		      sym->label_placement_type = RL2_LABEL_PLACEMENT_UNKNOWN;
  3033   3031   		      sym->label_placement = NULL;
  3034   3032   		      while (child)
  3035   3033   			{
................................................................................
  3995   3993       rl2PrivTextSymbolizerPtr text;
  3996   3994   
  3997   3995       pR = style->first_rule;
  3998   3996       while (pR != NULL)
  3999   3997         {
  4000   3998   	  /* counting max column names */
  4001   3999   	  if (pR->column_name != NULL)
  4002         -	      count++;
  4003         -	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4004   4000   	    {
  4005         -		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4006         -		item = pV->first;
  4007         -		while (item != NULL)
         4001  +		count++;
         4002  +		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4008   4003   		  {
  4009         -		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4010         -			  && item->symbolizer != NULL)
         4004  +		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4005  +		      item = pV->first;
         4006  +		      while (item != NULL)
  4011   4007   			{
  4012         -			    text =
  4013         -				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
  4014         -			    if (text->label != NULL)
  4015         -				count++;
         4008  +			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4009  +				&& item->symbolizer != NULL)
         4010  +			      {
         4011  +				  text =
         4012  +				      (rl2PrivTextSymbolizerPtr)
         4013  +				      (item->symbolizer);
         4014  +				  if (text->label != NULL)
         4015  +				      count++;
         4016  +			      }
         4017  +			    item = item->next;
  4016   4018   			}
  4017         -		      item = item->next;
  4018   4019   		  }
  4019   4020   	    }
  4020   4021   	  pR = pR->next;
  4021   4022         }
  4022   4023       pR = style->else_rule;
  4023   4024       if (pR != NULL)
  4024   4025         {
  4025   4026   	  if (pR->column_name != NULL)
  4026         -	      count++;
  4027         -	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4028   4027   	    {
  4029         -		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4030         -		item = pV->first;
  4031         -		while (item != NULL)
         4028  +		count++;
         4029  +		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4032   4030   		  {
  4033         -		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4034         -			  && item->symbolizer != NULL)
         4031  +		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4032  +		      item = pV->first;
         4033  +		      while (item != NULL)
  4035   4034   			{
  4036         -			    text =
  4037         -				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
  4038         -			    if (text->label != NULL)
  4039         -				count++;
         4035  +			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4036  +				&& item->symbolizer != NULL)
         4037  +			      {
         4038  +				  text =
         4039  +				      (rl2PrivTextSymbolizerPtr)
         4040  +				      (item->symbolizer);
         4041  +				  if (text->label != NULL)
         4042  +				      count++;
         4043  +			      }
         4044  +			    item = item->next;
  4040   4045   			}
  4041         -		      item = item->next;
  4042   4046   		  }
  4043   4047   	    }
  4044   4048         }
  4045   4049       if (count == 0)
  4046   4050   	return;
  4047   4051   
  4048   4052       strings = malloc (sizeof (char *) * count);
................................................................................
  4055   4059   	  if (pR->column_name != NULL)
  4056   4060   	    {
  4057   4061   		len = strlen (pR->column_name);
  4058   4062   		*(strings + i) = malloc (len + 1);
  4059   4063   		strcpy (*(strings + i), pR->column_name);
  4060   4064   		*(dupl + i) = 'N';
  4061   4065   		i++;
  4062         -	    }
  4063         -	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4064         -	    {
  4065         -		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4066         -		item = pV->first;
  4067         -		while (item != NULL)
         4066  +		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4068   4067   		  {
  4069         -		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4070         -			  && item->symbolizer != NULL)
         4068  +		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4069  +		      item = pV->first;
         4070  +		      while (item != NULL)
  4071   4071   			{
  4072         -			    text =
  4073         -				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
  4074         -			    if (text->label != NULL)
         4072  +			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4073  +				&& item->symbolizer != NULL)
  4075   4074   			      {
  4076         -				  len = strlen (text->label);
  4077         -				  *(strings + i) = malloc (len + 1);
  4078         -				  strcpy (*(strings + i), text->label);
  4079         -				  *(dupl + i) = 'N';
  4080         -				  i++;
         4075  +				  text =
         4076  +				      (rl2PrivTextSymbolizerPtr)
         4077  +				      (item->symbolizer);
         4078  +				  if (text->label != NULL)
         4079  +				    {
         4080  +					len = strlen (text->label);
         4081  +					*(strings + i) = malloc (len + 1);
         4082  +					strcpy (*(strings + i), text->label);
         4083  +					*(dupl + i) = 'N';
         4084  +					i++;
         4085  +				    }
  4081   4086   			      }
         4087  +			    item = item->next;
  4082   4088   			}
  4083         -		      item = item->next;
  4084   4089   		  }
  4085   4090   	    }
  4086   4091   	  pR = pR->next;
  4087   4092         }
  4088   4093       pR = style->else_rule;
  4089   4094       if (pR != NULL)
  4090   4095         {
................................................................................
  4091   4096   	  if (pR->column_name != NULL)
  4092   4097   	    {
  4093   4098   		len = strlen (pR->column_name);
  4094   4099   		*(strings + i) = malloc (len + 1);
  4095   4100   		strcpy (*(strings + i), pR->column_name);
  4096   4101   		*(dupl + i) = 'N';
  4097   4102   		i++;
  4098         -	    }
  4099         -	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4100         -	    {
  4101         -		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4102         -		item = pV->first;
  4103         -		while (item != NULL)
         4103  +		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4104   4104   		  {
  4105         -		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4106         -			  && item->symbolizer != NULL)
         4105  +		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4106  +		      item = pV->first;
         4107  +		      while (item != NULL)
  4107   4108   			{
  4108         -			    text =
  4109         -				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
  4110         -			    if (text->label != NULL)
         4109  +			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4110  +				&& item->symbolizer != NULL)
  4111   4111   			      {
  4112         -				  len = strlen (text->label);
  4113         -				  *(strings + i) = malloc (len + 1);
  4114         -				  strcpy (*(strings + i), text->label);
  4115         -				  *(dupl + i) = 'N';
  4116         -				  i++;
         4112  +				  text =
         4113  +				      (rl2PrivTextSymbolizerPtr)
         4114  +				      (item->symbolizer);
         4115  +				  if (text->label != NULL)
         4116  +				    {
         4117  +					len = strlen (text->label);
         4118  +					*(strings + i) = malloc (len + 1);
         4119  +					strcpy (*(strings + i), text->label);
         4120  +					*(dupl + i) = 'N';
         4121  +					i++;
         4122  +				    }
  4117   4123   			      }
         4124  +			    item = item->next;
  4118   4125   			}
  4119         -		      item = item->next;
  4120   4126   		  }
  4121   4127   	    }
  4122   4128         }
  4123   4129   
  4124   4130       for (i = 0; i < count; i++)
  4125   4131         {
  4126   4132   	  /* identifying all duplicates */
................................................................................
  4428   4434   	  lyr->raster_stats = NULL;
  4429   4435         }
  4430   4436       return ptr;
  4431   4437   }
  4432   4438   
  4433   4439   static int
  4434   4440   rl2_group_renderer_set_raster (rl2PrivGroupRendererPtr group, int index,
  4435         -			       const char *layer_name,
  4436         -			       rl2CoveragePtr coverage,
         4441  +			       const char *layer_name, rl2CoveragePtr coverage,
  4437   4442   			       sqlite3_int64 style_id,
  4438   4443   			       rl2RasterSymbolizerPtr symbolizer,
  4439   4444   			       rl2RasterStatisticsPtr stats)
  4440   4445   {
  4441   4446   /* setting up one of the Layers within the Group */
  4442   4447       int len;
  4443   4448       rl2PrivGroupRendererLayerPtr lyr;

Changes to src/rl2tiff.c.

   547    547       uint32 height = 0;
   548    548       double cx;
   549    549       double cy;
   550    550       GTIFDefn definition;
   551    551       char *pString;
   552    552       int len;
   553    553       int basic = 0;
   554         -    short pixel_mode = RasterPixelIsArea;
   555    554       TIFF *in = (TIFF *) 0;
   556    555       GTIF *gtif = (GTIF *) 0;
   557    556   
   558    557   /* suppressing TIFF messages */
   559    558       TIFFSetErrorHandler (NULL);
   560    559       TIFFSetWarningHandler (NULL);
   561    560   
................................................................................
   642    641   
   643    642   /* computing the pixel resolution */
   644    643       origin->hResolution = (origin->maxX - origin->minX) / (double) width;
   645    644       origin->vResolution = (origin->maxY - origin->minY) / (double) height;
   646    645       origin->isGeoReferenced = 1;
   647    646       origin->isGeoTiff = 1;
   648    647   
   649         -/* retrieving GTRasterTypeGeoKey */
   650         -    if (!GTIFKeyGet (gtif, GTRasterTypeGeoKey, &pixel_mode, 0, 1))
   651         -	pixel_mode = RasterPixelIsArea;
   652         -    if (pixel_mode == RasterPixelIsPoint)
   653         -      {
   654         -	  /* adjusting the BBOX */
   655         -	  origin->minX -= origin->hResolution / 2.0;
   656         -	  origin->minY -= origin->vResolution / 2.0;
   657         -	  origin->maxX += origin->hResolution / 2.0;
   658         -	  origin->maxY += origin->vResolution / 2.0;
   659         -
   660         -      }
   661         -
   662    648     error:
   663    649       if (basic && origin->isGeoTiff == 0)
   664    650   	recover_incomplete_geotiff (origin, in, width, height, force_srid);
   665    651       if (in != (TIFF *) 0)
   666    652   	XTIFFClose (in);
   667    653       if (gtif != (GTIF *) 0)
   668    654   	GTIFFree (gtif);
................................................................................
  1429   1415         {
  1430   1416   	  /* attempting to recover badly formatted TIFFs */
  1431   1417   	  origin->planarConfig = PLANARCONFIG_CONTIG;
  1432   1418         }
  1433   1419       else
  1434   1420   	origin->planarConfig = value16;
  1435   1421   
  1436         -    if (origin->bitsPerSample == 16
  1437         -	&& origin->sampleFormat == SAMPLEFORMAT_UINT
         1422  +    if (origin->bitsPerSample == 16 && origin->sampleFormat == SAMPLEFORMAT_UINT
  1438   1423   	&& origin->planarConfig == PLANARCONFIG_SEPARATE)
  1439   1424   	;
  1440   1425       else if (origin->bitsPerSample == 8
  1441   1426   	     && origin->sampleFormat == SAMPLEFORMAT_UINT
  1442   1427   	     && origin->planarConfig == PLANARCONFIG_SEPARATE)
  1443   1428   	;
  1444   1429       else if (origin->planarConfig != PLANARCONFIG_CONTIG)
................................................................................
  2184   2169       if (coverage->mixedResolutions)
  2185   2170         {
  2186   2171   	  /* accepting any resolution */
  2187   2172         }
  2188   2173       else if (coverage->strictResolution)
  2189   2174         {
  2190   2175   	  /* enforcing Strict Resolution check */
  2191         -	  double x_diff = fabs (coverage->hResolution - hResolution);
  2192         -	  double y_diff = fabs (coverage->vResolution - vResolution);
  2193         -	  double x_lim = coverage->hResolution / 1000000.0;
  2194         -	  double y_lim = coverage->vResolution / 1000000.0;
  2195         -	  if (x_diff > x_lim)
         2176  +	  if (hResolution != coverage->hResolution)
  2196   2177   	    {
  2197   2178   		if (verbose)
  2198   2179   		    fprintf (stderr,
  2199   2180   			     "Mismatching Horizontal Resolution (Strict) !!!\n");
  2200   2181   		return RL2_FALSE;
  2201   2182   	    }
  2202         -	  if (y_diff > y_lim)
         2183  +	  if (vResolution != coverage->vResolution)
  2203   2184   	    {
  2204   2185   		if (verbose)
  2205   2186   		    fprintf (stderr,
  2206   2187   			     "Mismatching Vertical Resolution (Strict) !!!\n");
  2207   2188   		return RL2_FALSE;
  2208   2189   	    }
  2209   2190         }
................................................................................
  2751   2732   		if (tiff_max_x < startCol)
  2752   2733   		    skip = 1;
  2753   2734   		if (skip)
  2754   2735   		  {
  2755   2736   		      /* skipping any not required tile */
  2756   2737   		      continue;
  2757   2738   		  }
  2758         -		if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0)
  2759         -		    < 0)
         2739  +		if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0) <
         2740  +		    0)
  2760   2741   		    goto error;
  2761   2742   		if (convert != RL2_CONVERT_NO)
  2762   2743   		  {
  2763   2744   		      /* applying some format conversion */
  2764   2745   		      copy_convert_tile (origin, tiff_tile, pixels, startRow,
  2765   2746   					 startCol, width, height, tile_y,
  2766   2747   					 tile_x, convert);
................................................................................
  2781   2762   			      {
  2782   2763   			      case RL2_SAMPLE_INT8:
  2783   2764   				  p_in_8 = (char *) tiff_tile;
  2784   2765   				  p_in_8 += y * origin->tileWidth;
  2785   2766   				  p_in_8 += x;
  2786   2767   				  p_out_8 = (char *) pixels;
  2787   2768   				  p_out_8 +=
  2788         -				      ((dest_y - startRow) * width) +
  2789         -				      (dest_x - startCol);
         2769  +				      ((dest_y - startRow) * width) + (dest_x -
         2770  +								       startCol);
  2790   2771   				  break;
  2791   2772   			      case RL2_SAMPLE_UINT8:
  2792   2773   				  p_in_u8 = (unsigned char *) tiff_tile;
  2793   2774   				  p_in_u8 += y * origin->tileWidth * num_bands;
  2794   2775   				  p_in_u8 += x * num_bands;
  2795   2776   				  p_out_u8 = (unsigned char *) pixels;
  2796   2777   				  p_out_u8 +=
................................................................................
  2800   2781   				  break;
  2801   2782   			      case RL2_SAMPLE_INT16:
  2802   2783   				  p_in_16 = (short *) tiff_tile;
  2803   2784   				  p_in_16 += y * origin->tileWidth;
  2804   2785   				  p_in_16 += x;
  2805   2786   				  p_out_16 = (short *) pixels;
  2806   2787   				  p_out_16 +=
  2807         -				      ((dest_y - startRow) * width) +
  2808         -				      (dest_x - startCol);
         2788  +				      ((dest_y - startRow) * width) + (dest_x -
         2789  +								       startCol);
  2809   2790   				  break;
  2810   2791   			      case RL2_SAMPLE_UINT16:
  2811   2792   				  p_in_u16 = (unsigned short *) tiff_tile;
  2812   2793   				  p_in_u16 += y * origin->tileWidth * num_bands;
  2813   2794   				  p_in_u16 += x * num_bands;
  2814   2795   				  p_out_u16 = (unsigned short *) pixels;
  2815   2796   				  p_out_u16 +=
................................................................................
  2819   2800   				  break;
  2820   2801   			      case RL2_SAMPLE_INT32:
  2821   2802   				  p_in_32 = (int *) tiff_tile;
  2822   2803   				  p_in_32 += y * origin->tileWidth;
  2823   2804   				  p_in_32 += x;
  2824   2805   				  p_out_32 = (int *) pixels;
  2825   2806   				  p_out_32 +=
  2826         -				      ((dest_y - startRow) * width) +
  2827         -				      (dest_x - startCol);
         2807  +				      ((dest_y - startRow) * width) + (dest_x -
         2808  +								       startCol);
  2828   2809   				  break;
  2829   2810   			      case RL2_SAMPLE_UINT32:
  2830   2811   				  p_in_u32 = (unsigned int *) tiff_tile;
  2831   2812   				  p_in_u32 += y * origin->tileWidth;
  2832   2813   				  p_in_u32 += x;
  2833   2814   				  p_out_u32 = (unsigned int *) pixels;
  2834   2815   				  p_out_u32 +=
  2835         -				      ((dest_y - startRow) * width) +
  2836         -				      (dest_x - startCol);
         2816  +				      ((dest_y - startRow) * width) + (dest_x -
         2817  +								       startCol);
  2837   2818   				  break;
  2838   2819   			      case RL2_SAMPLE_FLOAT:
  2839   2820   				  p_in_flt = (float *) tiff_tile;
  2840   2821   				  p_in_flt += y * origin->tileWidth;
  2841   2822   				  p_in_flt += x;
  2842   2823   				  p_out_flt = (float *) pixels;
  2843   2824   				  p_out_flt +=
  2844         -				      ((dest_y - startRow) * width) +
  2845         -				      (dest_x - startCol);
         2825  +				      ((dest_y - startRow) * width) + (dest_x -
         2826  +								       startCol);
  2846   2827   				  break;
  2847   2828   			      case RL2_SAMPLE_DOUBLE:
  2848   2829   				  p_in_dbl = (double *) tiff_tile;
  2849   2830   				  p_in_dbl += y * origin->tileWidth;
  2850   2831   				  p_in_dbl += x;
  2851   2832   				  p_out_dbl = (double *) pixels;
  2852   2833   				  p_out_dbl +=
  2853         -				      ((dest_y - startRow) * width) +
  2854         -				      (dest_x - startCol);
         2834  +				      ((dest_y - startRow) * width) + (dest_x -
         2835  +								       startCol);
  2855   2836   				  break;
  2856   2837   			      };
  2857   2838   			    for (bnd = 0; bnd < num_bands; bnd++)
  2858   2839   			      {
  2859   2840   				  switch (sample_type)
  2860   2841   				    {
  2861   2842   				    case RL2_SAMPLE_INT8:
................................................................................
  3391   3372         }
  3392   3373   
  3393   3374       for (y = 0; y < height; y++)
  3394   3375         {
  3395   3376   	  /* scanning scanlines by row */
  3396   3377   	  line_no = y + startRow;
  3397   3378   	  if (line_no >= origin->height)
  3398         -	      continue;
         3379  +	    {
         3380  +		switch (sample_type)
         3381  +		  {
         3382  +		  case RL2_SAMPLE_INT8:
         3383  +		      p_out_8 = (char *) pixels;
         3384  +		      for (x = 0; x < width; x++)
         3385  +			  *p_out_8++ = 0;
         3386  +		      break;
         3387  +		  case RL2_SAMPLE_UINT8:
         3388  +		      p_out_u8 = (unsigned char *) pixels;
         3389  +		      for (x = 0; x < width * num_bands; x++)
         3390  +			  *p_out_u8++ = 0;
         3391  +		      break;
         3392  +		  case RL2_SAMPLE_INT16:
         3393  +		      p_out_16 = (short *) pixels;
         3394  +		      for (x = 0; x < width; x++)
         3395  +			  *p_out_16++ = 0;
         3396  +		      break;
         3397  +		  case RL2_SAMPLE_UINT16:
         3398  +		      p_out_u16 = (unsigned short *) pixels;
         3399  +		      for (x = 0; x < width * num_bands; x++)
         3400  +			  *p_out_u16++ = 0;
         3401  +		      break;
         3402  +		  case RL2_SAMPLE_INT32:
         3403  +		      p_out_32 = (int *) pixels;
         3404  +		      for (x = 0; x < width; x++)
         3405  +			  *p_out_32++ = 0;
         3406  +		      break;
         3407  +		  case RL2_SAMPLE_UINT32:
         3408  +		      p_out_u32 = (unsigned int *) pixels;
         3409  +		      for (x = 0; x < width; x++)
         3410  +			  *p_out_u32++ = 0;
         3411  +		      break;
         3412  +		  case RL2_SAMPLE_FLOAT:
         3413  +		      p_out_flt = (float *) pixels;
         3414  +		      for (x = 0; x < width; x++)
         3415  +			  *p_out_flt++ = 0;
         3416  +		      break;
         3417  +		  case RL2_SAMPLE_DOUBLE:
         3418  +		      p_out_dbl = (double *) pixels;
         3419  +		      for (x = 0; x < width; x++)
         3420  +			  *p_out_dbl++ = 0;
         3421  +		      break;
         3422  +		  default:
         3423  +		      goto error;
         3424  +		  };
         3425  +		continue;
         3426  +	    }
  3399   3427   	  if (TIFFReadScanline (in, tiff_scanline, line_no, 0) < 0)
  3400   3428   	      goto error;
  3401   3429   	  if (convert != RL2_CONVERT_NO)
  3402   3430   	    {
  3403   3431   		/* applying some format conversion */
  3404   3432   		copy_convert_scanline (origin, tiff_scanline, pixels, y,
  3405   3433   				       startCol, width, convert);
................................................................................
  3613   3641   					p_in_u16 = (unsigned short *) tiff_tile;
  3614   3642   					p_in_u16 += y * origin->tileWidth;
  3615   3643   					p_in_u16 += x;
  3616   3644   					p_out_u16 = (unsigned short *) pixels;
  3617   3645   					p_out_u16 +=
  3618   3646   					    ((dest_y -
  3619   3647   					      startRow) * width * num_bands) +
  3620         -					    ((dest_x -
  3621         -					      startCol) * num_bands) + band;
         3648  +					    ((dest_x - startCol) * num_bands) +
         3649  +					    band;
  3622   3650   					*p_out_u16 = *p_in_u16;
  3623   3651   				    }
  3624   3652   				  if (sample_type == RL2_SAMPLE_UINT8)
  3625   3653   				    {
  3626   3654   					p_in_u8 = (unsigned char *) tiff_tile;
  3627   3655   					p_in_u8 += y * origin->tileWidth;
  3628   3656   					p_in_u8 += x;
  3629   3657   					p_out_u8 = (unsigned char *) pixels;
  3630   3658   					p_out_u8 +=
  3631   3659   					    ((dest_y -
  3632   3660   					      startRow) * width * num_bands) +
  3633         -					    ((dest_x -
  3634         -					      startCol) * num_bands) + band;
         3661  +					    ((dest_x - startCol) * num_bands) +
         3662  +					    band;
  3635   3663   					*p_out_u8 = *p_in_u8;
  3636   3664   				    }
  3637   3665   			      }
  3638   3666   			}
  3639   3667   		  }
  3640   3668   	    }
  3641   3669         }
................................................................................
  3645   3673     error:
  3646   3674       if (tiff_tile != NULL)
  3647   3675   	free (tiff_tile);
  3648   3676       return RL2_ERROR;
  3649   3677   }
  3650   3678   
  3651   3679   static int
  3652         -read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin,
  3653         -			     unsigned short width, unsigned short height,
  3654         -			     unsigned char sample_type,
         3680  +read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin, unsigned short width,
         3681  +			     unsigned short height, unsigned char sample_type,
  3655   3682   			     unsigned char num_bands, unsigned int startRow,
  3656   3683   			     unsigned int startCol, void *pixels)
  3657   3684   {
  3658   3685   /* reading TIFF raw strips - separate planes */
  3659   3686       uint32 line_no;
  3660   3687       uint32 x;
  3661   3688       uint32 y;
................................................................................
  4145   4172   	      goto error;
  4146   4173         }
  4147   4174       else
  4148   4175         {
  4149   4176   	  /* contiguous planar configuration */
  4150   4177   	  if (origin->bitsPerSample <= 8
  4151   4178   	      && origin->sampleFormat == SAMPLEFORMAT_UINT
  4152         -	      && (origin->samplesPerPixel == 1
  4153         -		  || origin->samplesPerPixel == 3)
         4179  +	      && (origin->samplesPerPixel == 1 || origin->samplesPerPixel == 3)
  4154   4180   	      && (pixel_type == RL2_PIXEL_MONOCHROME
  4155   4181   		  || pixel_type == RL2_PIXEL_PALETTE
  4156   4182   		  || pixel_type == RL2_PIXEL_GRAYSCALE
  4157   4183   		  || pixel_type == RL2_PIXEL_RGB))
  4158   4184   	    {
  4159   4185   		/* using the TIFF RGBA methods */
  4160   4186   		if (origin->isTiled)
................................................................................
  4176   4202   		if (origin->isTiled)
  4177   4203   		    ret =
  4178   4204   			read_raw_tiles (origin, width, height, sample_type,
  4179   4205   					num_bands, startRow, startCol,
  4180   4206   					bufPixels);
  4181   4207   		else
  4182   4208   		    ret =
  4183         -			read_raw_scanlines (origin, width, height,
  4184         -					    sample_type, num_bands, startRow,
  4185         -					    startCol, bufPixels);
         4209  +			read_raw_scanlines (origin, width, height, sample_type,
         4210  +					    num_bands, startRow, startCol,
         4211  +					    bufPixels);
  4186   4212   		if (ret != RL2_OK)
  4187   4213   		    goto error;
  4188   4214   	    }
  4189   4215         }
  4190   4216   
  4191   4217       *pixels = bufPixels;
  4192   4218       *pixels_sz = bufPixelsSz;
................................................................................
  4356   4382   		  }
  4357   4383   	    }
  4358   4384         }
  4359   4385   
  4360   4386   /* attempting to create the tile */
  4361   4387       if (read_from_tiff
  4362   4388   	(origin, coverage->tileWidth, coverage->tileHeight,
  4363         -	 coverage->sampleType, coverage->pixelType, coverage->nBands,
  4364         -	 startRow, startCol, &pixels, &pixels_sz, palette) != RL2_OK)
         4389  +	 coverage->sampleType, coverage->pixelType, coverage->nBands, startRow,
         4390  +	 startCol, &pixels, &pixels_sz, palette) != RL2_OK)
  4365   4391   	goto error;
  4366   4392       if (startCol + coverage->tileWidth > origin->width)
  4367   4393   	unused_width = (startCol + coverage->tileWidth) - origin->width;
  4368   4394       if (startRow + coverage->tileHeight > origin->height)
  4369   4395   	unused_height = (startRow + coverage->tileHeight) - origin->height;
  4370   4396       if (unused_width || unused_height)
  4371   4397         {
................................................................................
  5052   5078     error:
  5053   5079       return 0;
  5054   5080   }
  5055   5081   
  5056   5082   RL2_DECLARE rl2TiffDestinationPtr
  5057   5083   rl2_create_tiff_destination (const char *path, unsigned int width,
  5058   5084   			     unsigned int height, unsigned char sample_type,
  5059         -			     unsigned char pixel_type,
  5060         -			     unsigned char num_bands, rl2PalettePtr plt,
  5061         -			     unsigned char tiff_compression, int tiled,
  5062         -			     unsigned int tile_size)
         5085  +			     unsigned char pixel_type, unsigned char num_bands,
         5086  +			     rl2PalettePtr plt, unsigned char tiff_compression,
         5087  +			     int tiled, unsigned int tile_size)
  5063   5088   {
  5064   5089   /* attempting to create a file-based TIFF destination (no georeferencing) */
  5065   5090       rl2PrivTiffDestinationPtr destination = NULL;
  5066   5091       if (!check_color_model
  5067   5092   	(sample_type, pixel_type, num_bands, plt, tiff_compression))
  5068   5093         {
  5069   5094   	  fprintf (stderr, "RL2-TIFF writer: unsupported pixel format\n");
................................................................................
  5735   5760         }
  5736   5761       if (TIFFWriteScanline (tiff->out, tiff->tiffBuffer, row, 0) < 0)
  5737   5762   	return 0;
  5738   5763       return 1;
  5739   5764   }
  5740   5765   
  5741   5766   static int
  5742         -tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff,
  5743         -		       rl2PrivRasterPtr raster, unsigned int row)
         5767  +tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster,
         5768  +		       unsigned int row)
  5744   5769   {
  5745   5770   /* writing a TIFF Grayscale scanline */
  5746   5771       unsigned int x;
  5747   5772       unsigned char *p_in = raster->rasterBuffer;
  5748   5773       unsigned char *p_out = tiff->tiffBuffer;
  5749   5774   
  5750   5775       for (x = 0; x < raster->width; x++)
................................................................................
  6138   6163   	      0)
  6139   6164   	      return 0;
  6140   6165         }
  6141   6166       return 1;
  6142   6167   }
  6143   6168   
  6144   6169   static int
  6145         -tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff,
  6146         -			rl2PrivRasterPtr raster, unsigned int row,
  6147         -			unsigned int col)
         6170  +tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster,
         6171  +			unsigned int row, unsigned int col)
  6148   6172   {
  6149   6173   /* writing a TIFF RGB tile - UINT8 */
  6150   6174       unsigned int y;
  6151   6175       unsigned int x;
  6152   6176       unsigned char *p_in = raster->rasterBuffer;
  6153   6177       unsigned char *p_out = tiff->tiffBuffer;
  6154   6178   
................................................................................
  6515   6539   	     && rst->nBands == destination->samplesPerPixel
  6516   6540   	     && destination->tileWidth == rst->width
  6517   6541   	     && destination->tileHeight == rst->height)
  6518   6542   	ret =
  6519   6543   	    tiff_write_tile_multiband16 (destination, rst, startRow, startCol);
  6520   6544       else if (destination->sampleFormat == SAMPLEFORMAT_UINT
  6521   6545   	     && destination->samplesPerPixel == 1
  6522         -	     && destination->photometric < 2
  6523         -	     && destination->bitsPerSample == 8
         6546  +	     && destination->photometric < 2 && destination->bitsPerSample == 8
  6524   6547   	     && rst->sampleType == RL2_SAMPLE_UINT8
  6525   6548   	     && rst->pixelType == RL2_PIXEL_GRAYSCALE && rst->nBands == 1
  6526   6549   	     && destination->tileWidth == rst->width
  6527   6550   	     && destination->tileHeight == rst->height)
  6528   6551   	ret = tiff_write_tile_gray (destination, rst, startRow, startCol);
  6529   6552       else if (destination->sampleFormat == SAMPLEFORMAT_UINT
  6530   6553   	     && destination->samplesPerPixel == 1
................................................................................
  6635   6658   	return RL2_ERROR;
  6636   6659       if (destination->tfw_path == NULL)
  6637   6660   	return RL2_ERROR;
  6638   6661   
  6639   6662       tfw = fopen (destination->tfw_path, "w");
  6640   6663       if (tfw == NULL)
  6641   6664         {
  6642         -	  fprintf (stderr,
  6643         -		   "RL2-TIFF writer: unable to open Worldfile \"%s\"\n",
         6665  +	  fprintf (stderr, "RL2-TIFF writer: unable to open Worldfile \"%s\"\n",
  6644   6666   		   destination->tfw_path);
  6645   6667   	  return RL2_ERROR;
  6646   6668         }
  6647   6669       fprintf (tfw, "        %1.16f\n", destination->hResolution);
  6648   6670       fprintf (tfw, "        0.0\n");
  6649   6671       fprintf (tfw, "        0.0\n");
  6650   6672       fprintf (tfw, "        -%1.16f\n", destination->vResolution);
................................................................................
  6953   6975       TIFFClose (in);
  6954   6976       if (tiff_buffer != NULL)
  6955   6977   	free (tiff_buffer);
  6956   6978       return RL2_ERROR;
  6957   6979   }
  6958   6980   
  6959   6981   static int
  6960         -rgb_tiff_common (TIFF * out, const unsigned char *buffer,
  6961         -		 unsigned short width, unsigned short height)
         6982  +rgb_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width,
         6983  +		 unsigned short height)
  6962   6984   {
  6963   6985   /* common implementation of RGB TIFF export */
  6964   6986       tsize_t buf_size;
  6965   6987       void *tiff_buffer = NULL;
  6966   6988       int y;
  6967   6989       int x;
  6968   6990       const unsigned char *p_in;
................................................................................
  7236   7258       return 0;
  7237   7259   }
  7238   7260   
  7239   7261   static int
  7240   7262   output_palette_tiff (const unsigned char *buffer,
  7241   7263   		     unsigned short width,
  7242   7264   		     unsigned short height, unsigned char *red,
  7243         -		     unsigned char *green, unsigned char *blue,
  7244         -		     int max_palette, unsigned char **blob, int *blob_size)
         7265  +		     unsigned char *green, unsigned char *blue, int max_palette,
         7266  +		     unsigned char **blob, int *blob_size)
  7245   7267   {
  7246   7268   /* generating a PALETTE TIFF - actual work */
  7247   7269       struct memfile clientdata;
  7248   7270       TIFF *out = (TIFF *) 0;
  7249   7271   
  7250   7272   /* suppressing TIFF warnings */
  7251   7273       TIFFSetWarningHandler (NULL);
................................................................................
  7485   7507   	       tiff_size))
  7486   7508   	      return RL2_ERROR;
  7487   7509         }
  7488   7510       return RL2_OK;
  7489   7511   }
  7490   7512   
  7491   7513   static int
  7492         -gray_tiff_common (TIFF * out, const unsigned char *buffer,
  7493         -		  unsigned short width, unsigned short height)
         7514  +gray_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width,
         7515  +		  unsigned short height)
  7494   7516   {
  7495   7517   /* common implementation of Grayscale TIFF export */
  7496   7518       tsize_t buf_size;
  7497   7519       void *tiff_buffer = NULL;
  7498   7520       int y;
  7499   7521       int x;
  7500   7522       const unsigned char *p_in;
................................................................................
  7965   7987   	xml =
  7966   7988   	    sqlite3_mprintf ("%s<Compression>%u</Compression>", prev,
  7967   7989   			     org->compression);
  7968   7990       sqlite3_free (prev);
  7969   7991       prev = xml;
  7970   7992       if (org->sampleFormat == SAMPLEFORMAT_UINT)
  7971   7993   	xml =
  7972         -	    sqlite3_mprintf
  7973         -	    ("%s<SampleFormat>unsigned integer</SampleFormat>", prev);
         7994  +	    sqlite3_mprintf ("%s<SampleFormat>unsigned integer</SampleFormat>",
         7995  +			     prev);
  7974   7996       else if (org->sampleFormat == SAMPLEFORMAT_INT)
  7975   7997   	xml =
  7976   7998   	    sqlite3_mprintf ("%s<SampleFormat>signed integer</SampleFormat>",
  7977   7999   			     prev);
  7978   8000       else if (org->sampleFormat == SAMPLEFORMAT_IEEEFP)
  7979   8001   	xml =
  7980   8002   	    sqlite3_mprintf ("%s<SampleFormat>floating point</SampleFormat>",
................................................................................
  8060   8082   	  xml = sqlite3_mprintf ("%s</BoundingBox>", prev);
  8061   8083   	  sqlite3_free (prev);
  8062   8084   	  prev = xml;
  8063   8085   	  xml = sqlite3_mprintf ("%s<Extent>", prev);
  8064   8086   	  sqlite3_free (prev);
  8065   8087   	  prev = xml;
  8066   8088   	  xml =
  8067         -	      sqlite3_mprintf
  8068         -	      ("%s<HorizontalExtent>%1.10f</HorizontalExtent>", prev,
  8069         -	       org->maxX - org->minX);
         8089  +	      sqlite3_mprintf ("%s<HorizontalExtent>%1.10f</HorizontalExtent>",
         8090  +			       prev, org->maxX - org->minX);
  8070   8091   	  sqlite3_free (prev);
  8071   8092   	  prev = xml;
  8072   8093   	  xml =
  8073   8094   	      sqlite3_mprintf ("%s<VerticalExtent>%1.10f</VerticalExtent>",
  8074   8095   			       prev, org->maxY - org->minY);
  8075   8096   	  sqlite3_free (prev);
  8076   8097   	  prev = xml;

Changes to src/rl2webp.c.

   154    154   	  else
   155    155   	      return RL2_ERROR;
   156    156         }
   157    157       return RL2_OK;
   158    158   }
   159    159   
   160    160   static void
   161         -copy_pixels (unsigned char *out, const unsigned char *in, int width,
   162         -	     int height, int num_bands)
          161  +copy_pixels (unsigned char *out, const unsigned char *in, int width, int height,
          162  +	     int num_bands)
   163    163   {
   164    164   /* copying pixels */
   165    165       int x;
   166    166       int y;
   167    167       int ib;
   168    168       const unsigned char *p_in = in;
   169    169       unsigned char *p_out = out;
................................................................................
   293    293   	RL2_ERROR)
   294    294   	return RL2_ERROR;
   295    295       if (quality > 100)
   296    296   	quality = 100;
   297    297       if (quality < 0)
   298    298   	quality = 75;
   299    299       size =
   300         -	WebPEncodeRGBA (rgba, rst->width, rst->height, rst->width * 4,
   301         -			quality, &output);
          300  +	WebPEncodeRGBA (rgba, rst->width, rst->height, rst->width * 4, quality,
          301  +			&output);
   302    302       free (rgba);
   303    303       if (size == 0)
   304    304   	return RL2_ERROR;
   305    305       *webp = output;
   306    306       *webp_size = size;
   307    307       return RL2_OK;
   308    308   }

Changes to src/rl2wms.c.

   534    534       while (pI != NULL)
   535    535         {
   536    536   	  /* populating the array */
   537    537   	  *(cache->SortedByUrl + pos) = pI;
   538    538   	  pos++;
   539    539   	  pI = pI->Next;
   540    540         }
   541         -    qsort (cache->SortedByUrl, cache->NumCachedItems,
   542         -	   sizeof (wmsCachedItemPtr), compare_url);
          541  +    qsort (cache->SortedByUrl, cache->NumCachedItems, sizeof (wmsCachedItemPtr),
          542  +	   compare_url);
   543    543   }
   544    544   
   545    545   static void
   546    546   wmsCacheSqueeze (wmsCachePtr cache, int limit)
   547    547   {
   548    548   /* squeezing the WMS Cache */
   549    549       int i;
................................................................................
   592    592   	cache->LastCapab->Next = ptr;
   593    593       cache->LastCapab = ptr;
   594    594       cache->TotalDownload += (double) size;
   595    595   }
   596    596   
   597    597   
   598    598   static void
   599         -wmsAddCachedItem (wmsCachePtr cache, const char *url,
   600         -		  const unsigned char *item, int size, const char *image_format)
          599  +wmsAddCachedItem (wmsCachePtr cache, const char *url, const unsigned char *item,
          600  +		  int size, const char *image_format)
   601    601   {
   602    602   /* adding a new WMS Cached Item */
   603    603       wmsCachedItemPtr ptr;
   604    604       if (cache == NULL)
   605    605   	return;
   606    606       if (cache->CurrentSize + size > cache->MaxSize)
   607    607   	wmsCacheSqueeze (cache, cache->MaxSize - size);
................................................................................
  1099   1099   	ptr->first = arg;
  1100   1100       if (ptr->last != NULL)
  1101   1101   	ptr->last->next = arg;
  1102   1102       ptr->last = arg;
  1103   1103   }
  1104   1104   
  1105   1105   static void
  1106         -parse_pattern_bbox (const char *value, double *minx, double *miny,
  1107         -		    double *maxx, double *maxy)
         1106  +parse_pattern_bbox (const char *value, double *minx, double *miny, double *maxx,
         1107  +		    double *maxy)
  1108   1108   {
  1109   1109   /* parsing a BBOX arg [minx,miny,maxx,maxy] */
  1110   1110       int step = 0;
  1111   1111       const char *p_start = value;
  1112   1112       const char *p_end = value;
  1113   1113       *minx = DBL_MAX;
  1114   1114       *miny = DBL_MAX;
................................................................................
  2027   2027   		outbuf.WriteOffset -= 2;
  2028   2028   		continue;
  2029   2029   	    }
  2030   2030   	  if (cdata)
  2031   2031   	    {
  2032   2032   		/* masking XML special characters */
  2033   2033   		if (*(p_in + i) == '<')
  2034         -		    wmsMemBufferAppend (&outbuf,
  2035         -					(const unsigned char *) "&lt;", 4);
         2034  +		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&lt;",
         2035  +					4);
  2036   2036   		else if (*(p_in + i) == '>')
  2037         -		    wmsMemBufferAppend (&outbuf,
  2038         -					(const unsigned char *) "&gt;", 4);
         2037  +		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&gt;",
         2038  +					4);
  2039   2039   		else if (*(p_in + i) == '&')
  2040   2040   		    wmsMemBufferAppend (&outbuf,
  2041   2041   					(const unsigned char *) "&amp;", 5);
  2042   2042   		else if (*(p_in + i) == '>')
  2043   2043   		    wmsMemBufferAppend (&outbuf,
  2044   2044   					(const unsigned char *) "&quot;", 6);
  2045   2045   		else
................................................................................
  2119   2119   		outbuf.WriteOffset -= 2;
  2120   2120   		continue;
  2121   2121   	    }
  2122   2122   	  if (cdata)
  2123   2123   	    {
  2124   2124   		/* masking XML special characters */
  2125   2125   		if (*(p_in + i) == '<')
  2126         -		    wmsMemBufferAppend (&outbuf,
  2127         -					(const unsigned char *) "&lt;", 4);
         2126  +		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&lt;",
         2127  +					4);
  2128   2128   		else if (*(p_in + i) == '>')
  2129         -		    wmsMemBufferAppend (&outbuf,
  2130         -					(const unsigned char *) "&gt;", 4);
         2129  +		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&gt;",
         2130  +					4);
  2131   2131   		else if (*(p_in + i) == '&')
  2132   2132   		    wmsMemBufferAppend (&outbuf,
  2133   2133   					(const unsigned char *) "&amp;", 5);
  2134   2134   		else if (*(p_in + i) == '>')
  2135   2135   		    wmsMemBufferAppend (&outbuf,
  2136   2136   					(const unsigned char *) "&quot;", 6);
  2137   2137   		else
................................................................................
  2705   2705   		      if (child_node != NULL)
  2706   2706   			{
  2707   2707   			    if (child_node->type == XML_TEXT_NODE)
  2708   2708   				*contact_organization =
  2709   2709   				    (const char *) (child_node->content);
  2710   2710   			}
  2711   2711   		  }
  2712         -		if (strcmp ((const char *) (cur_node->name), "ContactPerson")
  2713         -		    == 0)
         2712  +		if (strcmp ((const char *) (cur_node->name), "ContactPerson") ==
         2713  +		    0)
  2714   2714   		  {
  2715   2715   		      child_node = cur_node->children;
  2716   2716   		      if (child_node != NULL)
  2717   2717   			{
  2718   2718   			    if (child_node->type == XML_TEXT_NODE)
  2719   2719   				*contact_person =
  2720   2720   				    (const char *) (child_node->content);
................................................................................
  2752   2752   		      child_node = cur_node->children;
  2753   2753   		      if (child_node != NULL)
  2754   2754   			{
  2755   2755   			    if (child_node->type == XML_TEXT_NODE)
  2756   2756   				*city = (const char *) (child_node->content);
  2757   2757   			}
  2758   2758   		  }
  2759         -		if (strcmp
  2760         -		    ((const char *) (cur_node->name), "StateOrProvince") == 0)
         2759  +		if (strcmp ((const char *) (cur_node->name), "StateOrProvince")
         2760  +		    == 0)
  2761   2761   		  {
  2762   2762   		      child_node = cur_node->children;
  2763   2763   		      if (child_node != NULL)
  2764   2764   			{
  2765   2765   			    if (child_node->type == XML_TEXT_NODE)
  2766   2766   				*state_province =
  2767   2767   				    (const char *) (child_node->content);
................................................................................
  2805   2805       xmlNodePtr cur_node = NULL;
  2806   2806       xmlNodePtr child_node = NULL;
  2807   2807   
  2808   2808       for (cur_node = node; cur_node; cur_node = cur_node->next)
  2809   2809         {
  2810   2810   	  if (cur_node->type == XML_ELEMENT_NODE)
  2811   2811   	    {
  2812         -		if (strcmp
  2813         -		    ((const char *) (cur_node->name), "ContactPosition") == 0)
         2812  +		if (strcmp ((const char *) (cur_node->name), "ContactPosition")
         2813  +		    == 0)
  2814   2814   		  {
  2815   2815   		      child_node = cur_node->children;
  2816   2816   		      if (child_node != NULL)
  2817   2817   			{
  2818   2818   			    if (child_node->type == XML_TEXT_NODE)
  2819   2819   				*contact_position =
  2820   2820   				    (const char *) (child_node->content);
................................................................................
  2934   2934   		    ((const char *) (cur_node->name),
  2935   2935   		     "ContactInformation") == 0)
  2936   2936   		    parse_wms_contact_information (cur_node->children,
  2937   2937   						   &contact_person,
  2938   2938   						   &contact_organization,
  2939   2939   						   &contact_position,
  2940   2940   						   &postal_address, &city,
  2941         -						   &state_province,
  2942         -						   &post_code, &country,
  2943         -						   &voice_telephone,
         2941  +						   &state_province, &post_code,
         2942  +						   &country, &voice_telephone,
  2944   2943   						   &fax_telephone,
  2945   2944   						   &email_address);
  2946   2945   		if (strcmp ((const char *) (cur_node->name), "Fees") == 0)
  2947   2946   		  {
  2948   2947   		      child_node = cur_node->children;
  2949   2948   		      if (child_node != NULL)
  2950   2949   			{
................................................................................
  3246   3245   						    cap->GetMapURLGet = NULL;
  3247   3246   						}
  3248   3247   					      p = (const char
  3249   3248   						   *) (text->content);
  3250   3249   					      len = strlen (p);
  3251   3250   					      cap->GetTileServiceURLGet =
  3252   3251   						  malloc (len + 1);
  3253         -					      strcpy
  3254         -						  (cap->GetTileServiceURLGet,
  3255         -						   p);
         3252  +					      strcpy (cap->GetTileServiceURLGet,
         3253  +						      p);
  3256   3254   					  }
  3257   3255   				    }
  3258   3256   			      }
  3259   3257   			    attr = attr->next;
  3260   3258   			}
  3261   3259   		  }
  3262   3260   	    }
................................................................................
  3286   3284   				  if (strcmp
  3287   3285   				      ((const char *) (attr->name),
  3288   3286   				       "href") == 0)
  3289   3287   				    {
  3290   3288   					xmlNodePtr text = attr->children;
  3291   3289   					if (text->type == XML_TEXT_NODE)
  3292   3290   					  {
  3293         -					      if (cap->GetTileServiceURLPost
  3294         -						  != NULL)
         3291  +					      if (cap->GetTileServiceURLPost !=
         3292  +						  NULL)
  3295   3293   						{
  3296   3294   						    free (cap->
  3297   3295   							  GetTileServiceURLPost);
  3298   3296   						    cap->GetTileServiceURLPost =
  3299   3297   							NULL;
  3300   3298   						}
  3301   3299   					      p = (const char
................................................................................
  3351   3349   							NULL;
  3352   3350   						}
  3353   3351   					      p = (const char
  3354   3352   						   *) (text->content);
  3355   3353   					      len = strlen (p);
  3356   3354   					      cap->GetFeatureInfoURLGet =
  3357   3355   						  malloc (len + 1);
  3358         -					      strcpy
  3359         -						  (cap->GetFeatureInfoURLGet,
  3360         -						   p);
         3356  +					      strcpy (cap->GetFeatureInfoURLGet,
         3357  +						      p);
  3361   3358   					  }
  3362   3359   				    }
  3363   3360   			      }
  3364   3361   			    attr = attr->next;
  3365   3362   			}
  3366   3363   		  }
  3367   3364   	    }
................................................................................
  3391   3388   				  if (strcmp
  3392   3389   				      ((const char *) (attr->name),
  3393   3390   				       "href") == 0)
  3394   3391   				    {
  3395   3392   					xmlNodePtr text = attr->children;
  3396   3393   					if (text->type == XML_TEXT_NODE)
  3397   3394   					  {
  3398         -					      if (cap->GetFeatureInfoURLPost
  3399         -						  != NULL)
         3395  +					      if (cap->GetFeatureInfoURLPost !=
         3396  +						  NULL)
  3400   3397   						{
  3401   3398   						    free (cap->GetFeatureInfoURLPost);
  3402   3399   						    cap->GetFeatureInfoURLPost =
  3403   3400   							NULL;
  3404   3401   						}
  3405   3402   					      p = (const char
  3406   3403   						   *) (text->content);
................................................................................
  3585   3582   					    ok = 1;
  3586   3583   					if (strcmp
  3587   3584   					    (format,
  3588   3585   					     "application/vnd.ogc.gml") == 0)
  3589   3586   					    ok = 1;
  3590   3587   					if (strcmp
  3591   3588   					    (format,
  3592         -					     "application/vnd.ogc.gml/3.1.1")
  3593         -					    == 0)
         3589  +					     "application/vnd.ogc.gml/3.1.1") ==
         3590  +					    0)
  3594   3591   					    ok = 1;
  3595   3592   					if (ok)
  3596   3593   					  {
  3597   3594   					      int len = strlen (format);
  3598   3595   					      cap->GmlMimeType =
  3599   3596   						  malloc (len + 1);
  3600   3597   					      strcpy (cap->GmlMimeType, format);
................................................................................
  4380   4377   
  4381   4378       for (; cur_node; cur_node = cur_node->next)
  4382   4379         {
  4383   4380   	  if (cur_node->type == XML_ELEMENT_NODE)
  4384   4381   	    {
  4385   4382   		if (strcmp ((const char *) (cur_node->name), "Service") == 0)
  4386   4383   		    parse_tile_service_info (cur_node, cap);
  4387         -		if (strcmp ((const char *) (cur_node->name), "TiledPatterns")
  4388         -		    == 0)
         4384  +		if (strcmp ((const char *) (cur_node->name), "TiledPatterns") ==
         4385  +		    0)
  4389   4386   		    parse_tiled_patterns (cur_node, cap);
  4390   4387   	    }
  4391   4388         }
  4392   4389   }
  4393   4390   
  4394   4391   static void
  4395   4392   parse_wms_get_tile_service (wmsCapabilitiesPtr capabilities, const char *buf)
................................................................................
  4762   4759       else
  4763   4760   	return;
  4764   4761   
  4765   4762       for (; cur_node; cur_node = cur_node->next)
  4766   4763         {
  4767   4764   	  if (cur_node->type == XML_ELEMENT_NODE)
  4768   4765   	    {
  4769         -		if (strcmp ((const char *) (cur_node->name), "featureMember")
  4770         -		    == 0)
         4766  +		if (strcmp ((const char *) (cur_node->name), "featureMember") ==
         4767  +		    0)
  4771   4768   		    parse_wms_feature_member (cur_node->children, coll);
  4772   4769   	    }
  4773   4770         }
  4774   4771   }
  4775   4772   
  4776   4773   static wmsFeatureCollectionPtr
  4777   4774   parse_wms_feature_collection (const char *buf)
................................................................................
  4832   4829   	    }
  4833   4830         }
  4834   4831   
  4835   4832       return coll;
  4836   4833   }
  4837   4834   
  4838   4835   static int
  4839         -query_TileService (rl2WmsCachePtr cache_handle,
  4840         -		   wmsCapabilitiesPtr capabilities, const char *proxy)
         4836  +query_TileService (rl2WmsCachePtr cache_handle, wmsCapabilitiesPtr capabilities,
         4837  +		   const char *proxy)
  4841   4838   {
  4842   4839   /* attempting to get and parse a WMS GetTileService request */
  4843   4840       CURL *curl = NULL;
  4844   4841       CURLcode res;
  4845   4842       wmsMemBuffer headerBuf;
  4846   4843       wmsMemBuffer bodyBuf;
  4847   4844       int http_status;
................................................................................
  6948   6945   	  attr = attr->next;
  6949   6946         }
  6950   6947       return NULL;
  6951   6948   }
  6952   6949   
  6953   6950   RL2_DECLARE int
  6954   6951   get_wms_feature_attribute_blob_geometry (rl2WmsFeatureMemberPtr handle,
  6955         -					 int index,
  6956         -					 const unsigned char **blob,
         6952  +					 int index, const unsigned char **blob,
  6957   6953   					 int *blob_size)
  6958   6954   {
  6959   6955   /* attempting to get the Nth FeatureAttribute (Geometry) from some WMS-FeatureMember object */
  6960   6956       int count = 0;
  6961   6957       wmsFeatureAttributePtr attr;
  6962   6958       wmsFeatureMemberPtr ptr = (wmsFeatureMemberPtr) handle;
  6963   6959       if (ptr == NULL)
................................................................................
  7067   7063   	  /* "?" marker not declared */
  7068   7064   	  if (swap_xy)
  7069   7065   	      request =
  7070   7066   		  sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7071   7067   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7072   7068   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7073   7069   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7074         -				   version, layer, crs_prefix, crs, miny,
  7075         -				   minx, maxy, maxx, width, height, style,
  7076         -				   format, (opaque == 0) ? "TRUE" : "FALSE");
         7070  +				   version, layer, crs_prefix, crs, miny, minx,
         7071  +				   maxy, maxx, width, height, style, format,
         7072  +				   (opaque == 0) ? "TRUE" : "FALSE");
  7077   7073   	  else
  7078   7074   	      request =
  7079   7075   		  sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7080   7076   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7081   7077   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7082   7078   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7083         -				   version, layer, crs_prefix, crs, minx,
  7084         -				   miny, maxx, maxy, width, height, style,
  7085         -				   format, (opaque == 0) ? "TRUE" : "FALSE");
         7079  +				   version, layer, crs_prefix, crs, minx, miny,
         7080  +				   maxx, maxy, width, height, style, format,
         7081  +				   (opaque == 0) ? "TRUE" : "FALSE");
  7086   7082         }
  7087   7083       else
  7088   7084         {
  7089   7085   	  /* "?" marker already defined */
  7090   7086   	  if (swap_xy)
  7091   7087   	      request =
  7092   7088   		  sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7093   7089   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7094   7090   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7095   7091   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7096         -				   version, layer, crs_prefix, crs, miny,
  7097         -				   minx, maxy, maxx, width, height, style,
  7098         -				   format, (opaque == 0) ? "TRUE" : "FALSE");
         7092  +				   version, layer, crs_prefix, crs, miny, minx,
         7093  +				   maxy, maxx, width, height, style, format,
         7094  +				   (opaque == 0) ? "TRUE" : "FALSE");
  7099   7095   	  else
  7100   7096   	      request =
  7101   7097   		  sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7102   7098   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7103   7099   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7104   7100   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7105         -				   version, layer, crs_prefix, crs, minx,
  7106         -				   miny, maxx, maxy, width, height, style,
  7107         -				   format, (opaque == 0) ? "TRUE" : "FALSE");
         7101  +				   version, layer, crs_prefix, crs, minx, miny,
         7102  +				   maxx, maxy, width, height, style, format,
         7103  +				   (opaque == 0) ? "TRUE" : "FALSE");
  7108   7104         }
  7109         -    fprintf (stderr, "\n%s\n", request);
  7110   7105   
  7111   7106       if (cache != NULL)
  7112   7107         {
  7113   7108   	  /* checks if it's already stored into the WMS Cache */
  7114   7109   	  wmsCachedItemPtr cachedItem = getWmsCachedItem (cache, request);
  7115   7110   	  if (cachedItem != NULL)
  7116   7111   	    {
................................................................................
  7276   7271   		    double maxx, double maxy, int width, int height,
  7277   7272   		    const char *style, const char *format, int opaque,
  7278   7273   		    int from_cache, char **err_msg)
  7279   7274   {
  7280   7275   /* attempting to execute a WMS GepMap request [method POST] */
  7281   7276   
  7282   7277   /* not yet implemented: just a stupid placeholder always returning NULL */
  7283         -    if (cache_handle == NULL || url == NULL || proxy == NULL
  7284         -	|| version == NULL || layer == NULL || crs == NULL)
         7278  +    if (cache_handle == NULL || url == NULL || proxy == NULL || version == NULL
         7279  +	|| layer == NULL || crs == NULL)
  7285   7280   	return NULL;
  7286         -    if (minx == miny || maxx == maxy || width == height
  7287         -	|| opaque == from_cache || width == swap_xy)
         7281  +    if (minx == miny || maxx == maxy || width == height || opaque == from_cache
         7282  +	|| width == swap_xy)
  7288   7283   	return NULL;
  7289   7284       if (style == NULL || format == NULL || err_msg == NULL)
  7290   7285   	return NULL;
  7291   7286       return NULL;
  7292   7287   }
  7293   7288   
  7294   7289   RL2_DECLARE unsigned char *
................................................................................
  7534   7529         {
  7535   7530   	  if (swap_xy)
  7536   7531   	      request =
  7537   7532   		  sqlite3_mprintf
  7538   7533   		  ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7539   7534   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7540   7535   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7541         -		   "&FEATURE_COUNT=50", url, version, layer, layer,
  7542         -		   crs_prefix, crs, miny, minx, maxy, maxx, width, height,
  7543         -		   mouse_x, mouse_y, format);
         7536  +		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
         7537  +		   crs, miny, minx, maxy, maxx, width, height, mouse_x,
         7538  +		   mouse_y, format);
  7544   7539   	  else
  7545   7540   	      request =
  7546   7541   		  sqlite3_mprintf
  7547   7542   		  ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7548   7543   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7549   7544   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7550         -		   "&FEATURE_COUNT=50", url, version, layer, layer,
  7551         -		   crs_prefix, crs, minx, miny, maxx, maxy, width, height,
  7552         -		   mouse_x, mouse_y, format);
         7545  +		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
         7546  +		   crs, minx, miny, maxx, maxy, width, height, mouse_x,
         7547  +		   mouse_y, format);
  7553   7548         }
  7554   7549       else
  7555   7550         {
  7556   7551   	  if (swap_xy)
  7557   7552   	      request =
  7558   7553   		  sqlite3_mprintf
  7559   7554   		  ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7560   7555   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7561   7556   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7562         -		   "&FEATURE_COUNT=50", url, version, layer, layer,
  7563         -		   crs_prefix, crs, miny, minx, maxy, maxx, width, height,
  7564         -		   mouse_x, mouse_y, format);
         7557  +		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
         7558  +		   crs, miny, minx, maxy, maxx, width, height, mouse_x,
         7559  +		   mouse_y, format);
  7565   7560   	  else
  7566   7561   	      request =
  7567   7562   		  sqlite3_mprintf
  7568   7563   		  ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7569   7564   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7570   7565   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7571         -		   "&FEATURE_COUNT=50", url, version, layer, layer,
  7572         -		   crs_prefix, crs, minx, miny, maxx, maxy, width, height,
  7573         -		   mouse_x, mouse_y, format);
         7566  +		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
         7567  +		   crs, minx, miny, maxx, maxy, width, height, mouse_x,
         7568  +		   mouse_y, format);
  7574   7569         }
  7575   7570   
  7576   7571       curl = curl_easy_init ();
  7577   7572       if (curl)
  7578   7573         {
  7579   7574   	  /* setting the URL */
  7580   7575   	  curl_easy_setopt (curl, CURLOPT_URL, request);
................................................................................
  7704   7699       return (rl2WmsFeatureCollectionPtr) coll;
  7705   7700   }
  7706   7701   
  7707   7702   RL2_DECLARE rl2WmsFeatureCollectionPtr
  7708   7703   do_wms_GetFeatureInfo_post (const char *url, const char *proxy,
  7709   7704   			    const char *version, const char *format,
  7710   7705   			    const char *layer, const char *crs, int swap_xy,
  7711         -			    double minx, double miny, double maxx,
  7712         -			    double maxy, int width, int height, int mouse_x,
  7713         -			    int mouse_y, char **err_msg)
         7706  +			    double minx, double miny, double maxx, double maxy,
         7707  +			    int width, int height, int mouse_x, int mouse_y,
         7708  +			    char **err_msg)
  7714   7709   {
  7715   7710   /* attempting to execute a WMS GepFeatureInfo request [method POST] */
  7716   7711   
  7717   7712   /* not yet implemented: just a stupid placeholder always returning NULL */
  7718   7713       if (url == NULL || proxy == NULL || version == NULL || format == NULL
  7719   7714   	|| layer == NULL || crs == NULL)
  7720   7715   	return NULL;

Changes to test/Makefile.am.

    17     17   	test_map_indiana test_load_wms \
    18     18   	test_map_noref test_map_trento \
    19     19   	test_map_trieste test_map_infrared \
    20     20   	test_map_orbetello test_raster_symbolizer \
    21     21   	test_svg test_raw test_openjpeg \
    22     22   	test_line_symbolizer test_polygon_symbolizer \
    23     23   	test_point_symbolizer test_text_symbolizer \
    24         -	test_vectors test_font test_copy_rastercov \
    25         -	test_tile_callback
           24  +	test_vectors test_font test_copy_rastercov
    26     25   
    27     26   AM_CPPFLAGS = -I@srcdir@/../headers @LIBXML2_CFLAGS@
    28     27   AM_LDFLAGS = -L../src -lrasterlite2 @LIBCAIRO_LIBS@ @LIBPNG_LIBS@ \
    29     28   	@LIBWEBP_LIBS@ @LIBLZMA_LIBS@ @LIBSPATIALITE_LIBS@ \
    30     29   	@LIBCURL_LIBS@ @LIBXML2_LIBS@  @LIBFREETYPE2_LIBS@ \
    31     30   	$(GCOV_FLAGS)
    32     31   

Changes to test/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   VPATH = @srcdir@
    17         -am__is_gnu_make = { \
    18         -  if test -z '$(MAKELEVEL)'; then \
    19         -    false; \
    20         -  elif test -n '$(MAKE_HOST)'; then \
    21         -    true; \
    22         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    23         -    true; \
    24         -  else \
    25         -    false; \
    26         -  fi; \
    27         -}
           17  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    28     18   am__make_running_with_option = \
    29     19     case $${target_option-} in \
    30     20         ?) ;; \
    31     21         *) echo "am__make_running_with_option: internal error: invalid" \
    32     22                 "target option '$${target_option-}' specified" >&2; \
    33     23            exit 1;; \
    34     24     esac; \
................................................................................
   108     98   	test_map_noref$(EXEEXT) test_map_trento$(EXEEXT) \
   109     99   	test_map_trieste$(EXEEXT) test_map_infrared$(EXEEXT) \
   110    100   	test_map_orbetello$(EXEEXT) test_raster_symbolizer$(EXEEXT) \
   111    101   	test_svg$(EXEEXT) test_raw$(EXEEXT) test_openjpeg$(EXEEXT) \
   112    102   	test_line_symbolizer$(EXEEXT) test_polygon_symbolizer$(EXEEXT) \
   113    103   	test_point_symbolizer$(EXEEXT) test_text_symbolizer$(EXEEXT) \
   114    104   	test_vectors$(EXEEXT) test_font$(EXEEXT) \
   115         -	test_copy_rastercov$(EXEEXT) test_tile_callback$(EXEEXT)
          105  +	test_copy_rastercov$(EXEEXT)
   116    106   subdir = test
          107  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
          108  +	$(top_srcdir)/depcomp $(top_srcdir)/test-driver
   117    109   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
   118    110   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
   119    111   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
   120    112   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
   121    113   	$(top_srcdir)/configure.ac
   122    114   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
   123    115   	$(ACLOCAL_M4)
   124         -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
   125    116   mkinstalldirs = $(install_sh) -d
   126    117   CONFIG_HEADER = $(top_builddir)/config.h
   127    118   CONFIG_CLEAN_FILES =
   128    119   CONFIG_CLEAN_VPATH_FILES =
   129    120   check_sql_stmt_SOURCES = check_sql_stmt.c
   130    121   check_sql_stmt_OBJECTS = check_sql_stmt.$(OBJEXT)
   131    122   check_sql_stmt_LDADD = $(LDADD)
................................................................................
   300    291   test_svg_LDADD = $(LDADD)
   301    292   test_text_symbolizer_SOURCES = test_text_symbolizer.c
   302    293   test_text_symbolizer_OBJECTS = test_text_symbolizer.$(OBJEXT)
   303    294   test_text_symbolizer_LDADD = $(LDADD)
   304    295   test_tifin_SOURCES = test_tifin.c
   305    296   test_tifin_OBJECTS = test_tifin.$(OBJEXT)
   306    297   test_tifin_LDADD = $(LDADD)
   307         -test_tile_callback_SOURCES = test_tile_callback.c
   308         -test_tile_callback_OBJECTS = test_tile_callback.$(OBJEXT)
   309         -test_tile_callback_LDADD = $(LDADD)
   310    298   test_vectors_SOURCES = test_vectors.c
   311    299   test_vectors_OBJECTS = test_vectors.$(OBJEXT)
   312    300   test_vectors_LDADD = $(LDADD)
   313    301   test_webp_SOURCES = test_webp.c
   314    302   test_webp_OBJECTS = test_webp.$(OBJEXT)
   315    303   test_webp_LDADD = $(LDADD)
   316    304   test_wms1_SOURCES = test_wms1.c
................................................................................
   367    355   	test_map_nile_u16.c test_map_nile_u32.c test_map_nile_u8.c \
   368    356   	test_map_noref.c test_map_orbetello.c test_map_rgb.c \
   369    357   	test_map_srtm.c test_map_trento.c test_map_trieste.c \
   370    358   	test_mask.c test_openjpeg.c test_paint.c test_palette.c \
   371    359   	test_point_symbolizer.c test_polygon_symbolizer.c \
   372    360   	test_raster.c test_raster_symbolizer.c test_raw.c \
   373    361   	test_section.c test_svg.c test_text_symbolizer.c test_tifin.c \
   374         -	test_tile_callback.c test_vectors.c test_webp.c test_wms1.c \
   375         -	test_wms2.c test_wr_tiff.c
          362  +	test_vectors.c test_webp.c test_wms1.c test_wms2.c \
          363  +	test_wr_tiff.c
   376    364   DIST_SOURCES = check_sql_stmt.c test1.c test10.c test11.c test12.c \
   377    365   	test13.c test14.c test15.c test16.c test17.c test18.c test19.c \
   378    366   	test2.c test20.c test3.c test4.c test5.c test6.c test7.c \
   379    367   	test8.c test9.c test_copy_rastercov.c test_coverage.c \
   380    368   	test_font.c test_gif.c test_line_symbolizer.c test_load_wms.c \
   381    369   	test_map_ascii.c test_map_gray.c test_map_indiana.c \
   382    370   	test_map_infrared.c test_map_mono.c test_map_nile_32.c \
................................................................................
   384    372   	test_map_nile_u16.c test_map_nile_u32.c test_map_nile_u8.c \
   385    373   	test_map_noref.c test_map_orbetello.c test_map_rgb.c \
   386    374   	test_map_srtm.c test_map_trento.c test_map_trieste.c \
   387    375   	test_mask.c test_openjpeg.c test_paint.c test_palette.c \
   388    376   	test_point_symbolizer.c test_polygon_symbolizer.c \
   389    377   	test_raster.c test_raster_symbolizer.c test_raw.c \
   390    378   	test_section.c test_svg.c test_text_symbolizer.c test_tifin.c \
   391         -	test_tile_callback.c test_vectors.c test_webp.c test_wms1.c \
   392         -	test_wms2.c test_wr_tiff.c
          379  +	test_vectors.c test_webp.c test_wms1.c test_wms2.c \
          380  +	test_wr_tiff.c
   393    381   RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
   394    382   	ctags-recursive dvi-recursive html-recursive info-recursive \
   395    383   	install-data-recursive install-dvi-recursive \
   396    384   	install-exec-recursive install-html-recursive \
   397    385   	install-info-recursive install-pdf-recursive \
   398    386   	install-ps-recursive install-recursive installcheck-recursive \
   399    387   	installdirs-recursive pdf-recursive ps-recursive \
................................................................................
   630    618   am__test_logs1 = $(TESTS:=.log)
   631    619   am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
   632    620   TEST_LOGS = $(am__test_logs2:.test.log=.log)
   633    621   TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
   634    622   TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
   635    623   	$(TEST_LOG_FLAGS)
   636    624   DIST_SUBDIRS = $(SUBDIRS)
   637         -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
   638         -	$(top_srcdir)/test-driver
   639    625   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   640    626   am__relativize = \
   641    627     dir0=`pwd`; \
   642    628     sed_first='s,^\([^/]*\)/.*$$,\1,'; \
   643    629     sed_rest='s,^[^/]*/*,,'; \
   644    630     sed_last='s,^.*/\([^/]*\)$$,\1,'; \
   645    631     sed_butlast='s,/*[^/]*$$,,'; \
................................................................................
   899    885   	        && { if test -f $@; then exit 0; else break; fi; }; \
   900    886   	      exit 1;; \
   901    887   	  esac; \
   902    888   	done; \
   903    889   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
   904    890   	$(am__cd) $(top_srcdir) && \
   905    891   	  $(AUTOMAKE) --gnu test/Makefile
          892  +.PRECIOUS: Makefile
   906    893   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   907    894   	@case '$?' in \
   908    895   	  *config.status*) \
   909    896   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   910    897   	  *) \
   911    898   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   912    899   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1158   1145   	@rm -f test_text_symbolizer$(EXEEXT)
  1159   1146   	$(AM_V_CCLD)$(LINK) $(test_text_symbolizer_OBJECTS) $(test_text_symbolizer_LDADD) $(LIBS)
  1160   1147   
  1161   1148   test_tifin$(EXEEXT): $(test_tifin_OBJECTS) $(test_tifin_DEPENDENCIES) $(EXTRA_test_tifin_DEPENDENCIES) 
  1162   1149   	@rm -f test_tifin$(EXEEXT)
  1163   1150   	$(AM_V_CCLD)$(LINK) $(test_tifin_OBJECTS) $(test_tifin_LDADD) $(LIBS)
  1164   1151   
  1165         -test_tile_callback$(EXEEXT): $(test_tile_callback_OBJECTS) $(test_tile_callback_DEPENDENCIES) $(EXTRA_test_tile_callback_DEPENDENCIES) 
  1166         -	@rm -f test_tile_callback$(EXEEXT)
  1167         -	$(AM_V_CCLD)$(LINK) $(test_tile_callback_OBJECTS) $(test_tile_callback_LDADD) $(LIBS)
  1168         -
  1169   1152   test_vectors$(EXEEXT): $(test_vectors_OBJECTS) $(test_vectors_DEPENDENCIES) $(EXTRA_test_vectors_DEPENDENCIES) 
  1170   1153   	@rm -f test_vectors$(EXEEXT)
  1171   1154   	$(AM_V_CCLD)$(LINK) $(test_vectors_OBJECTS) $(test_vectors_LDADD) $(LIBS)
  1172   1155   
  1173   1156   test_webp$(EXEEXT): $(test_webp_OBJECTS) $(test_webp_DEPENDENCIES) $(EXTRA_test_webp_DEPENDENCIES) 
  1174   1157   	@rm -f test_webp$(EXEEXT)
  1175   1158   	$(AM_V_CCLD)$(LINK) $(test_webp_OBJECTS) $(test_webp_LDADD) $(LIBS)
................................................................................
  1246   1229   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_raster.Po@am__quote@
  1247   1230   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_raster_symbolizer.Po@am__quote@
  1248   1231   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_raw.Po@am__quote@
  1249   1232   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_section.Po@am__quote@
  1250   1233   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_svg.Po@am__quote@
  1251   1234   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_text_symbolizer.Po@am__quote@
  1252   1235   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tifin.Po@am__quote@
  1253         -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tile_callback.Po@am__quote@
  1254   1236   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vectors.Po@am__quote@
  1255   1237   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_webp.Po@am__quote@
  1256   1238   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wms1.Po@am__quote@
  1257   1239   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wms2.Po@am__quote@
  1258   1240   @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wr_tiff.Po@am__quote@
  1259   1241   
  1260   1242   .c.o:
................................................................................
  1409   1391   	  if $(am__make_dryrun); then :; else \
  1410   1392   	    rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
  1411   1393   	  fi; \
  1412   1394   	fi; \
  1413   1395   	if test -n "$$am__remaking_logs"; then \
  1414   1396   	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
  1415   1397   	       "recursion detected" >&2; \
  1416         -	elif test -n "$$redo_logs"; then \
         1398  +	else \
  1417   1399   	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
  1418   1400   	fi; \
  1419   1401   	if $(am__make_dryrun); then :; else \
  1420   1402   	  st=0;  \
  1421   1403   	  errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
  1422   1404   	  for i in $$redo_bases; do \
  1423   1405   	    test -f $$i.trs && test -r $$i.trs \
................................................................................
  1961   1943   test_copy_rastercov.log: test_copy_rastercov$(EXEEXT)
  1962   1944   	@p='test_copy_rastercov$(EXEEXT)'; \
  1963   1945   	b='test_copy_rastercov'; \
  1964   1946   	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
  1965   1947   	--log-file $$b.log --trs-file $$b.trs \
  1966   1948   	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
  1967   1949   	"$$tst" $(AM_TESTS_FD_REDIRECT)
  1968         -test_tile_callback.log: test_tile_callback$(EXEEXT)
  1969         -	@p='test_tile_callback$(EXEEXT)'; \
  1970         -	b='test_tile_callback'; \
  1971         -	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
  1972         -	--log-file $$b.log --trs-file $$b.trs \
  1973         -	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
  1974         -	"$$tst" $(AM_TESTS_FD_REDIRECT)
  1975   1950   .test.log:
  1976   1951   	@p='$<'; \
  1977   1952   	$(am__set_b); \
  1978   1953   	$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
  1979   1954   	--log-file $$b.log --trs-file $$b.trs \
  1980   1955   	$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
  1981   1956   	"$$tst" $(AM_TESTS_FD_REDIRECT)
................................................................................
  2167   2142   	install-pdf install-pdf-am install-ps install-ps-am \
  2168   2143   	install-strip installcheck installcheck-am installdirs \
  2169   2144   	installdirs-am maintainer-clean maintainer-clean-generic \
  2170   2145   	mostlyclean mostlyclean-compile mostlyclean-generic \
  2171   2146   	mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
  2172   2147   	uninstall uninstall-am
  2173   2148   
  2174         -.PRECIOUS: Makefile
  2175         -
  2176   2149   
  2177   2150   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  2178   2151   # Otherwise a system limit (for SysV at least) may be exceeded.
  2179   2152   .NOEXPORT:

Changes to test/sql_stmt_security_tests/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   VPATH = @srcdir@
    17         -am__is_gnu_make = { \
    18         -  if test -z '$(MAKELEVEL)'; then \
    19         -    false; \
    20         -  elif test -n '$(MAKE_HOST)'; then \
    21         -    true; \
    22         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    23         -    true; \
    24         -  else \
    25         -    false; \
    26         -  fi; \
    27         -}
           17  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    28     18   am__make_running_with_option = \
    29     19     case $${target_option-} in \
    30     20         ?) ;; \
    31     21         *) echo "am__make_running_with_option: internal error: invalid" \
    32     22                 "target option '$${target_option-}' specified" >&2; \
    33     23            exit 1;; \
    34     24     esac; \
................................................................................
    84     74   POST_INSTALL = :
    85     75   NORMAL_UNINSTALL = :
    86     76   PRE_UNINSTALL = :
    87     77   POST_UNINSTALL = :
    88     78   build_triplet = @build@
    89     79   host_triplet = @host@
    90     80   subdir = test/sql_stmt_security_tests
           81  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
    91     82   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    92     83   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    93     84   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    94     85   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    95     86   	$(top_srcdir)/configure.ac
    96     87   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    97     88   	$(ACLOCAL_M4)
    98         -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
    99     89   mkinstalldirs = $(install_sh) -d
   100     90   CONFIG_HEADER = $(top_builddir)/config.h
   101     91   CONFIG_CLEAN_FILES =
   102     92   CONFIG_CLEAN_VPATH_FILES =
   103     93   AM_V_P = $(am__v_P_@AM_V@)
   104     94   am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
   105     95   am__v_P_0 = false
................................................................................
   116    106   DIST_SOURCES =
   117    107   am__can_run_installinfo = \
   118    108     case $$AM_UPDATE_INFO_DIR in \
   119    109       n|no|NO) false;; \
   120    110       *) (install-info --version) >/dev/null 2>&1;; \
   121    111     esac
   122    112   am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
   123         -am__DIST_COMMON = $(srcdir)/Makefile.in
   124    113   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   125    114   ACLOCAL = @ACLOCAL@
   126    115   AMTAR = @AMTAR@
   127    116   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   128    117   AR = @AR@
   129    118   AS = @AS@
   130    119   AUTOCONF = @AUTOCONF@
................................................................................
   907    896   	        && { if test -f $@; then exit 0; else break; fi; }; \
   908    897   	      exit 1;; \
   909    898   	  esac; \
   910    899   	done; \
   911    900   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/sql_stmt_security_tests/Makefile'; \
   912    901   	$(am__cd) $(top_srcdir) && \
   913    902   	  $(AUTOMAKE) --gnu test/sql_stmt_security_tests/Makefile
          903  +.PRECIOUS: Makefile
   914    904   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   915    905   	@case '$?' in \
   916    906   	  *config.status*) \
   917    907   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   918    908   	  *) \
   919    909   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   920    910   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1081   1071   	install-html-am install-info install-info-am install-man \
  1082   1072   	install-pdf install-pdf-am install-ps install-ps-am \
  1083   1073   	install-strip installcheck installcheck-am installdirs \
  1084   1074   	maintainer-clean maintainer-clean-generic mostlyclean \
  1085   1075   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
  1086   1076   	tags-am uninstall uninstall-am
  1087   1077   
  1088         -.PRECIOUS: Makefile
  1089         -
  1090   1078   
  1091   1079   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  1092   1080   # Otherwise a system limit (for SysV at least) may be exceeded.
  1093   1081   .NOEXPORT:

Changes to test/sql_stmt_tests/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   VPATH = @srcdir@
    17         -am__is_gnu_make = { \
    18         -  if test -z '$(MAKELEVEL)'; then \
    19         -    false; \
    20         -  elif test -n '$(MAKE_HOST)'; then \
    21         -    true; \
    22         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    23         -    true; \
    24         -  else \
    25         -    false; \
    26         -  fi; \
    27         -}
           17  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    28     18   am__make_running_with_option = \
    29     19     case $${target_option-} in \
    30     20         ?) ;; \
    31     21         *) echo "am__make_running_with_option: internal error: invalid" \
    32     22                 "target option '$${target_option-}' specified" >&2; \
    33     23            exit 1;; \
    34     24     esac; \
................................................................................
    84     74   POST_INSTALL = :
    85     75   NORMAL_UNINSTALL = :
    86     76   PRE_UNINSTALL = :
    87     77   POST_UNINSTALL = :
    88     78   build_triplet = @build@
    89     79   host_triplet = @host@
    90     80   subdir = test/sql_stmt_tests
           81  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
    91     82   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    92     83   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    93     84   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    94     85   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    95     86   	$(top_srcdir)/configure.ac
    96     87   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    97     88   	$(ACLOCAL_M4)
    98         -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
    99     89   mkinstalldirs = $(install_sh) -d
   100     90   CONFIG_HEADER = $(top_builddir)/config.h
   101     91   CONFIG_CLEAN_FILES =
   102     92   CONFIG_CLEAN_VPATH_FILES =
   103     93   AM_V_P = $(am__v_P_@AM_V@)
   104     94   am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
   105     95   am__v_P_0 = false
................................................................................
   116    106   DIST_SOURCES =
   117    107   am__can_run_installinfo = \
   118    108     case $$AM_UPDATE_INFO_DIR in \
   119    109       n|no|NO) false;; \
   120    110       *) (install-info --version) >/dev/null 2>&1;; \
   121    111     esac
   122    112   am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
   123         -am__DIST_COMMON = $(srcdir)/Makefile.in
   124    113   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   125    114   ACLOCAL = @ACLOCAL@
   126    115   AMTAR = @AMTAR@
   127    116   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   128    117   AR = @AR@
   129    118   AS = @AS@
   130    119   AUTOCONF = @AUTOCONF@
................................................................................
   879    868   	        && { if test -f $@; then exit 0; else break; fi; }; \
   880    869   	      exit 1;; \
   881    870   	  esac; \
   882    871   	done; \
   883    872   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile'; \
   884    873   	$(am__cd) $(top_srcdir) && \
   885    874   	  $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile
          875  +.PRECIOUS: Makefile
   886    876   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   887    877   	@case '$?' in \
   888    878   	  *config.status*) \
   889    879   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   890    880   	  *) \
   891    881   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   892    882   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1053   1043   	install-html-am install-info install-info-am install-man \
  1054   1044   	install-pdf install-pdf-am install-ps install-ps-am \
  1055   1045   	install-strip installcheck installcheck-am installdirs \
  1056   1046   	maintainer-clean maintainer-clean-generic mostlyclean \
  1057   1047   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
  1058   1048   	tags-am uninstall uninstall-am
  1059   1049   
  1060         -.PRECIOUS: Makefile
  1061         -
  1062   1050   	version.testcase 
  1063   1051   
  1064   1052   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  1065   1053   # Otherwise a system limit (for SysV at least) may be exceeded.
  1066   1054   .NOEXPORT:

Changes to test/symbolizers.sqlite.

cannot compute difference between binary files

Changes to test/test_line_symbolizer.c.

  1072   1072       if (rl2_line_symbolizer_get_stroke_color (line, &red, &green, &blue) !=
  1073   1073   	RL2_OK)
  1074   1074         {
  1075   1075   	  fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #4\n");
  1076   1076   	  *retcode += 18;
  1077   1077   	  return 0;
  1078   1078         }
  1079         -    if (red != 0x80 || green != 0x80 || blue != 0x80)
         1079  +    if (red != 0x00 || green != 0x00 || blue != 0xff)
  1080   1080         {
  1081   1081   	  fprintf (stderr,
  1082   1082   		   "Unexpected Line Symbolizer GetStrokeColor #4: %02x%02x%02x\n",
  1083   1083   		   red, green, blue);
  1084   1084   	  *retcode += 19;
  1085   1085   	  return 0;
  1086   1086         }
................................................................................
  1311   1311       if (rl2_line_symbolizer_get_stroke_color (line, &red, &green, &blue) !=
  1312   1312   	RL2_OK)
  1313   1313         {
  1314   1314   	  fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #9\n");
  1315   1315   	  *retcode += 48;
  1316   1316   	  return 0;
  1317   1317         }
  1318         -    if (red != 0x80 || green != 0x80 || blue != 0x80)
         1318  +    if (red != 0x00 || green != 0x00 || blue != 0xff)
  1319   1319         {
  1320   1320   	  fprintf (stderr,
  1321   1321   		   "Unexpected Line Symbolizer GetStrokeColor #9: %02x%02x%02x\n",
  1322   1322   		   red, green, blue);
  1323   1323   	  *retcode += 49;
  1324   1324   	  return 0;
  1325   1325         }
................................................................................
  1359   1359   	RL2_OK)
  1360   1360         {
  1361   1361   	  fprintf (stderr,
  1362   1362   		   "Unable to get Line Symbolizer GetStrokeColor #10\n");
  1363   1363   	  *retcode += 54;
  1364   1364   	  return 0;
  1365   1365         }
  1366         -    if (red != 0x80 || green != 0x80 || blue != 0x80)
         1366  +    if (red != 0x00 || green != 0x00 || blue != 0xff)
  1367   1367         {
  1368   1368   	  fprintf (stderr,
  1369   1369   		   "Unexpected Line Symbolizer GetStrokeColor #10: %02x%02x%02x\n",
  1370   1370   		   red, green, blue);
  1371   1371   	  *retcode += 55;
  1372   1372   	  return 0;
  1373   1373         }
................................................................................
  1407   1407   	RL2_OK)
  1408   1408         {
  1409   1409   	  fprintf (stderr,
  1410   1410   		   "Unable to get Line Symbolizer GetStrokeColor #11\n");
  1411   1411   	  *retcode += 60;
  1412   1412   	  return 0;
  1413   1413         }
  1414         -    if (red != 0x80 || green != 0x80 || blue != 0x80)
         1414  +    if (red != 0x00 || green != 0x00 || blue != 0xff)
  1415   1415         {
  1416   1416   	  fprintf (stderr,
  1417   1417   		   "Unexpected Line Symbolizer GetStrokeColor #11: %02x%02x%02x\n",
  1418   1418   		   red, green, blue);
  1419   1419   	  *retcode += 61;
  1420   1420   	  return 0;
  1421   1421         }

Changes to test/test_point_symbolizer.c.

   786    786       if (strcmp (style_name, "point_3") == 0)
   787    787         {
   788    788   	  if (dblval == 3.0 && dblval2 == 2.0)
   789    789   	      intval = 1;
   790    790         }
   791    791       else
   792    792         {
   793         -	  if (dblval == 0.5 && dblval2 == 0.5)
          793  +	  if (dblval == 0.0 && dblval2 == 0.0)
   794    794   	      intval = 1;
   795    795         }
   796    796       if (intval != 1)
   797    797         {
   798    798   	  fprintf (stderr,
   799    799   		   "%s: Unexpected Point Symbolizer GetAnchorPoint #1: %1.4f %1.4f\n",
   800    800   		   style_name, dblval, dblval2);

Changes to test/test_polygon_symbolizer.c.

  1506   1506       if (symbolizer == NULL)
  1507   1507         {
  1508   1508   	  fprintf (stderr, "Unexpected NULL VectorSymbolizer (%s) #6\n",
  1509   1509   		   style_name);
  1510   1510   	  *retcode += 22;
  1511   1511   	  return 0;
  1512   1512         }
  1513         -    polyg = rl2_get_polygon_symbolizer (symbolizer, 1);
         1513  +    polyg = rl2_get_polygon_symbolizer (symbolizer, 0);
  1514   1514       if (polyg == NULL)
  1515   1515         {
  1516   1516   	  fprintf (stderr, "Unable to get Polygon Symbolizer #5\n");
  1517   1517   	  *retcode += 23;
  1518   1518   	  return 0;
  1519   1519         }
  1520   1520       if (rl2_polygon_symbolizer_get_fill_color (polyg, &red, &green, &blue) !=
................................................................................
  1521   1521   	RL2_OK)
  1522   1522         {
  1523   1523   	  fprintf (stderr,
  1524   1524   		   "Unable to get Polygon Symbolizer GetFillColor #4\n");
  1525   1525   	  *retcode += 24;
  1526   1526   	  return 0;
  1527   1527         }
  1528         -    if (red != 0x37 || green != 0x81 || blue != 0xf2)
         1528  +    if (red != 0x70 || green != 0xff || blue != 0xc0)
  1529   1529         {
  1530   1530   	  fprintf (stderr,
  1531   1531   		   "Unexpected Polygon Symbolizer GetStrokeColor #5: %02x%02x%02x\n",
  1532   1532   		   red, green, blue);
  1533   1533   	  *retcode += 25;
  1534   1534   	  return 0;
  1535   1535         }

Deleted test/test_tile_callback.c.

     1         -/*
     2         -
     3         - test_tile_callback.c -- RasterLite2 Test Case
     4         -
     5         - Author: Alessandro Furieri <a.furieri@lqt.it>
     6         -
     7         - ------------------------------------------------------------------------------
     8         - 
     9         - Version: MPL 1.1/GPL 2.0/LGPL 2.1
    10         - 
    11         - The contents of this file are subject to the Mozilla Public License Version
    12         - 1.1 (the "License"); you may not use this file except in compliance with
    13         - the License. You may obtain a copy of the License at
    14         - http://www.mozilla.org/MPL/
    15         - 
    16         -Software distributed under the License is distributed on an "AS IS" basis,
    17         -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    18         -for the specific language governing rights and limitations under the
    19         -License.
    20         -
    21         -The Original Code is the RasterLite2 library
    22         -
    23         -The Initial Developer of the Original Code is Alessandro Furieri
    24         - 
    25         -Portions created by the Initial Developer are Copyright (C) 2013
    26         -the Initial Developer. All Rights Reserved.
    27         -
    28         -Contributor(s):
    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         -#include <stdlib.h>
    43         -#include <unistd.h>
    44         -#include <stdio.h>
    45         -#include <memory.h>
    46         -
    47         -#include "config.h"
    48         -
    49         -#include "sqlite3.h"
    50         -#include "spatialite.h"
    51         -
    52         -#include "rasterlite2/rasterlite2.h"
    53         -
    54         -struct tile_info
    55         -{
    56         -/* a struct supporting the Tile Callback function */
    57         -    unsigned char sample;
    58         -    unsigned char pixel;
    59         -    unsigned char num_bands;
    60         -    int srid;
    61         -    const char *coverage;
    62         -    unsigned int tile_w;
    63         -    unsigned int tile_h;
    64         -};
    65         -
    66         -static void
    67         -set_tile_pixel_gray8 (unsigned char *bufpix, unsigned int x, unsigned int y,
    68         -		      unsigned int tile_w, double map_x, double map_y)
    69         -{
    70         -/* pixel generator - GRAYSCALE UINT8 */
    71         -    unsigned char *p = bufpix + ((y * tile_w) + x);
    72         -    if (map_y >= -15.0 && map_y <= 15.0)
    73         -      {
    74         -	  if (map_x < 0.0)
    75         -	      *p = 248;
    76         -	  else
    77         -	      *p = 216;
    78         -      }
    79         -    else if (map_y >= -60.0 && map_y <= 60.0)
    80         -      {
    81         -	  if (map_x < 0.0)
    82         -	      *p = 208;
    83         -	  else
    84         -	      *p = 192;
    85         -      }
    86         -    else
    87         -      {
    88         -	  if (map_x < 0.0)
    89         -	      *p = 128;
    90         -	  else
    91         -	      *p = 96;
    92         -      }
    93         -}
    94         -
    95         -static void
    96         -set_tile_pixel_rgb8 (unsigned char *bufpix, unsigned int x, unsigned int y,
    97         -		     unsigned int tile_w, double map_x, double map_y,
    98         -		     unsigned int num_bands)
    99         -{
   100         -/* pixel generator - RGB UINT8 */
   101         -    unsigned char *p = bufpix + (y * tile_w * num_bands) + (x * num_bands);
   102         -    if (map_y >= -15.0 && map_y <= 15.0)
   103         -      {
   104         -	  if (map_x < 0.0)
   105         -	    {
   106         -		*p++ = 248;
   107         -		*p++ = 255;
   108         -		*p++ = 0;
   109         -	    }
   110         -	  else
   111         -	    {
   112         -		*p++ = 216;
   113         -		*p++ = 248;
   114         -		*p++ = 0;
   115         -	    }
   116         -      }
   117         -    else if (map_y >= -60.0 && map_y <= 60.0)
   118         -      {
   119         -	  if (map_x < 0.0)
   120         -	    {
   121         -		*p++ = 0;
   122         -		*p++ = 208;
   123         -		*p++ = 248;
   124         -	    }
   125         -	  else
   126         -	    {
   127         -		*p++ = 0;
   128         -		*p++ = 192;
   129         -		*p++ = 248;
   130         -	    }
   131         -      }
   132         -    else
   133         -      {
   134         -	  if (map_x < 0.0)
   135         -	    {
   136         -		*p++ = 192;
   137         -		*p++ = 192;
   138         -		*p++ = 128;
   139         -	    }
   140         -	  else
   141         -	    {
   142         -		*p++ = 192;
   143         -		*p++ = 192;
   144         -		*p++ = 96;
   145         -	    }
   146         -      }
   147         -}
   148         -
   149         -static void
   150         -set_tile_pixel_int16 (unsigned char *bufpix, unsigned int x, unsigned int y,
   151         -		      unsigned int tile_w, double map_x, double map_y)
   152         -{
   153         -/* pixel generator - DATAGRID INT16 */
   154         -    short *p = (short *) bufpix;
   155         -    p += ((y * tile_w) + x);
   156         -    if (map_y >= -15.0 && map_y <= 15.0)
   157         -      {
   158         -	  if (map_x < 0.0)
   159         -	      *p = -10;
   160         -	  else
   161         -	      *p = 50;
   162         -      }
   163         -    else if (map_y >= -60.0 && map_y <= 60.0)
   164         -      {
   165         -	  if (map_x < 0.0)
   166         -	      *p = 100;
   167         -	  else
   168         -	      *p = 200;
   169         -      }
   170         -    else
   171         -      {
   172         -	  if (map_x < 0.0)
   173         -	      *p = -100;
   174         -	  else
   175         -	      *p = -50;
   176         -      }
   177         -}
   178         -
   179         -static void
   180         -set_tile_pixel_double (unsigned char *bufpix, unsigned int x, unsigned int y,
   181         -		       unsigned int tile_w, double map_x, double map_y)
   182         -{
   183         -/* pixel generator - DATAGRID DOUBLE */
   184         -    double *p = (double *) bufpix;
   185         -    p += ((y * tile_w) + x);
   186         -    if (map_y >= -15.0 && map_y <= 15.0)
   187         -      {
   188         -	  if (map_x < 0.0)
   189         -	      *p = -10.06;
   190         -	  else
   191         -	      *p = 50.02;
   192         -      }
   193         -    else if (map_y >= -60.0 && map_y <= 60.0)
   194         -      {
   195         -	  if (map_x < 0.0)
   196         -	      *p = 100.03;
   197         -	  else
   198         -	      *p = 200.81;
   199         -      }
   200         -    else
   201         -      {
   202         -	  if (map_x < 0.0)
   203         -	      *p = -100.23;
   204         -	  else
   205         -	      *p = -50.41;
   206         -      }
   207         -}
   208         -
   209         -static void
   210         -set_tile_pixel_uint8 (unsigned char *bufpix, unsigned int x, unsigned int y,
   211         -		      unsigned int tile_w, double map_x, double map_y,
   212         -		      unsigned char pixel, unsigned char num_bands)
   213         -{
   214         -/* pixel generator - UINT8 */
   215         -    switch (pixel)
   216         -      {
   217         -      case RL2_PIXEL_GRAYSCALE:
   218         -	  set_tile_pixel_gray8 (bufpix, x, y, tile_w, map_x, map_y);
   219         -	  break;
   220         -      case RL2_PIXEL_RGB:
   221         -	  set_tile_pixel_rgb8 (bufpix, x, y, tile_w, map_x, map_y, num_bands);
   222         -	  break;
   223         -      };
   224         -}
   225         -
   226         -static void
   227         -set_tile_pixel (unsigned char *bufpix, unsigned int x, unsigned int y,
   228         -		unsigned int tile_w, double map_x, double map_y,
   229         -		unsigned char sample, unsigned char pixel,
   230         -		unsigned int num_bands)
   231         -{
   232         -/* generalized pixel generator */
   233         -    switch (sample)
   234         -      {
   235         -      case RL2_SAMPLE_UINT8:
   236         -	  set_tile_pixel_uint8 (bufpix, x, y, tile_w, map_x, map_y, pixel,
   237         -				num_bands);
   238         -	  break;
   239         -      case RL2_SAMPLE_INT16:
   240         -	  set_tile_pixel_int16 (bufpix, x, y, tile_w, map_x, map_y);
   241         -	  break;
   242         -      case RL2_SAMPLE_DOUBLE:
   243         -	  set_tile_pixel_double (bufpix, x, y, tile_w, map_x, map_y);
   244         -	  break;
   245         -      };
   246         -}
   247         -
   248         -static int
   249         -tile_callback (void *data, double tile_minx, double tile_miny, double tile_maxx,
   250         -	       double tile_maxy, unsigned char *bufpix, rl2PalettePtr * palette)
   251         -{
   252         -/* callback function initializing a Tile */
   253         -    struct tile_info *info = (struct tile_info *) data;
   254         -    unsigned int x;
   255         -    unsigned int y;
   256         -    double res_x = (tile_maxx - tile_minx) / (double) (info->tile_w);
   257         -    double res_y = (tile_maxy - tile_miny) / (double) (info->tile_h);
   258         -
   259         -/* setting tile pixels */
   260         -    for (y = 0; y < info->tile_h; y++)
   261         -      {
   262         -	  double map_y = tile_maxy - ((double) y * res_y);
   263         -	  if (map_y < tile_miny)
   264         -	      continue;
   265         -	  for (x = 0; x < info->tile_w; x++)
   266         -	    {
   267         -		double map_x = tile_minx + ((double) x * res_x);
   268         -		if (map_x > tile_maxx)
   269         -		    continue;
   270         -		set_tile_pixel (bufpix, x, y, info->tile_w, map_x, map_y,
   271         -				info->sample, info->pixel, info->num_bands);
   272         -	    }
   273         -      }
   274         -
   275         -    return 1;
   276         -}
   277         -
   278         -static rl2PixelPtr
   279         -default_nodata (unsigned char sample, unsigned char pixel,
   280         -		unsigned char num_bands)
   281         -{
   282         -/* creating a default NO-DATA value */
   283         -    int nb;
   284         -    rl2PixelPtr pxl = rl2_create_pixel (sample, pixel, num_bands);
   285         -    if (pxl == NULL)
   286         -	return NULL;
   287         -    switch (pixel)
   288         -      {
   289         -      case RL2_PIXEL_MONOCHROME:
   290         -	  rl2_set_pixel_sample_1bit (pxl, 0);
   291         -	  break;
   292         -      case RL2_PIXEL_PALETTE:
   293         -	  switch (sample)
   294         -	    {
   295         -	    case RL2_SAMPLE_1_BIT:
   296         -		rl2_set_pixel_sample_1bit (pxl, 0);
   297         -		break;
   298         -	    case RL2_SAMPLE_2_BIT:
   299         -		rl2_set_pixel_sample_2bit (pxl, 0);
   300         -		break;
   301         -	    case RL2_SAMPLE_4_BIT:
   302         -		rl2_set_pixel_sample_4bit (pxl, 0);
   303         -		break;
   304         -	    case RL2_SAMPLE_UINT8:
   305         -		rl2_set_pixel_sample_uint8 (pxl, 0, 0);
   306         -		break;
   307         -	    };
   308         -	  break;
   309         -      case RL2_PIXEL_GRAYSCALE:
   310         -	  switch (sample)
   311         -	    {
   312         -	    case RL2_SAMPLE_1_BIT:
   313         -		rl2_set_pixel_sample_1bit (pxl, 1);
   314         -		break;
   315         -	    case RL2_SAMPLE_2_BIT:
   316         -		rl2_set_pixel_sample_2bit (pxl, 3);
   317         -		break;
   318         -	    case RL2_SAMPLE_4_BIT:
   319         -		rl2_set_pixel_sample_4bit (pxl, 15);
   320         -		break;
   321         -	    case RL2_SAMPLE_UINT8:
   322         -		rl2_set_pixel_sample_uint8 (pxl, 0, 255);
   323         -		break;
   324         -	    case RL2_SAMPLE_UINT16:
   325         -		rl2_set_pixel_sample_uint16 (pxl, 0, 0);
   326         -		break;
   327         -	    };
   328         -	  break;
   329         -      case RL2_PIXEL_RGB:
   330         -	  switch (sample)
   331         -	    {
   332         -	    case RL2_SAMPLE_UINT8:
   333         -		rl2_set_pixel_sample_uint8 (pxl, 0, 255);
   334         -		rl2_set_pixel_sample_uint8 (pxl, 1, 255);
   335         -		rl2_set_pixel_sample_uint8 (pxl, 2, 255);
   336         -		break;
   337         -	    case RL2_SAMPLE_UINT16:
   338         -		rl2_set_pixel_sample_uint16 (pxl, 0, 0);
   339         -		rl2_set_pixel_sample_uint16 (pxl, 1, 0);
   340         -		rl2_set_pixel_sample_uint16 (pxl, 2, 0);
   341         -		break;
   342         -	    };
   343         -	  break;
   344         -      case RL2_PIXEL_DATAGRID:
   345         -	  switch (sample)
   346         -	    {
   347         -	    case RL2_SAMPLE_INT8:
   348         -		rl2_set_pixel_sample_int8 (pxl, 0);
   349         -		break;
   350         -	    case RL2_SAMPLE_UINT8:
   351         -		rl2_set_pixel_sample_uint8 (pxl, 0, 0);
   352         -		break;
   353         -	    case RL2_SAMPLE_INT16:
   354         -		rl2_set_pixel_sample_int16 (pxl, 0);
   355         -		break;
   356         -	    case RL2_SAMPLE_UINT16:
   357         -		rl2_set_pixel_sample_uint16 (pxl, 0, 0);
   358         -		break;
   359         -	    case RL2_SAMPLE_INT32:
   360         -		rl2_set_pixel_sample_int32 (pxl, 0);
   361         -		break;
   362         -	    case RL2_SAMPLE_UINT32:
   363         -		rl2_set_pixel_sample_uint32 (pxl, 0);
   364         -		break;
   365         -	    case RL2_SAMPLE_FLOAT:
   366         -		rl2_set_pixel_sample_float (pxl, 0.0);
   367         -		break;
   368         -	    case RL2_SAMPLE_DOUBLE:
   369         -		rl2_set_pixel_sample_double (pxl, 0.0);
   370         -		break;
   371         -	    };
   372         -	  break;
   373         -      case RL2_PIXEL_MULTIBAND:
   374         -	  switch (sample)
   375         -	    {
   376         -	    case RL2_SAMPLE_UINT8:
   377         -		for (nb = 0; nb < num_bands; nb++)
   378         -		    rl2_set_pixel_sample_uint8 (pxl, nb, 255);
   379         -		break;
   380         -	    case RL2_SAMPLE_UINT16:
   381         -		for (nb = 0; nb < num_bands; nb++)
   382         -		    rl2_set_pixel_sample_uint16 (pxl, nb, 0);
   383         -		break;
   384         -	    };
   385         -	  break;
   386         -      };
   387         -    return pxl;
   388         -}
   389         -
   390         -static int
   391         -test_uint8_gray (sqlite3 * handle)
   392         -{
   393         -/* testing UINT8 GRAYSCALE */
   394         -    struct tile_info info;
   395         -    rl2CoveragePtr cvg;
   396         -
   397         -    info.sample = RL2_SAMPLE_UINT8;
   398         -    info.pixel = RL2_PIXEL_GRAYSCALE;
   399         -    info.num_bands = 1;
   400         -    info.srid = 4326;
   401         -    info.coverage = "UINT8_GRAYSCALE";
   402         -    info.tile_w = 512;
   403         -    info.tile_h = 512;
   404         -
   405         -    rl2PixelPtr no_data =
   406         -	default_nodata (info.sample, info.pixel, info.num_bands);
   407         -    if (rl2_create_dbms_coverage
   408         -	(handle, info.coverage, info.sample, info.pixel, info.num_bands,
   409         -	 RL2_COMPRESSION_PNG, 100, info.tile_w, info.tile_h, info.srid, 0.1,
   410         -	 0.1, no_data, NULL, 1, 0, 0, 0, 0) != RL2_OK)
   411         -      {
   412         -	  fprintf (stderr, "Unable to create Coverage \"%s\"\n", info.coverage);
   413         -	  return 0;
   414         -      }
   415         -
   416         -    cvg = rl2_create_coverage_from_dbms (handle, info.coverage);
   417         -    if (cvg == NULL)
   418         -      {
   419         -	  rl2_destroy_coverage (cvg);
   420         -	  return 0;
   421         -      }
   422         -
   423         -    if (rl2_load_raw_tiles_into_dbms
   424         -	(handle, cvg, "Alpha", 3600, 1800, info.srid, -180, -90, 180, 90,
   425         -	 tile_callback, &info, 1) != RL2_OK)
   426         -      {
   427         -	  fprintf (stderr, "Unable to populate Tiles on Coverage \"%s\"\n",
   428         -		   info.coverage);
   429         -	  return 0;
   430         -      }
   431         -
   432         -    rl2_destroy_coverage (cvg);
   433         -    rl2_destroy_pixel (no_data);
   434         -    return 1;
   435         -}
   436         -
   437         -static int
   438         -test_uint8_rgb (sqlite3 * handle)
   439         -{
   440         -/* testing UINT8 RGB */
   441         -    struct tile_info info;
   442         -    rl2CoveragePtr cvg;
   443         -
   444         -    info.sample = RL2_SAMPLE_UINT8;
   445         -    info.pixel = RL2_PIXEL_RGB;
   446         -    info.num_bands = 3;
   447         -    info.srid = 4326;
   448         -    info.coverage = "UINT8_RGB";
   449         -    info.tile_w = 512;
   450         -    info.tile_h = 512;
   451         -
   452         -    rl2PixelPtr no_data =
   453         -	default_nodata (info.sample, info.pixel, info.num_bands);
   454         -    if (rl2_create_dbms_coverage
   455         -	(handle, info.coverage, info.sample, info.pixel, info.num_bands,
   456         -	 RL2_COMPRESSION_PNG, 100, info.tile_w, info.tile_h, info.srid, 0.1,
   457         -	 0.1, no_data, NULL, 1, 0, 0, 0, 0) != RL2_OK)
   458         -      {
   459         -	  fprintf (stderr, "Unable to create Coverage \"%s\"\n", info.coverage);
   460         -	  return 0;
   461         -      }
   462         -
   463         -    cvg = rl2_create_coverage_from_dbms (handle, info.coverage);
   464         -    if (cvg == NULL)
   465         -      {
   466         -	  rl2_destroy_coverage (cvg);
   467         -	  return 0;
   468         -      }
   469         -
   470         -    if (rl2_load_raw_tiles_into_dbms
   471         -	(handle, cvg, "Alpha", 3600, 1800, info.srid, -180, -90, 180, 90,
   472         -	 tile_callback, &info, 1) != RL2_OK)
   473         -      {
   474         -	  fprintf (stderr, "Unable to populate Tiles on Coverage \"%s\"\n",
   475         -		   info.coverage);
   476         -	  return 0;
   477         -      }
   478         -
   479         -    rl2_destroy_coverage (cvg);
   480         -    rl2_destroy_pixel (no_data);
   481         -    return 1;
   482         -}
   483         -
   484         -static int
   485         -test_int16_grid (sqlite3 * handle)
   486         -{
   487         -/* testing INT8 DATAGRID */
   488         -    struct tile_info info;
   489         -    rl2CoveragePtr cvg;
   490         -
   491         -    info.sample = RL2_SAMPLE_INT16;
   492         -    info.pixel = RL2_PIXEL_DATAGRID;
   493         -    info.num_bands = 1;
   494         -    info.srid = 4326;
   495         -    info.coverage = "INT16_GRID";
   496         -    info.tile_w = 512;
   497         -    info.tile_h = 512;
   498         -
   499         -    rl2PixelPtr no_data =
   500         -	default_nodata (info.sample, info.pixel, info.num_bands);
   501         -    if (rl2_create_dbms_coverage
   502         -	(handle, info.coverage, info.sample, info.pixel, info.num_bands,
   503         -	 RL2_COMPRESSION_DEFLATE, 100, info.tile_w, info.tile_h, info.srid, 0.1,
   504         -	 0.1, no_data, NULL, 1, 0, 0, 0, 0) != RL2_OK)
   505         -      {
   506         -	  fprintf (stderr, "Unable to create Coverage \"%s\"\n", info.coverage);
   507         -	  return 0;
   508         -      }
   509         -
   510         -    cvg = rl2_create_coverage_from_dbms (handle, info.coverage);
   511         -    if (cvg == NULL)
   512         -      {
   513         -	  rl2_destroy_coverage (cvg);
   514         -	  return 0;
   515         -      }
   516         -
   517         -    if (rl2_load_raw_tiles_into_dbms
   518         -	(handle, cvg, "Alpha", 3600, 1800, info.srid, -180, -90, 180, 90,
   519         -	 tile_callback, &info, 1) != RL2_OK)
   520         -      {
   521         -	  fprintf (stderr, "Unable to populate Tiles on Coverage \"%s\"\n",
   522         -		   info.coverage);
   523         -	  return 0;
   524         -      }
   525         -
   526         -    rl2_destroy_coverage (cvg);
   527         -    rl2_destroy_pixel (no_data);
   528         -    return 1;
   529         -}
   530         -
   531         -static int
   532         -test_double_grid (sqlite3 * handle)
   533         -{
   534         -/* testing DOUBLE DATAGRID */
   535         -    struct tile_info info;
   536         -    rl2CoveragePtr cvg;
   537         -
   538         -    info.sample = RL2_SAMPLE_DOUBLE;
   539         -    info.pixel = RL2_PIXEL_DATAGRID;
   540         -    info.num_bands = 1;
   541         -    info.srid = 4326;
   542         -    info.coverage = "DOUBLE_GRID";
   543         -    info.tile_w = 512;
   544         -    info.tile_h = 512;
   545         -
   546         -    rl2PixelPtr no_data =
   547         -	default_nodata (info.sample, info.pixel, info.num_bands);
   548         -    if (rl2_create_dbms_coverage
   549         -	(handle, info.coverage, info.sample, info.pixel, info.num_bands,
   550         -	 RL2_COMPRESSION_DEFLATE, 100, info.tile_w, info.tile_h, info.srid, 0.1,
   551         -	 0.1, no_data, NULL, 1, 0, 0, 0, 0) != RL2_OK)
   552         -      {
   553         -	  fprintf (stderr, "Unable to create Coverage \"%s\"\n", info.coverage);
   554         -	  return 0;
   555         -      }
   556         -
   557         -    cvg = rl2_create_coverage_from_dbms (handle, info.coverage);
   558         -    if (cvg == NULL)
   559         -      {
   560         -	  rl2_destroy_coverage (cvg);
   561         -	  return 0;
   562         -      }
   563         -
   564         -    if (rl2_load_raw_tiles_into_dbms
   565         -	(handle, cvg, "Alpha", 3600, 1800, info.srid, -180, -90, 180, 90,
   566         -	 tile_callback, &info, 1) != RL2_OK)
   567         -      {
   568         -	  fprintf (stderr, "Unable to populate Tiles on Coverage \"%s\"\n",
   569         -		   info.coverage);
   570         -	  return 0;
   571         -      }
   572         -
   573         -    rl2_destroy_coverage (cvg);
   574         -    rl2_destroy_pixel (no_data);
   575         -    return 1;
   576         -}
   577         -
   578         -int
   579         -main (int argc, char *argv[])
   580         -{
   581         -    int ret;
   582         -    sqlite3 *handle = NULL;
   583         -    char *err_msg = NULL;
   584         -    void *cache = spatialite_alloc_connection ();
   585         -    void *priv_data = rl2_alloc_private ();
   586         -
   587         -    if (argc > 1 || argv[0] == NULL)
   588         -	argc = 1;		/* silencing stupid compiler warnings */
   589         -    ret =
   590         -	sqlite3_open_v2 ("callback.sqlite", &handle,
   591         -			 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
   592         -    if (ret != SQLITE_OK)
   593         -      {
   594         -	  fprintf (stderr, "cannot open in-memory db: %s\n",
   595         -		   sqlite3_errmsg (handle));
   596         -	  return -1;
   597         -      }
   598         -    spatialite_init_ex (handle, cache, 0);
   599         -    rl2_init (handle, priv_data, 0);
   600         -
   601         -/* the complete test is handled as an unique SQL Transaction */
   602         -    ret = sqlite3_exec (handle, "BEGIN", NULL, NULL, &err_msg);
   603         -    if (ret != SQLITE_OK)
   604         -      {
   605         -	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", err_msg);
   606         -	  sqlite3_free (err_msg);
   607         -	  return -2;
   608         -      }
   609         -
   610         -    ret =
   611         -	sqlite3_exec (handle, "SELECT InitSpatialMetadata()", NULL, NULL,
   612         -		      &err_msg);
   613         -    if (ret != SQLITE_OK)
   614         -      {
   615         -	  fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
   616         -	  sqlite3_free (err_msg);
   617         -	  sqlite3_close (handle);
   618         -	  return -3;
   619         -      }
   620         -    ret =
   621         -	sqlite3_exec (handle, "SELECT CreateRasterCoveragesTable()", NULL,
   622         -		      NULL, &err_msg);
   623         -    if (ret != SQLITE_OK)
   624         -      {
   625         -	  fprintf (stderr, "CreateRasterCoveragesTable() error: %s\n", err_msg);
   626         -	  sqlite3_free (err_msg);
   627         -	  return -4;
   628         -      }
   629         -
   630         -    if (!test_uint8_gray (handle))
   631         -	return -5;
   632         -
   633         -    if (!test_uint8_rgb (handle))
   634         -	return -6;
   635         -
   636         -    if (!test_int16_grid (handle))
   637         -	return -7;
   638         -
   639         -    if (!test_double_grid (handle))
   640         -	return -8;
   641         -
   642         -/* committing the SQL Transaction */
   643         -    ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, &err_msg);
   644         -    if (ret != SQLITE_OK)
   645         -      {
   646         -	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", err_msg);
   647         -	  sqlite3_free (err_msg);
   648         -	  return -9;
   649         -      }
   650         -
   651         -    sqlite3_close (handle);
   652         -    spatialite_cleanup_ex (cache);
   653         -    rl2_cleanup_private (priv_data);
   654         -    spatialite_shutdown ();
   655         -    fprintf (stderr, "******** endok\n");
   656         -    return 0;
   657         -}

Changes to tools/Makefile.in.

     1         -# Makefile.in generated by automake 1.15 from Makefile.am.
            1  +# Makefile.in generated by automake 1.14.1 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2014 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2013 Free Software Foundation, Inc.
     5      5   
     6      6   # This Makefile.in is free software; the Free Software Foundation
     7      7   # gives unlimited permission to copy and/or distribute it,
     8      8   # with or without modifications, as long as this notice is preserved.
     9      9   
    10     10   # This program is distributed in the hope that it will be useful,
    11     11   # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    12     12   # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    13     13   # PARTICULAR PURPOSE.
    14     14   
    15     15   @SET_MAKE@
    16     16   
    17     17   VPATH = @srcdir@
    18         -am__is_gnu_make = { \
    19         -  if test -z '$(MAKELEVEL)'; then \
    20         -    false; \
    21         -  elif test -n '$(MAKE_HOST)'; then \
    22         -    true; \
    23         -  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    24         -    true; \
    25         -  else \
    26         -    false; \
    27         -  fi; \
    28         -}
           18  +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
    29     19   am__make_running_with_option = \
    30     20     case $${target_option-} in \
    31     21         ?) ;; \
    32     22         *) echo "am__make_running_with_option: internal error: invalid" \
    33     23                 "target option '$${target_option-}' specified" >&2; \
    34     24            exit 1;; \
    35     25     esac; \
................................................................................
    86     76   NORMAL_UNINSTALL = :
    87     77   PRE_UNINSTALL = :
    88     78   POST_UNINSTALL = :
    89     79   build_triplet = @build@
    90     80   host_triplet = @host@
    91     81   bin_PROGRAMS = rl2sniff$(EXEEXT) rl2tool$(EXEEXT) wmslite$(EXEEXT)
    92     82   subdir = tools
           83  +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
           84  +	$(top_srcdir)/depcomp
    93     85   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    94     86   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    95     87   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    96     88   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    97     89   	$(top_srcdir)/configure.ac
    98     90   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    99     91   	$(ACLOCAL_M4)
   100         -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
   101     92   mkinstalldirs = $(install_sh) -d
   102     93   CONFIG_HEADER = $(top_builddir)/config.h
   103     94   CONFIG_CLEAN_FILES =
   104     95   CONFIG_CLEAN_VPATH_FILES =
   105     96   am__installdirs = "$(DESTDIR)$(bindir)"
   106     97   PROGRAMS = $(bin_PROGRAMS)
   107     98   am_rl2sniff_OBJECTS = rl2sniff.$(OBJEXT)
................................................................................
   174    165   am__define_uniq_tagged_files = \
   175    166     list='$(am__tagged_files)'; \
   176    167     unique=`for i in $$list; do \
   177    168       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   178    169     done | $(am__uniquify_input)`
   179    170   ETAGS = etags
   180    171   CTAGS = ctags
   181         -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
   182    172   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   183    173   ACLOCAL = @ACLOCAL@
   184    174   AMTAR = @AMTAR@
   185    175   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   186    176   AR = @AR@
   187    177   AS = @AS@
   188    178   AUTOCONF = @AUTOCONF@
................................................................................
   363    353   	        && { if test -f $@; then exit 0; else break; fi; }; \
   364    354   	      exit 1;; \
   365    355   	  esac; \
   366    356   	done; \
   367    357   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
   368    358   	$(am__cd) $(top_srcdir) && \
   369    359   	  $(AUTOMAKE) --gnu tools/Makefile
          360  +.PRECIOUS: Makefile
   370    361   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   371    362   	@case '$?' in \
   372    363   	  *config.status*) \
   373    364   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   374    365   	  *) \
   375    366   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   376    367   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
   684    675   	install-info install-info-am install-man install-pdf \
   685    676   	install-pdf-am install-ps install-ps-am install-strip \
   686    677   	installcheck installcheck-am installdirs maintainer-clean \
   687    678   	maintainer-clean-generic mostlyclean mostlyclean-compile \
   688    679   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
   689    680   	tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
   690    681   
   691         -.PRECIOUS: Makefile
   692         -
   693    682   
   694    683   # Tell versions [3.59,3.63) of GNU make to not export all variables.
   695    684   # Otherwise a system limit (for SysV at least) may be exceeded.
   696    685   .NOEXPORT:

Changes to tools/rl2sniff.c.

   730    730       double cy;
   731    731       double minX;
   732    732       double minY;
   733    733       double maxX;
   734    734       double maxY;
   735    735       double x_res;
   736    736       double y_res;
   737         -    short pixel_mode = RasterPixelIsArea;
   738    737       GTIFDefn definition;
   739    738       char *md5 = NULL;
   740    739       TIFF *in = (TIFF *) 0;
   741    740       GTIF *gtif = (GTIF *) 0;
   742    741   
   743    742   /* suppressing TIFF messages */
   744    743       TIFFSetErrorHandler (NULL);
................................................................................
   898    897       GTIFImageToPCS (gtif, &cx, &cy);
   899    898       maxX = cx;
   900    899   
   901    900   /* computing the pixel resolution */
   902    901       x_res = (maxX - minX) / (double) width;
   903    902       y_res = (maxY - minY) / (double) height;
   904    903       is_geotiff = 1;
   905         -
   906         -/* retrieving GTRasterTypeGeoKey */
   907         -    if (!GTIFKeyGet (gtif, GTRasterTypeGeoKey, &pixel_mode, 0, 1))
   908         -	pixel_mode = RasterPixelIsArea;
   909         -    if (pixel_mode == RasterPixelIsPoint)
   910         -      {
   911         -	  /* adjusting the BBOX */
   912         -	  minX -= x_res / 2.0;
   913         -	  minY -= y_res / 2.0;
   914         -	  maxX += x_res / 2.0;
   915         -	  maxY += y_res / 2.0;
   916         -
   917         -      }
   918    904       goto print;
   919    905   
   920    906     recover:
   921    907       is_geotiff =
   922    908   	recover_incomplete_geotiff (in, width, height, &minX, &minY, &maxX,
   923    909   				    &maxY, &x_res, &y_res);
   924    910   

Changes to tools/rl2tool.c.

  1429   1429   
  1430   1430       sql =
  1431   1431   	"SELECT coverage_name, title, abstract, sample_type, pixel_type, "
  1432   1432   	"num_bands, compression, quality, tile_width, tile_height, "
  1433   1433   	"horz_resolution, vert_resolution, srid, auth_name, auth_srid, "
  1434   1434   	"ref_sys_name, extent_minx, extent_miny, extent_maxx, extent_maxy, "
  1435   1435   	"nodata_pixel, palette, statistics, red_band_index, green_band_index, "
  1436         -	"blue_band_index, nir_band_index, enable_auto_ndvi "
         1436  +	"blue_band_index, nir_band_index, eneble_auto_ndvi "
  1437   1437   	"FROM raster_coverages_ref_sys ORDER BY coverage_name";
  1438   1438       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  1439   1439       if (ret != SQLITE_OK)
  1440   1440   	goto stop;
  1441   1441   
  1442   1442       while (1)
  1443   1443         {
................................................................................
  1730   1730   			    printf
  1731   1731   				("       NIR band index: *** undefined ***\n");
  1732   1732   			}
  1733   1733   		  }
  1734   1734   		if (palette != NULL)
  1735   1735   		  {
  1736   1736   		      /* printing an eventual Palette */
  1737         -		      unsigned short i;
         1737  +		      unsigned char i;
  1738   1738   		      unsigned short num_entries;
  1739   1739   		      unsigned char *red = NULL;
  1740   1740   		      unsigned char *green = NULL;
  1741   1741   		      unsigned char *blue = NULL;
  1742   1742   		      rl2_get_palette_colors (palette, &num_entries, &red,
  1743   1743   					      &green, &blue);
  1744   1744   		      for (i = 0; i < num_entries; i++)

Changes to tools/wmslite.c.

    47     47   #endif
    48     48   
    49     49   #include <rasterlite2/rasterlite2.h>
    50     50   #include <spatialite.h>
    51     51   
    52     52   #define ARG_NONE		0
    53     53   #define ARG_DB_PATH		1
    54         -#define ARG_IP_ADDR		2
    55         -#define ARG_IP_PORT		3
    56         -#define ARG_MAX_THREADS		4
    57         -#define ARG_CACHE_SIZE		5
           54  +#define ARG_IP_PORT		2
           55  +#define ARG_MAX_THREADS		3
           56  +#define ARG_CACHE_SIZE		4
    58     57   
    59     58   #define WMS_ILLEGAL_REQUEST	0
    60     59   #define WMS_GET_CAPABILITIES	1
    61     60   #define WMS_GET_MAP		2
    62     61   
    63     62   #define WMS_UNKNOWN		-1
    64     63   #define WMS_TRANSPARENT		10
................................................................................
   306    305       unsigned char blue;
   307    306   };
   308    307   
   309    308   struct http_request
   310    309   {
   311    310   /* a struct wrapping an HTTP request */
   312    311       unsigned int id;		/* request ID */
   313         -    const char *ip_addr;
   314    312       int port_no;
   315    313   #ifdef _WIN32
   316    314       SOCKET socket;		/* Socket on which to receive data */
   317    315   #else
   318    316       int socket;			/* Socket on which to receive data */
   319    317   #endif
   320    318       struct wms_list *list;
................................................................................
  2568   2566       sqlite3_free (dummy);
  2569   2567       gaiaAppendToOutBuffer (xml_response, "Connection: close\r\n\r\n");
  2570   2568       gaiaAppendToOutBuffer (xml_response, xml_text.Buffer);
  2571   2569       gaiaOutBufferReset (&xml_text);
  2572   2570   }
  2573   2571   
  2574   2572   static void
  2575         -build_http_error (int http_status, gaiaOutBufferPtr xml_response,
  2576         -		  const char *ip_addr, int port_no)
         2573  +build_http_error (int http_status, gaiaOutBufferPtr xml_response, int port_no)
  2577   2574   {
  2578   2575   /* preparing an HTTP error */
  2579   2576       char *dummy;
  2580   2577       gaiaOutBuffer http_text;
  2581   2578       gaiaOutBufferInitialize (&http_text);
  2582   2579       gaiaAppendToOutBuffer (&http_text,
  2583   2580   			   "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n");
................................................................................
  2596   2593   				 "HTTP/1.1 500 Internal Server Error\r\n");
  2597   2594   	  gaiaAppendToOutBuffer (&http_text,
  2598   2595   				 "<title>500 Internal Server Error</title>\r\n");
  2599   2596   	  gaiaAppendToOutBuffer (&http_text, "</head><body>\r\n");
  2600   2597   	  gaiaAppendToOutBuffer (&http_text,
  2601   2598   				 "<h1>Internal Server Error</h1>\n");
  2602   2599         }
  2603         -    if (strcmp (ip_addr, "127.0.0.1") == 0)
  2604         -	dummy =
  2605         -	    sqlite3_mprintf
  2606         -	    ("<address>WmsLite/%s [%s] at localhost (127.0.0.1) Port %d</address>\r\n",
  2607         -	     rl2_version (), rl2_target_cpu (), port_no);
  2608         -    else
  2609         -	dummy =
  2610         -	    sqlite3_mprintf
  2611         -	    ("<address>WmsLite/%s [%s] at IP-addr %s Port %d</address>\r\n",
  2612         -	     rl2_version (), rl2_target_cpu (), ip_addr, port_no);
         2600  +    dummy =
         2601  +	sqlite3_mprintf
         2602  +	("<address>WmsLite/%s [%s] at localhost (127.0.0.1) Port %d</address>\r\n",
         2603  +	 rl2_version (), rl2_target_cpu (), port_no);
  2613   2604       gaiaAppendToOutBuffer (&http_text, dummy);
  2614   2605       sqlite3_free (dummy);
  2615   2606       gaiaAppendToOutBuffer (&http_text, "</body></html>\r\n");
  2616   2607       gaiaAppendToOutBuffer (&http_text, "");
  2617   2608       dummy = get_current_timestamp ();
  2618   2609       gaiaAppendToOutBuffer (xml_response, dummy);
  2619   2610       sqlite3_free (dummy);
................................................................................
  2625   2616       gaiaAppendToOutBuffer (xml_response, "Connection: close\r\n\r\n");
  2626   2617       gaiaAppendToOutBuffer (xml_response, http_text.Buffer);
  2627   2618       gaiaOutBufferReset (&http_text);
  2628   2619   }
  2629   2620   
  2630   2621   static void
  2631   2622   build_get_capabilities (struct wms_list *list, char **cached, int *cached_len,
  2632         -			const char *ip_addr, int port_no)
         2623  +			int port_no)
  2633   2624   {
  2634   2625   /* preparing the WMS GetCapabilities XML document */
  2635   2626       struct wms_layer *lyr;
  2636   2627       struct wms_group *grp;
  2637   2628       struct wms_style *style;
  2638   2629       struct wms_alt_srid *alt_srid;
  2639   2630       struct wms_keyword *keyword;
................................................................................
  2652   2643   			   "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd\">\r\n");
  2653   2644       gaiaAppendToOutBuffer (&xml_text, "<Service>\r\n<Name>WMS</Name>\r\n");
  2654   2645       gaiaAppendToOutBuffer (&xml_text, "<Title>WmsLite test server</Title>\r\n");
  2655   2646       gaiaAppendToOutBuffer (&xml_text,
  2656   2647   			   "<Abstract>A simple light-weight WMS server for testing RasterLite2 Coverages.</Abstract>\r\n");
  2657   2648       gaiaAppendToOutBuffer (&xml_text,
  2658   2649   			   "<KeywordList>\r\n<Keyword>maps</Keyword>\r\n</KeywordList>\r\n");
  2659         -    if (port_no == 80)
  2660         -	dummy =
  2661         -	    sqlite3_mprintf
  2662         -	    ("<OnlineResource xlink:href=\"http://%s/wmslite?\" ", ip_addr);
  2663         -    else
  2664         -	dummy =
  2665         -	    sqlite3_mprintf
  2666         -	    ("<OnlineResource xlink:href=\"http://%s:%d/wmslite?\" ",
  2667         -	     ip_addr, port_no);
         2650  +    dummy =
         2651  +	sqlite3_mprintf
         2652  +	("<OnlineResource xlink:href=\"http://127.0.0.1:%d/wmslite?\" ",
         2653  +	 port_no);
  2668   2654       gaiaAppendToOutBuffer (&xml_text, dummy);
  2669   2655       sqlite3_free (dummy);
  2670   2656       gaiaAppendToOutBuffer (&xml_text,
  2671   2657   			   "xlink:type=\"simple\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/>\r\n");
  2672   2658       gaiaAppendToOutBuffer (&xml_text,
  2673   2659   			   "<ContactInformation>\r\n<ContactPersonPrimary>\r\n");
  2674   2660       gaiaAppendToOutBuffer (&xml_text,
................................................................................
  2696   2682       gaiaAppendToOutBuffer (&xml_text, "<MaxWidth>5000</MaxWidth>\r\n");
  2697   2683       gaiaAppendToOutBuffer (&xml_text, "<MaxHeight>5000</MaxHeight>\r\n");
  2698   2684       gaiaAppendToOutBuffer (&xml_text, "</Service>\r\n");
  2699   2685       gaiaAppendToOutBuffer (&xml_text,
  2700   2686   			   "<Capability>\r\n<Request>\r\n<GetCapabilities>\r\n");
  2701   2687       gaiaAppendToOutBuffer (&xml_text,
  2702   2688   			   "<Format>text/xml</Format>\r\n<DCPType>\r\n<HTTP>\r\n");
  2703         -    if (port_no == 80)
  2704         -	dummy =
  2705         -	    sqlite3_mprintf
  2706         -	    ("<Get><OnlineResource xlink:href=\"http://%s/wmslite?\" ",
  2707         -	     ip_addr);
  2708         -    else
  2709         -	dummy =
  2710         -	    sqlite3_mprintf
  2711         -	    ("<Get><OnlineResource xlink:href=\"http://%s:%d/wmslite?\" ",
  2712         -	     ip_addr, port_no);
         2689  +    dummy =
         2690  +	sqlite3_mprintf
         2691  +	("<Get><OnlineResource xlink:href=\"http://127.0.0.1:%d/wmslite?\" ",
         2692  +	 port_no);
  2713   2693       gaiaAppendToOutBuffer (&xml_text, dummy);
  2714   2694       sqlite3_free (dummy);
  2715   2695       gaiaAppendToOutBuffer (&xml_text,
  2716   2696   			   "xlink:type=\"simple\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/></Get>\r\n");
  2717   2697       gaiaAppendToOutBuffer (&xml_text,
  2718   2698   			   "</HTTP>\r\n</DCPType>\r\n</GetCapabilities>\r\n");
  2719   2699       gaiaAppendToOutBuffer (&xml_text,
  2720   2700   			   "<GetMap>\r\n<Format>image/png</Format>\r\n");
  2721   2701       gaiaAppendToOutBuffer (&xml_text, "<Format>image/jpeg</Format>\r\n");
  2722   2702       gaiaAppendToOutBuffer (&xml_text, "<Format>application/x-pdf</Format>\r\n");
  2723   2703       gaiaAppendToOutBuffer (&xml_text, "<Format>image/tiff</Format>\r\n");
  2724   2704       gaiaAppendToOutBuffer (&xml_text, "<DCPType>\r\n<HTTP>\r\n<Get>");
  2725         -    if (port_no == 80)
  2726         -	dummy =
  2727         -	    sqlite3_mprintf
  2728         -	    ("<OnlineResource xlink:href=\"http://%s/wmslite?\" ", ip_addr);
  2729         -    else
  2730         -	dummy =
  2731         -	    sqlite3_mprintf
  2732         -	    ("<OnlineResource xlink:href=\"http://%s:%d/wmslite?\" ",
  2733         -	     ip_addr, port_no);
         2705  +    dummy =
         2706  +	sqlite3_mprintf
         2707  +	("<OnlineResource xlink:href=\"http://127.0.0.1:%d/wmslite?\" ",
         2708  +	 port_no);
  2734   2709       gaiaAppendToOutBuffer (&xml_text, dummy);
  2735   2710       sqlite3_free (dummy);
  2736   2711       gaiaAppendToOutBuffer (&xml_text,
  2737   2712   			   "xlink:type=\"simple\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/></Get>\r\n");
  2738   2713       gaiaAppendToOutBuffer (&xml_text,
  2739   2714   			   "</HTTP>\r\n</DCPType>\r\n</GetMap>\r\n</Request>\r\n");
  2740   2715       gaiaAppendToOutBuffer (&xml_text,
................................................................................
  3218   3193   	sqlite3_bind_text (stmt, 9, "image/png", strlen ("image/png"),
  3219   3194   			   SQLITE_TRANSIENT);
  3220   3195       if (args->has_bgcolor)
  3221   3196   	sprintf (bgcolor, "#%02x%02x%02x", args->red, args->green, args->blue);
  3222   3197       else
  3223   3198   	strcpy (bgcolor, "#ffffff");
  3224   3199       sqlite3_bind_text (stmt, 10, bgcolor, strlen (bgcolor), SQLITE_TRANSIENT);
  3225         -    if (args->transparent == WMS_OPAQUE)
  3226         -	sqlite3_bind_int (stmt, 11, 0);
  3227         -    else
  3228         -	sqlite3_bind_int (stmt, 11, 1);
         3200  +    sqlite3_bind_int (stmt, 11, args->transparent);
  3229   3201       if (args->format == RL2_OUTPUT_FORMAT_JPEG)
  3230   3202   	sqlite3_bind_int (stmt, 12, 80);
  3231   3203       else
  3232   3204   	sqlite3_bind_int (stmt, 12, 100);
  3233   3205       while (1)
  3234   3206         {
  3235   3207   	  ret = sqlite3_step (stmt);
................................................................................
  3427   3399   	  wms_get_capabilities (req->socket, req->cached_capabilities,
  3428   3400   				req->cached_capabilities_len, req->log);
  3429   3401         }
  3430   3402       if (args->request_type == WMS_GET_MAP)
  3431   3403         {
  3432   3404   	  /* preparing the WMS GetMap payload */
  3433   3405   	  args->db_handle = req->conn->handle;
  3434         -	  args->stmt_get_map_raster = req->conn->stmt_get_map_raster;
  3435         -	  args->stmt_get_map_vector = req->conn->stmt_get_map_vector;
         3406  +	  args->stmt_get_map = req->conn->stmt_get_map;
  3436   3407   	  log_get_map_1 (req->log, timestamp, http_status, method, url, args);
  3437   3408   	  wms_get_map (args, req->socket, req->log);
  3438   3409         }
  3439   3410       goto end_request;
  3440   3411   
  3441   3412   /* preparing an HTTP error code */
  3442   3413     http_error:
  3443   3414       gaiaOutBufferInitialize (&xml_response);
  3444         -    build_http_error (http_status, &xml_response, req->ip_addr, req->port_no);
         3415  +    build_http_error (http_status, &xml_response, req->port_no);
  3445   3416       curr = 0;
  3446   3417       while (1)
  3447   3418         {
  3448   3419   	  rd = get_xml_bytes (&xml_response, curr, SEND_BLOK_SZ);
  3449   3420   	  if (rd == 0)
  3450   3421   	      break;
  3451   3422   	  send (req->socket, xml_response.Buffer + curr, rd, 0);
................................................................................
  3549   3520   	  wms_get_map (args, req->socket, req->log);
  3550   3521         }
  3551   3522       goto end_request;
  3552   3523   
  3553   3524   /* preparing an HTTP error code */
  3554   3525     http_error:
  3555   3526       gaiaOutBufferInitialize (&xml_response);
  3556         -    build_http_error (http_status, &xml_response, req->ip_addr, req->port_no);
         3527  +    build_http_error (http_status, &xml_response, req->port_no);
  3557   3528       curr = 0;
  3558   3529       while (1)
  3559   3530         {
  3560   3531   	  rd = get_xml_bytes (&xml_response, curr, SEND_BLOK_SZ);
  3561   3532   	  if (rd == 0)
  3562   3533   	      break;
  3563   3534   	  send (req->socket, xml_response.Buffer + curr, rd, 0);
................................................................................
  3592   3563       req->conn->status = CONNECTION_AVAILABLE;
  3593   3564       free (req);
  3594   3565       pthread_exit (NULL);
  3595   3566   }
  3596   3567   #endif
  3597   3568   
  3598   3569   static void
  3599         -do_accept_loop (struct neutral_socket *skt, struct wms_list *list,
  3600         -		const char *xip_addr, int port_no, sqlite3 * db_handle,
  3601         -		sqlite3_stmt * stmt_log, struct connections_pool *pool,
  3602         -		struct server_log *log, char *cached_capab,
  3603         -		int cached_capab_len)
         3570  +do_accept_loop (struct neutral_socket *skt, struct wms_list *list, int port_no,
         3571  +		sqlite3 * db_handle, sqlite3_stmt * stmt_log,
         3572  +		struct connections_pool *pool, struct server_log *log,
         3573  +		char *cached_capab, int cached_capab_len)
  3604   3574   {
  3605   3575   /* implementing the ACCEPT loop */
  3606   3576       unsigned int id = 0;
  3607   3577       struct read_connection *conn;
  3608   3578       int ic;
  3609   3579       time_t diff;
  3610   3580       time_t now;
................................................................................
  3637   3607   		      WSACleanup ();
  3638   3608   		      fprintf (stderr, "error from accept()\n");
  3639   3609   		      return;
  3640   3610   		  }
  3641   3611   	    }
  3642   3612   	  req = malloc (sizeof (struct http_request));
  3643   3613   	  req->id = id++;
  3644         -	  req->ip_addr = xip_addr;
  3645   3614   	  req->port_no = port_no;
  3646   3615   	  req->socket = client;
  3647   3616   	  req->list = list;
  3648   3617   	  req->cached_capabilities = cached_capab;
  3649   3618   	  req->cached_capabilities_len = cached_capab_len;
  3650   3619   	  while (1)
  3651   3620   	    {
................................................................................
  3723   3692   	    {
  3724   3693   		close (socket);
  3725   3694   		fprintf (stderr, "error from accept()\n");
  3726   3695   		return;
  3727   3696   	    }
  3728   3697   	  req = malloc (sizeof (struct http_request));
  3729   3698   	  req->id = id++;
  3730         -	  req->ip_addr = xip_addr;
  3731   3699   	  req->port_no = port_no;
  3732   3700   	  req->socket = client;
  3733   3701   	  req->list = list;
  3734   3702   	  req->cached_capabilities = cached_capab;
  3735   3703   	  req->cached_capabilities_len = cached_capab_len;
  3736   3704   	  while (1)
  3737   3705   	    {
................................................................................
  3793   3761   	  pthread_create (&thread_id, NULL, berkeley_http_request,
  3794   3762   			  (void *) req);
  3795   3763         }
  3796   3764   #endif
  3797   3765   }
  3798   3766   
  3799   3767   static int
  3800         -do_start_http (const char *ip_addr, int port_no, struct neutral_socket *srv_skt,
  3801         -	       int max_threads)
         3768  +do_start_http (int port_no, struct neutral_socket *srv_skt, int max_threads)
  3802   3769   {
  3803   3770   /* starting the HTTP server */
  3804   3771   #ifdef _WIN32
  3805   3772   /* Winsockets */
  3806   3773       WSADATA wd;
  3807   3774       SOCKET skt = INVALID_SOCKET;
  3808   3775       SOCKADDR_IN addr;
................................................................................
  3816   3783       if (skt == INVALID_SOCKET)
  3817   3784         {
  3818   3785   	  fprintf (stderr, "unable to create a socket\n");
  3819   3786   	  return 0;
  3820   3787         }
  3821   3788       addr.sin_family = AF_INET;
  3822   3789       addr.sin_port = htons (port_no);
  3823         -    addr.sin_addr.s_addr = inet_addr (ip_addr);
         3790  +    addr.sin_addr.s_addr = inet_addr ("127.0.0.1");
  3824   3791       if (bind (skt, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR)
  3825   3792         {
  3826   3793   	  fprintf (stderr, "unable to bind the socket\n");
  3827   3794   	  closesocket (skt);
  3828   3795   	  return 0;
  3829   3796         }
  3830   3797       if (listen (skt, SOMAXCONN) == SOCKET_ERROR)
................................................................................
  3843   3810       if (skt == -1)
  3844   3811         {
  3845   3812   	  fprintf (stderr, "unable to create a socket\n");
  3846   3813   	  return 0;
  3847   3814         }
  3848   3815       addr.sin_family = AF_INET;
  3849   3816       addr.sin_port = htons (port_no);
  3850         -    //addr.sin_addr.s_addr = htonl (INADDR_ANY);
  3851         -    addr.sin_addr.s_addr = inet_addr (ip_addr);
         3817  +    addr.sin_addr.s_addr = htonl (INADDR_ANY);
  3852   3818       if (bind (skt, (struct sockaddr *) &addr, sizeof (addr)) == -1)
  3853   3819         {
  3854   3820   	  fprintf (stderr, "unable to bind the socket\n");
  3855   3821   	  close (skt);
  3856   3822   	  return 0;
  3857   3823         }
  3858   3824       if (listen (skt, SOMAXCONN) == -1)
................................................................................
  4474   4440   static void
  4475   4441   get_raster_styles (sqlite3 * handle, struct wms_list *list)
  4476   4442   {
  4477   4443   /* retrieving all declared Raster Styles */
  4478   4444       int ret;
  4479   4445       sqlite3_stmt *stmt;
  4480   4446       const char *sql = "SELECT coverage_name, name, title, abstract "
  4481         -	"FROM SE_raster_styled_layers_view ORDER BY coverage_name, name";
         4447  +	"FROM SE_raster_styled_layers_view ORDER BY coverage_name, style_id";
  4482   4448       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  4483   4449       if (ret != SQLITE_OK)
  4484   4450   	return;
  4485   4451       while (1)
  4486   4452         {
  4487   4453   	  /* scrolling the result set rows */
  4488   4454   	  ret = sqlite3_step (stmt);
................................................................................
  4509   4475   static void
  4510   4476   get_vector_styles (sqlite3 * handle, struct wms_list *list)
  4511   4477   {
  4512   4478   /* retrieving all declared Vector Styles */
  4513   4479       int ret;
  4514   4480       sqlite3_stmt *stmt;
  4515   4481       const char *sql = "SELECT coverage_name, name, title, abstract "
  4516         -	"FROM SE_vector_styled_layers_view ORDER BY coverage_name, name";
         4482  +	"FROM SE_vector_styled_layers_view ORDER BY coverage_name, style_id";
  4517   4483       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  4518   4484       if (ret != SQLITE_OK)
  4519   4485   	return;
  4520   4486       while (1)
  4521   4487         {
  4522   4488   	  /* scrolling the result set rows */
  4523   4489   	  ret = sqlite3_step (stmt);
................................................................................
  4780   4746   {
  4781   4747   /* printing the argument list */
  4782   4748       fprintf (stderr, "\n\nusage: wmslite ARGLIST ]\n");
  4783   4749       fprintf (stderr,
  4784   4750   	     "==============================================================\n");
  4785   4751       fprintf (stderr, "-db or --db-path      pathname  RasterLite2 DB path\n");
  4786   4752       fprintf (stderr,
  4787         -	     "-ip or --ip-addr    ip-address  IP address [default: 127.0.0.1]\n\n");
  4788         -    fprintf (stderr,
  4789   4753   	     "-p or --ip-port       number    IP port number [default: 8080]\n\n");
  4790   4754       fprintf (stderr,
  4791   4755   	     "-mt or --max-threads   num      max number of concurrent threads\n");
  4792   4756       fprintf (stderr,
  4793   4757   	     "-cs or --cache-size    num      DB cache size (how many pages)\n");
  4794   4758       fprintf (stderr,
  4795   4759   	     "-dbg or --debug                 verbose debugginh mode\n");
................................................................................
  4804   4768       sqlite3_stmt *stmt_log = NULL;
  4805   4769       const char *sql;
  4806   4770       int ret;
  4807   4771       int i;
  4808   4772       int error = 0;
  4809   4773       int next_arg = ARG_NONE;
  4810   4774       const char *db_path = NULL;
  4811         -    const char *ip_addr = "127.0.0.1";
  4812   4775       int port_no = 8080;
  4813   4776       int cache_size = 0;
  4814   4777       void *cache;
  4815   4778       void *priv_data;
  4816   4779       struct wms_list *list = NULL;
  4817   4780       struct connections_pool *pool;
  4818   4781       struct server_log *log;
................................................................................
  4842   4805   	  if (next_arg != ARG_NONE)
  4843   4806   	    {
  4844   4807   		switch (next_arg)
  4845   4808   		  {
  4846   4809   		  case ARG_DB_PATH:
  4847   4810   		      db_path = argv[i];
  4848   4811   		      break;
  4849         -		  case ARG_IP_ADDR:
  4850         -		      ip_addr = argv[i];
  4851         -		      break;
  4852   4812   		  case ARG_IP_PORT:
  4853   4813   		      port_no = atoi (argv[i]);
  4854   4814   		      break;
  4855   4815   		  case ARG_CACHE_SIZE:
  4856   4816   		      cache_size = atoi (argv[i]);
  4857   4817   		      break;
  4858   4818   		  case ARG_MAX_THREADS:
................................................................................
  4871   4831   	    }
  4872   4832   	  if (strcmp (argv[i], "-db") == 0
  4873   4833   	      || strcasecmp (argv[i], "--db-path") == 0)
  4874   4834   	    {
  4875   4835   		next_arg = ARG_DB_PATH;
  4876   4836   		continue;
  4877   4837   	    }
  4878         -	  if (strcmp (argv[i], "-ip") == 0
  4879         -	      || strcasecmp (argv[i], "--ip-addr") == 0)
  4880         -	    {
  4881         -		next_arg = ARG_IP_ADDR;
  4882         -		continue;
  4883         -	    }
  4884   4838   	  if (strcmp (argv[i], "-p") == 0
  4885   4839   	      || strcasecmp (argv[i], "--ip-port") == 0)
  4886   4840   	    {
  4887   4841   		next_arg = ARG_IP_PORT;
  4888   4842   		continue;
  4889   4843   	    }
  4890   4844   	  if (strcasecmp (argv[i], "--max-threads") == 0
................................................................................
  4978   4932       get_raster_alt_srids (handle, list);
  4979   4933       get_vector_alt_srids (handle, list);
  4980   4934       get_raster_keywords (handle, list);
  4981   4935       get_vector_keywords (handle, list);
  4982   4936       glob.list = list;
  4983   4937       complete_layer_config (handle, list);
  4984   4938       build_get_capabilities (list, &cached_capabilities,
  4985         -			    &cached_capabilities_len, ip_addr, port_no);
         4939  +			    &cached_capabilities_len, port_no);
  4986   4940       glob.cached_capabilities = cached_capabilities;
  4987   4941   
  4988   4942   /* creating the read connections pool */
  4989   4943       pool = alloc_connections_pool (db_path, max_threads);
  4990   4944       if (pool == NULL)
  4991   4945         {
  4992   4946   	  fprintf (stderr, "ERROR: unable to initialize a connections pool\n");
................................................................................
  5000   4954         {
  5001   4955   	  fprintf (stderr, "ERROR: unable to initialize the server log\n");
  5002   4956   	  goto stop;
  5003   4957         }
  5004   4958       glob.log = log;
  5005   4959   
  5006   4960   /* starting the HTTP server */
  5007         -    if (!do_start_http (ip_addr, port_no, &skt_ptr, max_threads))
         4961  +    if (!do_start_http (port_no, &skt_ptr, max_threads))
  5008   4962   	goto stop;
  5009   4963   
  5010   4964   /* starting the logging facility */
  5011   4965       sql = "CREATE TABLE IF NOT EXISTS wms_server_log (\n"
  5012   4966   	"\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n"
  5013   4967   	"\ttimestamp TEXT NOT NULL,\n"
  5014   4968   	"\tclient_ip_addr TEXT NOT NULL,\n"
................................................................................
  5045   4999         {
  5046   5000   	  printf ("INSERT INTO LOG error: %s\n", sqlite3_errmsg (handle));
  5047   5001   	  goto stop;
  5048   5002         }
  5049   5003       glob.stmt_log = stmt_log;
  5050   5004   
  5051   5005   /* looping on requests */
  5052         -    do_accept_loop (&skt_ptr, list, ip_addr, port_no, handle, stmt_log, pool,
  5053         -		    log, cached_capabilities, cached_capabilities_len);
         5006  +    do_accept_loop (&skt_ptr, list, port_no, handle, stmt_log, pool, log,
         5007  +		    cached_capabilities, cached_capabilities_len);
  5054   5008   
  5055   5009     stop:
  5056   5010       destroy_wms_list (list);
  5057   5011       list = NULL;
  5058   5012       glob.list = NULL;
  5059   5013       clean_shutdown ();
  5060   5014       return 0;
  5061   5015   }