Check-in Differences
Not logged in

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

Difference From c5692a3458233cdd To 9ad78b460f74e562

2015-06-29
01:34
supporting a dummy def for SQLITE_DETERMINISTIC intended for obsolete sqlite3 check-in: 728323e837 user: sandro tags: trunk
2015-06-28
13:26
restting SONAME to 1.0.0 check-in: 9ad78b460f user: sandro tags: trunk
2015-06-26
11:05
adding "AUTOMAKE_OPTIONS=foreign" to Makefile.am check-in: ad8b2cf084 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

Deleted 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)

Added 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.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.2.0.mk rasterlite2-4.2.0.mk \
            5  +EXTRA_DIST = mainpage.doxy Android_R4.3.0.mk rasterlite2-4.3.0.mk \
     6      6   	Makefile-static-MinGW
     7      7   
     8         -AUTOMAKE_OPTIONS = dist-zip
            8  +AUTOMAKE_OPTIONS = dist-zip foreign
     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     18   	genhtml --rc lcov_branch_coverage=1 -o covresults rasterlite2_cov.info
    19     19   
    20     20   MOSTLYCLEANFILES = rasterlite2_cov.info 

Changes to Makefile.in.

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

Changes to aclocal.m4.

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

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-rc1.
            3  +# Generated by GNU Autoconf 2.69 for librasterlite2 1.0.0-devel.
     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-rc1'
   594         -PACKAGE_STRING='librasterlite2 1.0.0-rc1'
          593  +PACKAGE_VERSION='1.0.0-devel'
          594  +PACKAGE_STRING='librasterlite2 1.0.0-devel'
   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-rc1 to adapt to many kinds of systems.
         1375  +\`configure' configures librasterlite2 1.0.0-devel 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-rc1:";;
         1445  +     short | recursive ) echo "Configuration of librasterlite2 1.0.0-devel:";;
  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-rc1
         1597  +librasterlite2 configure 1.0.0-devel
  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-rc1, which was
         2141  +It was created by librasterlite2 $as_me 1.0.0-devel, 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.14'
         2526  +am__api_version='1.15'
  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}" != xset; then
         2718  +if test x"${install_sh+set}" != 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-rc1'
         3012  + VERSION='1.0.0-devel'
  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.  The system "awk" is bad on
  3047         -# some platforms.
         3046  +# We need awk for the "check" target (and possibly the TAP driver).  The
         3047  +# system "awk" is bad on 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  +
  3104   3105   
  3105   3106   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
  3106   3107   $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
  3107   3108       # Check whether --enable-maintainer-mode was given.
  3108   3109   if test "${enable_maintainer_mode+set}" = set; then :
  3109   3110     enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
  3110   3111   else
................................................................................
 19156  19157   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 19157  19158   
 19158  19159   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 19159  19160   # Save the log message, to keep $0 and so on meaningful, and to
 19160  19161   # report actual input values of CONFIG_FILES etc. instead of their
 19161  19162   # values after options handling.
 19162  19163   ac_log="
 19163         -This file was extended by librasterlite2 $as_me 1.0.0-rc1, which was
        19164  +This file was extended by librasterlite2 $as_me 1.0.0-devel, which was
 19164  19165   generated by GNU Autoconf 2.69.  Invocation command line was
 19165  19166   
 19166  19167     CONFIG_FILES    = $CONFIG_FILES
 19167  19168     CONFIG_HEADERS  = $CONFIG_HEADERS
 19168  19169     CONFIG_LINKS    = $CONFIG_LINKS
 19169  19170     CONFIG_COMMANDS = $CONFIG_COMMANDS
 19170  19171     $ $0 $@
................................................................................
 19222  19223   
 19223  19224   Report bugs to <a.furieri@lqt.it>."
 19224  19225   
 19225  19226   _ACEOF
 19226  19227   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 19227  19228   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 19228  19229   ac_cs_version="\\
 19229         -librasterlite2 config.status 1.0.0-rc1
        19230  +librasterlite2 config.status 1.0.0-devel
 19230  19231   configured by $0, generated by GNU Autoconf 2.69,
 19231  19232     with options \\"\$ac_cs_config\\"
 19232  19233   
 19233  19234   Copyright (C) 2012 Free Software Foundation, Inc.
 19234  19235   This config.status script is free software; the Free Software Foundation
 19235  19236   gives unlimited permission to copy, distribute and modify it."
 19236  19237   

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-rc1, a.furieri@lqt.it)
            5  +AC_INIT(librasterlite2, 1.0.0-devel, 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.14.1 from Makefile.am.
            1  +# Makefile.in generated by automake 1.15 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2013 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2014 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 = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
           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  +}
    19     29   am__make_running_with_option = \
    20     30     case $${target_option-} in \
    21     31         ?) ;; \
    22     32         *) echo "am__make_running_with_option: internal error: invalid" \
    23     33                 "target option '$${target_option-}' specified" >&2; \
    24     34            exit 1;; \
    25     35     esac; \
................................................................................
    75     85   POST_INSTALL = :
    76     86   NORMAL_UNINSTALL = :
    77     87   PRE_UNINSTALL = :
    78     88   POST_UNINSTALL = :
    79     89   build_triplet = @build@
    80     90   host_triplet = @host@
    81     91   subdir = headers
    82         -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
    83         -	$(nobase_include_HEADERS) $(noinst_HEADERS)
    84     92   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    85     93   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    86     94   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    87     95   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    88     96   	$(top_srcdir)/configure.ac
    89     97   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    90     98   	$(ACLOCAL_M4)
           99  +DIST_COMMON = $(srcdir)/Makefile.am $(nobase_include_HEADERS) \
          100  +	$(noinst_HEADERS) $(am__DIST_COMMON)
    91    101   mkinstalldirs = $(install_sh) -d
    92    102   CONFIG_HEADER = $(top_builddir)/config.h
    93    103   CONFIG_CLEAN_FILES =
    94    104   CONFIG_CLEAN_VPATH_FILES =
    95    105   AM_V_P = $(am__v_P_@AM_V@)
    96    106   am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
    97    107   am__v_P_0 = false
................................................................................
   155    165   am__define_uniq_tagged_files = \
   156    166     list='$(am__tagged_files)'; \
   157    167     unique=`for i in $$list; do \
   158    168       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   159    169     done | $(am__uniquify_input)`
   160    170   ETAGS = etags
   161    171   CTAGS = ctags
          172  +am__DIST_COMMON = $(srcdir)/Makefile.in
   162    173   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   163    174   ACLOCAL = @ACLOCAL@
   164    175   AMTAR = @AMTAR@
   165    176   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   166    177   AR = @AR@
   167    178   AS = @AS@
   168    179   AUTOCONF = @AUTOCONF@
................................................................................
   321    332   	        && { if test -f $@; then exit 0; else break; fi; }; \
   322    333   	      exit 1;; \
   323    334   	  esac; \
   324    335   	done; \
   325    336   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu headers/Makefile'; \
   326    337   	$(am__cd) $(top_srcdir) && \
   327    338   	  $(AUTOMAKE) --gnu headers/Makefile
   328         -.PRECIOUS: Makefile
   329    339   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   330    340   	@case '$?' in \
   331    341   	  *config.status*) \
   332    342   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   333    343   	  *) \
   334    344   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   335    345   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
   570    580   	install-info install-info-am install-man \
   571    581   	install-nobase_includeHEADERS install-pdf install-pdf-am \
   572    582   	install-ps install-ps-am install-strip installcheck \
   573    583   	installcheck-am installdirs maintainer-clean \
   574    584   	maintainer-clean-generic mostlyclean mostlyclean-generic \
   575    585   	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
   576    586   	uninstall-am uninstall-nobase_includeHEADERS
          587  +
          588  +.PRECIOUS: Makefile
   577    589   
   578    590   
   579    591   # Tell versions [3.59,3.63) of GNU make to not export all variables.
   580    592   # Otherwise a system limit (for SysV at least) may be exceeded.
   581    593   .NOEXPORT:

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;
  1104   1108   	struct rl2_linestring *next;
  1105   1109       } rl2Linestring;
  1106   1110       typedef rl2Linestring *rl2LinestringPtr;
  1107   1111   
  1108   1112       typedef struct rl2_ring
  1109   1113       {
  1110   1114   	int points;
  1111   1115   	double *coords;
         1116  +	double minx;
         1117  +	double miny;
         1118  +	double maxx;
         1119  +	double maxy;
  1112   1120   	struct rl2_ring *next;
  1113   1121       } rl2Ring;
  1114   1122       typedef rl2Ring *rl2RingPtr;
  1115   1123   
  1116   1124       typedef struct rl2_polygon
  1117   1125       {
  1118   1126   	rl2RingPtr exterior;
................................................................................
  1253   1261   				    unsigned int *height,
  1254   1262   				    unsigned char sample_type,
  1255   1263   				    unsigned char pixel_type,
  1256   1264   				    unsigned char num_bands,
  1257   1265   				    unsigned char **pixels, int *pixels_sz);
  1258   1266   
  1259   1267       RL2_PRIVATE int
  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);
         1268  +	rl2_data_to_png (const unsigned char *pixels,
         1269  +			 const unsigned char *mask, double opacity,
         1270  +			 rl2PalettePtr plt, unsigned int width,
         1271  +			 unsigned int height, unsigned char sample_type,
         1272  +			 unsigned char pixel_type, unsigned char num_bands,
         1273  +			 unsigned char **compr_data, int *compressed_size);
  1266   1274   
  1267   1275       RL2_PRIVATE int
  1268   1276   	rl2_decode_png (const unsigned char *png, int png_sz,
  1269   1277   			unsigned int *width, unsigned int *height,
  1270   1278   			unsigned char *sample_type, unsigned char *pixel_type,
  1271   1279   			unsigned char *num_bands, unsigned char **pixels,
  1272   1280   			int *pixels_sz, unsigned char **mask, int *mask_sz,
................................................................................
  1278   1286   			    unsigned char pixel_type, unsigned char num_bands,
  1279   1287   			    unsigned char **compr_data, int *compressed_size);
  1280   1288   
  1281   1289       RL2_PRIVATE int
  1282   1290   	rl2_decode_charls (const unsigned char *charls, int charls_sz,
  1283   1291   			   unsigned int *width, unsigned int *height,
  1284   1292   			   unsigned char *sample_type,
  1285         -			   unsigned char *pixel_type, unsigned char *num_bands,
  1286         -			   unsigned char **pixels, int *pixels_sz);
         1293  +			   unsigned char *pixel_type,
         1294  +			   unsigned char *num_bands, unsigned char **pixels,
         1295  +			   int *pixels_sz);
  1287   1296   
  1288   1297       RL2_PRIVATE int
  1289   1298   	rl2_data_to_gif (const unsigned char *pixels,
  1290   1299   			 rl2PalettePtr plt, unsigned int width,
  1291   1300   			 unsigned int height, unsigned char sample_type,
  1292   1301   			 unsigned char pixel_type, unsigned char **compr_data,
  1293   1302   			 int *compressed_size);
................................................................................
  1343   1352   					 unsigned int height,
  1344   1353   					 unsigned char sample_type,
  1345   1354   					 unsigned char num_bands,
  1346   1355   					 unsigned char auto_ndvi,
  1347   1356   					 unsigned char red_band_index,
  1348   1357   					 unsigned char nir_band_index,
  1349   1358   					 double x_res, double y_res,
  1350         -					 double minx, double miny, double maxx,
  1351         -					 double maxy, int level, int scale,
  1352         -					 rl2PalettePtr palette,
         1359  +					 double minx, double miny,
         1360  +					 double maxx, double maxy, int level,
         1361  +					 int scale, rl2PalettePtr palette,
  1353   1362   					 rl2PixelPtr no_data,
  1354   1363   					 rl2RasterSymbolizerPtr style,
  1355   1364   					 rl2RasterStatisticsPtr stats);
  1356   1365   
  1357   1366       RL2_PRIVATE int rl2_load_dbms_tiles_section (sqlite3 * handle,
  1358   1367   						 int max_threads,
  1359   1368   						 sqlite3_int64 section_id,
................................................................................
  1447   1456   					  int scale, double x_res,
  1448   1457   					  double y_res);
  1449   1458   
  1450   1459       RL2_PRIVATE int rl2_find_best_resolution_level (sqlite3 * handle,
  1451   1460   						    const char *coverage,
  1452   1461   						    int by_section,
  1453   1462   						    sqlite3_int64 section_id,
  1454         -						    double x_res, double y_res,
         1463  +						    double x_res,
         1464  +						    double y_res,
  1455   1465   						    int *level_id, int *scale,
  1456   1466   						    int *real_scale,
  1457   1467   						    double *xx_res,
  1458   1468   						    double *yy_res);
  1459   1469   
  1460   1470       RL2_PRIVATE unsigned char get_palette_format (rl2PrivPalettePtr plt);
  1461   1471   
................................................................................
  1497   1507   						     unsigned char format,
  1498   1508   						     int quality,
  1499   1509   						     unsigned char **image,
  1500   1510   						     int *image_sz);
  1501   1511   
  1502   1512       RL2_PRIVATE int get_payload_from_palette_transparent (unsigned int width,
  1503   1513   							  unsigned int height,
  1504         -							  unsigned char *pixels,
  1505         -							  rl2PalettePtr palette,
  1506         -							  unsigned char format,
  1507         -							  int quality,
  1508         -							  unsigned char **image,
         1514  +							  unsigned char
         1515  +							  *pixels,
         1516  +							  rl2PalettePtr
         1517  +							  palette,
         1518  +							  unsigned char
         1519  +							  format, int quality,
         1520  +							  unsigned char
         1521  +							  **image,
  1509   1522   							  int *image_sz,
  1510         -							  unsigned char bg_red,
         1523  +							  unsigned char
         1524  +							  bg_red,
  1511   1525   							  unsigned char
  1512   1526   							  bg_green,
  1513   1527   							  unsigned char
  1514   1528   							  bg_blue,
  1515   1529   							  double opacity);
  1516   1530   
  1517   1531       RL2_PRIVATE int get_payload_from_grayscale_opaque (unsigned int width,
  1518   1532   						       unsigned int height,
  1519   1533   						       sqlite3 * handle,
  1520         -						       double minx, double miny,
  1521         -						       double maxx, double maxy,
  1522         -						       int srid,
         1534  +						       double minx,
         1535  +						       double miny,
         1536  +						       double maxx,
         1537  +						       double maxy, int srid,
  1523   1538   						       unsigned char *pixels,
  1524   1539   						       unsigned char format,
  1525   1540   						       int quality,
  1526   1541   						       unsigned char **image,
  1527   1542   						       int *image_sz);
  1528   1543   
  1529   1544       RL2_PRIVATE int get_payload_from_grayscale_transparent (unsigned int
  1530   1545   							    width,
  1531   1546   							    unsigned int
  1532   1547   							    height,
  1533   1548   							    unsigned char
  1534   1549   							    *pixels,
  1535   1550   							    unsigned char
  1536         -							    format, int quality,
         1551  +							    format,
         1552  +							    int quality,
  1537   1553   							    unsigned char
  1538   1554   							    **image,
  1539   1555   							    int *image_sz,
  1540   1556   							    unsigned char
  1541   1557   							    bg_gray,
  1542   1558   							    double opacity);
  1543   1559   
  1544   1560       RL2_PRIVATE int get_payload_from_rgb_opaque (unsigned int width,
  1545   1561   						 unsigned int height,
  1546         -						 sqlite3 * handle, double minx,
  1547         -						 double miny, double maxx,
  1548         -						 double maxy, int srid,
         1562  +						 sqlite3 * handle,
         1563  +						 double minx, double miny,
         1564  +						 double maxx, double maxy,
         1565  +						 int srid,
  1549   1566   						 unsigned char *pixels,
  1550   1567   						 unsigned char format,
  1551   1568   						 int quality,
  1552   1569   						 unsigned char **image,
  1553   1570   						 int *image_sz);
  1554   1571   
  1555   1572       RL2_PRIVATE int get_payload_from_rgb_transparent (unsigned int width,
................................................................................
  1574   1591       RL2_PRIVATE int get_rgba_from_monochrome_opaque (unsigned int width,
  1575   1592   						     unsigned int height,
  1576   1593   						     unsigned char *pixels,
  1577   1594   						     unsigned char *rgba);
  1578   1595   
  1579   1596       RL2_PRIVATE int get_rgba_from_monochrome_transparent (unsigned int width,
  1580   1597   							  unsigned int height,
  1581         -							  unsigned char *pixels,
         1598  +							  unsigned char
         1599  +							  *pixels,
  1582   1600   							  unsigned char *rgba);
  1583   1601   
  1584   1602       RL2_PRIVATE int get_rgba_from_palette_mask (unsigned int base_width,
  1585   1603   						unsigned int base_height,
  1586   1604   						unsigned char *pixels,
  1587   1605   						unsigned char *mask,
  1588   1606   						rl2PalettePtr palette,
................................................................................
  1614   1632       RL2_PRIVATE int get_rgba_from_grayscale_opaque (unsigned int width,
  1615   1633   						    unsigned int height,
  1616   1634   						    unsigned char *pixels,
  1617   1635   						    unsigned char *rgba);
  1618   1636   
  1619   1637       RL2_PRIVATE int get_rgba_from_grayscale_transparent (unsigned int width,
  1620   1638   							 unsigned int height,
  1621         -							 unsigned char *pixels,
         1639  +							 unsigned char
         1640  +							 *pixels,
  1622   1641   							 unsigned char *rgba,
  1623   1642   							 unsigned char bg_gray);
  1624   1643   
  1625   1644       RL2_PRIVATE int get_rgba_from_rgb_mask (unsigned int width,
  1626   1645   					    unsigned int height,
  1627   1646   					    unsigned char *pixels,
  1628   1647   					    unsigned char *mask,
................................................................................
  1658   1677   						  unsigned char *mask,
  1659   1678   						  rl2PrivPixelPtr no_made,
  1660   1679   						  unsigned char *rgba);
  1661   1680   
  1662   1681       RL2_PRIVATE int get_payload_from_gray_rgba_opaque (unsigned int width,
  1663   1682   						       unsigned int height,
  1664   1683   						       sqlite3 * handle,
  1665         -						       double minx, double miny,
  1666         -						       double maxx, double maxy,
  1667         -						       int srid,
         1684  +						       double minx,
         1685  +						       double miny,
         1686  +						       double maxx,
         1687  +						       double maxy, int srid,
  1668   1688   						       unsigned char *rgb,
  1669   1689   						       unsigned char format,
  1670   1690   						       int quality,
  1671   1691   						       unsigned char **image,
  1672   1692   						       int *image_sz);
  1673   1693   
  1674   1694       RL2_PRIVATE int get_payload_from_gray_rgba_transparent (unsigned int
  1675   1695   							    width,
  1676   1696   							    unsigned int
  1677   1697   							    height,
  1678         -							    unsigned char *rgb,
         1698  +							    unsigned char
         1699  +							    *rgb,
  1679   1700   							    unsigned char
  1680   1701   							    *alpha,
  1681   1702   							    unsigned char
  1682         -							    format, int quality,
         1703  +							    format,
         1704  +							    int quality,
  1683   1705   							    unsigned char
  1684   1706   							    **image,
  1685   1707   							    int *image_sz,
  1686   1708   							    double opacity);
  1687   1709   
  1688   1710       RL2_PRIVATE int get_payload_from_rgb_rgba_opaque (unsigned int width,
  1689   1711   						      unsigned int height,
  1690   1712   						      sqlite3 * handle,
  1691         -						      double minx, double miny,
  1692         -						      double maxx, double maxy,
  1693         -						      int srid,
         1713  +						      double minx,
         1714  +						      double miny,
         1715  +						      double maxx,
         1716  +						      double maxy, int srid,
  1694   1717   						      unsigned char *rgb,
  1695   1718   						      unsigned char format,
  1696   1719   						      int quality,
  1697   1720   						      unsigned char **image,
  1698   1721   						      int *image_sz);
  1699   1722   
  1700   1723       RL2_PRIVATE int get_payload_from_rgb_rgba_transparent (unsigned int width,
  1701   1724   							   unsigned int
  1702   1725   							   height,
  1703   1726   							   unsigned char *rgb,
  1704         -							   unsigned char *alpha,
  1705         -							   unsigned char format,
         1727  +							   unsigned char
         1728  +							   *alpha,
         1729  +							   unsigned char
         1730  +							   format,
  1706   1731   							   int quality,
  1707   1732   							   unsigned char
  1708   1733   							   **image,
  1709   1734   							   int *image_sz,
  1710   1735   							   double opacity,
  1711   1736   							   int
  1712   1737   							   half_transparent);
  1713   1738   
  1714   1739       RL2_PRIVATE int build_rgb_alpha (unsigned int width,
  1715   1740   				     unsigned int height, unsigned char *rgba,
  1716         -				     unsigned char **rgb, unsigned char **alpha,
         1741  +				     unsigned char **rgb,
         1742  +				     unsigned char **alpha,
  1717   1743   				     unsigned char bg_red,
  1718   1744   				     unsigned char bg_green,
  1719   1745   				     unsigned char bg_blue);
  1720   1746   
  1721   1747       RL2_PRIVATE int get_rgba_from_multiband8 (unsigned int width,
  1722   1748   					      unsigned int height,
  1723   1749   					      unsigned char red_band,
................................................................................
  1742   1768       RL2_PRIVATE int parse_worldfile (FILE * in, double *px, double *py,
  1743   1769   				     double *pres_x, double *pres_y);
  1744   1770   
  1745   1771       RL2_PRIVATE rl2CoverageStylePtr coverage_style_from_xml (char *name,
  1746   1772   							     unsigned char
  1747   1773   							     *xml);
  1748   1774   
  1749         -    RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char *name,
         1775  +    RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char
         1776  +								    *name,
  1750   1777   								    unsigned
  1751   1778   								    char *xml);
  1752   1779   
  1753   1780       RL2_PRIVATE rl2GroupStylePtr group_style_from_sld_xml (char *name,
  1754   1781   							   unsigned char *xml);
  1755   1782   
  1756   1783       RL2_PRIVATE rl2PrivCoverageStylePtr
................................................................................
  1831   1858   
  1832   1859       RL2_PRIVATE void rl2_destroy_point_symbolizer (rl2PrivPointSymbolizerPtr
  1833   1860   						   symbolizer);
  1834   1861   
  1835   1862       RL2_PRIVATE void rl2_destroy_line_symbolizer (rl2PrivLineSymbolizerPtr
  1836   1863   						  symbolizer);
  1837   1864   
  1838         -    RL2_PRIVATE void rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr
  1839         -						     symbolizer);
         1865  +    RL2_PRIVATE void
         1866  +	rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr symbolizer);
  1840   1867   
  1841   1868       RL2_PRIVATE void rl2_destroy_text_symbolizer (rl2PrivTextSymbolizerPtr
  1842   1869   						  symbolizer);
  1843   1870   
  1844   1871       RL2_PRIVATE rl2PrivRuleSingleArgPtr
  1845   1872   	rl2_create_default_rule_single_arg (void);
  1846   1873   
................................................................................
  1881   1908   					 rl2RasterSymbolizerPtr style,
  1882   1909   					 rl2RasterStatisticsPtr stats);
  1883   1910   
  1884   1911       RL2_PRIVATE unsigned char *rl2_copy_endian_raw_pixels (const unsigned char
  1885   1912   							   *pixels,
  1886   1913   							   int pixels_sz,
  1887   1914   							   unsigned int width,
  1888         -							   unsigned int height,
         1915  +							   unsigned int
         1916  +							   height,
  1889   1917   							   unsigned char
  1890   1918   							   sample_type,
  1891   1919   							   unsigned char
  1892   1920   							   num_bands,
  1893   1921   							   int big_endian);
  1894   1922   
  1895   1923       RL2_PRIVATE int rl2_build_shaded_relief_mask (sqlite3 * handle,
................................................................................
  1910   1938   					const char *title,
  1911   1939   					const char *abstract);
  1912   1940   
  1913   1941       RL2_PRIVATE int rl2_test_layer_group (sqlite3 * handle,
  1914   1942   					  const char *group_name);
  1915   1943   
  1916   1944       RL2_PRIVATE int rl2_rgba_raster_data (sqlite3 * handle,
  1917         -					  const char *coverage_name, void *ctx,
  1918         -					  int level, double minx, double miny,
  1919         -					  double maxx, double maxy,
  1920         -					  rl2PalettePtr palette,
         1945  +					  const char *coverage_name,
         1946  +					  void *ctx, int level, double minx,
         1947  +					  double miny, double maxx,
         1948  +					  double maxy, rl2PalettePtr palette,
  1921   1949   					  rl2PixelPtr no_data);
  1922   1950   
  1923   1951       RL2_PRIVATE int rl2_aux_render_image (struct aux_renderer *aux,
  1924   1952   					  unsigned char **ximage,
  1925   1953   					  int *ximage_size);
         1954  +
         1955  +    RL2_PRIVATE int rl2_aux_default_image (unsigned int width,
         1956  +					   unsigned int height,
         1957  +					   unsigned char red,
         1958  +					   unsigned char green,
         1959  +					   unsigned char blue, int format_id,
         1960  +					   int transparent, int quality,
         1961  +					   unsigned char **ximage,
         1962  +					   int *ximage_size);
  1926   1963   
  1927   1964       RL2_PRIVATE void rl2_aux_group_renderer (struct aux_group_renderer *auxgrp);
  1928   1965   
  1929   1966       RL2_PRIVATE double rl2_get_shaded_relief_scale_factor (sqlite3 * handle,
  1930   1967   							   const char
  1931   1968   							   *coverage);
  1932   1969   
................................................................................
  1950   1987   						    rl2CoveragePtr cvg,
  1951   1988   						    int by_section,
  1952   1989   						    sqlite3_int64 section_id,
  1953   1990   						    unsigned int width,
  1954   1991   						    unsigned int height,
  1955   1992   						    double minx, double miny,
  1956   1993   						    double maxx, double maxy,
  1957         -						    double x_res, double y_res,
         1994  +						    double x_res,
         1995  +						    double y_res,
  1958   1996   						    unsigned char **buffer,
  1959   1997   						    int *buf_size,
  1960   1998   						    rl2PalettePtr * palette,
  1961   1999   						    unsigned char out_pixel,
  1962   2000   						    rl2PixelPtr bgcolor,
  1963   2001   						    rl2RasterSymbolizerPtr
  1964   2002   						    style,
................................................................................
  1972   2010   				     double *x, double *y);
  1973   2011   
  1974   2012       RL2_PRIVATE int rl2_parse_point_generic (sqlite3 * sqlite,
  1975   2013   					     const unsigned char *blob,
  1976   2014   					     int blob_sz, double *x, double *y);
  1977   2015   
  1978   2016       RL2_PRIVATE int rl2_parse_bbox_srid (sqlite3 * sqlite,
  1979         -					 const unsigned char *blob, int blob_sz,
  1980         -					 int *srid, double *minx, double *miny,
  1981         -					 double *maxx, double *maxy);
         2017  +					 const unsigned char *blob,
         2018  +					 int blob_sz, int *srid, double *minx,
         2019  +					 double *miny, double *maxx,
         2020  +					 double *maxy);
  1982   2021   
  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);
         2022  +    RL2_PRIVATE int rl2_parse_bbox (sqlite3 * sqlite,
         2023  +				    const unsigned char *blob, int blob_sz,
         2024  +				    double *minx, double *miny, double *maxx,
         2025  +				    double *maxy);
  1986   2026   
  1987   2027       RL2_PRIVATE int rl2_build_bbox (sqlite3 * sqlite, int srid, double minx,
  1988   2028   				    double miny, double maxx, double maxy,
  1989   2029   				    unsigned char **blob, int *blob_sz);
  1990   2030   
  1991   2031       RL2_PRIVATE int rl2_delta_encode (unsigned char *buffer, int size,
  1992   2032   				      int distance);
  1993   2033   
  1994   2034       RL2_PRIVATE int rl2_delta_decode (unsigned char *buffer, int size,
  1995   2035   				      int distance);
  1996   2036   
  1997         -    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char *name,
         2037  +    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char
         2038  +							       *name,
  1998   2039   							       sqlite3_int64
  1999   2040   							       value);
  2000   2041   
  2001   2042       RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_double (const char
  2002   2043   								  *name,
  2003   2044   								  double value);
  2004   2045   
................................................................................
  2012   2053   
  2013   2054       RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_null (const char
  2014   2055   								*name);
  2015   2056   
  2016   2057       RL2_PRIVATE void rl2_destroy_variant_value (rl2PrivVariantValuePtr value);
  2017   2058   
  2018   2059       RL2_PRIVATE void rl2_draw_vector_feature (void *ctx, sqlite3 * handle,
  2019         -					      rl2VectorSymbolizerPtr symbolizer,
  2020         -					      int height, double minx,
  2021         -					      double miny, double x_res,
  2022         -					      double y_res,
         2060  +					      const void *priv_data,
         2061  +					      rl2VectorSymbolizerPtr
         2062  +					      symbolizer, int height,
         2063  +					      double minx, double miny,
         2064  +					      double maxx, double maxy,
         2065  +					      double x_res, double y_res,
  2023   2066   					      rl2GeometryPtr geom,
  2024   2067   					      rl2VariantArrayPtr variant);
  2025   2068   
  2026   2069       RL2_PRIVATE rl2GeometryPtr
  2027   2070   	rl2_geometry_from_blob (const unsigned char *blob, int blob_sz);
  2028   2071   
  2029   2072       RL2_PRIVATE rl2GeometryPtr
................................................................................
  2033   2076   
  2034   2077       RL2_PRIVATE int rl2_serialize_linestring (rl2LinestringPtr line,
  2035   2078   					      unsigned char **blob,
  2036   2079   					      int *blob_sz);
  2037   2080   
  2038   2081       RL2_PRIVATE int rl2_serialize_ring (rl2RingPtr ring, unsigned char **blob,
  2039   2082   					int *blob_sz);
         2083  +
         2084  +    RL2_PRIVATE int rl2_serialize_ring_as_linestring (rl2RingPtr ring,
         2085  +						      unsigned char **blob,
         2086  +						      int *blob_sz);
  2040   2087   
  2041   2088       RL2_PRIVATE double rl2_compute_curve_length (rl2GeometryPtr geom);
  2042   2089   
  2043   2090       RL2_PRIVATE rl2GeometryPtr
  2044         -	rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom, double from,
  2045         -			     double to);
         2091  +	rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom,
         2092  +			     double from, double to);
  2046   2093   
  2047   2094       RL2_PRIVATE rl2GeometryPtr rl2_clone_curve (rl2GeometryPtr in);
  2048   2095   
  2049   2096       RL2_PRIVATE rl2GeometryPtr rl2_clone_linestring (rl2LinestringPtr in);
  2050   2097   
  2051   2098       RL2_PRIVATE rl2GeometryPtr
  2052   2099   	rl2_build_circle (double x, double y, double radius);
................................................................................
  2053   2100   
  2054   2101       RL2_PRIVATE int rl2_load_font_into_dbms (sqlite3 * handle,
  2055   2102   					     unsigned char *blob, int blob_sz);
  2056   2103   
  2057   2104       RL2_PRIVATE int rl2_get_font_from_dbms (sqlite3 * handle,
  2058   2105   					    const char *facename,
  2059   2106   					    unsigned char **font, int *font_sz);
         2107  +
         2108  +    RL2_PRIVATE rl2LinestringPtr rl2_linestring_to_image (rl2LinestringPtr line,
         2109  +							  int height,
         2110  +							  double minx,
         2111  +							  double miny,
         2112  +							  double x_res,
         2113  +							  double y_res);
         2114  +
         2115  +    RL2_PRIVATE rl2RingPtr rl2_ring_to_image (rl2RingPtr ring, int height,
         2116  +					      double minx, double miny,
         2117  +					      double x_res, double y_res);
         2118  +
         2119  +    RL2_PRIVATE void rl2DestroyLinestring (rl2LinestringPtr ptr);
         2120  +
         2121  +    RL2_PRIVATE void rl2DestroyRing (rl2RingPtr ptr);
  2060   2122   
  2061   2123   #ifdef __cplusplus
  2062   2124   }
  2063   2125   #endif
  2064   2126   
  2065   2127   #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, double *x,
   510         -							  double *y);
          509  +    RL2_PRIVATE rl2PrivSvgPolylinePtr svg_alloc_polyline (int points,
          510  +							  double *x, double *y);
   511    511   
   512         -    RL2_PRIVATE rl2PrivSvgPolylinePtr svg_clone_polyline (rl2PrivSvgPolylinePtr
   513         -							  in);
          512  +    RL2_PRIVATE rl2PrivSvgPolylinePtr
          513  +	svg_clone_polyline (rl2PrivSvgPolylinePtr 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 svg_clone_path_move (rl2PrivSvgPathMovePtr
   524         -							   in);
          523  +    RL2_PRIVATE rl2PrivSvgPathMovePtr
          524  +	svg_clone_path_move (rl2PrivSvgPathMovePtr 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 green,
   614         -								   double blue,
          613  +								   double
          614  +								   green,
          615  +								   double
          616  +								   blue,
   615    617   								   double
   616    618   								   opacity);
   617    619   
   618    620       RL2_PRIVATE rl2PrivSvgGradientStopPtr
   619    621   	svg_clone_gradient_stop (rl2PrivSvgGradientStopPtr in);
   620    622   
   621    623       RL2_PRIVATE rl2PrivSvgGradientPtr svg_alloc_gradient (void);
   622    624   
   623         -    RL2_PRIVATE rl2PrivSvgGradientPtr svg_clone_gradient (rl2PrivSvgGradientPtr
   624         -							  in,
   625         -							  rl2PrivSvgGradientPtr
   626         -							  old);
          625  +    RL2_PRIVATE rl2PrivSvgGradientPtr
          626  +	svg_clone_gradient (rl2PrivSvgGradientPtr in,
          627  +			    rl2PrivSvgGradientPtr old);
   627    628   
   628    629       RL2_PRIVATE rl2PrivSvgDocumentPtr svg_alloc_document (void);
   629    630   
   630    631       RL2_PRIVATE void svg_close_group (rl2PrivSvgDocumentPtr svg_doc);
   631    632   
   632    633       RL2_PRIVATE void svg_insert_group (rl2PrivSvgDocumentPtr svg_doc);
   633    634   
   634    635       RL2_PRIVATE void svg_close_clip (rl2PrivSvgDocumentPtr svg_doc);
   635    636   
   636    637       RL2_PRIVATE void svg_insert_clip (rl2PrivSvgDocumentPtr svg_doc);
   637    638   
   638         -    RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr svg_doc,
          639  +    RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr
          640  +						 svg_doc,
   639    641   						 const char *xlink_href,
   640    642   						 double x, double y,
   641    643   						 double width, double height);
   642    644   
   643         -    RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc, int type,
   644         -				       void *data);
          645  +    RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc,
          646  +				       int type, void *data);
   645    647   
   646    648       RL2_PRIVATE void svg_insert_gradient_stop (rl2PrivSvgGradientPtr gradient,
   647    649   					       double offset, double red,
   648    650   					       double green, double blue,
   649    651   					       double opacity);
   650    652   
   651    653       RL2_PRIVATE rl2PrivSvgGradientPtr
   652    654   	svg_insert_linear_gradient (rl2PrivSvgDocumentPtr svg_doc,
   653    655   				    const char *id, const char *xlink_href,
   654         -				    double x1, double y1, double x2, double y2,
   655         -				    int units);
          656  +				    double x1, double y1, double x2,
          657  +				    double y2, int units);
   656    658   
   657    659       RL2_PRIVATE rl2PrivSvgGradientPtr
   658    660   	svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc,
   659    661   				    const char *id, const char *xlink_href,
   660         -				    double cx, double cy, double fx, double fy,
   661         -				    double r, int units);
          662  +				    double cx, double cy, double fx,
          663  +				    double fy, double r, int units);
   662    664   
   663    665       RL2_PRIVATE rl2PrivSvgGradientPtr
   664    666   	svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc,
   665    667   				    const char *id, const char *xlink_href,
   666         -				    double cx, double cy, double fx, double fy,
   667         -				    double r, int units);
          668  +				    double cx, double cy, double fx,
          669  +				    double fy, double r, int units);
   668    670   
   669    671       RL2_PRIVATE void svg_init_style (rl2PrivSvgStylePtr style);
   670    672   
   671    673       RL2_PRIVATE void svg_style_cleanup (rl2PrivSvgStylePtr style);
   672    674   
   673    675   
   674    676   #ifdef __cplusplus
   675    677   }
   676    678   #endif
   677    679   
   678    680   #endif				/* _RL2SVG_PRIVATE_H */

Deleted 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)

Added 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 0:0:0
           28  +librasterlite2_la_LDFLAGS = -version-info 1: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 0:0:0
           53  +mod_rasterlite2_la_LDFLAGS = -module -version-info 1: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.14.1 from Makefile.am.
            1  +# Makefile.in generated by automake 1.15 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2013 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2014 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 = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
           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  +}
    20     30   am__make_running_with_option = \
    21     31     case $${target_option-} in \
    22     32         ?) ;; \
    23     33         *) echo "am__make_running_with_option: internal error: invalid" \
    24     34                 "target option '$${target_option-}' specified" >&2; \
    25     35            exit 1;; \
    26     36     esac; \
................................................................................
    80     90   build_triplet = @build@
    81     91   host_triplet = @host@
    82     92   @MINGW_TRUE@am__append_1 = -lm
    83     93   @MINGW_FALSE@am__append_2 = -lpthread -lm
    84     94   @MINGW_TRUE@am__append_3 = -lm
    85     95   @MINGW_FALSE@am__append_4 = -lpthread -lm
    86     96   subdir = src
    87         -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
    88         -	$(top_srcdir)/depcomp $(noinst_HEADERS)
    89     97   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    90     98   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    91     99   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    92    100   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    93    101   	$(top_srcdir)/configure.ac
    94    102   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    95    103   	$(ACLOCAL_M4)
          104  +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
          105  +	$(am__DIST_COMMON)
    96    106   mkinstalldirs = $(install_sh) -d
    97    107   CONFIG_HEADER = $(top_builddir)/config.h
    98    108   CONFIG_CLEAN_FILES =
    99    109   CONFIG_CLEAN_VPATH_FILES =
   100    110   am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
   101    111   am__vpath_adj = case $$p in \
   102    112       $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
................................................................................
   230    240   am__define_uniq_tagged_files = \
   231    241     list='$(am__tagged_files)'; \
   232    242     unique=`for i in $$list; do \
   233    243       if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   234    244     done | $(am__uniquify_input)`
   235    245   ETAGS = etags
   236    246   CTAGS = ctags
          247  +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
   237    248   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   238    249   ACLOCAL = @ACLOCAL@
   239    250   AMTAR = @AMTAR@
   240    251   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   241    252   AR = @AR@
   242    253   AS = @AS@
   243    254   AUTOCONF = @AUTOCONF@
................................................................................
   391    402   	rl2svgaux.c rl2symbolizer.c rl2symbaux.c rl2rastersym.c \
   392    403   	rl2version.c rl2md5.c md5.c rl2charls.c rl2openjpeg.c \
   393    404   	rl2auxgeom.c rl2auxfont.c
   394    405   
   395    406   librasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ @LIBLZMA_LIBS@ \
   396    407   	@LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \
   397    408   	@LIBFREETYPE2_LIBS@ $(am__append_1) $(am__append_2)
   398         -@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 0:0:0
          409  +@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 1:0:0
   399    410   @MINGW_TRUE@librasterlite2_la_LDFLAGS = -avoid-version -no-undefined
   400    411   mod_rasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \
   401    412   	rl2jpeg.c rl2png.c rl2gif.c rl2webp.c rl2tiff.c rl2wms.c \
   402    413   	rl2ascii.c rl2paint.c rl2dbms.c rl2import.c rl2pyramid.c \
   403    414   	rl2sql.c rl2sqlaux.c rl2auxrender.c rl2svg.c rl2svgxml.c \
   404    415   	rl2svgaux.c rl2symbolizer.c rl2symbaux.c rl2rastersym.c \
   405    416   	rl2version.c rl2md5.c md5.c rl2charls.c rl2openjpeg.c \
................................................................................
   407    418   
   408    419   mod_rasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ \
   409    420   	@LIBLZMA_LIBS@ @LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \
   410    421   	@LIBFREETYPE2_LIBS@ $(am__append_3) $(am__append_4)
   411    422   mod_rasterlite2_la_CPPFLAGS = @CFLAGS@ -I$(top_srcdir)/headers -I. \
   412    423   	-DLOADABLE_EXTENSION
   413    424   mod_rasterlite2_la_LIBTOOLFLAGS = --tag=disable-static
   414         -@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 0:0:0
          425  +@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 1:0:0
   415    426   @MINGW_TRUE@mod_rasterlite2_la_LDFLAGS = -module -avoid-version -no-undefined
   416    427   MOSTLYCLEANFILES = *.gcna *.gcno *.gcda
   417    428   all: all-am
   418    429   
   419    430   .SUFFIXES:
   420    431   .SUFFIXES: .c .lo .o .obj
   421    432   $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
................................................................................
   426    437   	        && { if test -f $@; then exit 0; else break; fi; }; \
   427    438   	      exit 1;; \
   428    439   	  esac; \
   429    440   	done; \
   430    441   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
   431    442   	$(am__cd) $(top_srcdir) && \
   432    443   	  $(AUTOMAKE) --gnu src/Makefile
   433         -.PRECIOUS: Makefile
   434    444   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   435    445   	@case '$?' in \
   436    446   	  *config.status*) \
   437    447   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   438    448   	  *) \
   439    449   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   440    450   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
   996   1006   	install-exec-am install-html install-html-am install-info \
   997   1007   	install-info-am install-libLTLIBRARIES install-man install-pdf \
   998   1008   	install-pdf-am install-ps install-ps-am install-strip \
   999   1009   	installcheck installcheck-am installdirs maintainer-clean \
  1000   1010   	maintainer-clean-generic mostlyclean mostlyclean-compile \
  1001   1011   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
  1002   1012   	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
         1013  +
         1014  +.PRECIOUS: Makefile
  1003   1015   
  1004   1016   
  1005   1017   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  1006   1018   # Otherwise a system limit (for SysV at least) may be exceeded.
  1007   1019   .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, unsigned char sample_type,
   518         -			unsigned char pixel_type, unsigned char num_samples)
          517  +check_coverage_no_data (rl2PrivPixelPtr pxl_no_data,
          518  +			unsigned char sample_type, unsigned char pixel_type,
          519  +			unsigned char num_samples)
   519    520   {
   520    521   /* checking if the NoData pixel is consistent with the Coverage */
   521    522       if (pxl_no_data == NULL)
   522    523   	return 1;
   523    524       if (pxl_no_data->sampleType != sample_type)
   524    525   	return 0;
   525    526       if (pxl_no_data->pixelType != pixel_type)
................................................................................
  1251   1252       return (rl2RasterPtr) rst;
  1252   1253   }
  1253   1254   
  1254   1255   RL2_DECLARE rl2RasterPtr
  1255   1256   rl2_create_raster (unsigned int width, unsigned int height,
  1256   1257   		   unsigned char sample_type, unsigned char pixel_type,
  1257   1258   		   unsigned char num_samples, unsigned char *bufpix,
  1258         -		   int bufpix_size, rl2PalettePtr palette, unsigned char *mask,
  1259         -		   int mask_size, rl2PixelPtr no_data)
         1259  +		   int bufpix_size, rl2PalettePtr palette,
         1260  +		   unsigned char *mask, int mask_size, rl2PixelPtr no_data)
  1260   1261   {
  1261   1262   /* allocating and initializing a Raster object with an optional Transparency Mask */
  1262   1263       return create_raster_common (width, height, sample_type, pixel_type,
  1263   1264   				 num_samples, bufpix, bufpix_size, palette,
  1264   1265   				 mask, mask_size, no_data, 0);
  1265   1266   }
  1266   1267   
................................................................................
  1428   1429       rst->minY = cy - vExt;
  1429   1430       rst->maxX = cx + hExt;
  1430   1431       rst->maxY = cy + vExt;
  1431   1432       return RL2_OK;
  1432   1433   }
  1433   1434   
  1434   1435   RL2_DECLARE int
  1435         -rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid, double horz_res,
  1436         -				    double vert_res, double x, double y)
         1436  +rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid,
         1437  +				    double horz_res, double vert_res,
         1438  +				    double x, double y)
  1437   1439   {
  1438   1440   /* setting the Raster's georeferencing infos - UpperLeft corner */
  1439   1441       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1440   1442       double hExt;
  1441   1443       double vExt;
  1442   1444       if (rst == NULL)
  1443   1445   	return RL2_ERROR;
................................................................................
  1451   1453       rst->maxX = x + hExt;
  1452   1454       rst->maxY = y;
  1453   1455       return RL2_OK;
  1454   1456   }
  1455   1457   
  1456   1458   RL2_DECLARE int
  1457   1459   rl2_raster_georeference_upper_right (rl2RasterPtr ptr, int srid,
  1458         -				     double horz_res, double vert_res, double x,
  1459         -				     double y)
         1460  +				     double horz_res, double vert_res,
         1461  +				     double x, double y)
  1460   1462   {
  1461   1463   /* setting the Raster's georeferencing infos - UpperRight corner */
  1462   1464       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1463   1465       double hExt;
  1464   1466       double vExt;
  1465   1467       if (rst == NULL)
  1466   1468   	return RL2_ERROR;
................................................................................
  1473   1475       rst->minY = y - vExt;
  1474   1476       rst->maxX = x;
  1475   1477       rst->maxY = y;
  1476   1478       return RL2_OK;
  1477   1479   }
  1478   1480   
  1479   1481   RL2_DECLARE int
  1480         -rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid, double horz_res,
  1481         -				    double vert_res, double x, double y)
         1482  +rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid,
         1483  +				    double horz_res, double vert_res,
         1484  +				    double x, double y)
  1482   1485   {
  1483   1486   /* setting the Raster's georeferencing infos - LowerLeft corner */
  1484   1487       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1485   1488       double hExt;
  1486   1489       double vExt;
  1487   1490       if (rst == NULL)
  1488   1491   	return RL2_ERROR;
................................................................................
  1496   1499       rst->maxX = x + hExt;
  1497   1500       rst->maxY = y + vExt;
  1498   1501       return RL2_OK;
  1499   1502   }
  1500   1503   
  1501   1504   RL2_DECLARE int
  1502   1505   rl2_raster_georeference_lower_right (rl2RasterPtr ptr, int srid,
  1503         -				     double horz_res, double vert_res, double x,
  1504         -				     double y)
         1506  +				     double horz_res, double vert_res,
         1507  +				     double x, double y)
  1505   1508   {
  1506   1509   /* setting the Raster's georeferencing infos - LowerRight corner */
  1507   1510       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr;
  1508   1511       double hExt;
  1509   1512       double vExt;
  1510   1513       if (rst == NULL)
  1511   1514   	return RL2_ERROR;
................................................................................
  1803   1806       entry->red = r;
  1804   1807       entry->green = g;
  1805   1808       entry->blue = b;
  1806   1809       return RL2_OK;
  1807   1810   }
  1808   1811   
  1809   1812   RL2_DECLARE int
  1810         -rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index, unsigned char r,
  1811         -		       unsigned char g, unsigned char b)
         1813  +rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index,
         1814  +		       unsigned char r, unsigned char g, unsigned char b)
  1812   1815   {
  1813   1816   /* finding the index corresponding to the given color (if any) */
  1814   1817       int i;
  1815   1818       rl2PrivPaletteEntryPtr entry;
  1816   1819       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) ptr;
  1817   1820       if (plt == NULL)
  1818   1821   	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, miny,
   324         -			    maxx, maxy, xres, yres, no_data);
          323  +	alloc_ascii_origin (path, srid, sample_type, width, height, minx,
          324  +			    miny, 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 (ascii, &hResolution, &vResolution)
   622         -	!= RL2_OK)
          621  +    if (rl2_get_ascii_grid_origin_resolution
          622  +	(ascii, &hResolution, &vResolution) != 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, pixels,
  1076         -			   pixels_sz, NULL, mask, mask_size, NULL);
         1075  +			   coverage->sampleType, RL2_PIXEL_DATAGRID, 1,
         1076  +			   pixels, 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;
   731    730       if (facename == NULL)
   732    731   	return RL2_ERROR;
   733    732   
   734    733       *font = NULL;
   735    734       *font_sz = 0;
   736    735   /* preparing the SQL query statement */
   737    736       sql = "SELECT font FROM SE_fonts WHERE Lower(font_facename) = Lower(?)";

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

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, unsigned char bg_red,
   296         -	      unsigned char bg_green, unsigned char bg_blue)
          295  +	      unsigned char *inbuf, rl2PalettePtr palette,
          296  +	      unsigned char bg_red, unsigned char bg_green,
          297  +	      unsigned char bg_blue)
   297    298   {
   298    299   /* copying from Palette to RGBA */
   299    300       unsigned int x;
   300    301       unsigned int y;
   301    302       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette;
   302    303       unsigned char *p_in = inbuf;
   303    304       unsigned char *p_out = rgba;
................................................................................
   450    451   	goto error;
   451    452   
   452    453       if (aux->base_width == aux->width && aux->base_height == aux->height)
   453    454         {
   454    455   	  if (aux->out_pixel == RL2_PIXEL_MONOCHROME)
   455    456   	    {
   456    457   		/* Monochrome */
   457         -		copy_monochrome (aggreg_rgba, aux->base_width, aux->base_height,
   458         -				 aux->outbuf);
          458  +		copy_monochrome (aggreg_rgba, aux->base_width,
          459  +				 aux->base_height, aux->outbuf);
   459    460   		aux->outbuf = NULL;
   460    461   	    }
   461    462   	  else if (aux->out_pixel == RL2_PIXEL_PALETTE)
   462    463   	    {
   463    464   		/* Palette */
   464    465   		copy_palette (aggreg_rgba, aux->base_width, aux->base_height,
   465    466   			      aux->outbuf, aux->palette, aux->bg_red,
   466    467   			      aux->bg_green, aux->bg_blue);
   467    468   		aux->outbuf = NULL;
   468    469   	    }
   469    470   	  else if (aux->out_pixel == RL2_PIXEL_GRAYSCALE)
   470    471   	    {
   471    472   		/* Grayscale */
   472         -		copy_grayscale (aggreg_rgba, aux->base_width, aux->base_height,
   473         -				aux->outbuf, aux->bg_red);
          473  +		copy_grayscale (aggreg_rgba, aux->base_width,
          474  +				aux->base_height, aux->outbuf, aux->bg_red);
   474    475   		aux->outbuf = NULL;
   475    476   	    }
   476    477   	  else
   477    478   	    {
   478    479   		/* RGB */
   479    480   		copy_rgb (aggreg_rgba, aux->base_width, aux->base_height,
   480    481   			  aux->outbuf, aux->bg_red, aux->bg_green,
................................................................................
   607    608   			}
   608    609   		  }
   609    610   		else
   610    611   		  {
   611    612   		      if (!get_payload_from_monochrome_opaque
   612    613   			  (aux->base_width, aux->base_height, aux->sqlite,
   613    614   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   614         -			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
   615         -			   &image, &image_size))
          615  +			   aux->srid, aux->outbuf, aux->format_id,
          616  +			   aux->quality, &image, &image_size))
   616    617   			{
   617    618   			    aux->outbuf = NULL;
   618    619   			    goto error;
   619    620   			}
   620    621   		  }
   621    622   		aux->outbuf = NULL;
   622    623   	    }
................................................................................
   636    637   			}
   637    638   		  }
   638    639   		else
   639    640   		  {
   640    641   		      if (!get_payload_from_palette_opaque
   641    642   			  (aux->base_width, aux->base_height, aux->sqlite,
   642    643   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   643         -			   aux->srid, aux->outbuf, aux->palette, aux->format_id,
   644         -			   aux->quality, &image, &image_size))
          644  +			   aux->srid, aux->outbuf, aux->palette,
          645  +			   aux->format_id, aux->quality, &image, &image_size))
   645    646   			{
   646    647   			    aux->outbuf = NULL;
   647    648   			    goto error;
   648    649   			}
   649    650   		  }
   650    651   		aux->outbuf = NULL;
   651    652   	    }
................................................................................
   664    665   			}
   665    666   		  }
   666    667   		else
   667    668   		  {
   668    669   		      if (!get_payload_from_grayscale_opaque
   669    670   			  (aux->base_width, aux->base_height, aux->sqlite,
   670    671   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   671         -			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
   672         -			   &image, &image_size))
          672  +			   aux->srid, aux->outbuf, aux->format_id,
          673  +			   aux->quality, &image, &image_size))
   673    674   			{
   674    675   			    aux->outbuf = NULL;
   675    676   			    goto error;
   676    677   			}
   677    678   		  }
   678    679   		aux->outbuf = NULL;
   679    680   	    }
................................................................................
   693    694   			}
   694    695   		  }
   695    696   		else
   696    697   		  {
   697    698   		      if (!get_payload_from_rgb_opaque
   698    699   			  (aux->base_width, aux->base_height, aux->sqlite,
   699    700   			   aux->minx, aux->miny, aux->maxx, aux->maxy,
   700         -			   aux->srid, aux->outbuf, aux->format_id, aux->quality,
   701         -			   &image, &image_size))
          701  +			   aux->srid, aux->outbuf, aux->format_id,
          702  +			   aux->quality, &image, &image_size))
   702    703   			{
   703    704   			    aux->outbuf = NULL;
   704    705   			    goto error;
   705    706   			}
   706    707   		  }
   707    708   		aux->outbuf = NULL;
   708    709   	    }
................................................................................
   769    770   	    }
   770    771   	  else if (aux->out_pixel == RL2_PIXEL_GRAYSCALE)
   771    772   	    {
   772    773   		/* Grayscale */
   773    774   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   774    775   		  {
   775    776   		      if (!get_rgba_from_grayscale_transparent
   776         -			  (aux->base_width, aux->base_height, aux->outbuf, rgba,
   777         -			   aux->bg_red))
          777  +			  (aux->base_width, aux->base_height, aux->outbuf,
          778  +			   rgba, aux->bg_red))
   778    779   			{
   779    780   			    aux->outbuf = NULL;
   780    781   			    goto error;
   781    782   			}
   782    783   		  }
   783    784   		else
   784    785   		  {
................................................................................
   794    795   	    }
   795    796   	  else
   796    797   	    {
   797    798   		/* RGB */
   798    799   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   799    800   		  {
   800    801   		      if (!get_rgba_from_rgb_transparent
   801         -			  (aux->base_width, aux->base_height, aux->outbuf, rgba,
   802         -			   aux->bg_red, aux->bg_green, aux->bg_blue))
          802  +			  (aux->base_width, aux->base_height, aux->outbuf,
          803  +			   rgba, aux->bg_red, aux->bg_green, aux->bg_blue))
   803    804   			{
   804    805   			    aux->outbuf = NULL;
   805    806   			    goto error;
   806    807   			}
   807    808   		  }
   808    809   		else
   809    810   		  {
................................................................................
   838    839   	    {
   839    840   		/* Grayscale or Monochrome upsampled */
   840    841   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   841    842   		  {
   842    843   		      if (alpha == NULL)
   843    844   			  goto error;
   844    845   		      if (!get_payload_from_gray_rgba_transparent
   845         -			  (aux->width, aux->height, rgb, alpha, aux->format_id,
   846         -			   aux->quality, &image, &image_size, aux->opacity))
          846  +			  (aux->width, aux->height, rgb, alpha,
          847  +			   aux->format_id, aux->quality, &image, &image_size,
          848  +			   aux->opacity))
   847    849   			  goto error;
   848    850   		  }
   849    851   		else
   850    852   		  {
   851    853   		      if (alpha != NULL)
   852    854   			  free (alpha);
   853    855   		      alpha = NULL;
................................................................................
   862    864   	    {
   863    865   		/* RGB */
   864    866   		if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG)
   865    867   		  {
   866    868   		      if (alpha == NULL)
   867    869   			  goto error;
   868    870   		      if (!get_payload_from_rgb_rgba_transparent
   869         -			  (aux->width, aux->height, rgb, alpha, aux->format_id,
   870         -			   aux->quality, &image, &image_size, aux->opacity, 0))
          871  +			  (aux->width, aux->height, rgb, alpha,
          872  +			   aux->format_id, aux->quality, &image, &image_size,
          873  +			   aux->opacity, 0))
   871    874   			  goto error;
   872    875   		  }
   873    876   		else
   874    877   		  {
   875    878   		      if (alpha != NULL)
   876    879   			  free (alpha);
   877    880   		      alpha = NULL;
................................................................................
   978    981       coverage = rl2_get_coverage_name (aux->coverage);
   979    982       if (coverage == NULL)
   980    983   	return 0;
   981    984       scale_factor = rl2_get_shaded_relief_scale_factor (aux->sqlite, coverage);
   982    985   
   983    986       if (rl2_build_shaded_relief_mask
   984    987   	(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,
          988  +	 scale_factor, aux->base_width, aux->base_height, aux->minx,
          989  +	 aux->miny, aux->maxx, aux->maxy, aux->xx_res, aux->yy_res, &shr_mask,
   987    990   	 &shr_size) != RL2_OK)
   988    991   	return 0;
   989    992   
   990    993   /* allocating the RGBA buffer */
   991    994       rgba = malloc (aux->base_width * aux->base_height * 4);
   992    995       if (rgba == NULL)
   993    996   	return 0;
................................................................................
  1534   1537   RL2_DECLARE int
  1535   1538   rl2_get_raw_raster_data_mixed_resolutions (sqlite3 * handle, int max_threads,
  1536   1539   					   rl2CoveragePtr cvg,
  1537   1540   					   unsigned int width,
  1538   1541   					   unsigned int height, double minx,
  1539   1542   					   double miny, double maxx,
  1540   1543   					   double maxy, double x_res,
  1541         -					   double y_res, unsigned char **buffer,
         1544  +					   double y_res,
         1545  +					   unsigned char **buffer,
  1542   1546   					   int *buf_size,
  1543   1547   					   rl2PalettePtr * palette,
  1544   1548   					   unsigned char *out_pixel,
  1545   1549   					   unsigned char bg_red,
  1546   1550   					   unsigned char bg_green,
  1547   1551   					   unsigned char bg_blue,
  1548   1552   					   rl2RasterSymbolizerPtr style,
................................................................................
  1745   1749       if (no_data != NULL)
  1746   1750   	rl2_destroy_pixel (no_data);
  1747   1751       if (outbuf != NULL)
  1748   1752   	free (outbuf);
  1749   1753       return RL2_ERROR;
  1750   1754   }
  1751   1755   
  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)
  1858         -{
  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;
         1756  +static int
         1757  +point_bbox_matches (rl2PointPtr point, double minx, double miny, double maxx,
         1758  +		    double maxy)
         1759  +{
         1760  +/* checks if the Point is visible */
         1761  +    if (minx > point->x)
         1762  +	return 0;
         1763  +    if (maxx < point->x)
         1764  +	return 0;
         1765  +    if (miny > point->y)
         1766  +	return 0;
         1767  +    if (maxy < point->y)
         1768  +	return 0;
         1769  +    return 1;
  1937   1770   }
  1938   1771   
  1939   1772   static void
  1940   1773   draw_points (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  1941   1774   	     rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  1942         -	     double miny, double x_res, double y_res, rl2GeometryPtr geom)
         1775  +	     double miny, double maxx, double maxy, double x_res,
         1776  +	     double y_res, rl2GeometryPtr geom)
  1943   1777   {
  1944   1778   /* drawing Point-type features */
  1945   1779       rl2PrivVectorSymbolizerItemPtr item;
  1946   1780       rl2PointPtr point;
  1947   1781   
  1948   1782       item = sym->first;
  1949   1783       while (item != NULL)
................................................................................
  1968   1802   		      unsigned char well_known_type;
  1969   1803   		      int fill = 0;
  1970   1804   		      int stroke = 0;
  1971   1805   		      int pen_cap;
  1972   1806   		      int pen_join;
  1973   1807   		      double opacity;
  1974   1808   		      unsigned char norm_opacity;
  1975         -		      rl2GraphicsBitmapPtr pattern = NULL;
         1809  +		      rl2GraphicsPatternPtr pattern = NULL;
  1976   1810   		      rl2GraphicsPatternPtr pattern_fill = NULL;
  1977   1811   		      rl2GraphicsPatternPtr pattern_stroke = NULL;
  1978   1812   
  1979   1813   		      if (graphic->type == RL2_MARK_GRAPHIC)
  1980   1814   			{
  1981   1815   			    rl2PrivMarkPtr mark =
  1982   1816   				(rl2PrivMarkPtr) (graphic->item);
................................................................................
  1985   1819   				  well_known_type = mark->well_known_type;
  1986   1820   				  is_mark = 1;
  1987   1821   				  if (mark->fill != NULL)
  1988   1822   				    {
  1989   1823   					if (mark->fill->graphic != NULL)
  1990   1824   					  {
  1991   1825   					      /* external Graphic fill */
  1992         -					      pattern_fill =
  1993         -						  load_external_graphic_from_dbms
  1994         -						  (handle, mark->fill->graphic);
         1826  +					      const char *xlink_href = NULL;
         1827  +					      int recolor = 0;
         1828  +					      unsigned char red;
         1829  +					      unsigned char green;
         1830  +					      unsigned char blue;
         1831  +					      pattern_fill = NULL;
         1832  +					      if (mark->fill->graphic->first !=
         1833  +						  NULL)
         1834  +						{
         1835  +						    if (mark->fill->
         1836  +							graphic->first->type ==
         1837  +							RL2_EXTERNAL_GRAPHIC)
         1838  +						      {
         1839  +							  rl2PrivExternalGraphicPtr
         1840  +							      ext =
         1841  +							      (rl2PrivExternalGraphicPtr)
         1842  +							      (mark->
         1843  +							       fill->graphic->
         1844  +							       first->item);
         1845  +							  xlink_href =
         1846  +							      ext->xlink_href;
         1847  +							  if (ext->first !=
         1848  +							      NULL)
         1849  +							    {
         1850  +								recolor = 1;
         1851  +								red =
         1852  +								    ext->
         1853  +								    first->red;
         1854  +								green =
         1855  +								    ext->
         1856  +								    first->green;
         1857  +								blue =
         1858  +								    ext->
         1859  +								    first->blue;
         1860  +							    }
         1861  +						      }
         1862  +						}
         1863  +					      if (xlink_href != NULL)
         1864  +						  pattern_fill =
         1865  +						      rl2_create_pattern_from_external_graphic
         1866  +						      (handle, xlink_href, 1);
  1995   1867   					      if (pattern_fill != NULL)
  1996   1868   						{
         1869  +						    if (recolor)
         1870  +						      {
         1871  +							  /* attempting to recolor the External Graphic resource */
         1872  +							  rl2_graph_pattern_recolor
         1873  +							      (pattern_fill,
         1874  +							       red, green,
         1875  +							       blue);
         1876  +						      }
         1877  +						    if (mark->fill->opacity <=
         1878  +							0.0)
         1879  +							norm_opacity = 0;
         1880  +						    else if (mark->
         1881  +							     fill->opacity >=
         1882  +							     1.0)
         1883  +							norm_opacity = 255;
         1884  +						    else
         1885  +						      {
         1886  +							  opacity =
         1887  +							      255.0 *
         1888  +							      mark->
         1889  +							      fill->opacity;
         1890  +							  if (opacity <= 0.0)
         1891  +							      norm_opacity = 0;
         1892  +							  else if (opacity >=
         1893  +								   255.0)
         1894  +							      norm_opacity =
         1895  +								  255;
         1896  +							  else
         1897  +							      norm_opacity =
         1898  +								  opacity;
         1899  +						      }
         1900  +						    if (norm_opacity < 1.0)
         1901  +							rl2_graph_pattern_transparency
         1902  +							    (pattern_fill,
         1903  +							     norm_opacity);
  1997   1904   						    rl2_graph_set_pattern_brush
  1998   1905   							(ctx, pattern_fill);
  1999         -						    fill = 1;
         1906  +						}
         1907  +					      else
         1908  +						{
         1909  +						    /* invalid Pattern: defaulting to a Gray brush */
         1910  +						    rl2_graph_set_brush (ctx,
         1911  +									 128,
         1912  +									 128,
         1913  +									 128,
         1914  +									 255);
  2000   1915   						}
         1916  +					      fill = 1;
  2001   1917   					  }
  2002   1918   					else
  2003   1919   					  {
  2004   1920   					      /* solid RGB fill */
  2005   1921   					      if (gr->opacity <= 0.0)
  2006   1922   						  norm_opacity = 0;
  2007   1923   					      else if (gr->opacity >= 1.0)
................................................................................
  2028   1944   					      fill = 1;
  2029   1945   					  }
  2030   1946   				    }
  2031   1947   				  if (mark->stroke != NULL)
  2032   1948   				    {
  2033   1949   					if (mark->stroke->graphic != NULL)
  2034   1950   					  {
  2035         -					      /* external Graphic stroke */
  2036         -					      pattern_stroke =
  2037         -						  load_external_graphic_from_dbms
  2038         -						  (handle,
  2039         -						   mark->stroke->graphic);
  2040         -					      if (pattern_stroke != NULL)
         1951  +					      const char *xlink_href = NULL;
         1952  +					      int recolor = 0;
         1953  +					      unsigned char red;
         1954  +					      unsigned char green;
         1955  +					      unsigned char blue;
         1956  +					      pattern_stroke = NULL;
         1957  +					      if (mark->stroke->
         1958  +						  graphic->first != NULL)
  2041   1959   						{
  2042         -						    switch (mark->
  2043         -							    stroke->linecap)
         1960  +						    if (mark->stroke->
         1961  +							graphic->first->type ==
         1962  +							RL2_EXTERNAL_GRAPHIC)
  2044   1963   						      {
  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)
         1964  +							  rl2PrivExternalGraphicPtr
         1965  +							      ext =
         1966  +							      (rl2PrivExternalGraphicPtr)
         1967  +							      (mark->
         1968  +							       stroke->graphic->
         1969  +							       first->item);
         1970  +							  xlink_href =
         1971  +							      ext->xlink_href;
         1972  +							  if (ext->first !=
         1973  +							      NULL)
         1974  +							    {
         1975  +								recolor = 1;
         1976  +								red =
         1977  +								    ext->
         1978  +								    first->red;
         1979  +								green =
         1980  +								    ext->
         1981  +								    first->green;
         1982  +								blue =
         1983  +								    ext->
         1984  +								    first->blue;
         1985  +							    }
         1986  +						      }
         1987  +						}
         1988  +					      if (xlink_href != NULL)
         1989  +						  pattern_stroke =
         1990  +						      rl2_create_pattern_from_external_graphic
         1991  +						      (handle, xlink_href, 1);
         1992  +					      if (pattern != NULL)
         1993  +						{
         1994  +						    if (recolor)
  2060   1995   						      {
  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);
         1996  +							  /* attempting to recolor the External Graphic resource */
         1997  +							  rl2_graph_pattern_recolor
         1998  +							      (pattern_stroke,
         1999  +							       red, green,
         2000  +							       blue);
         2001  +						      }
         2002  +						    if (mark->stroke->opacity <=
         2003  +							0.0)
         2004  +							norm_opacity = 0;
         2005  +						    else if (mark->
         2006  +							     stroke->opacity >=
         2007  +							     1.0)
         2008  +							norm_opacity = 255;
  2091   2009   						    else
  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;
         2010  +						      {
         2011  +							  opacity =
         2012  +							      255.0 *
         2013  +							      mark->
         2014  +							      stroke->opacity;
         2015  +							  if (opacity <= 0.0)
         2016  +							      norm_opacity = 0;
         2017  +							  else if (opacity >=
         2018  +								   255.0)
         2019  +							      norm_opacity =
         2020  +								  255;
         2021  +							  else
         2022  +							      norm_opacity =
         2023  +								  opacity;
         2024  +						      }
         2025  +						    if (norm_opacity < 1.0)
         2026  +							rl2_graph_pattern_transparency
         2027  +							    (pattern_stroke,
         2028  +							     norm_opacity);
         2029  +						    if (pattern_stroke != NULL)
         2030  +						      {
         2031  +							  switch
         2032  +							      (mark->
         2033  +							       stroke->linecap)
         2034  +							    {
         2035  +							    case RL2_STROKE_LINECAP_ROUND:
         2036  +								pen_cap =
         2037  +								    RL2_PEN_CAP_ROUND;
         2038  +								break;
         2039  +							    case RL2_STROKE_LINECAP_SQUARE:
         2040  +								pen_cap =
         2041  +								    RL2_PEN_CAP_SQUARE;
         2042  +								break;
         2043  +							    default:
         2044  +								pen_cap =
         2045  +								    RL2_PEN_CAP_BUTT;
         2046  +								break;
         2047  +							    };
         2048  +							  switch
         2049  +							      (mark->
         2050  +							       stroke->linejoin)
         2051  +							    {
         2052  +							    case RL2_STROKE_LINEJOIN_BEVEL:
         2053  +								pen_join =
         2054  +								    RL2_PEN_JOIN_BEVEL;
         2055  +								break;
         2056  +							    case RL2_STROKE_LINEJOIN_ROUND:
         2057  +								pen_join =
         2058  +								    RL2_PEN_JOIN_ROUND;
         2059  +								break;
         2060  +							    default:
         2061  +								pen_join =
         2062  +								    RL2_PEN_JOIN_MITER;
         2063  +								break;
         2064  +							    };
         2065  +							  if (mark->
         2066  +							      stroke->dash_count
         2067  +							      > 0
         2068  +							      && mark->
         2069  +							      stroke->dash_list
         2070  +							      != NULL)
         2071  +							      rl2_graph_set_pattern_dashed_pen
         2072  +								  (ctx,
         2073  +								   pattern_stroke,
         2074  +								   mark->
         2075  +								   stroke->width,
         2076  +								   pen_cap,
         2077  +								   pen_join,
         2078  +								   mark->
         2079  +								   stroke->dash_count,
         2080  +								   mark->
         2081  +								   stroke->dash_list,
         2082  +								   mark->
         2083  +								   stroke->dash_offset);
         2084  +							  else
         2085  +							      rl2_graph_set_pattern_solid_pen
         2086  +								  (ctx,
         2087  +								   pattern_stroke,
         2088  +								   mark->
         2089  +								   stroke->width,
         2090  +								   pen_cap,
         2091  +								   pen_join);
         2092  +							  stroke = 1;
         2093  +						      }
  2099   2094   						}
  2100   2095   					  }
  2101   2096   					else
  2102   2097   					  {
  2103   2098   					      /* solid RGB stroke */
  2104   2099   					      if (gr->opacity <= 0.0)
  2105   2100   						  norm_opacity = 0;
................................................................................
  2151   2146   									    mark->stroke->red,
  2152   2147   									    mark->stroke->green,
  2153   2148   									    mark->stroke->blue,
  2154   2149   									    norm_opacity,
  2155   2150   									    mark->stroke->width,
  2156   2151   									    pen_cap,
  2157   2152   									    pen_join,
  2158         -									    mark->stroke->dash_count,
  2159         -									    mark->stroke->dash_list,
  2160         -									    mark->stroke->dash_offset);
         2153  +									    mark->
         2154  +									    stroke->dash_count,
         2155  +									    mark->
         2156  +									    stroke->dash_list,
         2157  +									    mark->
         2158  +									    stroke->dash_offset);
  2161   2159   					      else
  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);
         2160  +						  rl2_graph_set_solid_pen
         2161  +						      (ctx, mark->stroke->red,
         2162  +						       mark->stroke->green,
         2163  +						       mark->stroke->blue,
         2164  +						       norm_opacity,
         2165  +						       mark->stroke->width,
         2166  +						       pen_cap, pen_join);
  2170   2167   					      stroke = 1;
  2171   2168   					  }
  2172   2169   				    }
  2173   2170   			      }
  2174   2171   			}
  2175   2172   		      if (graphic->type == RL2_EXTERNAL_GRAPHIC)
  2176   2173   			{
  2177   2174   			    rl2PrivExternalGraphicPtr ext =
  2178   2175   				(rl2PrivExternalGraphicPtr) (graphic->item);
         2176  +			    const char *xlink_href = NULL;
         2177  +			    int recolor = 0;
         2178  +			    unsigned char red;
         2179  +			    unsigned char green;
         2180  +			    unsigned char blue;
         2181  +			    pattern = NULL;
  2179   2182   			    if (ext != NULL)
  2180   2183   			      {
  2181   2184   				  is_external = 1;
  2182         -				  pattern =
  2183         -				      load_external_bitmap_from_dbms (handle,
  2184         -								      ext->xlink_href);
         2185  +				  if (ext->xlink_href != NULL)
         2186  +				      xlink_href = ext->xlink_href;
         2187  +				  if (ext->first != NULL)
         2188  +				    {
         2189  +					recolor = 1;
         2190  +					red = ext->first->red;
         2191  +					green = ext->first->green;
         2192  +					blue = ext->first->blue;
         2193  +				    }
         2194  +				  if (xlink_href != NULL)
         2195  +				    {
         2196  +					/* first attempt: Bitmap */
         2197  +					pattern =
         2198  +					    rl2_create_pattern_from_external_graphic
         2199  +					    (handle, xlink_href, 1);
         2200  +					if (pattern == NULL)
         2201  +					  {
         2202  +					      /* second attempt: SVG */
         2203  +					      pattern =
         2204  +						  rl2_create_pattern_from_external_svg
         2205  +						  (handle, xlink_href,
         2206  +						   point_sym->graphic->size);
         2207  +					  }
         2208  +				    }
         2209  +			      }
         2210  +			    if (pattern != NULL)
         2211  +			      {
         2212  +				  if (recolor)
         2213  +				    {
         2214  +					/* attempting to recolor the External Graphic resource */
         2215  +					rl2_graph_pattern_recolor (pattern,
         2216  +								   red, green,
         2217  +								   blue);
         2218  +				    }
         2219  +				  if (point_sym->graphic->opacity <= 0.0)
         2220  +				      norm_opacity = 0;
         2221  +				  else if (point_sym->graphic->opacity >= 1.0)
         2222  +				      norm_opacity = 255;
         2223  +				  else
         2224  +				    {
         2225  +					opacity =
         2226  +					    255.0 * point_sym->graphic->opacity;
         2227  +					if (opacity <= 0.0)
         2228  +					    norm_opacity = 0;
         2229  +					else if (opacity >= 255.0)
         2230  +					    norm_opacity = 255;
         2231  +					else
         2232  +					    norm_opacity = opacity;
         2233  +				    }
         2234  +				  if (norm_opacity < 1.0)
         2235  +				      rl2_graph_pattern_transparency
         2236  +					  (pattern, norm_opacity);
         2237  +				  rl2_graph_set_pattern_brush (ctx, pattern);
         2238  +			      }
         2239  +			    else
         2240  +			      {
         2241  +				  /* invalid Pattern: defaulting to a Gray brush */
         2242  +				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
  2185   2243   			      }
  2186   2244   			}
  2187   2245   
  2188   2246   		      /* actual Point rendering */
  2189   2247   		      point = geom->first_point;
  2190   2248   		      while (point)
  2191   2249   			{
  2192   2250   			    /* drawing a POINT */
  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)
  2217         -				    {
  2218         -				    case RL2_GRAPHIC_MARK_CIRCLE:
  2219         -					rads = 0.0;
  2220         -					for (i = 0; i < 32; i++)
         2251  +			    if (point_bbox_matches
         2252  +				(point, minx, miny, maxx, maxy))
         2253  +			      {
         2254  +				  double x = (point->x - minx) / x_res;
         2255  +				  double y =
         2256  +				      (double) height -
         2257  +				      ((point->y - miny) / y_res);
         2258  +				  double size2 = gr->size / 2.0;
         2259  +				  double size4 = gr->size / 4.0;
         2260  +				  double size6 = gr->size / 6.0;
         2261  +				  double size13 = gr->size / 3.0;
         2262  +				  double size23 = (gr->size / 3.0) * 2.0;
         2263  +				  int i;
         2264  +				  double rads;
         2265  +				  if (size2 <= 0.0)
         2266  +				      size2 = 1.0;
         2267  +				  if (size4 <= 0.0)
         2268  +				      size4 = 1.0;
         2269  +				  if (size6 <= 0.0)
         2270  +				      size6 = 1.0;
         2271  +				  if (size13 <= 0.0)
         2272  +				      size13 = 1.0;
         2273  +				  if (size23 <= 0.0)
         2274  +				      size23 = 1.0;
         2275  +				  if (is_mark)
         2276  +				    {
         2277  +					/* drawing a well-known Mark */
         2278  +					switch (well_known_type)
  2221   2279   					  {
  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++)
         2280  +					  case RL2_GRAPHIC_MARK_CIRCLE:
         2281  +					      rads = 0.0;
         2282  +					      for (i = 0; i < 32; i++)
         2283  +						{
         2284  +						    double tic =
         2285  +							6.28318530718 / 32.0;
         2286  +						    double cx =
         2287  +							x +
         2288  +							(size2 * sin (rads));
         2289  +						    double cy =
         2290  +							y +
         2291  +							(size2 * cos (rads));
         2292  +						    if (i == 0)
         2293  +							rl2_graph_move_to_point
         2294  +							    (ctx, cx, cy);
         2295  +						    else
         2296  +							rl2_graph_add_line_to_path
         2297  +							    (ctx, cx, cy);
         2298  +						    rads += tic;
         2299  +						}
         2300  +					      rl2_graph_close_subpath (ctx);
         2301  +					      break;
         2302  +					  case RL2_GRAPHIC_MARK_TRIANGLE:
         2303  +					      rl2_graph_move_to_point (ctx, x,
         2304  +								       y -
         2305  +								       size23);
         2306  +					      rl2_graph_add_line_to_path (ctx,
         2307  +									  x -
         2308  +									  size2,
         2309  +									  y +
         2310  +									  size13);
         2311  +					      rl2_graph_add_line_to_path (ctx,
         2312  +									  x +
         2313  +									  size2,
         2314  +									  y +
         2315  +									  size13);
         2316  +					      rl2_graph_close_subpath (ctx);
         2317  +					      break;
         2318  +					  case RL2_GRAPHIC_MARK_STAR:
         2319  +					      rads = 3.14159265359;
         2320  +					      for (i = 0; i < 10; i++)
         2321  +						{
         2322  +						    double tic =
         2323  +							(i % 2) ? size6 : size2;
         2324  +						    double cx =
         2325  +							x + (tic * sin (rads));
         2326  +						    double cy =
         2327  +							y + (tic * cos (rads));
         2328  +						    if (i == 0)
         2329  +							rl2_graph_move_to_point
         2330  +							    (ctx, cx, cy);
         2331  +						    else
         2332  +							rl2_graph_add_line_to_path
         2333  +							    (ctx, cx, cy);
         2334  +						    rads += 0.628318530718;
         2335  +						}
         2336  +					      rl2_graph_close_subpath (ctx);
         2337  +					      break;
         2338  +					  case RL2_GRAPHIC_MARK_CROSS:
         2339  +					      rl2_graph_move_to_point (ctx,
         2340  +								       x -
         2341  +								       size6,
         2342  +								       y -
         2343  +								       size2);
         2344  +					      rl2_graph_add_line_to_path (ctx,
         2345  +									  x +
         2346  +									  size6,
         2347  +									  y -
         2348  +									  size2);
         2349  +					      rl2_graph_add_line_to_path (ctx,
         2350  +									  x +
         2351  +									  size6,
         2352  +									  y -
         2353  +									  size6);
         2354  +					      rl2_graph_add_line_to_path (ctx,
         2355  +									  x +
         2356  +									  size2,
         2357  +									  y -
         2358  +									  size6);
         2359  +					      rl2_graph_add_line_to_path (ctx,
         2360  +									  x +
         2361  +									  size2,
         2362  +									  y +
         2363  +									  size6);
         2364  +					      rl2_graph_add_line_to_path (ctx,
         2365  +									  x +
         2366  +									  size6,
         2367  +									  y +
         2368  +									  size6);
         2369  +					      rl2_graph_add_line_to_path (ctx,
         2370  +									  x +
         2371  +									  size6,
         2372  +									  y +
         2373  +									  size2);
         2374  +					      rl2_graph_add_line_to_path (ctx,
         2375  +									  x -
         2376  +									  size6,
         2377  +									  y +
         2378  +									  size2);
         2379  +					      rl2_graph_add_line_to_path (ctx,
         2380  +									  x -
         2381  +									  size6,
         2382  +									  y +
         2383  +									  size6);
         2384  +					      rl2_graph_add_line_to_path (ctx,
         2385  +									  x -
         2386  +									  size2,
         2387  +									  y +
         2388  +									  size6);
         2389  +					      rl2_graph_add_line_to_path (ctx,
         2390  +									  x -
         2391  +									  size2,
         2392  +									  y -
         2393  +									  size6);
         2394  +					      rl2_graph_add_line_to_path (ctx,
         2395  +									  x -
         2396  +									  size6,
         2397  +									  y -
         2398  +									  size6);
         2399  +					      rl2_graph_close_subpath (ctx);
         2400  +					      break;
         2401  +					  case RL2_GRAPHIC_MARK_X:
         2402  +					      rl2_graph_move_to_point (ctx,
         2403  +								       x -
         2404  +								       size2,
         2405  +								       y -
         2406  +								       size2);
         2407  +					      rl2_graph_add_line_to_path (ctx,
         2408  +									  x -
         2409  +									  size4,
         2410  +									  y -
         2411  +									  size2);
         2412  +					      rl2_graph_add_line_to_path (ctx,
         2413  +									  x,
         2414  +									  y -
         2415  +									  size6);
         2416  +					      rl2_graph_add_line_to_path (ctx,
         2417  +									  x +
         2418  +									  size6,
         2419  +									  y -
         2420  +									  size2);
         2421  +					      rl2_graph_add_line_to_path (ctx,
         2422  +									  x +
         2423  +									  size2,
         2424  +									  y -
         2425  +									  size2);
         2426  +					      rl2_graph_add_line_to_path (ctx,
         2427  +									  x +
         2428  +									  size4,
         2429  +									  y);
         2430  +					      rl2_graph_add_line_to_path (ctx,
         2431  +									  x +
         2432  +									  size2,
         2433  +									  y +
         2434  +									  size2);
         2435  +					      rl2_graph_add_line_to_path (ctx,
         2436  +									  x +
         2437  +									  size4,
         2438  +									  y +
         2439  +									  size2);
         2440  +					      rl2_graph_add_line_to_path (ctx,
         2441  +									  x,
         2442  +									  y +
         2443  +									  size6);
         2444  +					      rl2_graph_add_line_to_path (ctx,
         2445  +									  x -
         2446  +									  size6,
         2447  +									  y +
         2448  +									  size2);
         2449  +					      rl2_graph_add_line_to_path (ctx,
         2450  +									  x -
         2451  +									  size2,
         2452  +									  y +
         2453  +									  size2);
         2454  +					      rl2_graph_add_line_to_path (ctx,
         2455  +									  x -
         2456  +									  size4,
         2457  +									  y);
         2458  +					      rl2_graph_close_subpath (ctx);
         2459  +					      break;
         2460  +					  case RL2_GRAPHIC_MARK_SQUARE:
         2461  +					  default:
         2462  +					      rl2_graph_move_to_point (ctx,
         2463  +								       x -
         2464  +								       size2,
         2465  +								       y -
         2466  +								       size2);
         2467  +					      rl2_graph_add_line_to_path (ctx,
         2468  +									  x -
         2469  +									  size2,
         2470  +									  y +
         2471  +									  size2);
         2472  +					      rl2_graph_add_line_to_path (ctx,
         2473  +									  x +
         2474  +									  size2,
         2475  +									  y +
         2476  +									  size2);
         2477  +					      rl2_graph_add_line_to_path (ctx,
         2478  +									  x +
         2479  +									  size2,
         2480  +									  y -
         2481  +									  size2);
         2482  +					      rl2_graph_close_subpath (ctx);
         2483  +					      break;
         2484  +					  };
         2485  +					if (fill)
  2252   2486   					  {
  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);
         2487  +					      if (stroke)
         2488  +						  rl2_graph_fill_path (ctx,
         2489  +								       RL2_PRESERVE_PATH);
  2263   2490   					      else
  2264         -						  rl2_graph_add_line_to_path
  2265         -						      (ctx, cx, cy);
  2266         -					      rads += 0.628318530718;
         2491  +						  rl2_graph_fill_path (ctx,
         2492  +								       RL2_CLEAR_PATH);
  2267   2493   					  }
  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         -				    {
  2362   2494   					if (stroke)
  2363         -					    rl2_graph_fill_path (ctx,
  2364         -								 RL2_PRESERVE_PATH);
  2365         -					else
  2366         -					    rl2_graph_fill_path (ctx,
  2367         -								 RL2_CLEAR_PATH);
         2495  +					    rl2_graph_stroke_path (ctx,
         2496  +								   RL2_CLEAR_PATH);
  2368   2497   				    }
  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);
         2498  +				  if (is_external && pattern != NULL)
         2499  +				    {
         2500  +					/* drawing an External Graphic pattern */
         2501  +					unsigned int width;
         2502  +					unsigned int height;
         2503  +					rl2_graph_get_pattern_size (pattern,
         2504  +								    &width,
         2505  +								    &height);
         2506  +					double out_width = width;
         2507  +					double out_height = height;
         2508  +					rl2_graph_draw_graphic_symbol (ctx,
         2509  +								       pattern,
         2510  +								       out_width,
         2511  +								       out_height,
         2512  +								       x +
         2513  +								       point_sym->graphic->displacement_x,
         2514  +								       y -
         2515  +								       point_sym->graphic->displacement_y,
         2516  +								       point_sym->graphic->rotation,
         2517  +								       point_sym->graphic->anchor_point_x,
         2518  +								       point_sym->graphic->anchor_point_y);
         2519  +				    }
  2377   2520   			      }
  2378   2521   			    point = point->next;
  2379   2522   			}
  2380   2523   
  2381   2524   		      /* releasing Patterns */
  2382   2525   		      if (pattern != NULL)
  2383         -			  rl2_graph_destroy_bitmap (pattern);
         2526  +			  rl2_graph_destroy_pattern (pattern);
  2384   2527   		      if (pattern_fill != NULL)
  2385   2528   			{
  2386   2529   			    rl2_graph_release_pattern_pen (ctx);
  2387   2530   			    rl2_graph_destroy_pattern (pattern_fill);
  2388   2531   			}
  2389   2532   		      if (pattern_stroke != NULL)
  2390   2533   			{
................................................................................
  2393   2536   			}
  2394   2537   		      graphic = graphic->next;
  2395   2538   		  }
  2396   2539   	    }
  2397   2540   	  item = item->next;
  2398   2541         }
  2399   2542   }
         2543  +
         2544  +static int
         2545  +linestring_bbox_matches (rl2LinestringPtr ring, double minx, double miny,
         2546  +			 double maxx, double maxy)
         2547  +{
         2548  +/* checks if the Linestring BBOX is visible */
         2549  +    if (minx > ring->maxx)
         2550  +	return 0;
         2551  +    if (maxx < ring->minx)
         2552  +	return 0;
         2553  +    if (miny > ring->maxy)
         2554  +	return 0;
         2555  +    if (maxy < ring->miny)
         2556  +	return 0;
         2557  +    return 1;
         2558  +}
  2400   2559   
  2401   2560   static void
  2402   2561   draw_lines (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  2403   2562   	    rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  2404         -	    double miny, double x_res, double y_res, rl2GeometryPtr geom)
         2563  +	    double miny, double maxx, double maxy, double x_res, double y_res,
         2564  +	    rl2GeometryPtr geom)
  2405   2565   {
  2406   2566   /* drawing Linear-type features */
  2407   2567       rl2PrivVectorSymbolizerItemPtr item;
  2408   2568       int pen_cap;
  2409   2569       int pen_join;
  2410   2570       double opacity;
  2411   2571       unsigned char norm_opacity;
................................................................................
  2421   2581   		rl2PrivLineSymbolizerPtr line_sym =
  2422   2582   		    (rl2PrivLineSymbolizerPtr) (item->symbolizer);
  2423   2583   		if (line_sym->stroke != NULL)
  2424   2584   		  {
  2425   2585   		      if (line_sym->stroke->graphic != NULL)
  2426   2586   			{
  2427   2587   			    /* external Graphic stroke */
  2428         -			    pattern = load_external_graphic_from_dbms (handle,
  2429         -								       line_sym->stroke->graphic);
         2588  +			    const char *xlink_href = NULL;
         2589  +			    int recolor = 0;
         2590  +			    unsigned char red;
         2591  +			    unsigned char green;
         2592  +			    unsigned char blue;
         2593  +			    pattern = NULL;
         2594  +			    if (line_sym->stroke->graphic->first != NULL)
         2595  +			      {
         2596  +				  if (line_sym->stroke->graphic->first->type ==
         2597  +				      RL2_EXTERNAL_GRAPHIC)
         2598  +				    {
         2599  +					rl2PrivExternalGraphicPtr ext =
         2600  +					    (rl2PrivExternalGraphicPtr)
         2601  +					    (line_sym->stroke->graphic->
         2602  +					     first->item);
         2603  +					xlink_href = ext->xlink_href;
         2604  +					if (ext->first != NULL)
         2605  +					  {
         2606  +					      recolor = 1;
         2607  +					      red = ext->first->red;
         2608  +					      green = ext->first->green;
         2609  +					      blue = ext->first->blue;
         2610  +					  }
         2611  +				    }
         2612  +			      }
         2613  +			    if (xlink_href != NULL)
         2614  +				pattern =
         2615  +				    rl2_create_pattern_from_external_graphic
         2616  +				    (handle, xlink_href, 1);
  2430   2617   			    if (pattern != NULL)
  2431   2618   			      {
  2432         -				  switch (line_sym->stroke->linecap)
  2433         -				    {
  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)
  2445         -				    {
  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         -				    };
         2619  +				  if (recolor)
         2620  +				    {
         2621  +					/* attempting to recolor the External Graphic resource */
         2622  +					rl2_graph_pattern_recolor (pattern,
         2623  +								   red, green,
         2624  +								   blue);
         2625  +				    }
         2626  +				  if (line_sym->stroke->opacity <= 0.0)
         2627  +				      norm_opacity = 0;
         2628  +				  else if (line_sym->stroke->opacity >= 1.0)
         2629  +				      norm_opacity = 255;
         2630  +				  else
         2631  +				    {
         2632  +					opacity =
         2633  +					    255.0 * line_sym->stroke->opacity;
         2634  +					if (opacity <= 0.0)
         2635  +					    norm_opacity = 0;
         2636  +					else if (opacity >= 255.0)
         2637  +					    norm_opacity = 255;
         2638  +					else
         2639  +					    norm_opacity = opacity;
         2640  +				    }
         2641  +				  if (norm_opacity < 1.0)
         2642  +				      rl2_graph_pattern_transparency
         2643  +					  (pattern, norm_opacity);
  2456   2644   				  if (line_sym->stroke->dash_count > 0
  2457   2645   				      && line_sym->stroke->dash_list != NULL)
  2458   2646   				      rl2_add_pattern_to_multi_stroke_dash
  2459   2647   					  (multi_stroke, pattern,
  2460   2648   					   line_sym->stroke->width, pen_cap,
  2461   2649   					   pen_join,
  2462   2650   					   line_sym->stroke->dash_count,
................................................................................
  2464   2652   					   line_sym->stroke->dash_offset);
  2465   2653   				  else
  2466   2654   				      rl2_add_pattern_to_multi_stroke
  2467   2655   					  (multi_stroke, pattern,
  2468   2656   					   line_sym->stroke->width, pen_cap,
  2469   2657   					   pen_join);
  2470   2658   			      }
         2659  +			    else
         2660  +			      {
         2661  +				  /* invalid Pattern: defaulting to a Gray brush */
         2662  +				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
         2663  +			      }
  2471   2664   			}
  2472   2665   		      else
  2473   2666   			{
  2474   2667   			    /* solid RGB stroke */
  2475   2668   			    if (line_sym->stroke->opacity <= 0.0)
  2476   2669   				norm_opacity = 0;
  2477   2670   			    else if (line_sym->stroke->opacity >= 1.0)
................................................................................
  2547   2740       if (multi_stroke == NULL)
  2548   2741   	return;
  2549   2742   
  2550   2743       line = geom->first_linestring;
  2551   2744       while (line)
  2552   2745         {
  2553   2746   	  /* drawing a LINESTRING */
  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++)
  2563         -	    {
  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
  2574         -		  {
  2575         -		      if (x == lastX && y == lastY)
  2576         -			  ;
  2577         -		      else
  2578         -			{
  2579         -			    rl2_graph_add_line_to_path (ctx, x, y);
         2747  +	  if (linestring_bbox_matches (line, minx, miny, maxx, maxy))
         2748  +	    {
         2749  +		rl2PrivMultiStrokeItemPtr stroke_item;
         2750  +		int iv;
         2751  +		double dx;
         2752  +		double dy;
         2753  +		int x;
         2754  +		int y;
         2755  +		int lastX = 0;
         2756  +		int lastY = 0;
         2757  +		for (iv = 0; iv < line->points; iv++)
         2758  +		  {
         2759  +		      rl2GetPoint (line->coords, iv, &dx, &dy);
         2760  +		      x = (int) ((dx - minx) / x_res);
         2761  +		      y = height - (int) ((dy - miny) / y_res);
         2762  +		      if (iv == 0)
         2763  +			{
         2764  +			    rl2_graph_move_to_point (ctx, x, y);
  2580   2765   			    lastX = x;
  2581   2766   			    lastY = y;
  2582   2767   			}
  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);
         2768  +		      else
         2769  +			{
         2770  +			    if (x == lastX && y == lastY)
         2771  +				;
         2772  +			    else
         2773  +			      {
         2774  +				  rl2_graph_add_line_to_path (ctx, x, y);
         2775  +				  lastX = x;
         2776  +				  lastY = y;
         2777  +			      }
         2778  +			}
         2779  +		  }
         2780  +		stroke_item = multi_stroke->first;
         2781  +		while (stroke_item != NULL)
         2782  +		  {
         2783  +		      /* applying all strokes, one after the other */
         2784  +		      if (stroke_item->dash_count > 0
         2785  +			  && stroke_item->dash_list != NULL)
         2786  +			{
         2787  +			    if (stroke_item->pattern != NULL)
         2788  +				rl2_graph_set_pattern_dashed_pen (ctx,
         2789  +								  stroke_item->pattern,
         2790  +								  stroke_item->width,
         2791  +								  stroke_item->pen_cap,
         2792  +								  stroke_item->pen_join,
         2793  +								  stroke_item->dash_count,
         2794  +								  stroke_item->dash_list,
         2795  +								  stroke_item->dash_offset);
         2796  +			    else
         2797  +				rl2_graph_set_dashed_pen (ctx,
         2798  +							  stroke_item->red,
         2799  +							  stroke_item->green,
         2800  +							  stroke_item->blue,
         2801  +							  stroke_item->opacity,
         2802  +							  stroke_item->width,
         2803  +							  stroke_item->pen_cap,
         2804  +							  stroke_item->pen_join,
         2805  +							  stroke_item->dash_count,
         2806  +							  stroke_item->dash_list,
         2807  +							  stroke_item->dash_offset);
         2808  +			}
  2601   2809   		      else
  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);
  2612         -		  }
  2613         -		else
  2614         -		  {
  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);
         2810  +			{
         2811  +			    if (stroke_item->pattern != NULL)
         2812  +				rl2_graph_set_pattern_solid_pen (ctx,
         2813  +								 stroke_item->pattern,
         2814  +								 stroke_item->width,
         2815  +								 stroke_item->pen_cap,
         2816  +								 stroke_item->pen_join);
         2817  +			    else
         2818  +				rl2_graph_set_solid_pen (ctx,
         2819  +							 stroke_item->red,
         2820  +							 stroke_item->green,
         2821  +							 stroke_item->blue,
         2822  +							 stroke_item->opacity,
         2823  +							 stroke_item->width,
         2824  +							 stroke_item->pen_cap,
         2825  +							 stroke_item->pen_join);
         2826  +			}
         2827  +
         2828  +		      if (stroke_item == multi_stroke->last)
         2829  +			  rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH);
  2621   2830   		      else
  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);
         2831  +			  rl2_graph_stroke_path (ctx, RL2_PRESERVE_PATH);
         2832  +
         2833  +		      stroke_item = stroke_item->next;
         2834  +		      if (stroke_item == multi_stroke->last)
         2835  +			  rl2_graph_release_pattern_pen (ctx);
  2629   2836   		  }
  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);
  2639   2837   	    }
  2640   2838   	  line = line->next;
  2641   2839         }
  2642   2840       rl2_destroy_multi_stroke (multi_stroke);
  2643   2841   }
         2842  +
         2843  +static int
         2844  +ring_bbox_matches (rl2RingPtr ring, double minx, double miny, double maxx,
         2845  +		   double maxy)
         2846  +{
         2847  +/* checks if the Ring BBOX is visible */
         2848  +    if (minx > ring->maxx)
         2849  +	return 0;
         2850  +    if (maxx < ring->minx)
         2851  +	return 0;
         2852  +    if (miny > ring->maxy)
         2853  +	return 0;
         2854  +    if (maxy < ring->miny)
         2855  +	return 0;
         2856  +    return 1;
         2857  +}
  2644   2858   
  2645   2859   static void
  2646   2860   draw_polygons (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  2647   2861   	       rl2PrivVectorSymbolizerPtr sym, int height, double minx,
  2648         -	       double miny, double x_res, double y_res, rl2GeometryPtr geom)
         2862  +	       double miny, double maxx, double maxy, double x_res,
         2863  +	       double y_res, rl2GeometryPtr geom)
  2649   2864   {
  2650   2865   /* drawing Polygonal-type features */
  2651   2866       rl2PrivVectorSymbolizerItemPtr item;
  2652   2867       int stroke = 0;
  2653   2868       int fill = 0;
  2654   2869       int pen_cap;
  2655   2870       int pen_join;
................................................................................
  2704   2919   				    rl2_create_pattern_from_external_graphic
  2705   2920   				    (handle, xlink_href, 1);
  2706   2921   			    if (pattern_fill != NULL)
  2707   2922   			      {
  2708   2923   				  if (recolor)
  2709   2924   				    {
  2710   2925   					/* attempting to recolor the External Graphic resource */
  2711         -					rl2_graph_pattern_recolor (pattern_fill,
  2712         -								   red, green,
  2713         -								   blue);
         2926  +					rl2_graph_pattern_recolor
         2927  +					    (pattern_fill, red, green, blue);
  2714   2928   				    }
  2715   2929   				  if (polyg_sym->fill->opacity <= 0.0)
  2716   2930   				      norm_opacity = 0;
  2717   2931   				  else if (polyg_sym->fill->opacity >= 1.0)
  2718   2932   				      norm_opacity = 255;
  2719   2933   				  else
  2720   2934   				    {
................................................................................
  2765   2979   			}
  2766   2980   		  }
  2767   2981   		if (polyg_sym->stroke != NULL)
  2768   2982   		  {
  2769   2983   		      if (polyg_sym->stroke->graphic != NULL)
  2770   2984   			{
  2771   2985   			    /* external Graphic stroke */
  2772         -			    pattern_stroke =
  2773         -				load_external_graphic_from_dbms (handle,
  2774         -								 polyg_sym->stroke->graphic);
         2986  +			    const char *xlink_href = NULL;
         2987  +			    int recolor = 0;
         2988  +			    unsigned char red;
         2989  +			    unsigned char green;
         2990  +			    unsigned char blue;
         2991  +			    pattern_stroke = NULL;
         2992  +			    if (polyg_sym->stroke->graphic->first != NULL)
         2993  +			      {
         2994  +				  if (polyg_sym->stroke->graphic->first->type ==
         2995  +				      RL2_EXTERNAL_GRAPHIC)
         2996  +				    {
         2997  +					rl2PrivExternalGraphicPtr ext =
         2998  +					    (rl2PrivExternalGraphicPtr)
         2999  +					    (polyg_sym->stroke->graphic->
         3000  +					     first->item);
         3001  +					xlink_href = ext->xlink_href;
         3002  +					if (ext->first != NULL)
         3003  +					  {
         3004  +					      recolor = 1;
         3005  +					      red = ext->first->red;
         3006  +					      green = ext->first->green;
         3007  +					      blue = ext->first->blue;
         3008  +					  }
         3009  +				    }
         3010  +			      }
         3011  +			    if (xlink_href != NULL)
         3012  +				pattern_stroke =
         3013  +				    rl2_create_pattern_from_external_graphic
         3014  +				    (handle, xlink_href, 1);
  2775   3015   			    if (pattern_stroke != NULL)
  2776   3016   			      {
  2777         -				  switch (polyg_sym->stroke->linecap)
         3017  +				  if (recolor)
  2778   3018   				    {
  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)
         3019  +					/* attempting to recolor the External Graphic resource */
         3020  +					rl2_graph_pattern_recolor
         3021  +					    (pattern_stroke, red, green, blue);
         3022  +				    }
         3023  +				  if (polyg_sym->stroke->opacity <= 0.0)
         3024  +				      norm_opacity = 0;
         3025  +				  else if (polyg_sym->stroke->opacity >= 1.0)
         3026  +				      norm_opacity = 255;
         3027  +				  else
  2790   3028   				    {
  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;
         3029  +					opacity =
         3030  +					    255.0 * polyg_sym->stroke->opacity;
         3031  +					if (opacity <= 0.0)
         3032  +					    norm_opacity = 0;
         3033  +					else if (opacity >= 255.0)
         3034  +					    norm_opacity = 255;
         3035  +					else
         3036  +					    norm_opacity = opacity;
         3037  +				    }
         3038  +				  if (norm_opacity < 1.0)
         3039  +				      rl2_graph_pattern_transparency
         3040  +					  (pattern_stroke, norm_opacity);
         3041  +				  rl2_graph_set_pattern_brush (ctx,
         3042  +							       pattern_stroke);
         3043  +			      }
         3044  +			    else
         3045  +			      {
         3046  +				  /* invalid Pattern: defaulting to a Gray brush */
         3047  +				  rl2_graph_set_brush (ctx, 128, 128, 128, 255);
  2820   3048   			      }
         3049  +			    stroke = 1;
  2821   3050   			}
  2822   3051   		      else
  2823   3052   			{
  2824   3053   			    /* solid RGB stroke */
  2825   3054   			    if (polyg_sym->stroke->opacity <= 0.0)
  2826   3055   				norm_opacity = 0;
  2827   3056   			    else if (polyg_sym->stroke->opacity >= 1.0)
................................................................................
  2910   3139   		int x;
  2911   3140   		int y;
  2912   3141   		int lastX = 0;
  2913   3142   		int lastY = 0;
  2914   3143   		int ib;
  2915   3144   		rl2RingPtr ring = polyg->exterior;
  2916   3145   		/* exterior border */
  2917         -		for (iv = 0; iv < ring->points; iv++)
         3146  +		if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
  2918   3147   		  {
  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++)
  2942         -		  {
  2943         -		      /* interior borders */
  2944         -		      ring = polyg->interiors + ib;
  2945   3148   		      for (iv = 0; iv < ring->points; iv++)
  2946   3149   			{
  2947   3150   			    rl2GetPoint (ring->coords, iv, &dx, &dy);
  2948   3151   			    x = (int) ((dx - minx) / x_res);
  2949   3152   			    y = height - (int) ((dy - miny) / y_res);
  2950   3153   			    if (iv == 0)
  2951   3154   			      {
................................................................................
  2962   3165   					rl2_graph_add_line_to_path (ctx, x, y);
  2963   3166   					lastX = x;
  2964   3167   					lastY = y;
  2965   3168   				    }
  2966   3169   			      }
  2967   3170   			}
  2968   3171   		      rl2_graph_close_subpath (ctx);
         3172  +		  }
         3173  +		else
         3174  +		  {
         3175  +		      /* if the exterior ring is invisible we'll ignore all internal rings */
         3176  +		      polyg = polyg->next;
         3177  +		      continue;
         3178  +		  }
         3179  +		for (ib = 0; ib < polyg->num_interiors; ib++)
         3180  +		  {
         3181  +		      /* interior borders */
         3182  +		      ring = polyg->interiors + ib;
         3183  +		      if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
         3184  +			{
         3185  +			    for (iv = 0; iv < ring->points; iv++)
         3186  +			      {
         3187  +				  rl2GetPoint (ring->coords, iv, &dx, &dy);
         3188  +				  x = (int) ((dx - minx) / x_res);
         3189  +				  y = height - (int) ((dy - miny) / y_res);
         3190  +				  if (iv == 0)
         3191  +				    {
         3192  +					rl2_graph_move_to_point (ctx, x, y);
         3193  +					lastX = x;
         3194  +					lastY = y;
         3195  +				    }
         3196  +				  else
         3197  +				    {
         3198  +					if (x == lastX && y == lastY)
         3199  +					    ;
         3200  +					else
         3201  +					  {
         3202  +					      rl2_graph_add_line_to_path (ctx,
         3203  +									  x, y);
         3204  +					      lastX = x;
         3205  +					      lastY = y;
         3206  +					  }
         3207  +				    }
         3208  +			      }
         3209  +			    rl2_graph_close_subpath (ctx);
         3210  +			}
  2969   3211   		  }
  2970   3212   		if (fill)
  2971   3213   		  {
  2972   3214   		      if (stroke)
  2973   3215   			  rl2_graph_fill_path (ctx, RL2_PRESERVE_PATH);
  2974   3216   		      else
  2975   3217   			  rl2_graph_fill_path (ctx, RL2_CLEAR_PATH);
................................................................................
  2989   3231   		rl2_graph_destroy_pattern (pattern_stroke);
  2990   3232   	    }
  2991   3233   	  item = item->next;
  2992   3234         }
  2993   3235   }
  2994   3236   
  2995   3237   static int
  2996         -label_get_xy (sqlite3 * handle, const unsigned char *blob, int size, double *x,
  2997         -	      double *y)
         3238  +label_get_xy (sqlite3 * handle, const unsigned char *blob, int size,
         3239  +	      double *x, double *y)
  2998   3240   {
  2999   3241   /* resolving Point XY coords */
  3000   3242       const char *sql;
  3001   3243       int ret;
  3002   3244       sqlite3_stmt *stmt = NULL;
  3003   3245       int ok = 0;
  3004   3246   
................................................................................
  3061   3303   	  if (ret == SQLITE_DONE)
  3062   3304   	      break;		/* end of result set */
  3063   3305   	  if (ret == SQLITE_ROW)
  3064   3306   	    {
  3065   3307   		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3066   3308   		  {
  3067   3309   		      const unsigned char *g_blob =
  3068         -			  (const unsigned char *) sqlite3_column_blob (stmt, 0);
         3310  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3311  +								       0);
  3069   3312   		      int g_size = sqlite3_column_bytes (stmt, 0);
  3070   3313   		      if (label_get_xy (handle, g_blob, g_size, x, y))
  3071   3314   			  ok = 1;
  3072   3315   		  }
  3073   3316   	    }
  3074   3317         }
  3075   3318       sqlite3_finalize (stmt);
................................................................................
  3108   3351   	  if (ret == SQLITE_DONE)
  3109   3352   	      break;		/* end of result set */
  3110   3353   	  if (ret == SQLITE_ROW)
  3111   3354   	    {
  3112   3355   		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
  3113   3356   		  {
  3114   3357   		      const unsigned char *g_blob =
  3115         -			  (const unsigned char *) sqlite3_column_blob (stmt, 0);
         3358  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3359  +								       0);
         3360  +		      int g_size = sqlite3_column_bytes (stmt, 0);
         3361  +		      if (label_get_xy (handle, g_blob, g_size, x, y))
         3362  +			  ok = 1;
         3363  +		  }
         3364  +	    }
         3365  +      }
         3366  +    sqlite3_finalize (stmt);
         3367  +    return ok;
         3368  +}
         3369  +
         3370  +static int
         3371  +label_get_ring_midpoint (sqlite3 * handle, rl2RingPtr ring, double *x,
         3372  +			 double *y)
         3373  +{
         3374  +/* computing a Ring MidPoint */
         3375  +    unsigned char *blob;
         3376  +    int blob_sz;
         3377  +    const char *sql;
         3378  +    int ret;
         3379  +    sqlite3_stmt *stmt = NULL;
         3380  +    int ok = 0;
         3381  +
         3382  +    if (ring == NULL)
         3383  +	return 0;
         3384  +    if (!rl2_serialize_ring_as_linestring (ring, &blob, &blob_sz))
         3385  +	return 0;
         3386  +
         3387  +    sql = "SELECT ST_Line_Interpolate_Point(?, 0.5)";
         3388  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         3389  +    if (ret != SQLITE_OK)
         3390  +	return 0;
         3391  +
         3392  +    sqlite3_reset (stmt);
         3393  +    sqlite3_clear_bindings (stmt);
         3394  +    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
         3395  +    while (1)
         3396  +      {
         3397  +	  /* scrolling the result set rows */
         3398  +	  ret = sqlite3_step (stmt);
         3399  +	  if (ret == SQLITE_DONE)
         3400  +	      break;		/* end of result set */
         3401  +	  if (ret == SQLITE_ROW)
         3402  +	    {
         3403  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
         3404  +		  {
         3405  +		      const unsigned char *g_blob =
         3406  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3407  +								       0);
  3116   3408   		      int g_size = sqlite3_column_bytes (stmt, 0);
  3117   3409   		      if (label_get_xy (handle, g_blob, g_size, x, y))
  3118   3410   			  ok = 1;
  3119   3411   		  }
  3120   3412   	    }
  3121   3413         }
  3122   3414       sqlite3_finalize (stmt);
  3123   3415       return ok;
  3124   3416   }
         3417  +
         3418  +static rl2GeometryPtr
         3419  +do_generalize_linestring (sqlite3 * handle, rl2LinestringPtr line,
         3420  +			  double generalize_factor)
         3421  +{
         3422  +/* simplifying a Linestring */
         3423  +    rl2GeometryPtr geom = NULL;
         3424  +    unsigned char *blob;
         3425  +    int blob_sz;
         3426  +    const char *sql;
         3427  +    int ret;
         3428  +    sqlite3_stmt *stmt = NULL;
         3429  +
         3430  +    if (line == NULL)
         3431  +	return NULL;
         3432  +    if (line->points < 2)
         3433  +	return NULL;
         3434  +    if (!rl2_serialize_linestring (line, &blob, &blob_sz))
         3435  +	return NULL;
         3436  +
         3437  +    sql = "SELECT ST_Simplify(?, ?)";
         3438  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         3439  +    if (ret != SQLITE_OK)
         3440  +	return NULL;
         3441  +
         3442  +    sqlite3_reset (stmt);
         3443  +    sqlite3_clear_bindings (stmt);
         3444  +    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
         3445  +    sqlite3_bind_double (stmt, 2, generalize_factor);
         3446  +    while (1)
         3447  +      {
         3448  +	  /* scrolling the result set rows */
         3449  +	  ret = sqlite3_step (stmt);
         3450  +	  if (ret == SQLITE_DONE)
         3451  +	      break;		/* end of result set */
         3452  +	  if (ret == SQLITE_ROW)
         3453  +	    {
         3454  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
         3455  +		  {
         3456  +		      const unsigned char *g_blob =
         3457  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3458  +								       0);
         3459  +		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
         3460  +		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
         3461  +		  }
         3462  +	    }
         3463  +      }
         3464  +    sqlite3_finalize (stmt);
         3465  +    return geom;
         3466  +}
         3467  +
         3468  +static rl2GeometryPtr
         3469  +do_generalize_ring (sqlite3 * handle, rl2RingPtr ring, double generalize_factor)
         3470  +{
         3471  +/* simplifying a Ring */
         3472  +    rl2GeometryPtr geom = NULL;
         3473  +    unsigned char *blob;
         3474  +    int blob_sz;
         3475  +    const char *sql;
         3476  +    int ret;
         3477  +    sqlite3_stmt *stmt = NULL;
         3478  +
         3479  +    if (ring == NULL)
         3480  +	return NULL;
         3481  +    if (ring->points < 2)
         3482  +	return NULL;
         3483  +    if (!rl2_serialize_ring (ring, &blob, &blob_sz))
         3484  +	return NULL;
         3485  +
         3486  +    sql = "SELECT ST_SimplifyPreserveTopology(?, ?)";
         3487  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         3488  +    if (ret != SQLITE_OK)
         3489  +	return NULL;
         3490  +
         3491  +    sqlite3_reset (stmt);
         3492  +    sqlite3_clear_bindings (stmt);
         3493  +    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
         3494  +    sqlite3_bind_double (stmt, 2, generalize_factor);
         3495  +    while (1)
         3496  +      {
         3497  +	  /* scrolling the result set rows */
         3498  +	  ret = sqlite3_step (stmt);
         3499  +	  if (ret == SQLITE_DONE)
         3500  +	      break;		/* end of result set */
         3501  +	  if (ret == SQLITE_ROW)
         3502  +	    {
         3503  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
         3504  +		  {
         3505  +		      const unsigned char *g_blob =
         3506  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3507  +								       0);
         3508  +		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
         3509  +		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
         3510  +		  }
         3511  +	    }
         3512  +      }
         3513  +    sqlite3_finalize (stmt);
         3514  +    return geom;
         3515  +}
         3516  +
         3517  +static int
         3518  +check_valid_line (rl2LinestringPtr line)
         3519  +{
         3520  +/* testing for a valid linestring */
         3521  +    int iv;
         3522  +    int pts = 0;
         3523  +    double x;
         3524  +    double y;
         3525  +    double x0;
         3526  +    double y0;
         3527  +
         3528  +    if (line == NULL)
         3529  +	return 0;
         3530  +    if (line->points < 2)
         3531  +	return 0;
         3532  +    rl2GetPoint (line->coords, 0, &x0, &y0);
         3533  +    for (iv = 1; iv < line->points; iv++)
         3534  +      {
         3535  +	  rl2GetPoint (line->coords, iv, &x, &y);
         3536  +	  if (x != x0 || y != y0)
         3537  +	    {
         3538  +		pts++;
         3539  +		break;
         3540  +	    }
         3541  +      }
         3542  +    if (pts == 0)
         3543  +	return 0;
         3544  +    return 1;
         3545  +}
         3546  +
         3547  +static rl2GeometryPtr
         3548  +do_offset_linestring (sqlite3 * handle, rl2LinestringPtr line,
         3549  +		      double perpendicular_offset)
         3550  +{
         3551  +/* Offest Curve (from Linestring) */
         3552  +    rl2GeometryPtr geom = NULL;
         3553  +    unsigned char *blob;
         3554  +    int blob_sz;
         3555  +    const char *sql;
         3556  +    int ret;
         3557  +    sqlite3_stmt *stmt = NULL;
         3558  +
         3559  +    if (!check_valid_line (line))
         3560  +	return NULL;
         3561  +    if (!rl2_serialize_linestring (line, &blob, &blob_sz))
         3562  +	return NULL;
         3563  +
         3564  +    sql = "SELECT ST_OffsetCurve(?, ?)";
         3565  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         3566  +    if (ret != SQLITE_OK)
         3567  +	return NULL;
         3568  +
         3569  +    sqlite3_reset (stmt);
         3570  +    sqlite3_clear_bindings (stmt);
         3571  +    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
         3572  +    sqlite3_bind_double (stmt, 2, perpendicular_offset);
         3573  +    while (1)
         3574  +      {
         3575  +	  /* scrolling the result set rows */
         3576  +	  ret = sqlite3_step (stmt);
         3577  +	  if (ret == SQLITE_DONE)
         3578  +	      break;		/* end of result set */
         3579  +	  if (ret == SQLITE_ROW)
         3580  +	    {
         3581  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
         3582  +		  {
         3583  +		      const unsigned char *g_blob =
         3584  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3585  +								       0);
         3586  +		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
         3587  +		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
         3588  +		  }
         3589  +	    }
         3590  +      }
         3591  +    sqlite3_finalize (stmt);
         3592  +    return geom;
         3593  +}
         3594  +
         3595  +static int
         3596  +check_valid_ring (rl2RingPtr ring)
         3597  +{
         3598  +/* testing for a valid ring */
         3599  +    int iv;
         3600  +    int pts = 0;
         3601  +    int last;
         3602  +    double x;
         3603  +    double y;
         3604  +    double x0;
         3605  +    double y0;
         3606  +    double x1;
         3607  +    double y1;
         3608  +
         3609  +    if (ring == NULL)
         3610  +	return 0;
         3611  +    if (ring->points < 4)
         3612  +	return 0;
         3613  +    rl2GetPoint (ring->coords, 0, &x0, &y0);
         3614  +    for (iv = 1; iv < ring->points; iv++)
         3615  +      {
         3616  +	  rl2GetPoint (ring->coords, iv, &x, &y);
         3617  +	  if (pts == 0)
         3618  +	    {
         3619  +		if (x != x0 || y != y0)
         3620  +		  {
         3621  +		      pts++;
         3622  +		      x1 = x;
         3623  +		      y1 = y;
         3624  +		  }
         3625  +	    }
         3626  +	  else
         3627  +	    {
         3628  +		if ((x != x0 || y != y0) && (x != x1 || y != y1))
         3629  +		  {
         3630  +		      pts++;
         3631  +		      break;
         3632  +		  }
         3633  +	    }
         3634  +      }
         3635  +    last = ring->points - 1;
         3636  +    rl2GetPoint (ring->coords, last, &x1, &y1);
         3637  +    if (pts == 2 && x0 == x1 && y0 == y1)
         3638  +	return 1;
         3639  +    return 0;
         3640  +}
         3641  +
         3642  +static rl2GeometryPtr
         3643  +do_buffered_ring (sqlite3 * handle, rl2RingPtr ring,
         3644  +		  double perpendicular_offset)
         3645  +{
         3646  +/* Buffer (from Ring) */
         3647  +    rl2GeometryPtr geom = NULL;
         3648  +    unsigned char *blob;
         3649  +    int blob_sz;
         3650  +    const char *sql;
         3651  +    int ret;
         3652  +    sqlite3_stmt *stmt = NULL;
         3653  +
         3654  +    if (!check_valid_ring (ring))
         3655  +	return NULL;
         3656  +    if (!rl2_serialize_ring (ring, &blob, &blob_sz))
         3657  +	return NULL;
         3658  +
         3659  +    sql = "SELECT ST_Buffer(?, ?)";
         3660  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
         3661  +    if (ret != SQLITE_OK)
         3662  +	return NULL;
         3663  +
         3664  +    sqlite3_reset (stmt);
         3665  +    sqlite3_clear_bindings (stmt);
         3666  +    sqlite3_bind_blob (stmt, 1, blob, blob_sz, free);
         3667  +    sqlite3_bind_double (stmt, 2, perpendicular_offset);
         3668  +    while (1)
         3669  +      {
         3670  +	  /* scrolling the result set rows */
         3671  +	  ret = sqlite3_step (stmt);
         3672  +	  if (ret == SQLITE_DONE)
         3673  +	      break;		/* end of result set */
         3674  +	  if (ret == SQLITE_ROW)
         3675  +	    {
         3676  +		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
         3677  +		  {
         3678  +		      const unsigned char *g_blob =
         3679  +			  (const unsigned char *) sqlite3_column_blob (stmt,
         3680  +								       0);
         3681  +		      int g_blob_sz = sqlite3_column_bytes (stmt, 0);
         3682  +		      geom = rl2_geometry_from_blob (g_blob, g_blob_sz);
         3683  +		  }
         3684  +	    }
         3685  +      }
         3686  +    sqlite3_finalize (stmt);
         3687  +    return geom;
         3688  +}
         3689  +
         3690  +static void
         3691  +create_line_array_from_linestring (sqlite3 * handle, rl2LinestringPtr line,
         3692  +				   double perpendicular_offset, int *points,
         3693  +				   double **x_array, double **y_array,
         3694  +				   int generalize_line,
         3695  +				   double generalize_factor, int height,
         3696  +				   double minx, double miny, double x_res,
         3697  +				   double y_res)
         3698  +{
         3699  +/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */
         3700  +    rl2GeometryPtr geom = NULL;
         3701  +    rl2GeometryPtr geom2 = NULL;
         3702  +    rl2LinestringPtr aux_line;
         3703  +    rl2LinestringPtr in_line;
         3704  +    double *xx = NULL;
         3705  +    double *yy = NULL;
         3706  +    int iv;
         3707  +    double x;
         3708  +    double y;
         3709  +
         3710  +    *points = 0;
         3711  +    *x_array = NULL;
         3712  +    *y_array = NULL;
         3713  +    if (line == NULL)
         3714  +	goto error;
         3715  +
         3716  +    aux_line = rl2_linestring_to_image (line, height, minx, miny, x_res, y_res);
         3717  +    if (aux_line == NULL)
         3718  +	goto error;
         3719  +    in_line = aux_line;
         3720  +    if (generalize_line)
         3721  +      {
         3722  +	  geom = do_generalize_linestring (handle, in_line, generalize_factor);
         3723  +	  if (geom == NULL)
         3724  +	      goto error;
         3725  +	  in_line = geom->first_linestring;
         3726  +	  if (in_line == NULL)
         3727  +	      goto error;
         3728  +      }
         3729  +    if (perpendicular_offset != 0.0)
         3730  +      {
         3731  +	  geom2 = do_offset_linestring (handle, in_line, perpendicular_offset);
         3732  +	  if (geom2 == NULL)
         3733  +	      goto error;
         3734  +	  in_line = geom2->first_linestring;
         3735  +	  if (in_line == NULL)
         3736  +	      goto error;
         3737  +      }
         3738  +
         3739  +/* allocating the X and Y arrays */
         3740  +    if (in_line->points < 2)
         3741  +	goto error;
         3742  +    xx = malloc (sizeof (double) * in_line->points);
         3743  +    yy = malloc (sizeof (double) * in_line->points);
         3744  +    if (xx == NULL || yy == NULL)
         3745  +      {
         3746  +	  if (xx != NULL)
         3747  +	      free (xx);
         3748  +	  if (yy != NULL)
         3749  +	      free (yy);
         3750  +	  goto error;
         3751  +      }
         3752  +    for (iv = 0; iv < in_line->points; iv++)
         3753  +      {
         3754  +	  /* populating the X and Y arrays */
         3755  +	  rl2GetPoint (in_line->coords, iv, &x, &y);
         3756  +	  *(xx + iv) = x;
         3757  +	  *(yy + iv) = y;
         3758  +      }
         3759  +    *points = in_line->points;
         3760  +    *x_array = xx;
         3761  +    *y_array = yy;
         3762  +
         3763  +  error:
         3764  +    if (aux_line)
         3765  +	rl2DestroyLinestring (aux_line);
         3766  +    if (geom)
         3767  +	rl2_destroy_geometry (geom);
         3768  +    if (geom2)
         3769  +	rl2_destroy_geometry (geom2);
         3770  +}
         3771  +
         3772  +static void
         3773  +create_line_array_from_ring (sqlite3 * handle, rl2RingPtr ring,
         3774  +			     double perpendicular_offset, int *points,
         3775  +			     double **x_array, double **y_array,
         3776  +			     int generalize_line, double generalize_factor,
         3777  +			     int height, double minx, double miny, double x_res,
         3778  +			     double y_res)
         3779  +{
         3780  +/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */
         3781  +    rl2GeometryPtr geom = NULL;
         3782  +    rl2GeometryPtr geom2 = NULL;
         3783  +    rl2PolygonPtr pg;
         3784  +    rl2RingPtr aux_ring;
         3785  +    rl2RingPtr in_ring;
         3786  +    double *xx = NULL;
         3787  +    double *yy = NULL;
         3788  +    int iv;
         3789  +    double x;
         3790  +    double y;
         3791  +
         3792  +    *points = 0;
         3793  +    *x_array = NULL;
         3794  +    *y_array = NULL;
         3795  +    if (ring == NULL)
         3796  +	goto error;
         3797  +
         3798  +    aux_ring = rl2_ring_to_image (ring, height, minx, miny, x_res, y_res);
         3799  +    if (aux_ring == NULL)
         3800  +	goto error;
         3801  +    in_ring = aux_ring;
         3802  +    if (generalize_line)
         3803  +      {
         3804  +	  geom = do_generalize_ring (handle, in_ring, generalize_factor);
         3805  +	  if (geom == NULL)
         3806  +	      goto error;
         3807  +	  pg = geom->first_polygon;
         3808  +	  if (pg == NULL)
         3809  +	      goto error;
         3810  +	  in_ring = pg->exterior;
         3811  +	  if (in_ring == NULL)
         3812  +	      goto error;
         3813  +      }
         3814  +    if (perpendicular_offset != 0.0)
         3815  +      {
         3816  +	  geom2 = do_buffered_ring (handle, in_ring, perpendicular_offset);
         3817  +	  if (geom2 == NULL)
         3818  +	      goto error;
         3819  +	  pg = geom2->first_polygon;
         3820  +	  if (pg == NULL)
         3821  +	      goto error;
         3822  +	  in_ring = pg->exterior;
         3823  +	  if (in_ring == NULL)
         3824  +	      goto error;
         3825  +      }
         3826  +
         3827  +/* allocating the X and Y arrays */
         3828  +    if (in_ring->points < 2)
         3829  +	goto error;
         3830  +    xx = malloc (sizeof (double) * in_ring->points);
         3831  +    yy = malloc (sizeof (double) * in_ring->points);
         3832  +    if (xx == NULL || yy == NULL)
         3833  +      {
         3834  +	  if (xx != NULL)
         3835  +	      free (xx);
         3836  +	  if (yy != NULL)
         3837  +	      free (yy);
         3838  +	  goto error;
         3839  +      }
         3840  +    for (iv = 0; iv < in_ring->points; iv++)
         3841  +      {
         3842  +	  /* populating the X and Y arrays */
         3843  +	  rl2GetPoint (in_ring->coords, iv, &x, &y);
         3844  +	  *(xx + iv) = x;
         3845  +	  *(yy + iv) = y;
         3846  +      }
         3847  +    *points = in_ring->points;
         3848  +    *x_array = xx;
         3849  +    *y_array = yy;
         3850  +
         3851  +  error:
         3852  +    if (aux_ring)
         3853  +	rl2DestroyRing (aux_ring);
         3854  +    if (geom)
         3855  +	rl2_destroy_geometry (geom);
         3856  +    if (geom2)
         3857  +	rl2_destroy_geometry (geom2);
         3858  +}
  3125   3859   
  3126   3860   static void
  3127   3861   draw_labels (rl2GraphicsContextPtr ctx, sqlite3 * handle,
  3128         -	     rl2PrivTextSymbolizerPtr sym, int height, double minx, double miny,
  3129         -	     double x_res, double y_res, rl2GeometryPtr geom,
  3130         -	     rl2PrivVariantValuePtr value)
         3862  +	     const void *priv_data, rl2PrivTextSymbolizerPtr sym, int height,
         3863  +	     double minx, double miny, double maxx, double maxy, double x_res,
         3864  +	     double y_res, rl2GeometryPtr geom, rl2PrivVariantValuePtr value)
  3131   3865   {
  3132   3866   /* drawing TextLabels */
  3133   3867       rl2GraphicsFontPtr font = NULL;
  3134   3868       char *dummy = NULL;
  3135   3869       const char *label = NULL;
  3136   3870       int font_style;
  3137   3871       int font_weight;
  3138   3872       double opacity;
  3139   3873       unsigned char norm_opacity;
  3140   3874       rl2PointPtr point;
  3141   3875       rl2LinestringPtr line;
  3142   3876       rl2PolygonPtr polyg;
         3877  +    double rotation = 0.0;
         3878  +    double anchor_point_x = 0.0;
         3879  +    double anchor_point_y = 0.0;
         3880  +    double displacement_x = 0.0;
         3881  +    double displacement_y = 0.0;
         3882  +    double perpendicular_offset = 0.0;
         3883  +    int is_repeated = 0;
         3884  +    double initial_gap = 0.0;
         3885  +    double gap = 0.0;
         3886  +    int is_aligned = 0;
         3887  +    int generalize_line = 0;
         3888  +    int i;
  3143   3889   
  3144   3890   /* preparing the Text */
  3145   3891       if (value->sqlite3_type == SQLITE_INTEGER)
  3146   3892         {
  3147   3893   	  dummy = sqlite3_malloc (1024);
  3148   3894   #if defined(_WIN32) && !defined(__MINGW32__)
  3149   3895   	  sprintf (dummy, "%I64d", value->int_value);
................................................................................
  3182   3928   	  font_weight = RL2_FONTWEIGHT_BOLD;
  3183   3929   	  break;
  3184   3930         case RL2_FONT_WEIGHT_NORMAL:
  3185   3931         default:
  3186   3932   	  font_weight = RL2_FONTWEIGHT_NORMAL;
  3187   3933   	  break;
  3188   3934         };
  3189         -    font =
  3190         -	rl2_graph_create_toy_font (NULL, sym->font_size, font_style,
  3191         -				   font_weight);
         3935  +    for (i = 0; i < RL2_MAX_FONT_FAMILIES; i++)
         3936  +      {
         3937  +	  const char *facename = sym->font_families[i];
         3938  +	  if (facename != NULL)
         3939  +	      font =
         3940  +		  rl2_search_TrueType_font (handle, priv_data, facename,
         3941  +					    sym->font_size);
         3942  +	  if (font != NULL)
         3943  +	      break;
         3944  +      }
         3945  +    if (font == NULL)
         3946  +      {
         3947  +	  /* defaulting to a toy font */
         3948  +	  fprintf (stderr, "default toy font\n");
         3949  +	  font =
         3950  +	      rl2_graph_create_toy_font (NULL, sym->font_size, font_style,
         3951  +					 font_weight);
         3952  +      }
  3192   3953       if (font == NULL)
  3193   3954   	goto stop;
  3194   3955       if (sym->fill != NULL)
  3195   3956         {
  3196   3957   	  if (sym->fill->opacity <= 0.0)
  3197   3958   	      norm_opacity = 0;
  3198   3959   	  else if (sym->fill->opacity >= 1.0)
................................................................................
  3223   3984   		    norm_opacity = 0;
  3224   3985   		else if (opacity >= 255.0)
  3225   3986   		    norm_opacity = 255;
  3226   3987   		else
  3227   3988   		    norm_opacity = opacity;
  3228   3989   	    }
  3229   3990   	  rl2_graph_font_set_halo (font, sym->halo->radius,
  3230         -				   sym->halo->fill->red, sym->halo->fill->green,
         3991  +				   sym->halo->fill->red,
         3992  +				   sym->halo->fill->green,
  3231   3993   				   sym->halo->fill->blue, norm_opacity);
  3232   3994         }
  3233   3995       rl2_graph_set_font (ctx, font);
  3234   3996   
  3235         -    polyg = geom->first_polygon;
  3236         -    while (polyg)
         3997  +    if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT)
         3998  +      {
         3999  +	  /* retrieving eventual Point Placement arguments */
         4000  +	  rl2PrivPointPlacementPtr ptpl =
         4001  +	      (rl2PrivPointPlacementPtr) (sym->label_placement);
         4002  +	  if (ptpl != NULL)
         4003  +	    {
         4004  +		anchor_point_x = ptpl->anchor_point_x;
         4005  +		anchor_point_y = ptpl->anchor_point_y;
         4006  +		displacement_x = ptpl->displacement_x;
         4007  +		displacement_y = ptpl->displacement_y;
         4008  +		rotation = ptpl->rotation;
         4009  +	    }
         4010  +      }
         4011  +    else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE)
         4012  +      {
         4013  +	  /* retrieving eventual Lineo Placement arguments */
         4014  +	  rl2PrivLinePlacementPtr lnpl =
         4015  +	      (rl2PrivLinePlacementPtr) (sym->label_placement);
         4016  +	  if (lnpl != NULL)
         4017  +	    {
         4018  +		perpendicular_offset = lnpl->perpendicular_offset;
         4019  +		is_repeated = lnpl->is_repeated;
         4020  +		initial_gap = lnpl->initial_gap;
         4021  +		gap = lnpl->gap;
         4022  +		is_aligned = lnpl->is_aligned;
         4023  +		generalize_line = lnpl->generalize_line;
         4024  +	    }
         4025  +      }
         4026  +
         4027  +    if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT)
  3237   4028         {
  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;
         4029  +	  /* POINT PLACEMENT */
         4030  +	  rl2Point pt;
  3247   4031   	  double cx;
  3248   4032   	  double cy;
  3249   4033   	  double x;
  3250   4034   	  double y;
  3251         -	  if (!label_get_centroid (handle, polyg, &cx, &cy))
         4035  +
         4036  +	  polyg = geom->first_polygon;
         4037  +	  while (polyg)
  3252   4038   	    {
         4039  +		/* drawing a POLYGON-based text label */
         4040  +		if (!label_get_centroid (handle, polyg, &cx, &cy))
         4041  +		  {
         4042  +		      polyg = polyg->next;
         4043  +		      continue;
         4044  +		  }
         4045  +		pt.x = cx;
         4046  +		pt.y = cy;
         4047  +		if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
         4048  +		  {
         4049  +		      x = (cx - minx) / x_res;
         4050  +		      y = (double) height - ((cy - miny) / y_res);
         4051  +		      rl2_graph_draw_text (ctx, label, x + displacement_x,
         4052  +					   y - displacement_y, rotation,
         4053  +					   anchor_point_x, anchor_point_y);
         4054  +		  }
  3253   4055   		polyg = polyg->next;
  3254         -		continue;
         4056  +	    }
         4057  +
         4058  +	  line = geom->first_linestring;
         4059  +	  while (line)
         4060  +	    {
         4061  +		/* drawing a LINESTRING-based text label */
         4062  +		label_get_midpoint (handle, line, &cx, &cy);
         4063  +		pt.x = cx;
         4064  +		pt.y = cy;
         4065  +		if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
         4066  +		  {
         4067  +		      x = (cx - minx) / x_res;
         4068  +		      y = (double) height - ((cy - miny) / y_res);
         4069  +		      rl2_graph_draw_text (ctx, label, x + displacement_x,
         4070  +					   y - displacement_y, rotation,
         4071  +					   anchor_point_x, anchor_point_y);
         4072  +		  }
         4073  +		line = line->next;
         4074  +	    }
         4075  +
         4076  +	  point = geom->first_point;
         4077  +	  while (point)
         4078  +	    {
         4079  +		/* drawing a POINT-based text label */
         4080  +		if (point_bbox_matches (point, minx, miny, maxx, maxy))
         4081  +		  {
         4082  +		      double x = (point->x - minx) / x_res;
         4083  +		      double y = (double) height - ((point->y - 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  +		point = point->next;
  3255   4089   	    }
  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;
         4090  +
  3265   4091         }
  3266         -
  3267         -    line = geom->first_linestring;
  3268         -    while (line)
         4092  +    else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE)
  3269   4093         {
  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;
         4094  +	  /* LINE PLACEMENT */
         4095  +	  rl2Point pt;
         4096  +	  int ib;
  3279   4097   	  double cx;
  3280   4098   	  double cy;
  3281   4099   	  double x;
  3282   4100   	  double y;
  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))
         4101  +	  double generalize_factor = 8.0;
         4102  +
         4103  +	  line = geom->first_linestring;
         4104  +	  while (line)
  3287   4105   	    {
         4106  +		/* drawing a LINESTRING-based text label */
         4107  +		if (!is_aligned)
         4108  +		  {
         4109  +		      /* horizontal label aligned to center point */
         4110  +		      label_get_midpoint (handle, line, &cx, &cy);
         4111  +		      pt.x = cx;
         4112  +		      pt.y = cy;
         4113  +		      if (point_bbox_matches (&pt, minx, miny, maxx, maxy))
         4114  +			{
         4115  +			    x = (cx - minx) / x_res;
         4116  +			    y = (double) height - ((cy - miny) / y_res);
         4117  +			    rl2_graph_draw_text (ctx, label, x, y, 0.0, 0.5,
         4118  +						 0.5);
         4119  +			}
         4120  +		  }
         4121  +		else
         4122  +		  {
         4123  +		      /* label is warped along the line */
         4124  +		      double *x_array = NULL;
         4125  +		      double *y_array = NULL;
         4126  +		      int points;
         4127  +		      if (linestring_bbox_matches
         4128  +			  (line, minx, miny, maxx, maxy))
         4129  +			{
         4130  +			    create_line_array_from_linestring (handle, line,
         4131  +							       perpendicular_offset,
         4132  +							       &points,
         4133  +							       &x_array,
         4134  +							       &y_array,
         4135  +							       generalize_line,
         4136  +							       generalize_factor,
         4137  +							       height, minx,
         4138  +							       miny, x_res,
         4139  +							       y_res);
         4140  +			    if (x_array != NULL && y_array != NULL)
         4141  +				rl2_graph_draw_warped_text (handle, ctx, label,
         4142  +							    points, x_array,
         4143  +							    y_array,
         4144  +							    initial_gap, gap,
         4145  +							    is_repeated);
         4146  +			    if (x_array)
         4147  +				free (x_array);
         4148  +			    if (y_array)
         4149  +				free (y_array);
         4150  +			}
         4151  +		  }
  3288   4152   		line = line->next;
  3289         -		continue;
  3290   4153   	    }
  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         -      }
  3299         -
  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;
         4154  +
         4155  +	  polyg = geom->first_polygon;
         4156  +	  while (polyg)
         4157  +	    {
         4158  +		/* drawing a POLYGON-based text label */
         4159  +		rl2RingPtr ring = polyg->exterior;
         4160  +		/* exterior border */
         4161  +		if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
         4162  +		  {
         4163  +		      if (!is_aligned)
         4164  +			{
         4165  +			    /* horizontal label aligned to Ring's center point */
         4166  +			    label_get_ring_midpoint (handle, ring, &cx, &cy);
         4167  +			    pt.x = cx;
         4168  +			    pt.y = cy;
         4169  +			    if (point_bbox_matches
         4170  +				(&pt, minx, miny, maxx, maxy))
         4171  +			      {
         4172  +				  x = (cx - minx) / x_res;
         4173  +				  y = (double) height - ((cy - miny) / y_res);
         4174  +				  rl2_graph_draw_text (ctx, label, x, y, 0.0,
         4175  +						       0.5, 0.5);
         4176  +			      }
         4177  +			}
         4178  +		      else
         4179  +			{
         4180  +			    /* label is warped along the Ring */
         4181  +			    double *x_array = NULL;
         4182  +			    double *y_array = NULL;
         4183  +			    int points;
         4184  +			    if (ring_bbox_matches
         4185  +				(ring, minx, miny, maxx, maxy))
         4186  +			      {
         4187  +				  create_line_array_from_ring (handle, ring,
         4188  +							       perpendicular_offset,
         4189  +							       &points,
         4190  +							       &x_array,
         4191  +							       &y_array,
         4192  +							       generalize_line,
         4193  +							       generalize_factor,
         4194  +							       height, minx,
         4195  +							       miny, x_res,
         4196  +							       y_res);
         4197  +				  if (x_array != NULL && y_array != NULL)
         4198  +				    {
         4199  +					rl2_graph_draw_warped_text (handle, ctx,
         4200  +								    label,
         4201  +								    points,
         4202  +								    x_array,
         4203  +								    y_array,
         4204  +								    initial_gap,
         4205  +								    gap,
         4206  +								    is_repeated);
         4207  +				    }
         4208  +				  if (x_array)
         4209  +				      free (x_array);
         4210  +				  if (y_array)
         4211  +				      free (y_array);
         4212  +			      }
         4213  +			}
         4214  +		  }
         4215  +		else
         4216  +		  {
         4217  +		      /* if the exterior ring is invisible we'll ignore all internal rings */
         4218  +		      polyg = polyg->next;
         4219  +		      continue;
         4220  +		  }
         4221  +		for (ib = 0; ib < polyg->num_interiors; ib++)
         4222  +		  {
         4223  +		      /* interior borders */
         4224  +		      ring = polyg->interiors + ib;
         4225  +		      if (ring_bbox_matches (ring, minx, miny, maxx, maxy))
         4226  +			{
         4227  +			    if (!is_aligned)
         4228  +			      {
         4229  +				  /* horizontal label aligned to Ring's center point */
         4230  +				  label_get_ring_midpoint (handle, ring, &cx,
         4231  +							   &cy);
         4232  +				  pt.x = cx;
         4233  +				  pt.y = cy;
         4234  +				  if (point_bbox_matches
         4235  +				      (&pt, minx, miny, maxx, maxy))
         4236  +				    {
         4237  +					x = (cx - minx) / x_res;
         4238  +					y = (double) height -
         4239  +					    ((cy - miny) / y_res);
         4240  +					rl2_graph_draw_text (ctx, label, x, y,
         4241  +							     0.0, 0.5, 0.5);
         4242  +				    }
         4243  +			      }
         4244  +			    else
         4245  +			      {
         4246  +				  /* label is warped along the Ring */
         4247  +				  double *x_array = NULL;
         4248  +				  double *y_array = NULL;
         4249  +				  int points;
         4250  +				  if (ring_bbox_matches
         4251  +				      (ring, minx, miny, maxx, maxy))
         4252  +				    {
         4253  +					create_line_array_from_ring (handle,
         4254  +								     ring,
         4255  +								     perpendicular_offset,
         4256  +								     &points,
         4257  +								     &x_array,
         4258  +								     &y_array,
         4259  +								     generalize_line,
         4260  +								     generalize_factor,
         4261  +								     height,
         4262  +								     minx, miny,
         4263  +								     x_res,
         4264  +								     y_res);
         4265  +					if (x_array != NULL && y_array != NULL)
         4266  +					    rl2_graph_draw_warped_text (handle,
         4267  +									ctx,
         4268  +									label,
         4269  +									points,
         4270  +									x_array,
         4271  +									y_array,
         4272  +									initial_gap,
         4273  +									gap,
         4274  +									is_repeated);
         4275  +					if (x_array)
         4276  +					    free (x_array);
         4277  +					if (y_array)
         4278  +					    free (y_array);
         4279  +				    }
         4280  +			      }
         4281  +			}
         4282  +		  }
         4283  +		polyg = polyg->next;
         4284  +	    }
  3321   4285         }
  3322   4286   
  3323   4287   /* final cleanup - relasing resources */
  3324   4288     stop:
  3325   4289       if (dummy != NULL)
  3326   4290   	sqlite3_free (dummy);
  3327   4291       if (font != NULL)
  3328   4292   	rl2_graph_destroy_font (font);
  3329   4293   }
  3330   4294   
  3331   4295   RL2_PRIVATE void
  3332         -rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle,
         4296  +rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle, const void *priv_data,
  3333   4297   			 rl2VectorSymbolizerPtr symbolizer, int height,
  3334         -			 double minx, double miny, double x_res, double y_res,
  3335         -			 rl2GeometryPtr geom, rl2VariantArrayPtr variant)
         4298  +			 double minx, double miny, double maxx, double maxy,
         4299  +			 double x_res, double y_res, rl2GeometryPtr geom,
         4300  +			 rl2VariantArrayPtr variant)
  3336   4301   {
  3337   4302   /* drawing a vector feature on the current canvass */
  3338   4303       rl2PrivVectorSymbolizerItemPtr item;
  3339   4304       rl2GraphicsContextPtr ctx = (rl2GraphicsContextPtr) p_ctx;
  3340   4305       rl2PrivVectorSymbolizerPtr sym = (rl2PrivVectorSymbolizerPtr) symbolizer;
  3341   4306       rl2PrivVectorSymbolizerPtr default_symbolizer = NULL;
  3342   4307   
................................................................................
  3419   4384   	      default_symbolizer->last->next = item;
  3420   4385   	  default_symbolizer->last = item;
  3421   4386   	  sym = default_symbolizer;
  3422   4387         }
  3423   4388   
  3424   4389   /* we'll render all geometries first */
  3425   4390       if (geom->first_polygon != NULL)
  3426         -	draw_polygons (ctx, handle, sym, height, minx, miny, x_res, y_res,
  3427         -		       geom);
         4391  +	draw_polygons (ctx, handle, sym, height, minx, miny, maxx, maxy,
         4392  +		       x_res, y_res, geom);
  3428   4393       if (geom->first_linestring != NULL)
  3429         -	draw_lines (ctx, handle, sym, height, minx, miny, x_res, y_res, geom);
         4394  +	draw_lines (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
         4395  +		    y_res, geom);
  3430   4396       if (geom->first_point != NULL)
  3431         -	draw_points (ctx, handle, sym, height, minx, miny, x_res, y_res, geom);
         4397  +	draw_points (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
         4398  +		     y_res, geom);
  3432   4399   
  3433   4400       if (sym != NULL)
  3434   4401         {
  3435   4402   	  /* then we'll render any eventual TextSymbolizer */
  3436   4403   	  item = sym->first;
  3437   4404   	  while (item != NULL)
  3438   4405   	    {
................................................................................
  3442   4409   		      rl2PrivTextSymbolizerPtr text =
  3443   4410   			  (rl2PrivTextSymbolizerPtr) (item->symbolizer);
  3444   4411   		      if (text->label != NULL)
  3445   4412   			{
  3446   4413   			    int v;
  3447   4414   			    rl2PrivVariantArrayPtr var =
  3448   4415   				(rl2PrivVariantArrayPtr) variant;
  3449         -			    for (v = 0; v < var->count; v++)
         4416  +			    if (var != NULL)
  3450   4417   			      {
  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);
         4418  +				  for (v = 0; v < var->count; v++)
         4419  +				    {
         4420  +					rl2PrivVariantValuePtr val =
         4421  +					    *(var->array + v);
         4422  +					if (val == NULL)
         4423  +					    continue;
         4424  +					if (val->column_name == NULL)
         4425  +					    continue;
         4426  +					if (strcasecmp
         4427  +					    (text->label,
         4428  +					     val->column_name) != 0)
         4429  +					    continue;
         4430  +					draw_labels (ctx, handle, priv_data,
         4431  +						     text, height, minx, miny,
         4432  +						     maxx, maxy, x_res, y_res,
         4433  +						     geom, val);
         4434  +				    }
  3462   4435   			      }
  3463   4436   			}
  3464   4437   		  }
  3465   4438   		item = item->next;
  3466   4439   	    }
  3467   4440         }
  3468   4441   
  3469   4442       if (default_symbolizer != NULL)
  3470   4443   	rl2_destroy_vector_symbolizer (default_symbolizer);
  3471   4444   }
         4445  +
         4446  +RL2_PRIVATE int
         4447  +rl2_aux_default_image (unsigned int width, unsigned int height,
         4448  +		       unsigned char red, unsigned char green,
         4449  +		       unsigned char blue, int format, int transparent,
         4450  +		       int quality, unsigned char **ximage, int *ximage_sz)
         4451  +{
         4452  +/* creating a default image */
         4453  +    unsigned int x;
         4454  +    unsigned int y;
         4455  +    unsigned char *pixels = malloc (width * height * 3);
         4456  +    unsigned char *po = pixels;
         4457  +    unsigned char *mask = NULL;
         4458  +    unsigned char *pm;
         4459  +
         4460  +    *ximage = NULL;
         4461  +    *ximage_sz = 0;
         4462  +    if (pixels == NULL)
         4463  +	return 0;
         4464  +
         4465  +    mask = malloc (width * height);
         4466  +    if (mask == NULL)
         4467  +	goto error;
         4468  +    pm = mask;
         4469  +
         4470  +/* priming the image buffer to background color */
         4471  +    for (y = 0; y < height; y++)
         4472  +      {
         4473  +	  for (x = 0; x < width; x++)
         4474  +	    {
         4475  +		*po++ = red;
         4476  +		*po++ = green;
         4477  +		*po++ = blue;
         4478  +		if (mask != NULL)
         4479  +		    *pm++ = 0;
         4480  +	    }
         4481  +      }
         4482  +
         4483  +    if (format == RL2_OUTPUT_FORMAT_PNG)
         4484  +      {
         4485  +	  if (transparent)
         4486  +	    {
         4487  +		if (rl2_rgb_alpha_to_png
         4488  +		    (width, height, pixels, mask, ximage, ximage_sz,
         4489  +		     1.0) != RL2_OK)
         4490  +		    goto error;
         4491  +	    }
         4492  +	  else
         4493  +	    {
         4494  +		if (rl2_rgb_to_png (width, height, pixels, ximage, ximage_sz)
         4495  +		    != RL2_OK)
         4496  +		    goto error;
         4497  +	    }
         4498  +      }
         4499  +    else if (format == RL2_OUTPUT_FORMAT_JPEG)
         4500  +      {
         4501  +	  if (rl2_rgb_to_jpeg
         4502  +	      (width, height, pixels, quality, ximage, ximage_sz) != RL2_OK)
         4503  +	      goto error;
         4504  +      }
         4505  +    else if (format == RL2_OUTPUT_FORMAT_TIFF)
         4506  +      {
         4507  +	  if (rl2_rgb_to_tiff (width, height, pixels, ximage, ximage_sz) !=
         4508  +	      RL2_OK)
         4509  +	      goto error;
         4510  +      }
         4511  +    else
         4512  +	goto error;
         4513  +    free (pixels);
         4514  +    if (mask != NULL)
         4515  +	free (mask);
         4516  +    return 1;
         4517  +
         4518  +  error:
         4519  +    if (pixels != NULL)
         4520  +	free (pixels);
         4521  +    if (mask != NULL)
         4522  +	free (mask);
         4523  +    return 0;
         4524  +}

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
    59     62   #include <CharLS/interface.h>
           63  +#endif
    60     64   
    61     65   static int
    62     66   endianness ()
    63     67   {
    64     68   /* checking if target CPU is a little-endian one */
    65     69       union cvt
    66     70       {
................................................................................
   278    282   		      p_out += num_bands;
   279    283   		  }
   280    284   	    }
   281    285         }
   282    286   }
   283    287   
   284    288   static void
   285         -from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width, int height,
   286         -		   int num_bands)
          289  +from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width,
          290  +		   int height, int num_bands)
   287    291   {
   288    292   /* rearranging pixels from separate LINE components - UINT 8 */
   289    293       int x;
   290    294       int y;
   291    295       int ib;
   292    296       unsigned char *p_in = in;
   293    297   
................................................................................
   449    453         {
   450    454   	  if (*sample_type == RL2_SAMPLE_UINT16)
   451    455   	      from_ilv_buffer_16 ((unsigned short *) (*pixels),
   452    456   				  (unsigned short *) out_buffer, *width,
   453    457   				  *height, *num_bands);
   454    458   	  else
   455    459   	      from_ilv_buffer_8 ((unsigned char *) (*pixels),
   456         -				 (unsigned char *) out_buffer, *width, *height,
   457         -				 *num_bands);
          460  +				 (unsigned char *) out_buffer, *width,
          461  +				 *height, *num_bands);
   458    462         }
   459    463       free (out_buffer);
   460    464       return RL2_OK;
   461    465   
   462    466     error:
   463    467       if (out_buffer != NULL)
   464    468   	free (out_buffer);
   465    469       return RL2_ERROR;
   466    470   }
   467    471   
   468    472   #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, unsigned char **blob_odd,
  2026         -		   int *blob_odd_sz, unsigned char **blob_even,
  2027         -		   int *blob_even_sz, int quality, int little_endian)
         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)
  2028   2029   {
  2029   2030   /* encoding a Raster into the internal RL2 binary format */
  2030   2031       rl2PrivRasterPtr raster = (rl2PrivRasterPtr) rst;
  2031   2032       int odd_rows;
  2032   2033       unsigned char *pixels_odd = NULL;
  2033   2034       int size_odd;
  2034   2035       int even_rows = 0;
................................................................................
  2122   2123   	|| compression == RL2_COMPRESSION_LZMA_NO)
  2123   2124         {
  2124   2125   	  /* preparing the pixels buffers */
  2125   2126   	  if (raster->sampleType == RL2_SAMPLE_1_BIT)
  2126   2127   	    {
  2127   2128   		/* packing 1-BIT data */
  2128   2129   		if (!pack_1bit_rows
  2129         -		    (raster, raster->rasterBuffer, &row_stride_odd, &pixels_odd,
  2130         -		     &size_odd))
         2130  +		    (raster, raster->rasterBuffer, &row_stride_odd,
         2131  +		     &pixels_odd, &size_odd))
  2131   2132   		    return RL2_ERROR;
  2132   2133   		odd_rows = raster->height;
  2133   2134   	    }
  2134   2135   	  else if (raster->sampleType == RL2_SAMPLE_2_BIT)
  2135   2136   	    {
  2136   2137   		/* packing 2-BIT data */
  2137   2138   		if (!pack_2bit_rows
................................................................................
  2147   2148   		    return RL2_ERROR;
  2148   2149   		odd_rows = raster->height;
  2149   2150   	    }
  2150   2151   	  else
  2151   2152   	    {
  2152   2153   		/* Odd/Even raster */
  2153   2154   		if (!odd_even_rows
  2154         -		    (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd,
  2155         -		     &even_rows, &row_stride_even, &pixels_even, &size_even,
  2156         -		     little_endian))
         2155  +		    (raster, &odd_rows, &row_stride_odd, &pixels_odd,
         2156  +		     &size_odd, &even_rows, &row_stride_even, &pixels_even,
         2157  +		     &size_even, little_endian))
  2157   2158   		    return RL2_ERROR;
  2158   2159   	    }
  2159   2160         }
  2160   2161       else if (compression == RL2_COMPRESSION_PNG)
  2161   2162         {
  2162   2163   	  if (raster->sampleType == RL2_SAMPLE_1_BIT
  2163   2164   	      || raster->sampleType == RL2_SAMPLE_2_BIT
................................................................................
  2165   2166   	    {
  2166   2167   		/* no special action is required */
  2167   2168   	    }
  2168   2169   	  else
  2169   2170   	    {
  2170   2171   		/* Odd/Even raster */
  2171   2172   		if (!odd_even_rows
  2172         -		    (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd,
  2173         -		     &even_rows, &row_stride_even, &pixels_even, &size_even,
  2174         -		     little_endian))
         2173  +		    (raster, &odd_rows, &row_stride_odd, &pixels_odd,
         2174  +		     &size_odd, &even_rows, &row_stride_even, &pixels_even,
         2175  +		     &size_even, little_endian))
  2175   2176   		    return RL2_ERROR;
  2176   2177   	    }
  2177   2178         }
  2178   2179       else if (compression == RL2_COMPRESSION_CHARLS)
  2179   2180         {
  2180   2181   	  /* Odd/Even raster */
  2181   2182   	  if (!odd_even_rows
................................................................................
  2467   2468   	  goto error;
  2468   2469   #endif /* end WebP conditional */
  2469   2470         }
  2470   2471       else if (compression == RL2_COMPRESSION_LOSSY_WEBP)
  2471   2472         {
  2472   2473   #ifndef OMIT_WEBP		/* only if WebP is enabled */
  2473   2474   	  /* compressing as lossy WEBP */
  2474         -	  if (rl2_raster_to_lossy_webp (rst, &compr_data, &compressed, quality)
  2475         -	      == RL2_OK)
         2475  +	  if (rl2_raster_to_lossy_webp
         2476  +	      (rst, &compr_data, &compressed, quality) == RL2_OK)
  2476   2477   	    {
  2477   2478   		/* ok, lossy WEBP compression was successful */
  2478   2479   		uncompressed = raster->width * raster->height * raster->nBands;
  2479   2480   		to_clean1 = compr_data;
  2480   2481   	    }
  2481   2482   	  else
  2482   2483   	      goto error;
................................................................................
  2587   2588   	  else
  2588   2589   	      goto error;
  2589   2590         }
  2590   2591       else if (compression == RL2_COMPRESSION_LOSSLESS_JP2)
  2591   2592         {
  2592   2593   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
  2593   2594   	  /* compressing as lossless Jpeg2000 */
  2594         -	  if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed) ==
  2595         -	      RL2_OK)
         2595  +	  if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed)
         2596  +	      == RL2_OK)
  2596   2597   	    {
  2597   2598   		/* ok, lossless Jpeg2000 compression was successful */
  2598   2599   		uncompressed = raster->width * raster->height * raster->nBands;
  2599   2600   		to_clean1 = compr_data;
  2600   2601   	    }
  2601   2602   	  else
  2602   2603   	      goto error;
................................................................................
  2719   2720   		      compressed = (int) zLen;
  2720   2721   		      compr_data = zip_buf;
  2721   2722   		      to_clean2 = zip_buf;
  2722   2723   		  }
  2723   2724   		else if (ret == Z_BUF_ERROR)
  2724   2725   		  {
  2725   2726   		      /* ZIP compression actually causes inflation: saving uncompressed data */
  2726         -		      if (rl2_delta_decode (pixels_even, size_even, delta_dist)
  2727         -			  != RL2_OK)
         2727  +		      if (rl2_delta_decode
         2728  +			  (pixels_even, size_even, delta_dist) != RL2_OK)
  2728   2729   			  goto error;
  2729   2730   		      uncompressed = size_even;
  2730   2731   		      compressed = size_even;
  2731   2732   		      compr_data = pixels_even;
  2732   2733   		      free (zip_buf);
  2733   2734   		      zip_buf = NULL;
  2734   2735   		  }
................................................................................
  3129   3130       *xnum_bands = num_bands;
  3130   3131       *xcompression = compression;
  3131   3132       *xcrc = crc;
  3132   3133       return 1;
  3133   3134   }
  3134   3135   
  3135   3136   static int
  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)
         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)
  3140   3142   {
  3141   3143   /* checking the EvenBlock for validity */
  3142   3144       const unsigned char *ptr;
  3143   3145       unsigned short width;
  3144   3146       unsigned short height;
  3145   3147       unsigned char sample_type;
  3146   3148       unsigned char pixel_type;
................................................................................
  3214   3216   check_scale (int scale, unsigned char sample_type, unsigned char compression,
  3215   3217   	     const unsigned char *blob_even)
  3216   3218   {
  3217   3219   /* checking if the encoded raster could be decoded at given scale */
  3218   3220       switch (scale)
  3219   3221         {
  3220   3222         case RL2_SCALE_1:
  3221         -	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
         3223  +	  if (sample_type == RL2_SAMPLE_1_BIT
         3224  +	      || sample_type == RL2_SAMPLE_2_BIT
  3222   3225   	      || sample_type == RL2_SAMPLE_4_BIT)
  3223   3226   	      ;
  3224   3227   	  else if (compression == RL2_COMPRESSION_JPEG
  3225   3228   		   || compression == RL2_COMPRESSION_LOSSY_WEBP
  3226   3229   		   || compression == RL2_COMPRESSION_LOSSLESS_WEBP
  3227   3230   		   || compression == RL2_COMPRESSION_CCITTFAX4
  3228   3231   		   || compression == RL2_COMPRESSION_LOSSY_JP2
................................................................................
  4190   4193   		else
  4191   4194   		    *p_out++ = *p_even++;
  4192   4195   	    }
  4193   4196         }
  4194   4197   }
  4195   4198   
  4196   4199   static void
  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)
         4200  +do_copy_uint32 (int swap, const unsigned int *p_odd,
         4201  +		const unsigned int *p_even, unsigned int *buf,
         4202  +		unsigned short width, unsigned short odd_rows,
         4203  +		unsigned short even_rows)
  4200   4204   {
  4201   4205   /* reassembling an UINT32 raster - scale 1:1 */
  4202   4206       int row;
  4203   4207       int col;
  4204   4208       unsigned int *p_out;
  4205   4209   
  4206   4210       p_out = buf;
................................................................................
  4878   4882       return 1;
  4879   4883   }
  4880   4884   
  4881   4885   RL2_DECLARE int
  4882   4886   rl2_is_valid_dbms_raster_tile (unsigned short level, unsigned int tile_width,
  4883   4887   			       unsigned int tile_height,
  4884   4888   			       const unsigned char *blob_odd, int blob_odd_sz,
  4885         -			       const unsigned char *blob_even, int blob_even_sz,
  4886         -			       unsigned char sample_type,
         4889  +			       const unsigned char *blob_even,
         4890  +			       int blob_even_sz, unsigned char sample_type,
  4887   4891   			       unsigned char pixel_type,
  4888   4892   			       unsigned char num_bands,
  4889   4893   			       unsigned char compression)
  4890   4894   {
  4891   4895   /* testing a serialized Raster Tile object for validity */
  4892   4896       unsigned int width;
  4893   4897       unsigned int height;
................................................................................
  4937   4941   	    {
  4938   4942   		/* small-PALETTE: expecting an RGB/PNG Pyramid tile */
  4939   4943   		if (xsample_type == RL2_SAMPLE_UINT8
  4940   4944   		    && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3
  4941   4945   		    && xcompression == RL2_COMPRESSION_PNG)
  4942   4946   		    return RL2_OK;
  4943   4947   	    }
  4944         -	  if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE
  4945         -	      && num_bands == 1)
         4948  +	  if (sample_type == RL2_SAMPLE_UINT8
         4949  +	      && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1)
  4946   4950   	    {
  4947   4951   		/* PALETTE 8bits: expecting an RGB/PNG Pyramid tile */
  4948   4952   		if (xsample_type == RL2_SAMPLE_UINT8
  4949   4953   		    && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3
  4950   4954   		    && xcompression == RL2_COMPRESSION_PNG)
  4951   4955   		    return RL2_OK;
  4952   4956   	    }
................................................................................
  5010   5014       if (!check_blob_odd
  5011   5015   	(blob_odd, blob_odd_sz, &width, &height, &sample_type, &pixel_type,
  5012   5016   	 &num_bands, &compression, &crc))
  5013   5017   	return NULL;
  5014   5018       if (blob_even != NULL)
  5015   5019         {
  5016   5020   	  if (!check_blob_even
  5017         -	      (blob_even, blob_even_sz, width, height, sample_type, pixel_type,
  5018         -	       num_bands, compression, crc))
         5021  +	      (blob_even, blob_even_sz, width, height, sample_type,
         5022  +	       pixel_type, num_bands, compression, crc))
  5019   5023   	      return NULL;
  5020   5024         }
  5021   5025       if (!check_scale (scale, sample_type, compression, blob_even))
  5022   5026   	return NULL;
  5023   5027   
  5024   5028       switch (pixel_type)
  5025   5029         {
................................................................................
  5146   5150   		const Bytef *in = pixels_even;
  5147   5151   		even_data = malloc (uncompressed_even);
  5148   5152   		if (even_data == NULL)
  5149   5153   		    goto error;
  5150   5154   		if (uncompress (even_data, &refLen, in, compressed_even) !=
  5151   5155   		    Z_OK)
  5152   5156   		    goto error;
  5153         -		if (rl2_delta_decode (even_data, uncompressed_even, delta_dist)
  5154         -		    != RL2_OK)
         5157  +		if (rl2_delta_decode
         5158  +		    (even_data, uncompressed_even, delta_dist) != RL2_OK)
  5155   5159   		    goto error;
  5156   5160   		pixels_even = even_data;
  5157   5161   	    }
  5158   5162         }
  5159   5163       if (compression == RL2_COMPRESSION_DEFLATE_NO
  5160   5164   	&& uncompressed_odd != compressed_odd)
  5161   5165         {
................................................................................
  5304   5308   	  int ret = RL2_ERROR;
  5305   5309   	  unsigned char pix_typ;
  5306   5310   	  switch (scale)
  5307   5311   	    {
  5308   5312   	    case RL2_SCALE_1:
  5309   5313   		ret =
  5310   5314   		    rl2_decode_jpeg_scaled (1, pixels_odd, compressed_odd,
  5311         -					    &width, &height, &pix_typ, &pixels,
  5312         -					    &pixels_sz);
         5315  +					    &width, &height, &pix_typ,
         5316  +					    &pixels, &pixels_sz);
  5313   5317   		break;
  5314   5318   	    case RL2_SCALE_2:
  5315   5319   		ret =
  5316   5320   		    rl2_decode_jpeg_scaled (2, pixels_odd, compressed_odd,
  5317         -					    &width, &height, &pix_typ, &pixels,
  5318         -					    &pixels_sz);
         5321  +					    &width, &height, &pix_typ,
         5322  +					    &pixels, &pixels_sz);
  5319   5323   		break;
  5320   5324   	    case RL2_SCALE_4:
  5321   5325   		ret =
  5322   5326   		    rl2_decode_jpeg_scaled (4, pixels_odd, compressed_odd,
  5323         -					    &width, &height, &pix_typ, &pixels,
  5324         -					    &pixels_sz);
         5327  +					    &width, &height, &pix_typ,
         5328  +					    &pixels, &pixels_sz);
  5325   5329   		break;
  5326   5330   	    case RL2_SCALE_8:
  5327   5331   		ret =
  5328   5332   		    rl2_decode_jpeg_scaled (8, pixels_odd, compressed_odd,
  5329         -					    &width, &height, &pix_typ, &pixels,
  5330         -					    &pixels_sz);
         5333  +					    &width, &height, &pix_typ,
         5334  +					    &pixels, &pixels_sz);
  5331   5335   		break;
  5332   5336   	    };
  5333   5337   	  if (ret != RL2_OK)
  5334   5338   	      goto error;
  5335   5339   	  goto done;
  5336   5340         }
  5337   5341       if (compression == RL2_COMPRESSION_LOSSY_WEBP
................................................................................
  5380   5384   	  goto error;
  5381   5385   #endif /* end WebP conditional */
  5382   5386         }
  5383   5387       if (compression == RL2_COMPRESSION_PNG)
  5384   5388         {
  5385   5389   	  /* decompressing from PNG */
  5386   5390   	  int ret;
  5387         -	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
         5391  +	  if (sample_type == RL2_SAMPLE_1_BIT
         5392  +	      || sample_type == RL2_SAMPLE_2_BIT
  5388   5393   	      || sample_type == RL2_SAMPLE_4_BIT)
  5389   5394   	    {
  5390   5395   		/* Palette or Grayscale - 1,2 or 4 bit isn't scalable */
  5391   5396   		if (scale != RL2_SCALE_1)
  5392   5397   		    goto error;
  5393   5398   		ret =
  5394   5399   		    rl2_decode_png (pixels_odd, compressed_odd,
  5395         -				    &width, &height, &sample_type, &pixel_type,
  5396         -				    &num_bands, &pixels, &pixels_sz, &mask,
  5397         -				    &mask_sz, &palette, 0);
         5400  +				    &width, &height, &sample_type,
         5401  +				    &pixel_type, &num_bands, &pixels,
         5402  +				    &pixels_sz, &mask, &mask_sz, &palette, 0);
  5398   5403   		if (ret != RL2_OK)
  5399   5404   		    goto error;
  5400   5405   		goto done;
  5401   5406   	    }
  5402   5407   	  else
  5403   5408   	    {
  5404   5409   		ret = rl2_decode_png (pixels_odd, compressed_odd,
................................................................................
  5409   5414   		if (ret != RL2_OK)
  5410   5415   		    goto error;
  5411   5416   		pixels_odd = odd_data;
  5412   5417   		if (scale == RL2_SCALE_1)
  5413   5418   		  {
  5414   5419   		      ret = rl2_decode_png (pixels_even, compressed_even,
  5415   5420   					    &width, &even_rows, &sample_type,
  5416         -					    &pixel_type, &num_bands, &even_data,
  5417         -					    &pixels_sz, &even_mask,
  5418         -					    &even_mask_sz, &palette2, 0);
         5421  +					    &pixel_type, &num_bands,
         5422  +					    &even_data, &pixels_sz,
         5423  +					    &even_mask, &even_mask_sz,
         5424  +					    &palette2, 0);
  5419   5425   		      if (ret != RL2_OK)
  5420   5426   			  goto error;
  5421   5427   		      rl2_destroy_palette (palette2);
  5422   5428   		  }
  5423   5429   		pixels_even = even_data;
  5424   5430   		if (odd_mask != NULL)
  5425   5431   		    free (odd_mask);
................................................................................
  5482   5488   	  int ret = RL2_ERROR;
  5483   5489   	  switch (scale)
  5484   5490   	    {
  5485   5491   	    case RL2_SCALE_1:
  5486   5492   		ret =
  5487   5493   		    rl2_decode_jpeg2000_scaled (1, pixels_odd, compressed_odd,
  5488   5494   						&width, &height, sample_type,
  5489         -						pixel_type, num_bands, &pixels,
  5490         -						&pixels_sz);
         5495  +						pixel_type, num_bands,
         5496  +						&pixels, &pixels_sz);
  5491   5497   		break;
  5492   5498   	    case RL2_SCALE_2:
  5493   5499   		ret =
  5494   5500   		    rl2_decode_jpeg2000_scaled (2, pixels_odd, compressed_odd,
  5495   5501   						&width, &height, sample_type,
  5496         -						pixel_type, num_bands, &pixels,
  5497         -						&pixels_sz);
         5502  +						pixel_type, num_bands,
         5503  +						&pixels, &pixels_sz);
  5498   5504   		break;
  5499   5505   	    case RL2_SCALE_4:
  5500   5506   		ret =
  5501   5507   		    rl2_decode_jpeg2000_scaled (4, pixels_odd, compressed_odd,
  5502   5508   						&width, &height, sample_type,
  5503         -						pixel_type, num_bands, &pixels,
  5504         -						&pixels_sz);
         5509  +						pixel_type, num_bands,
         5510  +						&pixels, &pixels_sz);
  5505   5511   		break;
  5506   5512   	    case RL2_SCALE_8:
  5507   5513   		ret =
  5508   5514   		    rl2_decode_jpeg2000_scaled (8, pixels_odd, compressed_odd,
  5509   5515   						&width, &height, sample_type,
  5510         -						pixel_type, num_bands, &pixels,
  5511         -						&pixels_sz);
         5516  +						pixel_type, num_bands,
         5517  +						&pixels, &pixels_sz);
  5512   5518   		break;
  5513   5519   	    };
  5514   5520   	  if (ret != RL2_OK)
  5515   5521   	      goto error;
  5516   5522   	  goto done;
  5517   5523   #else /* OpenJpeg is disabled */
  5518   5524   	  fprintf (stderr,
................................................................................
  5558   5564         {
  5559   5565   	  /* unpacking the mask */
  5560   5566   	  unsigned char *mask_pix;
  5561   5567   	  int mask_pix_sz;
  5562   5568   	  if (uncompressed_mask != (mask_width * mask_height))
  5563   5569   	      goto error;
  5564   5570   	  if (!unpack_rle
  5565         -	      (mask_width, mask_height, pixels_mask, compressed_mask, &mask_pix,
  5566         -	       &mask_pix_sz))
         5571  +	      (mask_width, mask_height, pixels_mask, compressed_mask,
         5572  +	       &mask_pix, &mask_pix_sz))
  5567   5573   	      goto error;
  5568   5574   	  if (!rescale_mask
  5569   5575   	      (scale, &mask_width, &mask_height, mask_pix, &mask, &mask_sz))
  5570   5576   	    {
  5571   5577   		free (mask_pix);
  5572   5578   		goto error;
  5573   5579   	    }
................................................................................
  5883   5889         {
  5884   5890   	  ignore_no_data = 0;
  5885   5891   	  if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands)
  5886   5892   	      != RL2_OK)
  5887   5893   	      ignore_no_data = 1;
  5888   5894   	  if (nbands != num_bands)
  5889   5895   	      ignore_no_data = 1;
  5890         -	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
         5896  +	  if (sample_type == RL2_SAMPLE_1_BIT
         5897  +	      || sample_type == RL2_SAMPLE_2_BIT
  5891   5898   	      || sample_type == RL2_SAMPLE_4_BIT
  5892   5899   	      || sample_type == RL2_SAMPLE_UINT8)
  5893   5900   	      ;
  5894   5901   	  else
  5895   5902   	      ignore_no_data = 1;
  5896   5903         }
  5897   5904   
................................................................................
  6493   6500   	    }
  6494   6501         }
  6495   6502       compute_int32_histogram (width, height, pixels, mask, st, no_data);
  6496   6503   }
  6497   6504   
  6498   6505   static void
  6499   6506   compute_uint32_histogram (unsigned short width, unsigned short height,
  6500         -			  const unsigned int *pixels, const unsigned char *mask,
         6507  +			  const unsigned int *pixels,
         6508  +			  const unsigned char *mask,
  6501   6509   			  rl2PrivRasterStatisticsPtr st, rl2PixelPtr no_data)
  6502   6510   {
  6503   6511   /* computing INT16 tile histogram */
  6504   6512       int x;
  6505   6513       int y;
  6506   6514       const unsigned int *p_in = pixels;
  6507   6515       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, int blob_no_data_sz,
    83         -			      int strict_resolution, int mixed_resolutions,
    84         -			      int section_paths, int section_md5,
    85         -			      int section_summary)
           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)
    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", xxcoverage,
   284         -		   sql_err);
          283  +	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n",
          284  +		   xxcoverage, 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", xxcoverage,
   344         -		   sql_err);
          343  +	  fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n",
          344  +		   xxcoverage, 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, sqlite3_int64 section_id,
         1251  +				       int by_section,
         1252  +				       sqlite3_int64 section_id,
  1252   1253   				       double *x_res, double *y_res)
  1253   1254   {
  1254   1255   /* resolving the Base Resolution */
  1255   1256       int ret;
  1256   1257       char *sql;
  1257   1258       double xres;
  1258   1259       double yres;
................................................................................
  1439   1440       sqlite3_stmt *stmt = NULL;
  1440   1441   
  1441   1442       *duplicate = 0;
  1442   1443       table = sqlite3_mprintf ("%s_sections", coverage);
  1443   1444       xtable = rl2_double_quoted_sql (table);
  1444   1445       sqlite3_free (table);
  1445   1446       sql =
  1446         -	sqlite3_mprintf ("SELECT section_id FROM \"%s\" WHERE section_name = ?",
  1447         -			 xtable);
         1447  +	sqlite3_mprintf
         1448  +	("SELECT section_id FROM \"%s\" WHERE section_name = ?", xtable);
  1448   1449       free (xtable);
  1449   1450       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  1450   1451       sqlite3_free (sql);
  1451   1452       if (ret != SQLITE_OK)
  1452   1453         {
  1453   1454   	  printf ("SELECT section_id SQL error: %s\n", sqlite3_errmsg (handle));
  1454   1455   	  goto error;
................................................................................
  2386   2387   		  }
  2387   2388   		if (sqlite3_column_type (stmt, 15) == SQLITE_INTEGER)
  2388   2389   		  {
  2389   2390   		      section_summary = sqlite3_column_int (stmt, 15);
  2390   2391   		      ok_summary = 1;
  2391   2392   		  }
  2392   2393   		if (ok_sample && ok_pixel && ok_num_bands && ok_compression
  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)
         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)
  2396   2398   		    ok = 1;
  2397   2399   	    }
  2398   2400         }
  2399   2401       sqlite3_finalize (stmt);
  2400   2402   
  2401   2403       if (!ok)
  2402   2404         {
................................................................................
  2420   2422   	  fprintf (stderr,
  2421   2423   		   "ERROR: unable to Georeference a Coverage Object supporting \"%s\"\n",
  2422   2424   		   coverage);
  2423   2425   	  rl2_destroy_coverage (cvg);
  2424   2426   	  return NULL;
  2425   2427         }
  2426   2428       if (rl2_set_coverage_policies
  2427         -	(cvg, strict_resolution, mixed_resolutions, section_paths, section_md5,
  2428         -	 section_summary) != RL2_OK)
         2429  +	(cvg, strict_resolution, mixed_resolutions, section_paths,
         2430  +	 section_md5, section_summary) != RL2_OK)
  2429   2431         {
  2430   2432   	  fprintf (stderr,
  2431   2433   		   "ERROR: unable to set the Policies on the Coverage Object supporting \"%s\"\n",
  2432   2434   		   coverage);
  2433   2435   	  rl2_destroy_coverage (cvg);
  2434   2436   	  return NULL;
  2435   2437         }
................................................................................
  2533   2535   	      free (f_table_name);
  2534   2536   	  if (f_geometry_column != NULL)
  2535   2537   	      free (f_geometry_column);
  2536   2538   	  return NULL;
  2537   2539         }
  2538   2540   
  2539   2541       vector =
  2540         -	rl2_create_vector_layer (f_table_name, f_geometry_column, geometry_type,
  2541         -				 srid, spatial_index);
         2542  +	rl2_create_vector_layer (f_table_name, f_geometry_column,
         2543  +				 geometry_type, srid, spatial_index);
  2542   2544       free (f_table_name);
  2543   2545       free (f_geometry_column);
  2544   2546       if (vector == NULL)
  2545   2547         {
  2546   2548   	  fprintf (stderr,
  2547   2549   		   "ERROR: unable to create a Vector Layer Object supporting \"%s\"\n",
  2548   2550   		   coverage);
................................................................................
  2888   2890   }
  2889   2891   
  2890   2892   static void
  2891   2893   do_decode_tile (rl2AuxDecoderPtr decoder)
  2892   2894   {
  2893   2895   /* servicing an AuxDecoder Tile request */
  2894   2896       decoder->raster =
  2895         -	(rl2PrivRasterPtr) rl2_raster_decode (decoder->scale, decoder->blob_odd,
         2897  +	(rl2PrivRasterPtr) rl2_raster_decode (decoder->scale,
         2898  +					      decoder->blob_odd,
  2896   2899   					      decoder->blob_odd_sz,
  2897   2900   					      decoder->blob_even,
  2898   2901   					      decoder->blob_even_sz,
  2899   2902   					      (rl2PalettePtr)
  2900   2903   					      (decoder->palette));
  2901   2904       if (decoder->blob_odd != NULL)
  2902   2905   	free (decoder->blob_odd);
................................................................................
  3073   3076   
  3074   3077     error:
  3075   3078       return 0;
  3076   3079   }
  3077   3080   
  3078   3081   static int
  3079   3082   rl2_load_dbms_tiles_common (sqlite3 * handle, int max_threads,
  3080         -			    sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data,
  3081         -			    unsigned char *outbuf, unsigned int width,
  3082         -			    unsigned int height, unsigned char sample_type,
         3083  +			    sqlite3_stmt * stmt_tiles,
         3084  +			    sqlite3_stmt * stmt_data, unsigned char *outbuf,
         3085  +			    unsigned int width, unsigned int height,
         3086  +			    unsigned char sample_type,
  3083   3087   			    unsigned char num_bands, unsigned char auto_ndvi,
  3084   3088   			    unsigned char red_band_index,
  3085   3089   			    unsigned char nir_band_index, double x_res,
  3086   3090   			    double y_res, double minx, double maxy, int scale,
  3087   3091   			    rl2PalettePtr palette, rl2PixelPtr no_data,
  3088   3092   			    rl2RasterSymbolizerPtr style,
  3089   3093   			    rl2RasterStatisticsPtr stats)
................................................................................
  3704   3708   		  {
  3705   3709   		      fprintf (stderr,
  3706   3710   			       "SELECT tiles data; sqlite3_step() error: %s\n",
  3707   3711   			       sqlite3_errmsg (handle));
  3708   3712   		      goto error;
  3709   3713   		  }
  3710   3714   		raster =
  3711         -		    rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even,
  3712         -				       blob_even_sz, NULL);
         3715  +		    rl2_raster_decode (scale, blob_odd, blob_odd_sz,
         3716  +				       blob_even, blob_even_sz, NULL);
  3713   3717   		if (raster == NULL)
  3714   3718   		  {
  3715   3719   		      fprintf (stderr, ERR_FRMT64, tile_id);
  3716   3720   		      goto error;
  3717   3721   		  }
  3718   3722   		if (!copy_triple_band_raw_pixels
  3719   3723   		    (raster, outbuf, width, height, red_band, green_band,
  3720         -		     blue_band, x_res, y_res, minx, maxy, tile_minx, tile_maxy,
  3721         -		     no_data))
         3724  +		     blue_band, x_res, y_res, minx, maxy, tile_minx,
         3725  +		     tile_maxy, no_data))
  3722   3726   		    goto error;
  3723   3727   		rl2_destroy_raster (raster);
  3724   3728   		raster = NULL;
  3725   3729   	    }
  3726   3730   	  else
  3727   3731   	    {
  3728   3732   		fprintf (stderr,
................................................................................
  3866   3870   
  3867   3871       return 1;
  3868   3872   }
  3869   3873   
  3870   3874   static int
  3871   3875   copy_mono_band_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf,
  3872   3876   			   unsigned int width, unsigned int height,
  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)
         3877  +			   unsigned char mono_band, double x_res,
         3878  +			   double y_res, double minx, double maxy,
         3879  +			   double tile_minx, double tile_maxy,
         3880  +			   rl2PixelPtr no_data)
  3876   3881   {
  3877   3882   /* copying raw pixels into the output buffer */
  3878   3883       unsigned int tile_width;
  3879   3884       unsigned int tile_height;
  3880   3885       unsigned int x;
  3881   3886       unsigned int y;
  3882   3887       int out_x;
................................................................................
  3999   4004       return 1;
  4000   4005   }
  4001   4006   
  4002   4007   static int
  4003   4008   load_mono_band_dbms_tiles (sqlite3 * handle, sqlite3_stmt * stmt_tiles,
  4004   4009   			   sqlite3_stmt * stmt_data, unsigned char *outbuf,
  4005   4010   			   unsigned int width, unsigned int height,
  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)
         4011  +			   unsigned char mono_band, double x_res,
         4012  +			   double y_res, double minx, double miny,
         4013  +			   double maxx, double maxy, int level, int scale,
         4014  +			   rl2PixelPtr no_data)
  4009   4015   {
  4010   4016   /* retrieving a full image from DBMS tiles */
  4011   4017       rl2RasterPtr raster = NULL;
  4012   4018       int ret;
  4013   4019   
  4014   4020   /* binding the query args */
  4015   4021       sqlite3_reset (stmt_tiles);
................................................................................
  4060   4066   		  {
  4061   4067   		      fprintf (stderr,
  4062   4068   			       "SELECT tiles data; sqlite3_step() error: %s\n",
  4063   4069   			       sqlite3_errmsg (handle));
  4064   4070   		      goto error;
  4065   4071   		  }
  4066   4072   		raster =
  4067         -		    rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even,
  4068         -				       blob_even_sz, NULL);
         4073  +		    rl2_raster_decode (scale, blob_odd, blob_odd_sz,
         4074  +				       blob_even, blob_even_sz, NULL);
  4069   4075   		if (raster == NULL)
  4070   4076   		  {
  4071   4077   		      fprintf (stderr, ERR_FRMT64, tile_id);
  4072   4078   		      goto error;
  4073   4079   		  }
  4074   4080   		if (!copy_mono_band_raw_pixels
  4075   4081   		    (raster, outbuf, width, height, mono_band, x_res, y_res,
................................................................................
  4097   4103   
  4098   4104   RL2_PRIVATE int
  4099   4105   rl2_load_dbms_tiles (sqlite3 * handle, int max_threads,
  4100   4106   		     sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data,
  4101   4107   		     unsigned char *outbuf, unsigned int width,
  4102   4108   		     unsigned int height, unsigned char sample_type,
  4103   4109   		     unsigned char num_bands, unsigned char auto_ndvi,
  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)
         4110  +		     unsigned char red_band_index,
         4111  +		     unsigned char nir_band_index, double x_res, double y_res,
         4112  +		     double minx, double miny, double maxx, double maxy,
         4113  +		     int level, int scale, rl2PalettePtr palette,
         4114  +		     rl2PixelPtr no_data, rl2RasterSymbolizerPtr style,
         4115  +		     rl2RasterStatisticsPtr stats)
  4109   4116   {
  4110   4117   /* binding the query args */
  4111   4118       sqlite3_reset (stmt_tiles);
  4112   4119       sqlite3_clear_bindings (stmt_tiles);
  4113   4120       sqlite3_bind_int (stmt_tiles, 1, level);
  4114   4121       sqlite3_bind_double (stmt_tiles, 2, minx);
  4115   4122       sqlite3_bind_double (stmt_tiles, 3, miny);
................................................................................
  4126   4133   
  4127   4134   RL2_PRIVATE int
  4128   4135   rl2_load_dbms_tiles_section (sqlite3 * handle, int max_threads,
  4129   4136   			     sqlite3_int64 section_id,
  4130   4137   			     sqlite3_stmt * stmt_tiles,
  4131   4138   			     sqlite3_stmt * stmt_data, unsigned char *outbuf,
  4132   4139   			     unsigned int width, unsigned int height,
  4133         -			     unsigned char sample_type, unsigned char num_bands,
  4134         -			     unsigned char auto_ndvi,
         4140  +			     unsigned char sample_type,
         4141  +			     unsigned char num_bands, unsigned char auto_ndvi,
  4135   4142   			     unsigned char red_band_index,
  4136   4143   			     unsigned char nir_band_index, double x_res,
  4137         -			     double y_res, double minx, double maxy, int scale,
  4138         -			     rl2PalettePtr palette, rl2PixelPtr no_data)
         4144  +			     double y_res, double minx, double maxy,
         4145  +			     int scale, rl2PalettePtr palette,
         4146  +			     rl2PixelPtr no_data)
  4139   4147   {
  4140   4148   /* binding the query args */
  4141   4149       sqlite3_reset (stmt_tiles);
  4142   4150       sqlite3_clear_bindings (stmt_tiles);
  4143   4151       sqlite3_bind_int (stmt_tiles, 1, section_id);
  4144   4152   
  4145   4153       if (!rl2_load_dbms_tiles_common
................................................................................
  4583   4591   			    free (blue);
  4584   4592   			}
  4585   4593   		      if (!ok)
  4586   4594   			{
  4587   4595   			    /* default: white */
  4588   4596   			    rl2_set_pixel_sample_uint8 (no_data, RL2_RED_BAND,
  4589   4597   							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);
         4598  +			    rl2_set_pixel_sample_uint8 (no_data,
         4599  +							RL2_GREEN_BAND, 255);
         4600  +			    rl2_set_pixel_sample_uint8 (no_data,
         4601  +							RL2_BLUE_BAND, 255);
  4594   4602   			}
  4595   4603   		  }
  4596   4604   	    }
  4597   4605   	  if (plt != NULL)
  4598   4606   	      rl2_destroy_palette (plt);
  4599   4607   	  plt = NULL;
  4600   4608   	  sample_type = RL2_SAMPLE_UINT8;
................................................................................
  4811   4819   			       bgcolor);
  4812   4820   	  else
  4813   4821   	      void_raw_buffer (bufpix, width, height, sample_type, num_bands,
  4814   4822   			       no_data);
  4815   4823         }
  4816   4824       if (!rl2_load_dbms_tiles
  4817   4825   	(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))
         4826  +	 sample_type, num_bands, auto_ndvi, red_band, nir_band, xx_res,
         4827  +	 yy_res, minx, miny, maxx, maxy, level, scale, plt, no_data, style,
         4828  +	 stats))
  4820   4829   	goto error;
  4821   4830       if (kill_no_data != NULL)
  4822   4831   	rl2_destroy_pixel (kill_no_data);
  4823   4832       sqlite3_finalize (stmt_tiles);
  4824   4833       sqlite3_finalize (stmt_data);
  4825   4834       if (shaded_relief != NULL)
  4826   4835         {
................................................................................
  4868   4877   	rl2_destroy_pixel (kill_no_data);
  4869   4878       if (shaded_relief != NULL)
  4870   4879   	free (shaded_relief);
  4871   4880       return RL2_ERROR;
  4872   4881   }
  4873   4882   
  4874   4883   RL2_DECLARE int
  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)
         4884  +rl2_get_raw_raster_data (sqlite3 * handle, int max_threads,
         4885  +			 rl2CoveragePtr cvg, unsigned int width,
         4886  +			 unsigned int height, double minx, double miny,
         4887  +			 double maxx, double maxy, double x_res, double y_res,
         4888  +			 unsigned char **buffer, int *buf_size,
         4889  +			 rl2PalettePtr * palette, unsigned char out_pixel)
  4881   4890   {
  4882   4891   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  4883   4892       return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 0, 0,
  4884   4893   					   width, height, minx, miny, maxx,
  4885         -					   maxy, x_res, y_res, buffer, buf_size,
  4886         -					   palette, out_pixel, NULL, NULL,
  4887         -					   NULL);
         4894  +					   maxy, x_res, y_res, buffer,
         4895  +					   buf_size, palette, out_pixel, NULL,
         4896  +					   NULL, NULL);
  4888   4897   }
  4889   4898   
  4890   4899   RL2_DECLARE int
  4891   4900   rl2_get_section_raw_raster_data (sqlite3 * handle, int max_threads,
  4892   4901   				 rl2CoveragePtr cvg, sqlite3_int64 section_id,
  4893   4902   				 unsigned int width, unsigned int height,
  4894   4903   				 double minx, double miny, double maxx,
................................................................................
  4897   4906   				 rl2PalettePtr * palette,
  4898   4907   				 unsigned char out_pixel)
  4899   4908   {
  4900   4909   /* attempting to return a buffer containing raw pixels from the DBMS Coverage/Section */
  4901   4910       return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 1,
  4902   4911   					   section_id, width, height, minx,
  4903   4912   					   miny, maxx, maxy, x_res, y_res,
  4904         -					   buffer, buf_size, palette, out_pixel,
  4905         -					   NULL, NULL, NULL);
         4913  +					   buffer, buf_size, palette,
         4914  +					   out_pixel, NULL, NULL, NULL);
  4906   4915   }
  4907   4916   
  4908   4917   static int
  4909   4918   get_triple_band_raw_raster_data_common (int by_section, sqlite3 * handle,
  4910   4919   					rl2CoveragePtr cvg,
  4911   4920   					sqlite3_int64 section_id,
  4912         -					unsigned int width, unsigned int height,
  4913         -					double minx, double miny, double maxx,
  4914         -					double maxy, double x_res, double y_res,
         4921  +					unsigned int width,
         4922  +					unsigned int height, double minx,
         4923  +					double miny, double maxx, double maxy,
         4924  +					double x_res, double y_res,
  4915   4925   					unsigned char red_band,
  4916   4926   					unsigned char green_band,
  4917   4927   					unsigned char blue_band,
  4918   4928   					unsigned char **buffer, int *buf_size,
  4919   4929   					rl2PixelPtr bgcolor)
  4920   4930   {
  4921   4931   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
................................................................................
  5072   5082   				     unsigned char blue_band,
  5073   5083   				     unsigned char **buffer, int *buf_size,
  5074   5084   				     rl2PixelPtr bgcolor)
  5075   5085   {
  5076   5086   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  5077   5087       return get_triple_band_raw_raster_data_common (0, handle, cvg, 0, width,
  5078   5088   						   height, minx, miny, maxx,
  5079         -						   maxy, x_res, y_res, red_band,
  5080         -						   green_band, blue_band,
  5081         -						   buffer, buf_size, bgcolor);
         5089  +						   maxy, x_res, y_res,
         5090  +						   red_band, green_band,
         5091  +						   blue_band, buffer,
         5092  +						   buf_size, bgcolor);
  5082   5093   }
  5083   5094   
  5084   5095   RL2_DECLARE int
  5085   5096   rl2_get_section_triple_band_raw_raster_data (sqlite3 * handle,
  5086   5097   					     rl2CoveragePtr cvg,
  5087   5098   					     sqlite3_int64 section_id,
  5088   5099   					     unsigned int width,
................................................................................
  5097   5108   					     int *buf_size, rl2PixelPtr bgcolor)
  5098   5109   {
  5099   5110   /* attempting to return a buffer containing raw pixels - Section */
  5100   5111       return get_triple_band_raw_raster_data_common (1, handle, cvg, section_id,
  5101   5112   						   width, height, minx, miny,
  5102   5113   						   maxx, maxy, x_res, y_res,
  5103   5114   						   red_band, green_band,
  5104         -						   blue_band, buffer, buf_size,
  5105         -						   bgcolor);
         5115  +						   blue_band, buffer,
         5116  +						   buf_size, bgcolor);
  5106   5117   }
  5107   5118   
  5108   5119   static int
  5109   5120   get_mono_band_raw_raster_data_common (int by_section, sqlite3 * handle,
  5110   5121   				      rl2CoveragePtr cvg,
  5111   5122   				      sqlite3_int64 section_id,
  5112   5123   				      unsigned int width, unsigned int height,
................................................................................
  5263   5274   				   double x_res, double y_res,
  5264   5275   				   unsigned char mono_band,
  5265   5276   				   unsigned char **buffer, int *buf_size,
  5266   5277   				   rl2PixelPtr no_data)
  5267   5278   {
  5268   5279   /* attempting to return a buffer containing raw pixels from the DBMS Coverage */
  5269   5280       return get_mono_band_raw_raster_data_common (0, handle, cvg, 0, width,
  5270         -						 height, minx, miny, maxx, maxy,
  5271         -						 x_res, y_res, buffer, buf_size,
  5272         -						 mono_band, no_data);
         5281  +						 height, minx, miny, maxx,
         5282  +						 maxy, x_res, y_res, buffer,
         5283  +						 buf_size, mono_band, no_data);
  5273   5284   }
  5274   5285   
  5275   5286   RL2_DECLARE int
  5276         -rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle, rl2CoveragePtr cvg,
         5287  +rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle,
         5288  +					   rl2CoveragePtr cvg,
  5277   5289   					   sqlite3_int64 section_id,
  5278   5290   					   unsigned int width,
  5279   5291   					   unsigned int height, double minx,
  5280   5292   					   double miny, double maxx,
  5281   5293   					   double maxy, double x_res,
  5282   5294   					   double y_res,
  5283   5295   					   unsigned char mono_band,
................................................................................
  5291   5303   						 buffer, buf_size, mono_band,
  5292   5304   						 no_data);
  5293   5305   }
  5294   5306   
  5295   5307   RL2_DECLARE int
  5296   5308   rl2_get_raw_raster_data_bgcolor (sqlite3 * handle, int max_threads,
  5297   5309   				 rl2CoveragePtr cvg, unsigned int width,
  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,
         5310  +				 unsigned int height, double minx,
         5311  +				 double miny, double maxx, double maxy,
         5312  +				 double x_res, double y_res,
         5313  +				 unsigned char **buffer, int *buf_size,
         5314  +				 rl2PalettePtr * palette,
         5315  +				 unsigned char *out_pixel,
         5316  +				 unsigned char bg_red, unsigned char bg_green,
         5317  +				 unsigned char bg_blue,
  5304   5318   				 rl2RasterSymbolizerPtr style,
  5305   5319   				 rl2RasterStatisticsPtr stats)
  5306   5320   {
  5307   5321   /* attempting to return a buffer containing raw pixels from the DBMS Coverage + bgcolor */
  5308   5322       int ret;
  5309   5323       rl2PixelPtr no_data = NULL;
  5310   5324       const char *coverage;
................................................................................
  5380   5394   	  if (index < 0)
  5381   5395   	    {
  5382   5396   		/* palette color found */
  5383   5397   		switch (sample_type)
  5384   5398   		  {
  5385   5399   		  case RL2_SAMPLE_1_BIT:
  5386   5400   		      no_data =
  5387         -			  rl2_create_pixel (RL2_SAMPLE_1_BIT, RL2_PIXEL_PALETTE,
  5388         -					    1);
         5401  +			  rl2_create_pixel (RL2_SAMPLE_1_BIT,
         5402  +					    RL2_PIXEL_PALETTE, 1);
  5389   5403   		      rl2_set_pixel_sample_1bit (no_data,
  5390   5404   						 (unsigned char) index);
  5391   5405   		      break;
  5392   5406   		  case RL2_SAMPLE_2_BIT:
  5393   5407   		      no_data =
  5394         -			  rl2_create_pixel (RL2_SAMPLE_2_BIT, RL2_PIXEL_PALETTE,
  5395         -					    1);
         5408  +			  rl2_create_pixel (RL2_SAMPLE_2_BIT,
         5409  +					    RL2_PIXEL_PALETTE, 1);
  5396   5410   		      rl2_set_pixel_sample_2bit (no_data,
  5397   5411   						 (unsigned char) index);
  5398   5412   		      break;
  5399   5413   		  case RL2_SAMPLE_4_BIT:
  5400   5414   		      no_data =
  5401         -			  rl2_create_pixel (RL2_SAMPLE_4_BIT, RL2_PIXEL_PALETTE,
  5402         -					    1);
         5415  +			  rl2_create_pixel (RL2_SAMPLE_4_BIT,
         5416  +					    RL2_PIXEL_PALETTE, 1);
  5403   5417   		      rl2_set_pixel_sample_4bit (no_data,
  5404   5418   						 (unsigned char) index);
  5405   5419   		      break;
  5406   5420   		  case RL2_SAMPLE_UINT8:
  5407   5421   		      no_data =
  5408         -			  rl2_create_pixel (RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE,
  5409         -					    1);
         5422  +			  rl2_create_pixel (RL2_SAMPLE_UINT8,
         5423  +					    RL2_PIXEL_PALETTE, 1);
  5410   5424   		      rl2_set_pixel_sample_uint8 (no_data, RL2_PALETTE_BAND,
  5411   5425   						  (unsigned char) index);
  5412   5426   		      break;
  5413   5427   
  5414   5428   		  };
  5415   5429   	    }
  5416   5430         }
................................................................................
  5703   5717       sqlite3_stmt *stmt = NULL;
  5704   5718       char *sql;
  5705   5719       int ret;
  5706   5720       if (handle == NULL || coverage == NULL || palette == NULL)
  5707   5721   	return RL2_ERROR;
  5708   5722   
  5709   5723       sql =
  5710         -	sqlite3_mprintf ("SELECT sample_type, pixel_type FROM raster_coverages "
  5711         -			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
         5724  +	sqlite3_mprintf
         5725  +	("SELECT sample_type, pixel_type FROM raster_coverages "
         5726  +	 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
  5712   5727       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  5713   5728       sqlite3_free (sql);
  5714   5729       if (ret != SQLITE_OK)
  5715   5730         {
  5716   5731   	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
  5717   5732   	  goto error;
  5718   5733         }
................................................................................
  6231   6246   	sqlite3_finalize (stmt);
  6232   6247       if (stl != NULL)
  6233   6248   	rl2_destroy_coverage_style (stl);
  6234   6249       return NULL;
  6235   6250   }
  6236   6251   
  6237   6252   RL2_DECLARE rl2FeatureTypeStylePtr
  6238         -rl2_create_feature_type_style_from_dbms (sqlite3 * handle, const char *coverage,
         6253  +rl2_create_feature_type_style_from_dbms (sqlite3 * handle,
         6254  +					 const char *coverage,
  6239   6255   					 const char *style)
  6240   6256   {
  6241   6257   /* attempting to load and parse a Feature Type Style */
  6242   6258       const char *sql;
  6243   6259       int ret;
  6244   6260       sqlite3_stmt *stmt = NULL;
  6245   6261       rl2FeatureTypeStylePtr stl = NULL;
................................................................................
  6375   6391       char **results;
  6376   6392       int rows;
  6377   6393       int columns;
  6378   6394       int i;
  6379   6395       int ok = 0;
  6380   6396   /* testing if the Layer Style exists */
  6381   6397       char *sql =
  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);
         6398  +	sqlite3_mprintf
         6399  +	("SELECT style_name FROM SE_raster_styled_layers AS r "
         6400  +	 "JOIN SE_raster_styles AS s ON (r.style_id = s.style_id) "
         6401  +	 "WHERE Lower(r.coverage_name) = Lower(%Q) AND "
         6402  +	 "Lower(s.style_name) = Lower(%Q)", namedLayer,
         6403  +	 namedStyle);
  6387   6404       ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, NULL);
  6388   6405       sqlite3_free (sql);
  6389   6406       if (ret != SQLITE_OK)
  6390   6407   	return 0;
  6391   6408       for (i = 1; i <= rows; i++)
  6392   6409   	ok = 1;
  6393   6410       sqlite3_free_table (results);
................................................................................
  7001   7018       int section_summary = 0;
  7002   7019       rl2PixelPtr no_data = NULL;
  7003   7020       rl2PalettePtr palette = NULL;
  7004   7021       char *title = NULL;
  7005   7022       char *abstract = NULL;
  7006   7023       unsigned char *statistics = NULL;
  7007   7024       int statistics_sz;
         7025  +    int ok_geo = 0;
  7008   7026       int ok_bbox = 0;
  7009   7027       double geo_minx;
  7010   7028       double geo_miny;
  7011   7029       double geo_maxx;
  7012   7030       double geo_maxy;
  7013   7031       double ext_minx;
  7014   7032       double ext_miny;
................................................................................
  7399   7417   		      strcpy (abstract, value);
  7400   7418   		  }
  7401   7419   		if (sqlite3_column_type (stmt, 18) == SQLITE_BLOB)
  7402   7420   		  {
  7403   7421   		      statistics_sz = sqlite3_column_bytes (stmt, 18);
  7404   7422   		      statistics = malloc (statistics_sz);
  7405   7423   		      memcpy (statistics,
  7406         -			      (const unsigned char *) sqlite3_column_blob (stmt,
  7407         -									   18),
  7408         -			      statistics_sz);
         7424  +			      (const unsigned char *)
         7425  +			      sqlite3_column_blob (stmt, 18), statistics_sz);
  7409   7426   		  }
  7410   7427   		if (sqlite3_column_type (stmt, 19) == SQLITE_FLOAT)
  7411   7428   		  {
  7412   7429   		      geo_minx = sqlite3_column_double (stmt, 19);
  7413         -		      ok_bbox++;
         7430  +		      ok_geo++;
  7414   7431   		  }
  7415   7432   		if (sqlite3_column_type (stmt, 20) == SQLITE_FLOAT)
  7416   7433   		  {
  7417   7434   		      geo_miny = sqlite3_column_double (stmt, 20);
  7418         -		      ok_bbox++;
         7435  +		      ok_geo++;
  7419   7436   		  }
  7420   7437   		if (sqlite3_column_type (stmt, 21) == SQLITE_FLOAT)
  7421   7438   		  {
  7422   7439   		      geo_maxx = sqlite3_column_double (stmt, 21);
  7423         -		      ok_bbox++;
         7440  +		      ok_geo++;
  7424   7441   		  }
  7425   7442   		if (sqlite3_column_type (stmt, 22) == SQLITE_FLOAT)
  7426   7443   		  {
  7427   7444   		      geo_maxy = sqlite3_column_double (stmt, 22);
  7428         -		      ok_bbox++;
         7445  +		      ok_geo++;
  7429   7446   		  }
  7430   7447   		if (sqlite3_column_type (stmt, 23) == SQLITE_FLOAT)
  7431   7448   		  {
  7432   7449   		      ext_minx = sqlite3_column_double (stmt, 23);
  7433   7450   		      ok_bbox++;
  7434   7451   		  }
  7435   7452   		if (sqlite3_column_type (stmt, 24) == SQLITE_FLOAT)
................................................................................
  7481   7498   		  {
  7482   7499   		      const unsigned char *blob =
  7483   7500   			  sqlite3_column_blob (stmt, 33);
  7484   7501   		      int blob_sz = sqlite3_column_bytes (stmt, 33);
  7485   7502   		      palette = rl2_deserialize_dbms_palette (blob, blob_sz);
  7486   7503   		  }
  7487   7504   		if (ok_sample && ok_pixel && ok_num_bands && ok_compression
  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)
         7505  +		    && ok_quality && ok_tile_width && ok_tile_height
         7506  +		    && ok_x_res && ok_y_res && ok_srid && ok_nodata
         7507  +		    && ok_strict && ok_mixed && ok_paths && ok_md5
         7508  +		    && ok_summary)
  7491   7509   		    ok = 1;
  7492         -		if (ok_bbox != 8)
         7510  +		if (ok_geo != 4)
         7511  +		    ok_geo = 0;
         7512  +		if (ok_bbox != 4)
  7493   7513   		    ok_bbox = 0;
  7494   7514   	    }
  7495   7515         }
  7496   7516       sqlite3_finalize (stmt);
  7497   7517       stmt = NULL;
  7498   7518       if (!ok)
  7499   7519   	goto error;
................................................................................
  7504   7524   				    compr, quality,
  7505   7525   				    (unsigned short) tile_width,
  7506   7526   				    (unsigned short) tile_height, srid,
  7507   7527   				    horz_res, vert_res, no_data, palette,
  7508   7528   				    strict_resolution, mixed_resolutions,
  7509   7529   				    section_paths, section_md5,
  7510   7530   				    section_summary);
  7511         -	if (no_data != NULL)
  7512         -	rl2_destroy_pixel(no_data);
  7513         -	if (palette != NULL)
  7514         -	rl2_destroy_palette(palette);
         7531  +    if (no_data != NULL)
         7532  +	rl2_destroy_pixel (no_data);
         7533  +    if (palette != NULL)
         7534  +	rl2_destroy_palette (palette);
  7515   7535       if (ret != RL2_OK)
  7516   7536   	goto error;
  7517   7537   
  7518   7538   /* completing the destination coverage */
  7519   7539       sql = "UPDATE main.raster_coverages SET title = ?, "
  7520   7540   	"abstract = ?, statistics = ?, geo_minx = ?, geo_miny = ?, geo_maxx = ?, "
  7521   7541   	"geo_maxy = ?, extent_minx = ?, extent_miny = ?, extent_maxx = ?, "
................................................................................
  7538   7558   	sqlite3_bind_null (stmt, 2);
  7539   7559       else
  7540   7560   	sqlite3_bind_text (stmt, 2, abstract, strlen (abstract), free);
  7541   7561       if (statistics == NULL)
  7542   7562   	sqlite3_bind_null (stmt, 3);
  7543   7563       else
  7544   7564   	sqlite3_bind_blob (stmt, 3, statistics, statistics_sz, free);
  7545         -    if (ok_bbox)
         7565  +    if (ok_geo)
  7546   7566         {
  7547   7567   	  sqlite3_bind_double (stmt, 4, geo_minx);
  7548   7568   	  sqlite3_bind_double (stmt, 5, geo_miny);
  7549   7569   	  sqlite3_bind_double (stmt, 6, geo_maxx);
  7550   7570   	  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);
  7555   7571         }
  7556   7572       else
  7557   7573         {
  7558   7574   	  sqlite3_bind_null (stmt, 4);
  7559   7575   	  sqlite3_bind_null (stmt, 5);
  7560   7576   	  sqlite3_bind_null (stmt, 6);
  7561   7577   	  sqlite3_bind_null (stmt, 7);
         7578  +      }
         7579  +    if (ok_bbox)
         7580  +      {
         7581  +	  sqlite3_bind_double (stmt, 8, ext_minx);
         7582  +	  sqlite3_bind_double (stmt, 9, ext_miny);
         7583  +	  sqlite3_bind_double (stmt, 10, ext_maxx);
         7584  +	  sqlite3_bind_double (stmt, 11, ext_maxy);
         7585  +      }
         7586  +    else
         7587  +      {
  7562   7588   	  sqlite3_bind_null (stmt, 8);
  7563   7589   	  sqlite3_bind_null (stmt, 9);
  7564   7590   	  sqlite3_bind_null (stmt, 10);
  7565   7591   	  sqlite3_bind_null (stmt, 11);
  7566   7592         }
  7567   7593       if (!ok_is_queryable)
  7568   7594   	sqlite3_bind_null (stmt, 12);
................................................................................
  7587   7613       if (!ok_enable_auto_ndvi)
  7588   7614   	sqlite3_bind_null (stmt, 17);
  7589   7615       else
  7590   7616   	sqlite3_bind_int (stmt, 17, enable_auto_ndvi);
  7591   7617       sqlite3_bind_text (stmt, 18, coverage_name, strlen (coverage_name),
  7592   7618   		       SQLITE_STATIC);
  7593   7619       ret = sqlite3_step (stmt);
  7594         -    sqlite3_finalize(stmt);
         7620  +    sqlite3_finalize (stmt);
         7621  +    stmt = NULL;
  7595   7622       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  7596   7623   	goto ok_continue;
  7597   7624       fprintf (stderr,
  7598   7625   	     "sqlite3_step() error: UPDATE raster_coverages \"%s\"\n",
  7599   7626   	     sqlite3_errmsg (sqlite));
  7600   7627       goto error;
  7601   7628   
................................................................................
  7609   7636   			   "x_resolution_1_4, y_resolution_1_4, x_resolution_1_8, y_resolution_1_8) "
  7610   7637   			   "SELECT pyramid_level, x_resolution_1_1, y_resolution_1_1, x_resolution_1_2, "
  7611   7638   			   "y_resolution_1_2, x_resolution_1_4, y_resolution_1_4, x_resolution_1_8, "
  7612   7639   			   "y_resolution_1_8 FROM \"%s\".\"%s\"", xxcoverage,
  7613   7640   			   xdb, xxcoverage);
  7614   7641       free (xxcoverage);
  7615   7642       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7616         -    sqlite3_free(sql);
         7643  +    sqlite3_free (sql);
  7617   7644       if (ret != SQLITE_OK)
  7618   7645   	goto error;
  7619   7646   
  7620   7647   /* copying  coverage-SECTIONS */
  7621   7648       xcoverage = sqlite3_mprintf ("%s_sections", coverage_name);
  7622   7649       xxcoverage = rl2_double_quoted_sql (xcoverage);
  7623   7650       sqlite3_free (xcoverage);
  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);
         7651  +    sql =
         7652  +	sqlite3_mprintf ("INSERT INTO main.\"%s\" (section_id, section_name, "
         7653  +			 "width, height, file_path, md5_checksum, summary, statistics, geometry) "
         7654  +			 "SELECT section_id, section_name, width, height, file_path, md5_checksum, "
         7655  +			 "summary, statistics, geometry FROM \"%s\".\"%s\"",
         7656  +			 xxcoverage, xdb, xxcoverage);
  7629   7657       free (xxcoverage);
  7630   7658       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7631         -    sqlite3_free(sql);
         7659  +    sqlite3_free (sql);
  7632   7660       if (ret != SQLITE_OK)
  7633   7661   	goto error;
  7634   7662   
  7635   7663   /* copying  coverage-TILES */
  7636   7664       xcoverage = sqlite3_mprintf ("%s_tiles", coverage_name);
  7637   7665       xxcoverage = rl2_double_quoted_sql (xcoverage);
  7638   7666       sqlite3_free (xcoverage);
  7639   7667       sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, pyramid_level, "
  7640   7668   			   "section_id, geometry) SELECT tile_id, pyramid_level, section_id, geometry "
  7641   7669   			   "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage);
  7642   7670       free (xxcoverage);
  7643   7671       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7644         -    sqlite3_free(sql);
         7672  +    sqlite3_free (sql);
  7645   7673       if (ret != SQLITE_OK)
  7646   7674   	goto error;
  7647   7675   
  7648   7676   /* copying  coverage-TILE_DATA */
  7649   7677       xcoverage = sqlite3_mprintf ("%s_tile_data", coverage_name);
  7650   7678       xxcoverage = rl2_double_quoted_sql (xcoverage);
  7651   7679       sqlite3_free (xcoverage);
  7652   7680       sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, tile_data_odd, "
  7653   7681   			   "tile_data_even) SELECT tile_id, tile_data_odd, tile_data_even "
  7654   7682   			   "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage);
  7655   7683       free (xxcoverage);
  7656   7684       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7657         -    sqlite3_free(sql);
         7685  +    sqlite3_free (sql);
  7658   7686       if (ret != SQLITE_OK)
  7659   7687   	goto error;
  7660   7688   
  7661   7689   /* copying KEYWORDS */
  7662   7690       sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_keyword "
  7663   7691   			   "(coverage_name, keyword) SELECT coverage_name, keyword "
  7664   7692   			   "FROM \"%s\".raster_coverages_keyword", xdb);
  7665   7693       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7666         -    sqlite3_free(sql);
         7694  +    sqlite3_free (sql);
  7667   7695       if (ret != SQLITE_OK)
  7668   7696   	goto error;
  7669   7697   
  7670   7698   /* copying SRID */
  7671   7699       sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_srid "
  7672   7700   			   "(coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx) "
  7673   7701   			   "SELECT coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx "
  7674   7702   			   "FROM \"%s\".raster_coverages_srid", xdb);
  7675   7703       ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL);
  7676         -    sqlite3_free(sql);
         7704  +    sqlite3_free (sql);
  7677   7705       if (ret != SQLITE_OK)
  7678   7706   	goto error;
  7679   7707   
  7680   7708       free (xdb);
  7681   7709       return RL2_OK;
  7682   7710   
  7683   7711     error:
  7684   7712       if (xdb != NULL)
  7685   7713   	free (xdb);
  7686   7714       if (stmt != NULL)
  7687   7715   	sqlite3_finalize (stmt);
  7688   7716       return RL2_ERROR;
  7689   7717   }

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, int *blob_sz,
   610         -		rl2PalettePtr * palette)
          609  +		unsigned char *xpixel_type, unsigned char **blob,
          610  +		int *blob_sz, 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, unsigned int col,
   108         -		     double minx, double maxy)
          107  +addTile2AuxImporter (rl2AuxImporterPtr aux, unsigned int row,
          108  +		     unsigned int col, 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, tile->row,
   354         -						   tile->col, aux->verbose);
          353  +						   ascii_grid_origin,
          354  +						   tile->row, tile->col,
          355  +						   aux->verbose);
   355    356   	  break;
   356    357         case RL2_ORIGIN_JPEG:
   357    358   	  raster_origin = (rl2RasterPtr) (aux->origin);
   358    359   	  tile->raster =
   359    360   	      rl2_get_tile_from_jpeg_origin ((rl2CoveragePtr) (aux->coverage),
   360    361   					     raster_origin, tile->row,
   361         -					     tile->col, aux->forced_conversion,
          362  +					     tile->col,
          363  +					     aux->forced_conversion,
   362    364   					     aux->verbose);
   363    365   	  break;
   364    366         case RL2_ORIGIN_JPEG2000:
   365    367   	  raster_origin = (rl2RasterPtr) (aux->origin);
   366    368   	  tile->raster =
   367    369   	      rl2_get_tile_from_jpeg2000_origin ((rl2CoveragePtr)
   368         -						 (aux->coverage), raster_origin,
   369         -						 tile->row, tile->col,
          370  +						 (aux->coverage),
          371  +						 raster_origin, tile->row,
          372  +						 tile->col,
   370    373   						 aux->forced_conversion,
   371    374   						 aux->verbose);
   372    375   	  break;
   373    376         case RL2_ORIGIN_TIFF:
   374    377   	  tiff_origin = (rl2TiffOriginPtr) (aux->origin);
   375    378   	  tile->raster =
   376    379   	      rl2_get_tile_from_tiff_origin ((rl2CoveragePtr) (aux->coverage),
   377         -					     tiff_origin, tile->row, tile->col,
   378         -					     aux->srid, aux->verbose);
          380  +					     tiff_origin, tile->row,
          381  +					     tile->col, aux->srid,
          382  +					     aux->verbose);
   379    383   	  break;
   380    384         case RL2_ORIGIN_RAW:
   381    385   	  raster_origin = (rl2RasterPtr) (aux->origin);
   382    386   	  tile->raster =
   383    387   	      rl2_get_tile_from_raw_pixels ((rl2CoveragePtr) (aux->coverage),
   384    388   					    raster_origin, tile->row,
   385    389   					    tile->col);
................................................................................
   637    641   	  fprintf (stderr, "Coverage/ASCII mismatch\n");
   638    642   	  goto error;
   639    643         }
   640    644       no_data = rl2_get_coverage_no_data (cvg);
   641    645   
   642    646   /* INSERTing the section */
   643    647       if (!rl2_do_insert_section
   644         -	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
   645         -	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
          648  +	(handle, src_path, section, srid, width, height, minx, miny, maxx,
          649  +	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
   646    650   	 coverage->sectionSummary, stmt_sect, &section_id))
   647    651   	goto error;
   648    652       section_stats = rl2_create_raster_statistics (sample_type, 1);
   649    653       if (section_stats == NULL)
   650    654   	goto error;
   651    655   /* INSERTing the base-levels */
   652    656       if (coverage->mixedResolutions)
................................................................................
   663    667   	      (handle, base_res_x, base_res_y, 1.0, sample_type, stmt_levl))
   664    668   	      goto error;
   665    669         }
   666    670   
   667    671   /* preparing all Tile Requests */
   668    672       aux =
   669    673   	createAuxImporter (coverage, srid, maxx, miny, tile_w, tile_h, res_x,
   670         -			   res_y, RL2_ORIGIN_ASCII_GRID, origin, RL2_CONVERT_NO,
   671         -			   verbose, compression, 100);
          674  +			   res_y, RL2_ORIGIN_ASCII_GRID, origin,
          675  +			   RL2_CONVERT_NO, verbose, compression, 100);
   672    676       tile_maxy = maxy;
   673    677       for (row = 0; row < height; row += tile_h)
   674    678         {
   675    679   	  tile_minx = minx;
   676    680   	  for (col = 0; col < width; col += tile_w)
   677    681   	    {
   678    682   		/* adding a Tile request */
................................................................................
   908    912   }
   909    913   
   910    914   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
   911    915   
   912    916   static int
   913    917   check_jpeg2000_origin_compatibility (rl2RasterPtr raster,
   914    918   				     rl2CoveragePtr coverage,
   915         -				     unsigned int *width, unsigned int *height,
          919  +				     unsigned int *width,
          920  +				     unsigned int *height,
   916    921   				     unsigned char *forced_conversion)
   917    922   {
   918    923   /* checking if the Jpeg2000 and the Coverage are mutually compatible */
   919    924       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
   920    925       rl2PrivCoveragePtr cvg = (rl2PrivCoveragePtr) coverage;
   921    926       if (rst == NULL || cvg == NULL)
   922    927   	return 0;
................................................................................
   994    999   	    {
   995   1000   		*width = rst->width;
   996   1001   		*height = rst->height;
   997   1002   		*forced_conversion = RL2_CONVERT_NO;
   998   1003   		return 1;
   999   1004   	    }
  1000   1005         }
  1001         -    if (rst->sampleType == RL2_SAMPLE_UINT16 && rst->pixelType == RL2_PIXEL_RGB
  1002         -	&& rst->nBands == 3)
         1006  +    if (rst->sampleType == RL2_SAMPLE_UINT16
         1007  +	&& rst->pixelType == RL2_PIXEL_RGB && rst->nBands == 3)
  1003   1008         {
  1004   1009   	  if (cvg->sampleType == RL2_SAMPLE_UINT16
  1005   1010   	      && cvg->pixelType == RL2_PIXEL_RGB && cvg->nBands == 3)
  1006   1011   	    {
  1007   1012   		*width = rst->width;
  1008   1013   		*height = rst->height;
  1009   1014   		*forced_conversion = RL2_CONVERT_NO;
................................................................................
  1229   1234   	  maxy = height - 1.0;
  1230   1235   	  res_x = 1.0;
  1231   1236   	  res_y = 1.0;
  1232   1237         }
  1233   1238       raster_in = (rl2PrivRasterPtr) rst_in;
  1234   1239       xml_summary =
  1235   1240   	rl2_build_jpeg_xml_summary (width, height, raster_in->pixelType,
  1236         -				    is_georeferenced, res_x, res_y, minx, miny,
  1237         -				    maxx, maxy);
         1241  +				    is_georeferenced, res_x, res_y, minx,
         1242  +				    miny, maxx, maxy);
  1238   1243   
  1239   1244       printf ("------------------\n");
  1240   1245       if (total > 1)
  1241   1246   	printf ("%d/%d) Importing: %s\n", current, total, src_path);
  1242   1247       else
  1243   1248   	printf ("Importing: %s\n", src_path);
  1244   1249       printf ("    Image Size (pixels): %d x %d\n", width, height);
................................................................................
  1309   1314   	    }
  1310   1315         }
  1311   1316   
  1312   1317       no_data = rl2_get_coverage_no_data (cvg);
  1313   1318   
  1314   1319   /* INSERTing the section */
  1315   1320       if (!rl2_do_insert_section
  1316         -	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
  1317         -	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         1321  +	(handle, src_path, section, srid, width, height, minx, miny, maxx,
         1322  +	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  1318   1323   	 coverage->sectionSummary, stmt_sect, &section_id))
  1319   1324   	goto error;
  1320   1325       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  1321   1326       if (section_stats == NULL)
  1322   1327   	goto error;
  1323   1328   /* INSERTing the base-levels */
  1324   1329       if (coverage->mixedResolutions)
................................................................................
  1677   1682   	  maxy = height - 1.0;
  1678   1683   	  res_x = 1.0;
  1679   1684   	  res_y = 1.0;
  1680   1685         }
  1681   1686       raster_in = (rl2PrivRasterPtr) rst_in;
  1682   1687       xml_summary =
  1683   1688   	rl2_build_jpeg2000_xml_summary (width, height, raster_in->sampleType,
  1684         -					raster_in->pixelType, raster_in->nBands,
  1685         -					is_georeferenced, res_x, res_y, minx,
  1686         -					miny, maxx, maxy, tile_width,
  1687         -					tile_height);
         1689  +					raster_in->pixelType,
         1690  +					raster_in->nBands, is_georeferenced,
         1691  +					res_x, res_y, minx, miny, maxx, maxy,
         1692  +					tile_width, tile_height);
  1688   1693   
  1689   1694       printf ("------------------\n");
  1690   1695       if (total > 1)
  1691   1696   	printf ("%d/%d) Importing: %s\n", current, total, src_path);
  1692   1697       else
  1693   1698   	printf ("Importing: %s\n", src_path);
  1694   1699       printf ("    Image Size (pixels): %d x %d\n", width, height);
................................................................................
  1759   1764   	    }
  1760   1765         }
  1761   1766   
  1762   1767       no_data = rl2_get_coverage_no_data (cvg);
  1763   1768   
  1764   1769   /* INSERTing the section */
  1765   1770       if (!rl2_do_insert_section
  1766         -	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
  1767         -	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         1771  +	(handle, src_path, section, srid, width, height, minx, miny, maxx,
         1772  +	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  1768   1773   	 coverage->sectionSummary, stmt_sect, &section_id))
  1769   1774   	goto error;
  1770   1775       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  1771   1776       if (section_stats == NULL)
  1772   1777   	goto error;
  1773   1778   /* INSERTing the base-levels */
  1774   1779       if (coverage->mixedResolutions)
................................................................................
  2070   2075       rl2AuxImporterTilePtr *thread_slots = NULL;
  2071   2076       int thread_count;
  2072   2077   
  2073   2078       if (is_ascii_grid (src_path))
  2074   2079   	return do_import_ascii_grid (handle, max_threads, src_path, cvg,
  2075   2080   				     section, force_srid, tile_w, tile_h,
  2076   2081   				     pyramidize, sample_type, compression,
  2077         -				     stmt_data, stmt_tils, stmt_sect, stmt_levl,
  2078         -				     stmt_upd_sect, verbose, current, total);
         2082  +				     stmt_data, stmt_tils, stmt_sect,
         2083  +				     stmt_levl, stmt_upd_sect, verbose,
         2084  +				     current, total);
  2079   2085   
  2080   2086       if (is_jpeg_image (src_path))
  2081   2087   	return do_import_jpeg_image (handle, max_threads, src_path, cvg,
  2082   2088   				     section, force_srid, tile_w, tile_h,
  2083   2089   				     pyramidize, sample_type, num_bands,
  2084         -				     compression, quality, stmt_data, stmt_tils,
  2085         -				     stmt_sect, stmt_levl, stmt_upd_sect,
  2086         -				     verbose, current, total);
         2090  +				     compression, quality, stmt_data,
         2091  +				     stmt_tils, stmt_sect, stmt_levl,
         2092  +				     stmt_upd_sect, verbose, current, total);
  2087   2093   
  2088   2094   #ifndef OMIT_OPENJPEG		/* only if OpenJpeg is enabled */
  2089   2095       if (is_jpeg2000_image (src_path))
  2090   2096   	return do_import_jpeg2000_image (handle, max_threads, src_path, cvg,
  2091   2097   					 section, force_srid, tile_w, tile_h,
  2092   2098   					 pyramidize, sample_type, num_bands,
  2093   2099   					 compression, quality, stmt_data,
................................................................................
  2219   2225   	  if (rl2_check_dbms_palette (handle, cvg, origin) != RL2_OK)
  2220   2226   	    {
  2221   2227   		fprintf (stderr, "Mismatching Palette !!!\n");
  2222   2228   		goto error;
  2223   2229   	    }
  2224   2230         }
  2225   2231   
  2226         -    if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose) !=
  2227         -	RL2_TRUE)
         2232  +    if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose)
         2233  +	!= RL2_TRUE)
  2228   2234         {
  2229   2235   	  fprintf (stderr, "Coverage/TIFF mismatch\n");
  2230   2236   	  goto error;
  2231   2237         }
  2232   2238       no_data = rl2_get_coverage_no_data (cvg);
  2233   2239   
  2234   2240   /* INSERTing the section */
  2235   2241       if (!rl2_do_insert_section
  2236         -	(handle, src_path, section, srid, width, height, minx, miny, maxx, maxy,
  2237         -	 xml_summary, coverage->sectionPaths, coverage->sectionMD5,
         2242  +	(handle, src_path, section, srid, width, height, minx, miny, maxx,
         2243  +	 maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5,
  2238   2244   	 coverage->sectionSummary, stmt_sect, &section_id))
  2239   2245   	goto error;
  2240   2246       section_stats = rl2_create_raster_statistics (sample_type, num_bands);
  2241   2247       if (section_stats == NULL)
  2242   2248   	goto error;
  2243   2249   /* INSERTing the base-levels */
  2244   2250       if (coverage->mixedResolutions)
................................................................................
  2534   2540   		      if ((c_file.attrib & _A_RDONLY) == _A_RDONLY
  2535   2541   			  || (c_file.attrib & _A_NORMAL) == _A_NORMAL)
  2536   2542   			{
  2537   2543   			    path =
  2538   2544   				sqlite3_mprintf ("%s/%s", dir_path,
  2539   2545   						 c_file.name);
  2540   2546   			    ret =
  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);
         2547  +				do_import_file (handle, max_threads, path,
         2548  +						cvg, section, worldfile,
         2549  +						force_srid, pyramidize,
         2550  +						sample_type, pixel_type,
         2551  +						num_bands, tile_w, tile_h,
         2552  +						compression, quality,
         2553  +						stmt_data, stmt_tils,
         2554  +						stmt_sect, stmt_levl,
         2555  +						stmt_upd_sect, verbose,
         2556  +						cnt + 1, total);
  2549   2557   			    sqlite3_free (path);
  2550   2558   			    if (!ret)
  2551   2559   				goto error;
  2552   2560   			    cnt++;
  2553   2561   			}
  2554   2562   		      if (_findnext (hFile, &c_file) != 0)
  2555   2563   			  break;
................................................................................
  2772   2780   	       stmt_sect, stmt_levl, stmt_upd_sect, verbose, -1, -1))
  2773   2781   	      goto error;
  2774   2782         }
  2775   2783       else
  2776   2784         {
  2777   2785   	  /* importing all Image files from a whole directory */
  2778   2786   	  if (!do_import_dir
  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))
         2787  +	      (handle, max_threads, dir_path, file_ext, cvg, section,
         2788  +	       worldfile, force_srid, pyramidize, sample_type, pixel_type,
         2789  +	       num_bands, tile_w, tile_h, compression, quality, stmt_data,
         2790  +	       stmt_tils, stmt_sect, stmt_levl, stmt_upd_sect, verbose))
  2783   2791   	      goto error;
  2784   2792         }
  2785   2793   
  2786   2794       sqlite3_finalize (stmt_upd_sect);
  2787   2795       sqlite3_finalize (stmt_sect);
  2788   2796       sqlite3_finalize (stmt_levl);
  2789   2797       sqlite3_finalize (stmt_tils);
................................................................................
  2961   2969   		  }
  2962   2970   		*p_out++ = *p_in++;
  2963   2971   	    }
  2964   2972         }
  2965   2973   }
  2966   2974   
  2967   2975   static void
  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)
         2976  +copy_uint16_outbuf_to_tile (const unsigned short *outbuf,
         2977  +			    unsigned short *tile, unsigned char num_bands,
         2978  +			    unsigned int width, unsigned int height,
         2979  +			    unsigned int tile_width, unsigned int tile_height,
         2980  +			    unsigned int base_y, unsigned int base_x)
  2974   2981   {
  2975   2982   /* copying UINT16 pixels from the output buffer into the tile */
  2976   2983       unsigned int x;
  2977   2984       unsigned int y;
  2978   2985       int b;
  2979   2986       const unsigned short *p_in;
  2980   2987       unsigned short *p_out = tile;
................................................................................
  3140   3147         case RL2_SAMPLE_INT8:
  3141   3148   	  copy_int8_outbuf_to_tile ((char *) outbuf,
  3142   3149   				    (char *) tile, width, height, tile_width,
  3143   3150   				    tile_height, base_y, base_x);
  3144   3151   	  break;
  3145   3152         case RL2_SAMPLE_INT16:
  3146   3153   	  copy_int16_outbuf_to_tile ((short *) outbuf,
  3147         -				     (short *) tile, width, height, tile_width,
  3148         -				     tile_height, base_y, base_x);
         3154  +				     (short *) tile, width, height,
         3155  +				     tile_width, tile_height, base_y, base_x);
  3149   3156   	  break;
  3150   3157         case RL2_SAMPLE_UINT16:
  3151   3158   	  copy_uint16_outbuf_to_tile ((unsigned short *) outbuf,
  3152   3159   				      (unsigned short *) tile, num_bands,
  3153   3160   				      width, height, tile_width, tile_height,
  3154   3161   				      base_y, base_x);
  3155   3162   	  break;
................................................................................
  3161   3168         case RL2_SAMPLE_UINT32:
  3162   3169   	  copy_uint32_outbuf_to_tile ((unsigned int *) outbuf,
  3163   3170   				      (unsigned int *) tile, width, height,
  3164   3171   				      tile_width, tile_height, base_y, base_x);
  3165   3172   	  break;
  3166   3173         case RL2_SAMPLE_FLOAT:
  3167   3174   	  copy_float_outbuf_to_tile ((float *) outbuf,
  3168         -				     (float *) tile, width, height, tile_width,
  3169         -				     tile_height, base_y, base_x);
         3175  +				     (float *) tile, width, height,
         3176  +				     tile_width, tile_height, base_y, base_x);
  3170   3177   	  break;
  3171   3178         case RL2_SAMPLE_DOUBLE:
  3172   3179   	  copy_double_outbuf_to_tile ((double *) outbuf,
  3173   3180   				      (double *) tile, width, height,
  3174   3181   				      tile_width, tile_height, base_y, base_x);
  3175   3182   	  break;
  3176   3183         default:
................................................................................
  3179   3186   				     height, tile_width, tile_height, base_y,
  3180   3187   				     base_x);
  3181   3188   	  break;
  3182   3189         };
  3183   3190   }
  3184   3191   
  3185   3192   static int
  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,
         3193  +export_geotiff_common (sqlite3 * handle, int max_threads,
         3194  +		       const char *dst_path, rl2CoveragePtr cvg,
         3195  +		       int by_section, sqlite3_int64 section_id, double x_res,
         3196  +		       double y_res, double minx, double miny, double maxx,
         3197  +		       double maxy, unsigned int width, unsigned int height,
  3191   3198   		       unsigned char compression, unsigned int tile_sz,
  3192   3199   		       int with_worldfile)
  3193   3200   {
  3194   3201   /* exporting a GeoTIFF common implementation */
  3195   3202       rl2RasterPtr raster = NULL;
  3196   3203       rl2PalettePtr palette = NULL;
  3197   3204       rl2PalettePtr plt2 = NULL;
................................................................................
  3254   3261   	    }
  3255   3262         }
  3256   3263   
  3257   3264       if (by_section)
  3258   3265         {
  3259   3266   	  /* just a single Section */
  3260   3267   	  if (rl2_get_section_raw_raster_data
  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)
         3268  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         3269  +	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
         3270  +	       &palette, pixel_type) != RL2_OK)
  3264   3271   	      goto error;
  3265   3272         }
  3266   3273       else
  3267   3274         {
  3268   3275   	  /* whole Coverage */
  3269   3276   	  if (rl2_get_raw_raster_data
  3270         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  3271         -	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3277  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         3278  +	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3272   3279   	       pixel_type) != RL2_OK)
  3273   3280   	      goto error;
  3274   3281         }
  3275   3282   
  3276   3283   /* computing the sample size */
  3277   3284       switch (sample_type)
  3278   3285         {
................................................................................
  3311   3318   			       "rl2tool Export: Insufficient Memory !!!\n");
  3312   3319   		      goto error;
  3313   3320   		  }
  3314   3321   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3315   3322   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3316   3323   						 no_data);
  3317   3324   		else
  3318         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  3319         -					 num_bands, no_data);
         3325  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
         3326  +					 sample_type, num_bands, no_data);
  3320   3327   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3321   3328   					  num_bands, width, height, tile_sz,
  3322   3329   					  tile_sz, base_y, base_x);
  3323   3330   		plt2 = rl2_clone_palette (palette);
  3324   3331   		raster =
  3325   3332   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3326   3333   				       pixel_type, num_bands, bufpix,
................................................................................
  3376   3383       return export_geotiff_common (handle, max_threads, dst_path, cvg, 0, 0,
  3377   3384   				  x_res, y_res, minx, miny, maxx, maxy, width,
  3378   3385   				  height, compression, tile_sz, with_worldfile);
  3379   3386   }
  3380   3387   
  3381   3388   RL2_DECLARE int
  3382   3389   rl2_export_section_geotiff_from_dbms (sqlite3 * handle, int max_threads,
  3383         -				      const char *dst_path, rl2CoveragePtr cvg,
         3390  +				      const char *dst_path,
         3391  +				      rl2CoveragePtr cvg,
  3384   3392   				      sqlite3_int64 section_id, double x_res,
  3385   3393   				      double y_res, double minx, double miny,
  3386   3394   				      double maxx, double maxy,
  3387   3395   				      unsigned int width, unsigned int height,
  3388   3396   				      unsigned char compression,
  3389   3397   				      unsigned int tile_sz, int with_worldfile)
  3390   3398   {
................................................................................
  3467   3475   	    }
  3468   3476         }
  3469   3477   
  3470   3478       if (by_section)
  3471   3479         {
  3472   3480   	  /* just a single select Section */
  3473   3481   	  if (rl2_get_section_raw_raster_data
  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)
         3482  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         3483  +	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
         3484  +	       &palette, pixel_type) != RL2_OK)
  3477   3485   	      goto error;
  3478   3486         }
  3479   3487       else
  3480   3488         {
  3481   3489   	  /* whole Coverage */
  3482   3490   	  if (rl2_get_raw_raster_data
  3483         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  3484         -	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3491  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         3492  +	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3485   3493   	       pixel_type) != RL2_OK)
  3486   3494   	      goto error;
  3487   3495         }
  3488   3496   
  3489   3497   /* computing the sample size */
  3490   3498       switch (sample_type)
  3491   3499         {
................................................................................
  3502   3510   	  pix_sz = 8;
  3503   3511   	  break;
  3504   3512         };
  3505   3513   
  3506   3514       tiff =
  3507   3515   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  3508   3516   					       sample_type, pixel_type,
  3509         -					       num_bands, palette, compression,
  3510         -					       1, tile_sz, srid, minx, miny,
  3511         -					       maxx, maxy, xx_res, yy_res);
         3517  +					       num_bands, palette,
         3518  +					       compression, 1, tile_sz, srid,
         3519  +					       minx, miny, maxx, maxy, xx_res,
         3520  +					       yy_res);
  3512   3521       if (tiff == NULL)
  3513   3522   	goto error;
  3514   3523       for (base_y = 0; base_y < height; base_y += tile_sz)
  3515   3524         {
  3516   3525   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  3517   3526   	    {
  3518   3527   		/* exporting all tiles from the output buffer */
................................................................................
  3524   3533   			       "rl2tool Export: Insufficient Memory !!!\n");
  3525   3534   		      goto error;
  3526   3535   		  }
  3527   3536   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3528   3537   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3529   3538   						 no_data);
  3530   3539   		else
  3531         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  3532         -					 num_bands, no_data);
         3540  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
         3541  +					 sample_type, num_bands, no_data);
  3533   3542   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3534   3543   					  num_bands, width, height, tile_sz,
  3535   3544   					  tile_sz, base_y, base_x);
  3536   3545   		plt2 = rl2_clone_palette (palette);
  3537   3546   		raster =
  3538   3547   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3539   3548   				       pixel_type, num_bands, bufpix,
................................................................................
  3580   3589   				     double miny, double maxx, double maxy,
  3581   3590   				     unsigned int width, unsigned int height,
  3582   3591   				     unsigned char compression,
  3583   3592   				     unsigned int tile_sz)
  3584   3593   {
  3585   3594   /* exporting a TIFF+TFW from the DBMS into the file-system */
  3586   3595       return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 0,
  3587         -					0, x_res, y_res, minx, miny, maxx, maxy,
  3588         -					width, height, compression, tile_sz);
         3596  +					0, x_res, y_res, minx, miny, maxx,
         3597  +					maxy, width, height, compression,
         3598  +					tile_sz);
  3589   3599   }
  3590   3600   
  3591   3601   RL2_DECLARE int
  3592         -rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle, int max_threads,
         3602  +rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle,
         3603  +					     int max_threads,
  3593   3604   					     const char *dst_path,
  3594   3605   					     rl2CoveragePtr cvg,
  3595   3606   					     sqlite3_int64 section_id,
  3596   3607   					     double x_res, double y_res,
  3597   3608   					     double minx, double miny,
  3598   3609   					     double maxx, double maxy,
  3599   3610   					     unsigned int width,
................................................................................
  3600   3611   					     unsigned int height,
  3601   3612   					     unsigned char compression,
  3602   3613   					     unsigned int tile_sz)
  3603   3614   {
  3604   3615   /* exporting a TIFF+TFW - single Section */
  3605   3616       return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 1,
  3606   3617   					section_id, x_res, y_res, minx, miny,
  3607         -					maxx, maxy, width, height, compression,
  3608         -					tile_sz);
         3618  +					maxx, maxy, width, height,
         3619  +					compression, tile_sz);
  3609   3620   }
  3610   3621   
  3611   3622   static int
  3612   3623   export_tiff_common (sqlite3 * handle, int max_threads, const char *dst_path,
  3613   3624   		    rl2CoveragePtr cvg, int by_section,
  3614   3625   		    sqlite3_int64 section_id, double x_res, double y_res,
  3615   3626   		    double minx, double miny, double maxx, double maxy,
................................................................................
  3681   3692   	    }
  3682   3693         }
  3683   3694   
  3684   3695       if (by_section)
  3685   3696         {
  3686   3697   	  /* just a single Section */
  3687   3698   	  if (rl2_get_section_raw_raster_data
  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)
         3699  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         3700  +	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size,
         3701  +	       &palette, pixel_type) != RL2_OK)
  3691   3702   	      goto error;
  3692   3703         }
  3693   3704       else
  3694   3705         {
  3695   3706   	  /* whole Coverage */
  3696   3707   	  if (rl2_get_raw_raster_data
  3697         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  3698         -	       xx_res, yy_res, &outbuf, &outbuf_size, &palette,
         3708  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         3709  +	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette,
  3699   3710   	       pixel_type) != RL2_OK)
  3700   3711   	      goto error;
  3701   3712         }
  3702   3713   
  3703   3714   /* computing the sample size */
  3704   3715       switch (sample_type)
  3705   3716         {
................................................................................
  3736   3747   			       "rl2tool Export: Insufficient Memory !!!\n");
  3737   3748   		      goto error;
  3738   3749   		  }
  3739   3750   		if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL)
  3740   3751   		    rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz,
  3741   3752   						 no_data);
  3742   3753   		else
  3743         -		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type,
  3744         -					 num_bands, no_data);
         3754  +		    rl2_prime_void_tile (bufpix, tile_sz, tile_sz,
         3755  +					 sample_type, num_bands, no_data);
  3745   3756   		copy_from_outbuf_to_tile (outbuf, bufpix, sample_type,
  3746   3757   					  num_bands, width, height, tile_sz,
  3747   3758   					  tile_sz, base_y, base_x);
  3748   3759   		plt2 = rl2_clone_palette (palette);
  3749   3760   		raster =
  3750   3761   		    rl2_create_raster (tile_sz, tile_sz, sample_type,
  3751   3762   				       pixel_type, num_bands, bufpix,
................................................................................
  3780   3791   	rl2_destroy_palette (palette);
  3781   3792       return RL2_ERROR;
  3782   3793   }
  3783   3794   
  3784   3795   RL2_DECLARE int
  3785   3796   rl2_export_tiff_from_dbms (sqlite3 * handle, int max_threads,
  3786   3797   			   const char *dst_path, rl2CoveragePtr cvg,
  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)
         3798  +			   double x_res, double y_res, double minx,
         3799  +			   double miny, double maxx, double maxy,
         3800  +			   unsigned int width, unsigned int height,
         3801  +			   unsigned char compression, unsigned int tile_sz)
  3791   3802   {
  3792   3803   /* exporting a plain TIFF from the DBMS into the file-system */
  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);
         3804  +    return export_tiff_common (handle, max_threads, dst_path, cvg, 0, 0,
         3805  +			       x_res, y_res, minx, miny, maxx, maxy, width,
         3806  +			       height, compression, tile_sz);
  3796   3807   }
  3797   3808   
  3798   3809   RL2_DECLARE int
  3799   3810   rl2_export_section_tiff_from_dbms (sqlite3 * handle, int max_threads,
  3800   3811   				   const char *dst_path, rl2CoveragePtr cvg,
  3801   3812   				   sqlite3_int64 section_id, double x_res,
  3802   3813   				   double y_res, double minx, double miny,
  3803         -				   double maxx, double maxy, unsigned int width,
  3804         -				   unsigned int height,
         3814  +				   double maxx, double maxy,
         3815  +				   unsigned int width, unsigned int height,
  3805   3816   				   unsigned char compression,
  3806   3817   				   unsigned int tile_sz)
  3807   3818   {
  3808   3819   /* exporting a plain TIFF - single Section*/
  3809   3820       return export_tiff_common (handle, max_threads, dst_path, cvg, 1,
  3810         -			       section_id, x_res, y_res, minx, miny, maxx, maxy,
  3811         -			       width, height, compression, tile_sz);
         3821  +			       section_id, x_res, y_res, minx, miny, maxx,
         3822  +			       maxy, width, height, compression, tile_sz);
  3812   3823   }
  3813   3824   
  3814   3825   static int
  3815   3826   export_triple_band_geotiff_common (int by_section, sqlite3 * handle,
  3816   3827   				   const char *dst_path,
  3817         -				   rl2CoveragePtr cvg, sqlite3_int64 section_id,
  3818         -				   double x_res, double y_res, double minx,
  3819         -				   double miny, double maxx, double maxy,
         3828  +				   rl2CoveragePtr cvg,
         3829  +				   sqlite3_int64 section_id, double x_res,
         3830  +				   double y_res, double minx, double miny,
         3831  +				   double maxx, double maxy,
  3820   3832   				   unsigned int width, unsigned int height,
  3821   3833   				   unsigned char red_band,
  3822   3834   				   unsigned char green_band,
  3823   3835   				   unsigned char blue_band,
  3824   3836   				   unsigned char compression,
  3825   3837   				   unsigned int tile_sz, int with_worldfile)
  3826   3838   {
................................................................................
  3892   3904   	      goto error;
  3893   3905         }
  3894   3906   
  3895   3907       tiff =
  3896   3908   	rl2_create_geotiff_destination (dst_path, handle, width, height,
  3897   3909   					sample_type, RL2_PIXEL_RGB, 3,
  3898   3910   					NULL, compression, 1, tile_sz, srid,
  3899         -					minx, miny, maxx, maxy, xx_res, yy_res,
  3900         -					with_worldfile);
         3911  +					minx, miny, maxx, maxy, xx_res,
         3912  +					yy_res, with_worldfile);
  3901   3913       if (tiff == NULL)
  3902   3914   	goto error;
  3903   3915       for (base_y = 0; base_y < height; base_y += tile_sz)
  3904   3916         {
  3905   3917   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  3906   3918   	    {
  3907   3919   		/* exporting all tiles from the output buffer */
................................................................................
  4090   4102       else
  4091   4103   	out_pixel = RL2_PIXEL_GRAYSCALE;
  4092   4104   
  4093   4105       tiff =
  4094   4106   	rl2_create_geotiff_destination (dst_path, handle, width, height,
  4095   4107   					sample_type, out_pixel, 1,
  4096   4108   					NULL, compression, 1, tile_sz, srid,
  4097         -					minx, miny, maxx, maxy, xx_res, yy_res,
  4098         -					with_worldfile);
         4109  +					minx, miny, maxx, maxy, xx_res,
         4110  +					yy_res, with_worldfile);
  4099   4111       if (tiff == NULL)
  4100   4112   	goto error;
  4101   4113       for (base_y = 0; base_y < height; base_y += tile_sz)
  4102   4114         {
  4103   4115   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4104   4116   	    {
  4105   4117   		/* exporting all tiles from the output buffer */
................................................................................
  4170   4182   					unsigned int height,
  4171   4183   					unsigned char mono_band,
  4172   4184   					unsigned char compression,
  4173   4185   					unsigned int tile_sz,
  4174   4186   					int with_worldfile)
  4175   4187   {
  4176   4188   /* exporting a Mono-Band GeoTIFF from the DBMS into the file-system */
  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,
         4189  +    return export_mono_band_geotiff_common (0, handle, dst_path, cvg, 0,
         4190  +					    x_res, y_res, minx, miny, maxx,
         4191  +					    maxy, width, height, mono_band,
  4180   4192   					    compression, tile_sz,
  4181   4193   					    with_worldfile);
  4182   4194   }
  4183   4195   
  4184   4196   RL2_DECLARE int
  4185   4197   rl2_export_section_mono_band_geotiff_from_dbms (sqlite3 * handle,
  4186   4198   						const char *dst_path,
................................................................................
  4206   4218   
  4207   4219   static int
  4208   4220   export_triple_band_tiff_worldfile_common (int by_section, sqlite3 * handle,
  4209   4221   					  const char *dst_path,
  4210   4222   					  rl2CoveragePtr cvg,
  4211   4223   					  sqlite3_int64 section_id,
  4212   4224   					  double x_res, double y_res,
  4213         -					  double minx, double miny, double maxx,
  4214         -					  double maxy, unsigned int width,
         4225  +					  double minx, double miny,
         4226  +					  double maxx, double maxy,
         4227  +					  unsigned int width,
  4215   4228   					  unsigned int height,
  4216   4229   					  unsigned char red_band,
  4217   4230   					  unsigned char green_band,
  4218   4231   					  unsigned char blue_band,
  4219   4232   					  unsigned char compression,
  4220   4233   					  unsigned int tile_sz)
  4221   4234   {
................................................................................
  4286   4299   	       no_data) != RL2_OK)
  4287   4300   	      goto error;
  4288   4301         }
  4289   4302   
  4290   4303       tiff =
  4291   4304   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  4292   4305   					       sample_type, RL2_PIXEL_RGB,
  4293         -					       3, NULL, compression, 1, tile_sz,
  4294         -					       srid, minx, miny, maxx, maxy,
  4295         -					       xx_res, yy_res);
         4306  +					       3, NULL, compression, 1,
         4307  +					       tile_sz, srid, minx, miny,
         4308  +					       maxx, maxy, xx_res, yy_res);
  4296   4309       if (tiff == NULL)
  4297   4310   	goto error;
  4298   4311       for (base_y = 0; base_y < height; base_y += tile_sz)
  4299   4312         {
  4300   4313   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4301   4314   	    {
  4302   4315   		/* exporting all tiles from the output buffer */
................................................................................
  4388   4401   							 double y_res,
  4389   4402   							 double minx,
  4390   4403   							 double miny,
  4391   4404   							 double maxx,
  4392   4405   							 double maxy,
  4393   4406   							 unsigned int width,
  4394   4407   							 unsigned int height,
  4395         -							 unsigned char red_band,
         4408  +							 unsigned char
         4409  +							 red_band,
  4396   4410   							 unsigned char
  4397   4411   							 green_band,
  4398   4412   							 unsigned char
  4399   4413   							 blue_band,
  4400   4414   							 unsigned char
  4401   4415   							 compression,
  4402   4416   							 unsigned int tile_sz)
................................................................................
  4410   4424   						     compression, tile_sz);
  4411   4425   }
  4412   4426   
  4413   4427   static int
  4414   4428   export_mono_band_tiff_worldfile_common (int by_section, sqlite3 * handle,
  4415   4429   					const char *dst_path,
  4416   4430   					rl2CoveragePtr cvg,
  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,
         4431  +					sqlite3_int64 section_id,
         4432  +					double x_res, double y_res,
         4433  +					double minx, double miny, double maxx,
         4434  +					double maxy, unsigned int width,
         4435  +					unsigned int height,
  4421   4436   					unsigned char mono_band,
  4422   4437   					unsigned char compression,
  4423   4438   					unsigned int tile_sz)
  4424   4439   {
  4425   4440   /* exporting a Mono-Band TIFF+TFW - common implementation */
  4426   4441       rl2RasterPtr raster = NULL;
  4427   4442       rl2PixelPtr no_data_multi = NULL;
................................................................................
  4488   4503   	out_pixel = RL2_PIXEL_DATAGRID;
  4489   4504       else
  4490   4505   	out_pixel = RL2_PIXEL_GRAYSCALE;
  4491   4506   
  4492   4507       tiff =
  4493   4508   	rl2_create_tiff_worldfile_destination (dst_path, width, height,
  4494   4509   					       sample_type, out_pixel,
  4495         -					       1, NULL, compression, 1, tile_sz,
  4496         -					       srid, minx, miny, maxx, maxy,
  4497         -					       xx_res, yy_res);
         4510  +					       1, NULL, compression, 1,
         4511  +					       tile_sz, srid, minx, miny,
         4512  +					       maxx, maxy, xx_res, yy_res);
  4498   4513       if (tiff == NULL)
  4499   4514   	goto error;
  4500   4515       for (base_y = 0; base_y < height; base_y += tile_sz)
  4501   4516         {
  4502   4517   	  for (base_x = 0; base_x < width; base_x += tile_sz)
  4503   4518   	    {
  4504   4519   		/* exporting all tiles from the output buffer */
................................................................................
  4566   4581   					       unsigned int width,
  4567   4582   					       unsigned int height,
  4568   4583   					       unsigned char mono_band,
  4569   4584   					       unsigned char compression,
  4570   4585   					       unsigned int tile_sz)
  4571   4586   {
  4572   4587   /* exporting a Mono-Band TIFF+TFW from the DBMS into the file-system */
  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);
         4588  +    return export_mono_band_tiff_worldfile_common (0, handle, dst_path, cvg,
         4589  +						   0, x_res, y_res, minx,
         4590  +						   miny, maxx, maxy, width,
         4591  +						   height, mono_band,
         4592  +						   compression, tile_sz);
  4578   4593   }
  4579   4594   
  4580   4595   RL2_DECLARE int
  4581   4596   rl2_export_section_mono_band_tiff_worldfile_from_dbms (sqlite3 * handle,
  4582   4597   						       const char *dst_path,
  4583   4598   						       rl2CoveragePtr cvg,
  4584         -						       sqlite3_int64 section_id,
         4599  +						       sqlite3_int64
         4600  +						       section_id,
  4585   4601   						       double x_res,
  4586   4602   						       double y_res,
  4587         -						       double minx, double miny,
  4588         -						       double maxx, double maxy,
         4603  +						       double minx,
         4604  +						       double miny,
         4605  +						       double maxx,
         4606  +						       double maxy,
  4589   4607   						       unsigned int width,
  4590   4608   						       unsigned int height,
  4591         -						       unsigned char mono_band,
         4609  +						       unsigned char
         4610  +						       mono_band,
  4592   4611   						       unsigned char
  4593   4612   						       compression,
  4594   4613   						       unsigned int tile_sz)
  4595   4614   {
  4596   4615   /* exporting a Mono-Band TIFF+TFW - Section */
  4597   4616       return export_mono_band_tiff_worldfile_common (1, handle, dst_path, cvg,
  4598   4617   						   section_id, x_res, y_res,
................................................................................
  4752   4771   				       unsigned char green_band,
  4753   4772   				       unsigned char blue_band,
  4754   4773   				       unsigned char compression,
  4755   4774   				       unsigned int tile_sz)
  4756   4775   {
  4757   4776   /* exporting a plain Band-Composed TIFF from the DBMS into the file-system */
  4758   4777       return export_triple_band_tiff_common (0, handle, dst_path, cvg, 0, x_res,
  4759         -					   y_res, minx, miny, maxx, maxy, width,
  4760         -					   height, red_band, green_band,
  4761         -					   blue_band, compression, tile_sz);
         4778  +					   y_res, minx, miny, maxx, maxy,
         4779  +					   width, height, red_band,
         4780  +					   green_band, blue_band, compression,
         4781  +					   tile_sz);
  4762   4782   }
  4763   4783   
  4764   4784   RL2_DECLARE int
  4765   4785   rl2_export_section_triple_band_tiff_from_dbms (sqlite3 * handle,
  4766   4786   					       const char *dst_path,
  4767   4787   					       rl2CoveragePtr cvg,
  4768   4788   					       sqlite3_int64 section_id,
................................................................................
  4774   4794   					       unsigned char red_band,
  4775   4795   					       unsigned char green_band,
  4776   4796   					       unsigned char blue_band,
  4777   4797   					       unsigned char compression,
  4778   4798   					       unsigned int tile_sz)
  4779   4799   {
  4780   4800   /* exporting a plain Band-Composed TIFF - Section */
  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);
         4801  +    return export_triple_band_tiff_common (1, handle, dst_path, cvg,
         4802  +					   section_id, x_res, y_res, minx,
         4803  +					   miny, maxx, maxy, width, height,
         4804  +					   red_band, green_band, blue_band,
         4805  +					   compression, tile_sz);
  4785   4806   }
  4786   4807   
  4787   4808   static int
  4788   4809   export_mono_band_tiff_common (int by_section, sqlite3 * handle,
  4789   4810   			      const char *dst_path, rl2CoveragePtr cvg,
  4790   4811   			      sqlite3_int64 section_id, double x_res,
  4791   4812   			      double y_res, double minx, double miny,
................................................................................
  4952   4973   					     unsigned char mono_band,
  4953   4974   					     unsigned char compression,
  4954   4975   					     unsigned int tile_sz)
  4955   4976   {
  4956   4977   /* exporting a plain Mono-Band TIFF from the DBMS - Section */
  4957   4978       return export_mono_band_tiff_common (1, handle, dst_path, cvg, section_id,
  4958   4979   					 x_res, y_res, minx, miny, maxx, maxy,
  4959         -					 width, height, mono_band, compression,
  4960         -					 tile_sz);
         4980  +					 width, height, mono_band,
         4981  +					 compression, tile_sz);
  4961   4982   }
  4962   4983   
  4963   4984   static int
  4964   4985   export_ascii_grid_common (int by_section, sqlite3 * handle, int max_threads,
  4965   4986   			  const char *dst_path, rl2CoveragePtr cvg,
  4966   4987   			  sqlite3_int64 section_id, double res, double minx,
  4967   4988   			  double miny, double maxx, double maxy,
................................................................................
  5061   5082   	    }
  5062   5083         }
  5063   5084   
  5064   5085       if (by_section)
  5065   5086         {
  5066   5087   	  /* single Section */
  5067   5088   	  if (rl2_get_section_raw_raster_data
  5068         -	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
  5069         -	       maxx, maxy, res, res, &pixels, &pixels_size, &palette,
         5089  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         5090  +	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
  5070   5091   	       RL2_PIXEL_DATAGRID) != RL2_OK)
  5071   5092   	      goto error;
  5072   5093         }
  5073   5094       else
  5074   5095         {
  5075   5096   	  /* whole Coverage */
  5076   5097   	  if (rl2_get_raw_raster_data
  5077         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  5078         -	       res, res, &pixels, &pixels_size, &palette,
         5098  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         5099  +	       maxy, res, res, &pixels, &pixels_size, &palette,
  5079   5100   	       RL2_PIXEL_DATAGRID) != RL2_OK)
  5080   5101   	      goto error;
  5081   5102         }
  5082   5103   
  5083   5104       ascii =
  5084   5105   	rl2_create_ascii_grid_destination (dst_path, width, height,
  5085   5106   					   xx_res, minx, miny, is_centered,
................................................................................
  5120   5141   				 double res, double minx, double miny,
  5121   5142   				 double maxx, double maxy, unsigned int width,
  5122   5143   				 unsigned int height, int is_centered,
  5123   5144   				 int decimal_digits)
  5124   5145   {
  5125   5146   /* exporting an ASCII Grid from the DBMS into the file-system */
  5126   5147       return export_ascii_grid_common (0, handle, max_threads, dst_path, cvg, 0,
  5127         -				     res, minx, miny, maxx, maxy, width, height,
  5128         -				     is_centered, decimal_digits);
         5148  +				     res, minx, miny, maxx, maxy, width,
         5149  +				     height, is_centered, decimal_digits);
  5129   5150   }
  5130   5151   
  5131   5152   RL2_DECLARE int
  5132   5153   rl2_export_section_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
  5133   5154   					 const char *dst_path,
  5134   5155   					 rl2CoveragePtr cvg,
  5135   5156   					 sqlite3_int64 section_id, double res,
  5136         -					 double minx, double miny, double maxx,
  5137         -					 double maxy, unsigned int width,
         5157  +					 double minx, double miny,
         5158  +					 double maxx, double maxy,
         5159  +					 unsigned int width,
  5138   5160   					 unsigned int height, int is_centered,
  5139   5161   					 int decimal_digits)
  5140   5162   {
  5141   5163   /* exporting an ASCII Grid - Section */
  5142   5164       return export_ascii_grid_common (1, handle, max_threads, dst_path, cvg,
  5143   5165   				     section_id, res, minx, miny, maxx, maxy,
  5144   5166   				     width, height, is_centered,
................................................................................
  5184   5206   	  if (match == no_data->nBands)
  5185   5207   	      return 1;
  5186   5208         }
  5187   5209       return 0;
  5188   5210   }
  5189   5211   
  5190   5212   static float
  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,
         5213  +compute_ndvi (void *pixels, unsigned char sample_type,
         5214  +	      unsigned char num_bands, unsigned short width,
         5215  +	      unsigned char red_band, unsigned char nir_band,
         5216  +	      unsigned short row, unsigned short col,
  5194   5217   	      rl2PrivPixelPtr in_no_data, float out_no_data)
  5195   5218   {
  5196   5219   /* computing a Normalized Difference Vegetaion Index -NDVI */
  5197   5220       float red;
  5198   5221       float nir;
  5199   5222       unsigned char *p8;
  5200   5223       unsigned short *p16;
................................................................................
  5223   5246   
  5224   5247   static int
  5225   5248   export_ndvi_ascii_grid_common (int by_section, sqlite3 * handle,
  5226   5249   			       int max_threads, const char *dst_path,
  5227   5250   			       rl2CoveragePtr cvg, sqlite3_int64 section_id,
  5228   5251   			       double res, double minx, double miny,
  5229   5252   			       double maxx, double maxy, unsigned int width,
  5230         -			       unsigned int height, int red_band, int nir_band,
  5231         -			       int is_centered, int decimal_digits)
         5253  +			       unsigned int height, int red_band,
         5254  +			       int nir_band, int is_centered,
         5255  +			       int decimal_digits)
  5232   5256   {
  5233   5257   /* exporting an NDVI ASCII Grid common implementation */
  5234   5258       rl2PalettePtr palette = NULL;
  5235   5259       rl2PixelPtr in_no_data;
  5236   5260       rl2AsciiGridDestinationPtr ascii = NULL;
  5237   5261       unsigned char level;
  5238   5262       unsigned char scale;
................................................................................
  5277   5301       if (red_band == nir_band)
  5278   5302   	goto error;
  5279   5303   
  5280   5304       if (by_section)
  5281   5305         {
  5282   5306   	  /* single Section */
  5283   5307   	  if (rl2_get_section_raw_raster_data
  5284         -	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
  5285         -	       maxx, maxy, res, res, &pixels, &pixels_size, &palette,
         5308  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         5309  +	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
  5286   5310   	       RL2_PIXEL_MULTIBAND) != RL2_OK)
  5287   5311   	      goto error;
  5288   5312         }
  5289   5313       else
  5290   5314         {
  5291   5315   	  /* whole Coverage */
  5292   5316   	  if (rl2_get_raw_raster_data
  5293         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  5294         -	       res, res, &pixels, &pixels_size, &palette,
         5317  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         5318  +	       maxy, res, res, &pixels, &pixels_size, &palette,
  5295   5319   	       RL2_PIXEL_MULTIBAND) != RL2_OK)
  5296   5320   	      goto error;
  5297   5321         }
  5298   5322   
  5299   5323   /* creating the output NDVI raster */
  5300   5324       out_pixels_size = width * height * sizeof (float);
  5301   5325       out_pixels = malloc (out_pixels_size);
................................................................................
  5303   5327   	goto error;
  5304   5328       po = (float *) out_pixels;
  5305   5329       for (row = 0; row < height; row++)
  5306   5330         {
  5307   5331   	  /* computing NDVI */
  5308   5332   	  for (col = 0; col < width; col++)
  5309   5333   	      *po++ =
  5310         -		  compute_ndvi (pixels, sample_type, num_bands, width, red_band,
  5311         -				nir_band, row, col,
         5334  +		  compute_ndvi (pixels, sample_type, num_bands, width,
         5335  +				red_band, nir_band, row, col,
  5312   5336   				(rl2PrivPixelPtr) in_no_data, out_no_data);
  5313   5337         }
  5314   5338       free (pixels);
  5315   5339       pixels = NULL;
  5316   5340   
  5317   5341       ascii =
  5318   5342   	rl2_create_ascii_grid_destination (dst_path, width, height,
................................................................................
  5347   5371       if (palette != NULL)
  5348   5372   	rl2_destroy_palette (palette);
  5349   5373       return RL2_ERROR;
  5350   5374   }
  5351   5375   
  5352   5376   RL2_DECLARE int
  5353   5377   rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
  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)
         5378  +				      const char *dst_path,
         5379  +				      rl2CoveragePtr cvg, double res,
         5380  +				      double minx, double miny, double maxx,
         5381  +				      double maxy, unsigned int width,
         5382  +				      unsigned int height, int red_band,
         5383  +				      int nir_band, int is_centered,
         5384  +				      int decimal_digits)
  5360   5385   {
  5361   5386   /* exporting an ASCII Grid from the DBMS into the file-system */
  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,
         5387  +    return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path,
         5388  +					  cvg, 0, res, minx, miny, maxx, maxy,
         5389  +					  width, height, red_band, nir_band,
  5365   5390   					  is_centered, decimal_digits);
  5366   5391   }
  5367   5392   
  5368   5393   RL2_DECLARE int
  5369         -rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
         5394  +rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
         5395  +					      int max_threads,
  5370   5396   					      const char *dst_path,
  5371   5397   					      rl2CoveragePtr cvg,
  5372   5398   					      sqlite3_int64 section_id,
  5373   5399   					      double res, double minx,
  5374   5400   					      double miny, double maxx,
  5375   5401   					      double maxy, unsigned int width,
  5376         -					      unsigned int height, int red_band,
  5377         -					      int nir_band, int is_centered,
         5402  +					      unsigned int height,
         5403  +					      int red_band, int nir_band,
         5404  +					      int is_centered,
  5378   5405   					      int decimal_digits)
  5379   5406   {
  5380   5407   /* exporting an ASCII Grid - Section */
  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,
         5408  +    return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path,
         5409  +					  cvg, section_id, res, minx, miny,
         5410  +					  maxx, maxy, width, height, red_band,
  5384   5411   					  nir_band, is_centered,
  5385   5412   					  decimal_digits);
  5386   5413   }
  5387   5414   
  5388   5415   static int
  5389   5416   export_jpeg_common (int by_section, sqlite3 * handle, int max_threads,
  5390   5417   		    const char *dst_path, rl2CoveragePtr cvg,
................................................................................
  5427   5454       else
  5428   5455   	goto error;
  5429   5456   
  5430   5457       if (by_section)
  5431   5458         {
  5432   5459   	  /* single Section */
  5433   5460   	  if (rl2_get_section_raw_raster_data
  5434         -	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
  5435         -	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5461  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         5462  +	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5436   5463   	       pixel_type) != RL2_OK)
  5437   5464   	      goto error;
  5438   5465         }
  5439   5466       else
  5440   5467         {
  5441   5468   	  /* whole Coverage */
  5442   5469   	  if (rl2_get_raw_raster_data
  5443         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  5444         -	       xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5470  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         5471  +	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5445   5472   	       pixel_type) != RL2_OK)
  5446   5473   	      goto error;
  5447   5474         }
  5448   5475   
  5449   5476       raster =
  5450   5477   	rl2_create_raster (width, height, sample_type, pixel_type, num_bands,
  5451   5478   			   outbuf, outbuf_size, NULL, NULL, 0, NULL);
................................................................................
  5478   5505   	free (outbuf);
  5479   5506       return RL2_ERROR;
  5480   5507   }
  5481   5508   
  5482   5509   RL2_DECLARE int
  5483   5510   rl2_export_jpeg_from_dbms (sqlite3 * handle, int max_threads,
  5484   5511   			   const char *dst_path, rl2CoveragePtr cvg,
  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)
         5512  +			   double x_res, double y_res, double minx,
         5513  +			   double miny, double maxx, double maxy,
         5514  +			   unsigned int width, unsigned int height,
         5515  +			   int quality, int with_worldfile)
  5488   5516   {
  5489   5517   /* exporting a JPEG (with possible JGW) from the DBMS into the file-system */
  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);
         5518  +    return export_jpeg_common (0, handle, max_threads, dst_path, cvg, 0,
         5519  +			       x_res, y_res, minx, miny, maxx, maxy, width,
         5520  +			       height, quality, with_worldfile);
  5493   5521   }
  5494   5522   
  5495   5523   RL2_DECLARE int
  5496   5524   rl2_export_section_jpeg_from_dbms (sqlite3 * handle, int max_threads,
  5497   5525   				   const char *dst_path, rl2CoveragePtr cvg,
  5498   5526   				   sqlite3_int64 section_id, double x_res,
  5499   5527   				   double y_res, double minx, double miny,
  5500         -				   double maxx, double maxy, unsigned int width,
  5501         -				   unsigned int height, int quality,
  5502         -				   int with_worldfile)
         5528  +				   double maxx, double maxy,
         5529  +				   unsigned int width, unsigned int height,
         5530  +				   int quality, int with_worldfile)
  5503   5531   {
  5504   5532   /* exporting a JPEG (with possible JGW) - Section */
  5505   5533       return export_jpeg_common (1, handle, max_threads, dst_path, cvg,
  5506         -			       section_id, x_res, y_res, minx, miny, maxx, maxy,
  5507         -			       width, height, quality, with_worldfile);
         5534  +			       section_id, x_res, y_res, minx, miny, maxx,
         5535  +			       maxy, width, height, quality, with_worldfile);
  5508   5536   }
  5509   5537   
  5510   5538   static int
  5511   5539   export_raw_pixels_common (int by_section, sqlite3 * handle, int max_threads,
  5512   5540   			  rl2CoveragePtr cvg, sqlite3_int64 section_id,
  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)
         5541  +			  double x_res, double y_res, double minx,
         5542  +			  double miny, double maxx, double maxy,
         5543  +			  unsigned int width, unsigned int height,
         5544  +			  int big_endian, unsigned char **blob, int *blob_size)
  5517   5545   {
  5518   5546   /* common implementation for Export RAW pixels */
  5519   5547       unsigned char level;
  5520   5548       unsigned char scale;
  5521   5549       double xx_res = x_res;
  5522   5550       double yy_res = y_res;
  5523   5551       unsigned char sample_type;
................................................................................
  5540   5568   	RL2_OK)
  5541   5569   	goto error;
  5542   5570   
  5543   5571       if (by_section)
  5544   5572         {
  5545   5573   	  /* single Section */
  5546   5574   	  if (rl2_get_section_raw_raster_data
  5547         -	      (handle, max_threads, cvg, section_id, width, height, minx, miny,
  5548         -	       maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5575  +	      (handle, max_threads, cvg, section_id, width, height, minx,
         5576  +	       miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5549   5577   	       pixel_type) != RL2_OK)
  5550   5578   	      goto error;
  5551   5579         }
  5552   5580       else
  5553   5581         {
  5554   5582   	  /* whole Coverage */
  5555   5583   	  if (rl2_get_raw_raster_data
  5556         -	      (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy,
  5557         -	       xx_res, yy_res, &outbuf, &outbuf_size, NULL,
         5584  +	      (handle, max_threads, cvg, width, height, minx, miny, maxx,
         5585  +	       maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL,
  5558   5586   	       pixel_type) != RL2_OK)
  5559   5587   	      goto error;
  5560   5588         }
  5561   5589       bufpix =
  5562   5590   	rl2_copy_endian_raw_pixels (outbuf, outbuf_size, width, height,
  5563   5591   				    sample_type, num_bands, big_endian);
  5564   5592       if (bufpix == NULL)
................................................................................
  5580   5608   				 double y_res, double minx, double miny,
  5581   5609   				 double maxx, double maxy,
  5582   5610   				 unsigned int width,
  5583   5611   				 unsigned int height, int big_endian,
  5584   5612   				 unsigned char **blob, int *blob_size)
  5585   5613   {
  5586   5614   /* exporting RAW pixel buffer and Transparency Mask from the DBMS */
  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);
         5615  +    return export_raw_pixels_common (0, handle, max_threads, coverage, 0,
         5616  +				     x_res, y_res, minx, miny, maxx, maxy,
         5617  +				     width, height, big_endian, blob,
         5618  +				     blob_size);
  5590   5619   }
  5591   5620   
  5592   5621   RL2_DECLARE int
  5593   5622   rl2_export_section_raw_pixels_from_dbms (sqlite3 * handle, int max_threads,
  5594   5623   					 rl2CoveragePtr coverage,
  5595   5624   					 sqlite3_int64 section_id,
  5596   5625   					 double x_res, double y_res,
................................................................................
  5599   5628   					 unsigned int width,
  5600   5629   					 unsigned int height,
  5601   5630   					 int big_endian,
  5602   5631   					 unsigned char **blob, int *blob_size)
  5603   5632   {
  5604   5633   /* exporting RAW pixel buffer and Transparency Mask - Section */
  5605   5634       return export_raw_pixels_common (1, handle, max_threads, coverage,
  5606         -				     section_id, x_res, y_res, minx, miny, maxx,
  5607         -				     maxy, width, height, big_endian, blob,
  5608         -				     blob_size);
         5635  +				     section_id, x_res, y_res, minx, miny,
         5636  +				     maxx, maxy, width, height, big_endian,
         5637  +				     blob, blob_size);
  5609   5638   }
  5610   5639   
  5611   5640   RL2_DECLARE int
  5612   5641   rl2_load_raw_raster_into_dbms (sqlite3 * handle, int max_threads,
  5613   5642   			       rl2CoveragePtr cvg, const char *section,
  5614   5643   			       rl2RasterPtr rst, int pyramidize)
  5615   5644   {

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

Changes to src/rl2openjpeg.c.

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

Changes to src/rl2paint.c.

   768    768   					 double height, unsigned char red1,
   769    769   					 unsigned char green1,
   770    770   					 unsigned char blue1,
   771    771   					 unsigned char alpha1,
   772    772   					 unsigned char red2,
   773    773   					 unsigned char green2,
   774    774   					 unsigned char blue2,
   775         -					 unsigned char alpha2, double pen_width,
   776         -					 int line_cap, int line_join)
          775  +					 unsigned char alpha2,
          776  +					 double pen_width, int line_cap,
          777  +					 int line_join)
   777    778   {
   778    779   /* setting up a Linear Gradient Pen - solid style */
   779    780       double d_red = (double) red1 / 255.0;
   780    781       double d_green = (double) green1 / 255.0;
   781    782       double d_blue = (double) blue1 / 255.0;
   782    783       double d_alpha = (double) alpha1 / 255.0;
   783    784       RL2GraphContextPtr ctx = (RL2GraphContextPtr) context;
................................................................................
  1043   1044       return 1;
  1044   1045   }
  1045   1046   
  1046   1047   RL2_DECLARE int
  1047   1048   rl2_graph_set_linear_gradient_brush (rl2GraphicsContextPtr context, double x,
  1048   1049   				     double y, double width, double height,
  1049   1050   				     unsigned char red1, unsigned char green1,
  1050         -				     unsigned char blue1, unsigned char alpha1,
  1051         -				     unsigned char red2, unsigned char green2,
         1051  +				     unsigned char blue1,
         1052  +				     unsigned char alpha1, unsigned char red2,
         1053  +				     unsigned char green2,
  1052   1054   				     unsigned char blue2, unsigned char alpha2)
  1053   1055   {
  1054   1056   /* setting up a Linear Gradient Brush */
  1055   1057       double d_red = (double) red1 / 255.0;
  1056   1058       double d_green = (double) green1 / 255.0;
  1057   1059       double d_blue = (double) blue1 / 255.0;
  1058   1060       double d_alpha = (double) alpha1 / 255.0;
................................................................................
  1554   1556       unsigned char red;
  1555   1557       unsigned char green;
  1556   1558       unsigned char blue;
  1557   1559       unsigned char alpha;
  1558   1560       unsigned char xred;
  1559   1561       unsigned char xgreen;
  1560   1562       unsigned char xblue;
         1563  +    unsigned char xalpha;
  1561   1564       int valid = 0;
         1565  +    int has_black = 0;
  1562   1566       unsigned char *bitmap;
  1563   1567       RL2PrivGraphPatternPtr pattern = (RL2PrivGraphPatternPtr) ptrn;
  1564   1568       if (pattern == NULL)
  1565   1569   	return RL2_ERROR;
  1566   1570   
  1567   1571       width = pattern->width;
  1568   1572       height = pattern->height;
................................................................................
  1571   1575       if (bitmap == NULL)
  1572   1576   	return RL2_ERROR;
  1573   1577   /* checking for a Monochrome Pattern */
  1574   1578       for (y = 0; y < height; y++)
  1575   1579         {
  1576   1580   	  for (x = 0; x < width; x++)
  1577   1581   	    {
  1578         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
  1579         -				       &alpha);
         1582  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
         1583  +				       &blue, &alpha);
  1580   1584   		if (alpha != 0)
  1581   1585   		  {
         1586  +		      if (red < 64 && green < 64 && blue < 64)
         1587  +			  has_black++;
  1582   1588   		      if (valid)
  1583   1589   			{
  1584         -			    if (xred == red && xgreen == green && xblue == blue)
         1590  +			    if (xred == red && xgreen == green
         1591  +				&& xblue == blue && alpha == xalpha)
  1585   1592   				;
  1586   1593   			    else
  1587         -				return RL2_ERROR;
         1594  +				goto not_mono;
  1588   1595   			}
  1589   1596   		      else
  1590   1597   			{
  1591   1598   			    xred = red;
  1592   1599   			    xgreen = green;
  1593   1600   			    xblue = blue;
         1601  +			    xalpha = alpha;
  1594   1602   			    valid = 1;
  1595   1603   			}
  1596   1604   		  }
  1597   1605   	    }
  1598   1606         }
  1599   1607   /* all right, applying the new color */
  1600   1608       for (y = 0; y < height; y++)
  1601   1609         {
  1602   1610   	  for (x = 0; x < width; x++)
  1603   1611   	    {
  1604         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
  1605         -				       &alpha);
         1612  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
         1613  +				       &blue, &alpha);
  1606   1614   		if (alpha != 0)
  1607   1615   		    aux_pattern_set_pixel (x, y, width, bitmap, r, g, b, alpha);
  1608   1616   	    }
  1609   1617         }
  1610   1618       cairo_surface_mark_dirty (pattern->bitmap);
  1611   1619       return RL2_OK;
         1620  +
         1621  +  not_mono:
         1622  +    if (has_black)
         1623  +      {
         1624  +	  /* recoloring only the black pixels */
         1625  +	  for (y = 0; y < height; y++)
         1626  +	    {
         1627  +		for (x = 0; x < width; x++)
         1628  +		  {
         1629  +		      aux_pattern_get_pixel (x, y, width, bitmap, &red,
         1630  +					     &green, &blue, &alpha);
         1631  +		      if (red < 64 && green < 64 && blue < 64)
         1632  +			  aux_pattern_set_pixel (x, y, width, bitmap, r, g, b,
         1633  +						 alpha);
         1634  +		  }
         1635  +	    }
         1636  +	  cairo_surface_mark_dirty (pattern->bitmap);
         1637  +	  return RL2_OK;
         1638  +      }
         1639  +    return RL2_ERROR;
  1612   1640   }
  1613   1641   
  1614   1642   RL2_DECLARE int
  1615   1643   rl2_graph_pattern_transparency (rl2GraphicsPatternPtr ptrn, unsigned char aleph)
  1616   1644   {
  1617   1645   /* changing the Pattern's transparency */
  1618   1646       int x;
................................................................................
  1635   1663       if (bitmap == NULL)
  1636   1664   	return RL2_ERROR;
  1637   1665   /* applying the new transparency */
  1638   1666       for (y = 0; y < height; y++)
  1639   1667         {
  1640   1668   	  for (x = 0; x < width; x++)
  1641   1669   	    {
  1642         -		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue,
  1643         -				       &alpha);
         1670  +		aux_pattern_get_pixel (x, y, width, bitmap, &red, &green,
         1671  +				       &blue, &alpha);
  1644   1672   		if (alpha != 0)
  1645   1673   		    aux_pattern_set_pixel (x, y, width, bitmap, red, green,
  1646   1674   					   blue, aleph);
  1647   1675   	    }
  1648   1676         }
  1649   1677       cairo_surface_mark_dirty (pattern->bitmap);
  1650   1678       return RL2_OK;
................................................................................
  1765   1793         }
  1766   1794   
  1767   1795   /* destroying the cached font */
  1768   1796       rl2_destroy_private_tt_font (font);
  1769   1797   }
  1770   1798   
  1771   1799   RL2_DECLARE rl2GraphicsFontPtr
  1772         -rl2_graph_create_TrueType_font (const void *priv_data, const unsigned char *ttf,
  1773         -				int ttf_bytes, double size)
         1800  +rl2_graph_create_TrueType_font (const void *priv_data,
         1801  +				const unsigned char *ttf, int ttf_bytes,
         1802  +				double size)
  1774   1803   {
  1775   1804   /* creating a TrueType font */
  1776   1805       RL2GraphFontPtr fnt;
  1777   1806       char *facename;
  1778   1807       int is_bold;
  1779   1808       int is_italic;
  1780   1809       unsigned char *font = NULL;
................................................................................
  2262   2291       set_current_pen (ctx);
  2263   2292       cairo_stroke (cairo);
  2264   2293       return 1;
  2265   2294   }
  2266   2295   
  2267   2296   RL2_DECLARE int
  2268   2297   rl2_graph_draw_circle_sector (rl2GraphicsContextPtr context, double center_x,
  2269         -			      double center_y, double radius, double from_angle,
  2270         -			      double to_angle)
         2298  +			      double center_y, double radius,
         2299  +			      double from_angle, double to_angle)
  2271   2300   {
  2272   2301   /* drawing a filled circular sector */
  2273   2302       cairo_t *cairo;
  2274   2303       RL2GraphContextPtr ctx = (RL2GraphContextPtr) context;
  2275   2304       if (ctx == NULL)
  2276   2305   	return 0;
  2277   2306       if (ctx->type == RL2_SURFACE_PDF)
................................................................................
  2427   2456       *height = extents.height;
  2428   2457       *post_x = extents.x_advance;
  2429   2458       *post_y = extents.y_advance;
  2430   2459       return 1;
  2431   2460   }
  2432   2461   
  2433   2462   RL2_DECLARE int
  2434         -rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text, double x,
  2435         -		     double y, double angle, double anchor_point_x,
         2463  +rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text,
         2464  +		     double x, double y, double angle, double anchor_point_x,
  2436   2465   		     double anchor_point_y)
  2437   2466   {
  2438   2467   /* drawing a text string (using the current font) */
  2439   2468       double rads;
  2440   2469       double pre_x;
  2441   2470       double pre_y;
  2442   2471       double width;
................................................................................
  2609   2638       rl2GetPoint (ln->coords, ln->points - 1, &xx, &yy);
  2610   2639       if (xx == x && yy == y)
  2611   2640   	return 1;
  2612   2641       return 0;
  2613   2642   }
  2614   2643   
  2615   2644   static rl2GeometryPtr
  2616         -aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom, rl2GeometryPtr circle,
  2617         -		  double x, double y)
         2645  +aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom,
         2646  +		  rl2GeometryPtr circle, double x, double y)
  2618   2647   {
  2619   2648   /* reducing a Curve by discarding the alreasdy processed portion */
  2620   2649       sqlite3_stmt *stmt = NULL;
  2621   2650       const char *sql;
  2622   2651       int ret;
  2623   2652       unsigned char *blob1;
  2624   2653       int size1;
................................................................................
  2681   2710       return out;
  2682   2711   
  2683   2712     error:
  2684   2713       if (stmt != NULL)
  2685   2714   	sqlite3_finalize (stmt);
  2686   2715       return NULL;
  2687   2716   }
         2717  +
         2718  +static int
         2719  +check_reverse (rl2GeometryPtr geom)
         2720  +{
         2721  +/* testing for an inverse label */
         2722  +    rl2LinestringPtr ln;
         2723  +    double x0;
         2724  +    double y0;
         2725  +    double x1;
         2726  +    double y1;
         2727  +    double width;
         2728  +    double height;
         2729  +    int last;
         2730  +
         2731  +    if (geom == NULL)
         2732  +	return 0;
         2733  +    ln = geom->first_linestring;
         2734  +    if (ln == NULL)
         2735  +	return 0;
         2736  +    if (ln->points < 2)
         2737  +	return 0;
         2738  +    last = ln->points - 1;
         2739  +
         2740  +    rl2GetPoint (ln->coords, 0, &x0, &y0);
         2741  +    rl2GetPoint (ln->coords, last, &x1, &y1);
         2742  +    width = fabs (x0 - x1);
         2743  +    height = fabs (y0 - y1);
         2744  +    if (width > 3.0)
         2745  +      {
         2746  +	  if (x0 > x1)
         2747  +	      return 1;
         2748  +      }
         2749  +    else
         2750  +      {
         2751  +	  if (y0 > y1)
         2752  +	      return 1;
         2753  +      }
         2754  +    return 0;
         2755  +}
         2756  +
         2757  +static void
         2758  +reverse_text (const char *in, char *dest, int len)
         2759  +{
         2760  +/* reversing a text string */
         2761  +    char *out;
         2762  +    int n = 1;
         2763  +    while (*in != '\0')
         2764  +      {
         2765  +	  out = dest + len - n;
         2766  +	  *out = *in++;
         2767  +	  n++;
         2768  +      }
         2769  +    *(dest + len) = '\0';
         2770  +}
  2688   2771   
  2689   2772   static rl2GeometryPtr
  2690   2773   rl2_draw_wrapped_label (sqlite3 * handle, rl2GraphicsContextPtr context,
  2691   2774   			cairo_t * cairo, const char *text, rl2GeometryPtr geom)
  2692   2775   {
  2693   2776   /* placing each character along the modelling line */
  2694   2777       double x0;
................................................................................
  2699   2782       double m;
  2700   2783       double rads;
  2701   2784       double angle;
  2702   2785       char buf[2];
  2703   2786       rl2GeometryPtr g2;
  2704   2787       rl2GeometryPtr g = rl2_clone_curve (geom);
  2705   2788       rl2GeometryPtr circle;
         2789  +    char *rev_text = NULL;
  2706   2790       const char *c = text;
  2707   2791       cairo_font_extents_t extents;
  2708   2792   
  2709   2793       cairo_font_extents (cairo, &extents);
  2710   2794       radius =
  2711   2795   	sqrt ((extents.max_x_advance * extents.max_x_advance) +
  2712   2796   	      (extents.height * extents.height)) / 2.0;
         2797  +    if (check_reverse (g))
         2798  +      {
         2799  +	  /* reverse text */
         2800  +	  int len = strlen (text);
         2801  +	  rev_text = malloc (len + 1);
         2802  +	  reverse_text (text, rev_text, len);
         2803  +	  c = rev_text;
         2804  +      }
  2713   2805       while (*c != '\0' && g != NULL)
  2714   2806         {
  2715   2807   	  buf[0] = *c;
  2716   2808   	  buf[1] = '\0';
  2717   2809   	  get_aux_start_point (g, &x0, &y0);
  2718   2810   	  circle = rl2_build_circle (x0, y0, radius);
  2719   2811   	  if (!get_aux_interception_point (handle, g, circle, &x1, &y1))
................................................................................
  2722   2814   		rl2_destroy_geometry (g);
  2723   2815   		g = NULL;
  2724   2816   		break;
  2725   2817   	    }
  2726   2818   	  m = (y1 - y0) / (x1 - x0);
  2727   2819   	  rads = atan (m);
  2728   2820   	  angle = rads / .0174532925199432958;
  2729         -	  if (x1 < x0)
         2821  +	  if (x1 < x0 && rev_text == NULL)
  2730   2822   	      angle += 180.0;
  2731   2823   	  rl2_graph_draw_text (context, buf, x0, y0, angle, 0.5, 0.5);
  2732   2824   	  c++;
  2733   2825   	  g2 = aux_reduce_curve (handle, g, circle, x0, y0);
  2734   2826   	  rl2_destroy_geometry (circle);
  2735   2827   	  rl2_destroy_geometry (g);
  2736   2828   	  g = g2;
  2737   2829         }
         2830  +    if (rev_text)
         2831  +	free (rev_text);
  2738   2832       return g;
  2739   2833   }
  2740   2834   
  2741   2835   RL2_DECLARE int
  2742   2836   rl2_graph_draw_warped_text (sqlite3 * handle, rl2GraphicsContextPtr context,
  2743         -			    const char *text, int points, double *x, double *y,
  2744         -			    double initial_gap, double gap, int repeated)
         2837  +			    const char *text, int points, double *x,
         2838  +			    double *y, double initial_gap, double gap,
         2839  +			    int repeated)
  2745   2840   {
  2746   2841   /* drawing a text string warped along a modelling curve (using the current font) */
  2747   2842       double curve_len;
  2748   2843       double text_len;
  2749   2844       double extra_len;
  2750   2845       double start;
  2751   2846       double from;
................................................................................
  2765   2860   
  2766   2861       geom = rl2_curve_from_XY (points, x, y);
  2767   2862       if (geom == NULL)
  2768   2863   	return 0;
  2769   2864   
  2770   2865       curve_len = rl2_compute_curve_length (geom);
  2771   2866       do_estimate_text_length (cairo, text, &text_len, &extra_len);
  2772         -    if ((text_len + (2.0 * extra_len)) > curve_len)
         2867  +    if ((initial_gap + text_len + (2.0 * extra_len)) > curve_len)
  2773   2868   	return 0;		/* not enough room to place the label */
  2774   2869   
  2775   2870       if (repeated)
  2776   2871         {
  2777   2872   	  /* repeated labels */
  2778   2873   	  int first = 1;
  2779   2874   	  rl2GeometryPtr geom3 = rl2_clone_linestring (geom->first_linestring);
................................................................................
  2783   2878   		  {
  2784   2879   		      start = initial_gap + extra_len;
  2785   2880   		      first = 0;
  2786   2881   		  }
  2787   2882   		else
  2788   2883   		    start = gap + extra_len;
  2789   2884   		curve_len = rl2_compute_curve_length (geom3);
         2885  +		if ((start + text_len + extra_len) > curve_len)
         2886  +		    break;	/* not enough room to place the label */
  2790   2887   		from = start / curve_len;
  2791   2888   		/* extracting the sub-path modelling the label */
  2792   2889   		geom2 = rl2_curve_substring (handle, geom3, from, 1.0);
  2793   2890   		rl2_destroy_geometry (geom3);
  2794   2891   		if (geom2 == NULL)
  2795   2892   		    goto error;
  2796   2893   		geom3 =

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, 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)
          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)
   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, const unsigned char *alpha,
  1088         -			   unsigned char **png, int *png_size)
         1087  +			   const unsigned char *rgb,
         1088  +			   const unsigned char *alpha, unsigned char **png,
         1089  +			   int *png_size)
  1089   1090   {
  1090   1091   /* creating a PNG image from two distinct RGB + Alpha buffer */
  1091   1092       unsigned char *blob;
  1092   1093       int blob_size;
  1093   1094       if (rgb == NULL || alpha == NULL)
  1094   1095   	return RL2_ERROR;
  1095   1096   
................................................................................
  1171   1172         case RL2_PIXEL_DATAGRID:
  1172   1173   	  if (sample_type == RL2_SAMPLE_UINT16)
  1173   1174   	      ret =
  1174   1175   		  compress_grayscale_png16 (pixels, width, height,
  1175   1176   					    sample_type, &blob, &blob_size);
  1176   1177   	  else
  1177   1178   	      ret =
  1178         -		  compress_grayscale_png8 (pixels, mask, opacity, width, height,
  1179         -					   sample_type, pixel_type, &blob,
  1180         -					   &blob_size);
         1179  +		  compress_grayscale_png8 (pixels, mask, opacity, width,
         1180  +					   height, sample_type, pixel_type,
         1181  +					   &blob, &blob_size);
  1181   1182   	  break;
  1182   1183         case RL2_PIXEL_RGB:
  1183   1184   	  if (sample_type == RL2_SAMPLE_UINT8)
  1184   1185   	      ret =
  1185   1186   		  compress_rgb_png8 (pixels, mask, opacity, width, height,
  1186   1187   				     &blob, &blob_size);
  1187   1188   	  else if (sample_type == RL2_SAMPLE_UINT16)
................................................................................
  1189   1190   		  compress_rgb_png16 (pixels, width, height, &blob, &blob_size);
  1190   1191   	  break;
  1191   1192         case RL2_PIXEL_MULTIBAND:
  1192   1193   	  if (sample_type == RL2_SAMPLE_UINT8)
  1193   1194   	    {
  1194   1195   		if (num_bands == 3)
  1195   1196   		    ret =
  1196         -			compress_rgb_png8 (pixels, mask, opacity, width, height,
  1197         -					   &blob, &blob_size);
         1197  +			compress_rgb_png8 (pixels, mask, opacity, width,
         1198  +					   height, &blob, &blob_size);
  1198   1199   		else if (num_bands == 4)
  1199   1200   		    ret =
  1200   1201   			compress_4bands_png8 (pixels, width, height, &blob,
  1201   1202   					      &blob_size);
  1202   1203   	    }
  1203   1204   	  else if (sample_type == RL2_SAMPLE_UINT16)
  1204   1205   	    {
................................................................................
  1411   1412   	  if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
  1412   1413   	      nBands = 4;
  1413   1414         }
  1414   1415       if (*xpixel_type == RL2_PIXEL_DATAGRID)
  1415   1416   	pixel_type = RL2_PIXEL_DATAGRID;
  1416   1417       if (pixel_type == RL2_PIXEL_PALETTE)
  1417   1418         {
  1418         -	  if (png_get_tRNS (png_ptr, info_ptr, &transp, &nTransp, &transpValues)
  1419         -	      == PNG_INFO_tRNS)
         1419  +	  if (png_get_tRNS
         1420  +	      (png_ptr, info_ptr, &transp, &nTransp,
         1421  +	       &transpValues) == PNG_INFO_tRNS)
  1420   1422   	    {
  1421   1423   		/* a Transparency palette is defined */
  1422   1424   		int i;
  1423   1425   		for (i = 0; i < nTransp; i++)
  1424   1426   		    *(alpha + i) = *(transp + i);
  1425   1427   		has_alpha = 1;
  1426   1428   	    }

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", xtable,
   263         -			 sect_id);
          262  +			 "WHERE section_id = %s AND pyramid_level > 0",
          263  +			 xtable, 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 = sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages "
   355         -			   "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
          354  +    sql =
          355  +	sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages "
          356  +			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
   356    357       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
   357    358       sqlite3_free (sql);
   358    359       if (ret != SQLITE_OK)
   359    360         {
   360    361   	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
   361    362   	  goto error;
   362    363         }
................................................................................
   487    488   	  free (tile_in);
   488    489   	  tile_in = tile_in_n;
   489    490         }
   490    491       free (pyr);
   491    492   }
   492    493   
   493    494   static int
   494         -insert_tile_into_section_pyramid (SectionPyramidPtr pyr, sqlite3_int64 tile_id,
   495         -				  double minx, double miny, double maxx,
   496         -				  double maxy)
          495  +insert_tile_into_section_pyramid (SectionPyramidPtr pyr,
          496  +				  sqlite3_int64 tile_id, double minx,
          497  +				  double miny, double maxx, double maxy)
   497    498   {
   498    499   /* inserting a base tile into the Pyramid level */
   499    500       SectionPyramidTileInPtr tile;
   500    501       if (pyr == NULL)
   501    502   	return 0;
   502    503       tile = alloc_section_pyramid_tile (tile_id, minx, miny, maxx, maxy);
   503    504       if (tile == NULL)
................................................................................
   572    573         {
   573    574   	  if (tile->cx > minx && tile->cx < maxx && tile->cy > miny
   574    575   	      && tile->cy < maxy)
   575    576   	    {
   576    577   		if (first)
   577    578   		  {
   578    579   		      out =
   579         -			  add_pyramid_out_tile (pyr, row, col, minx, miny, maxx,
   580         -						maxy);
          580  +			  add_pyramid_out_tile (pyr, row, col, minx, miny,
          581  +						maxx, maxy);
   581    582   		      first = 0;
   582    583   		  }
   583    584   		if (out != NULL)
   584    585   		    add_pyramid_sub_tile (out, tile);
   585    586   	    }
   586    587   	  tile = tile->next;
   587    588         }
................................................................................
   763    764   	  for (col = 0; col < (unsigned int) tic_x; col++)
   764    765   	    {
   765    766   		unsigned int xx = col + x;
   766    767   		char *p_out = p_out_base + xx;
   767    768   		if (xx >= tileWidth)
   768    769   		    break;
   769    770   		*p_out =
   770         -		    rescale_pixel_int8 (buf_in, tileWidth, tileHeight, col * 8,
   771         -					row * 8, nd);
          771  +		    rescale_pixel_int8 (buf_in, tileWidth, tileHeight,
          772  +					col * 8, row * 8, nd);
   772    773   	    }
   773    774         }
   774    775   }
   775    776   
   776    777   static double
   777    778   rescale_pixel_uint8 (const unsigned char *buf_in, unsigned int tileWidth,
   778    779   		     unsigned int tileHeight, int x, int y, unsigned char nd)
................................................................................
   843    844   	  for (col = 0; col < (unsigned int) tic_x; col++)
   844    845   	    {
   845    846   		unsigned int xx = col + x;
   846    847   		unsigned char *p_out = p_out_base + xx;
   847    848   		if (xx >= tileWidth)
   848    849   		    break;
   849    850   		*p_out =
   850         -		    rescale_pixel_uint8 (buf_in, tileWidth, tileHeight, col * 8,
   851         -					 row * 8, nd);
          851  +		    rescale_pixel_uint8 (buf_in, tileWidth, tileHeight,
          852  +					 col * 8, row * 8, nd);
   852    853   	    }
   853    854         }
   854    855   }
   855    856   
   856    857   static double
   857    858   rescale_pixel_int16 (const short *buf_in, unsigned int tileWidth,
   858    859   		     unsigned int tileHeight, int x, int y, short nd)
................................................................................
   923    924   	  for (col = 0; col < (unsigned int) tic_x; col++)
   924    925   	    {
   925    926   		unsigned int xx = col + x;
   926    927   		short *p_out = p_out_base + xx;
   927    928   		if (xx >= tileWidth)
   928    929   		    break;
   929    930   		*p_out =
   930         -		    rescale_pixel_int16 (buf_in, tileWidth, tileHeight, col * 8,
   931         -					 row * 8, nd);
          931  +		    rescale_pixel_int16 (buf_in, tileWidth, tileHeight,
          932  +					 col * 8, row * 8, nd);
   932    933   	    }
   933    934         }
   934    935   }
   935    936   
   936    937   static double
   937    938   rescale_pixel_uint16 (const unsigned short *buf_in, unsigned int tileWidth,
   938    939   		      unsigned int tileHeight, int x, int y, unsigned short nd)
................................................................................
  1083   1084   	  for (col = 0; col < (unsigned int) tic_x; col++)
  1084   1085   	    {
  1085   1086   		unsigned int xx = col + x;
  1086   1087   		int *p_out = p_out_base + xx;
  1087   1088   		if (xx >= tileWidth)
  1088   1089   		    break;
  1089   1090   		*p_out =
  1090         -		    rescale_pixel_int32 (buf_in, tileWidth, tileHeight, col * 8,
  1091         -					 row * 8, nd);
         1091  +		    rescale_pixel_int32 (buf_in, tileWidth, tileHeight,
         1092  +					 col * 8, row * 8, nd);
  1092   1093   	    }
  1093   1094         }
  1094   1095   }
  1095   1096   
  1096   1097   static double
  1097   1098   rescale_pixel_uint32 (const unsigned int *buf_in, unsigned int tileWidth,
  1098   1099   		      unsigned int tileHeight, int x, int y, unsigned int nd)
................................................................................
  1243   1244   	  for (col = 0; col < (unsigned int) tic_x; col++)
  1244   1245   	    {
  1245   1246   		unsigned int xx = col + x;
  1246   1247   		float *p_out = p_out_base + xx;
  1247   1248   		if (xx >= tileWidth)
  1248   1249   		    break;
  1249   1250   		*p_out =
  1250         -		    rescale_pixel_float (buf_in, tileWidth, tileHeight, col * 8,
  1251         -					 row * 8, nd);
         1251  +		    rescale_pixel_float (buf_in, tileWidth, tileHeight,
         1252  +					 col * 8, row * 8, nd);
  1252   1253   	    }
  1253   1254         }
  1254   1255   }
  1255   1256   
  1256   1257   static double
  1257   1258   rescale_pixel_double (const double *buf_in, unsigned int tileWidth,
  1258   1259   		      unsigned int tileHeight, int x, int y, double nd)
................................................................................
  1344   1345         {
  1345   1346         case RL2_SAMPLE_INT8:
  1346   1347   	  rescale_grid_int8 ((char *) buf_out, tileWidth, tileHeight,
  1347   1348   			     (const char *) buf_in, x, y, tic_x, tic_y,
  1348   1349   			     no_data);
  1349   1350   	  break;
  1350   1351         case RL2_SAMPLE_UINT8:
  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);
         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);
  1354   1355   	  break;
  1355   1356         case RL2_SAMPLE_INT16:
  1356   1357   	  rescale_grid_int16 ((short *) buf_out, tileWidth, tileHeight,
  1357   1358   			      (const short *) buf_in, x, y, tic_x, tic_y,
  1358   1359   			      no_data);
  1359   1360   	  break;
  1360   1361         case RL2_SAMPLE_UINT16:
................................................................................
  1364   1365   	  break;
  1365   1366         case RL2_SAMPLE_INT32:
  1366   1367   	  rescale_grid_int32 ((int *) buf_out, tileWidth, tileHeight,
  1367   1368   			      (const int *) buf_in, x, y, tic_x, tic_y,
  1368   1369   			      no_data);
  1369   1370   	  break;
  1370   1371         case RL2_SAMPLE_UINT32:
  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);
         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);
  1374   1375   	  break;
  1375   1376         case RL2_SAMPLE_FLOAT:
  1376   1377   	  rescale_grid_float ((float *) buf_out, tileWidth, tileHeight,
  1377   1378   			      (const float *) buf_in, x, y, tic_x, tic_y,
  1378   1379   			      no_data);
  1379   1380   	  break;
  1380   1381         case RL2_SAMPLE_DOUBLE:
................................................................................
  1515   1516   				  break;
  1516   1517   			      }
  1517   1518   			    pos_x += geo_x;
  1518   1519   			}
  1519   1520   		      pos_y -= geo_y;
  1520   1521   		  }
  1521   1522   		rst = (rl2PrivRasterPtr) raster_in;
  1522         -		rescale_grid (buf_out, tileWidth, tileHeight, rst->rasterBuffer,
  1523         -			      sample_type, x, y, tic_x, tic_y, no_data);
         1523  +		rescale_grid (buf_out, tileWidth, tileHeight,
         1524  +			      rst->rasterBuffer, sample_type, x, y, tic_x,
         1525  +			      tic_y, no_data);
  1524   1526   		rl2_destroy_raster (raster_in);
  1525   1527   		raster_in = NULL;
  1526   1528   		tile_in = tile_in->next;
  1527   1529   	    }
  1528   1530   
  1529   1531   	  raster_out = NULL;
  1530   1532   	  raster_out =
................................................................................
  1546   1548   		goto error;
  1547   1549   	    }
  1548   1550   	  rl2_destroy_raster (raster_out);
  1549   1551   	  raster_out = NULL;
  1550   1552   
  1551   1553   	  /* INSERTing the tile */
  1552   1554   	  if (!do_insert_pyramid_tile
  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))
         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))
  1556   1559   	      goto error;
  1557   1560   
  1558   1561   	  tile_out = tile_out->next;
  1559   1562         }
  1560   1563   
  1561   1564       return 1;
  1562   1565   
................................................................................
  1570   1573       if (mask != NULL)
  1571   1574   	free (mask);
  1572   1575       return 0;
  1573   1576   }
  1574   1577   
  1575   1578   static double
  1576   1579   rescale_mb_pixel_uint8 (const unsigned char *buf_in, unsigned int tileWidth,
  1577         -			unsigned int tileHeight, unsigned int x, unsigned int y,
  1578         -			unsigned char nd, unsigned char nb,
         1580  +			unsigned int tileHeight, unsigned int x,
         1581  +			unsigned int y, unsigned char nd, unsigned char nb,
  1579   1582   			unsigned char num_bands)
  1580   1583   {
  1581   1584   /* rescaling a MultiBand pixel sample (8x8) - UINT8 */
  1582   1585       unsigned int row;
  1583   1586       unsigned int col;
  1584   1587       int nodata = 0;
  1585   1588       int valid = 0;
................................................................................
  1648   1651   				&& pxl->nBands == num_bands)
  1649   1652   			      {
  1650   1653   				  rl2PrivSamplePtr sample = pxl->Samples + nb;
  1651   1654   				  nd = sample->uint8;
  1652   1655   			      }
  1653   1656   			}
  1654   1657   		      *(p_out + nb) =
  1655         -			  rescale_mb_pixel_uint8 (buf_in, tileWidth, tileHeight,
  1656         -						  col * 8, row * 8, nd, nb,
  1657         -						  num_bands);
         1658  +			  rescale_mb_pixel_uint8 (buf_in, tileWidth,
         1659  +						  tileHeight, col * 8,
         1660  +						  row * 8, nd, nb, num_bands);
  1658   1661   		  }
  1659   1662   	    }
  1660   1663         }
  1661   1664   }
  1662   1665   
  1663   1666   static double
  1664   1667   rescale_mb_pixel_uint16 (const unsigned short *buf_in, unsigned int tileWidth,
................................................................................
  1738   1741   			      {
  1739   1742   				  rl2PrivSamplePtr sample = pxl->Samples + nb;
  1740   1743   				  nd = sample->uint16;
  1741   1744   			      }
  1742   1745   			}
  1743   1746   		      *(p_out + nb) =
  1744   1747   			  rescale_mb_pixel_uint16 (buf_in, tileWidth,
  1745         -						   tileHeight, col * 8, row * 8,
  1746         -						   nd, nb, num_bands);
         1748  +						   tileHeight, col * 8,
         1749  +						   row * 8, nd, nb, num_bands);
  1747   1750   		  }
  1748   1751   	    }
  1749   1752         }
  1750   1753   }
  1751   1754   
  1752   1755   static void
  1753   1756   rescale_multiband (void *buf_out, unsigned int tileWidth,
................................................................................
  1762   1765         case RL2_SAMPLE_UINT8:
  1763   1766   	  rescale_multiband_uint8 ((unsigned char *) buf_out, tileWidth,
  1764   1767   				   tileHeight, (const unsigned char *) buf_in,
  1765   1768   				   x, y, tic_x, tic_y, num_bands, no_data);
  1766   1769   	  break;
  1767   1770         case RL2_SAMPLE_UINT16:
  1768   1771   	  rescale_multiband_uint16 ((unsigned short *) buf_out, tileWidth,
  1769         -				    tileHeight, (const unsigned short *) buf_in,
  1770         -				    x, y, tic_x, tic_y, num_bands, no_data);
         1772  +				    tileHeight,
         1773  +				    (const unsigned short *) buf_in, x, y,
         1774  +				    tic_x, tic_y, num_bands, no_data);
  1771   1775   	  break;
  1772   1776         };
  1773   1777   }
  1774   1778   
  1775   1779   static int
  1776   1780   update_sect_pyramid_multiband (sqlite3 * handle, sqlite3_stmt * stmt_rd,
  1777   1781   			       sqlite3_stmt * stmt_tils,
................................................................................
  1896   1900   			      }
  1897   1901   			    pos_x += geo_x;
  1898   1902   			}
  1899   1903   		      pos_y -= geo_y;
  1900   1904   		  }
  1901   1905   		rst = (rl2PrivRasterPtr) raster_in;
  1902   1906   		rescale_multiband (buf_out, tileWidth, tileHeight,
  1903         -				   rst->rasterBuffer, sample_type, num_bands, x,
  1904         -				   y, tic_x, tic_y, no_data);
         1907  +				   rst->rasterBuffer, sample_type, num_bands,
         1908  +				   x, y, tic_x, tic_y, no_data);
  1905   1909   		rl2_destroy_raster (raster_in);
  1906   1910   		raster_in = NULL;
  1907   1911   		tile_in = tile_in->next;
  1908   1912   	    }
  1909   1913   
  1910   1914   	  raster_out = NULL;
  1911   1915   	  raster_out =
................................................................................
  1927   1931   		goto error;
  1928   1932   	    }
  1929   1933   	  rl2_destroy_raster (raster_out);
  1930   1934   	  raster_out = NULL;
  1931   1935   
  1932   1936   	  /* INSERTing the tile */
  1933   1937   	  if (!do_insert_pyramid_tile
  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))
         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))
  1937   1942   	      goto error;
  1938   1943   
  1939   1944   	  tile_out = tile_out->next;
  1940   1945         }
  1941   1946   
  1942   1947       return 1;
  1943   1948   
................................................................................
  2118   2123   							    0);
  2119   2124   			}
  2120   2125   		      compression = RL2_COMPRESSION_PNG;
  2121   2126   		  }
  2122   2127   		else
  2123   2128   		    nd = rl2_clone_pixel (no_data);
  2124   2129   		raster =
  2125         -		    rl2_create_raster (tileWidth, tileHeight, RL2_SAMPLE_UINT8,
  2126         -				       RL2_PIXEL_GRAYSCALE, 1, gray,
  2127         -				       tileWidth * tileHeight, NULL, alpha,
  2128         -				       tileWidth * tileHeight, nd);
         2130  +		    rl2_create_raster (tileWidth, tileHeight,
         2131  +				       RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE,
         2132  +				       1, gray, tileWidth * tileHeight, NULL,
         2133  +				       alpha, tileWidth * tileHeight, nd);
  2129   2134   	    }
  2130   2135   	  else if (pyr->pixel_type == RL2_PIXEL_RGB)
  2131   2136   	    {
  2132   2137   		/* RGB Pyramid */
  2133   2138   		nd = rl2_clone_pixel (no_data);
  2134   2139   		raster =
  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);
         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);
  2139   2144   	    }
  2140   2145   	  if (raster == NULL)
  2141   2146   	    {
  2142   2147   		fprintf (stderr, "ERROR: unable to create a Pyramid Tile\n");
  2143   2148   		goto error;
  2144   2149   	    }
  2145   2150   	  if (rl2_raster_encode
................................................................................
  2152   2157   	  rl2_destroy_raster (raster);
  2153   2158   	  raster = NULL;
  2154   2159   	  rl2_graph_destroy_context (ctx);
  2155   2160   	  ctx = NULL;
  2156   2161   
  2157   2162   	  /* INSERTing the tile */
  2158   2163   	  if (!do_insert_pyramid_tile
  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))
         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))
  2162   2168   	      goto error;
  2163   2169   
  2164   2170   	  tile_out = tile_out->next;
  2165   2171         }
  2166   2172   
  2167   2173       return 1;
  2168   2174   
................................................................................
  2340   2346   	rl2_graph_destroy_context (ctx);
  2341   2347       return 0;
  2342   2348   }
  2343   2349   
  2344   2350   #define floor2(exp) ((long) exp)
  2345   2351   
  2346   2352   static rl2RasterPtr
  2347         -create_124_rescaled_raster (const unsigned char *rgba, unsigned char pixel_type,
  2348         -			    unsigned int tileWidth, unsigned int tileHeight,
  2349         -			    int scale)
         2353  +create_124_rescaled_raster (const unsigned char *rgba,
         2354  +			    unsigned char pixel_type, unsigned int tileWidth,
         2355  +			    unsigned int tileHeight, int scale)
  2350   2356   {
  2351   2357   /* creating a rescaled raster (1,2 or 4 bit pyramids) 
  2352   2358   /
  2353   2359   / this function builds an high quality rescaled sub-image by applying pixel interpolation
  2354   2360   /
  2355   2361   / this code is widely inspired by the original GD gdImageCopyResampled() function
  2356   2362   */
................................................................................
  2529   2535   			    *p_msk = 1;
  2530   2536   			}
  2531   2537   		  }
  2532   2538   	    }
  2533   2539         }
  2534   2540   
  2535   2541       raster =
  2536         -	rl2_create_raster (out_width, out_height, RL2_SAMPLE_UINT8, pixel_type,
  2537         -			   num_bands, rgb, rgb_sz, NULL, mask, mask_sz, NULL);
         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);
  2538   2545       return raster;
  2539   2546   }
  2540   2547   
  2541   2548   static void
  2542   2549   copy_124_rescaled (rl2RasterPtr raster_out, rl2RasterPtr raster_in,
  2543   2550   		   unsigned int base_x, unsigned int base_y)
  2544   2551   {
................................................................................
  2740   2747   		double tile_x = sqlite3_column_double (stmt_geo, 1);
  2741   2748   		double tile_y = sqlite3_column_double (stmt_geo, 2);
  2742   2749   
  2743   2750   		rgba = load_tile_base (stmt_data, tile_id, palette, no_data);
  2744   2751   		if (rgba == NULL)
  2745   2752   		    goto error;
  2746   2753   		base_tile =
  2747         -		    create_124_rescaled_raster (rgba, out_pixel_type, tileWidth,
  2748         -						tileHeight, factor);
         2754  +		    create_124_rescaled_raster (rgba, out_pixel_type,
         2755  +						tileWidth, tileHeight, factor);
  2749   2756   		free (rgba);
  2750   2757   		if (base_tile == NULL)
  2751   2758   		    goto error;
  2752   2759   		shift_x = tile_x - minx;
  2753   2760   		shift_y = maxy - tile_y;
  2754   2761   		x = (int) (shift_x / res_x);
  2755   2762   		y = (int) (shift_y / res_y);
................................................................................
  3115   3122       for (ib = 0; ib < num_bands; ib++)
  3116   3123   	*p_out++ = (unsigned char) (*(sum + ib) / (double) valid);
  3117   3124       free (sum);
  3118   3125       *p_msk = 1;
  3119   3126   }
  3120   3127   
  3121   3128   static void
  3122         -mb_prime_nodata_u8 (unsigned char *buf, unsigned int width, unsigned int height,
  3123         -		    unsigned char num_bands, rl2PixelPtr no_data)
         3129  +mb_prime_nodata_u8 (unsigned char *buf, unsigned int width,
         3130  +		    unsigned int height, unsigned char num_bands,
         3131  +		    rl2PixelPtr no_data)
  3124   3132   {
  3125   3133   /* priming a void buffer */
  3126   3134       rl2PrivPixelPtr nd = (rl2PrivPixelPtr) no_data;
  3127   3135       unsigned int x;
  3128   3136       unsigned int y;
  3129   3137       unsigned char ib;
  3130   3138       unsigned char *p = buf;
................................................................................
  3244   3252   					    (unsigned char *) buf_in, mask_in,
  3245   3253   					    (unsigned char *) buf, mask, x, y,
  3246   3254   					    ox, oy, no_data);
  3247   3255   		      break;
  3248   3256   		  case RL2_SAMPLE_UINT16:
  3249   3257   		      rescale_multiband_u16 (tileWidth, tileHeight, num_bands,
  3250   3258   					     out_width, out_height, factor,
  3251         -					     (unsigned short *) buf_in, mask_in,
  3252         -					     (unsigned short *) buf, mask, x, y,
  3253         -					     ox, oy, no_data);
         3259  +					     (unsigned short *) buf_in,
         3260  +					     mask_in, (unsigned short *) buf,
         3261  +					     mask, x, y, ox, oy, no_data);
  3254   3262   		      break;
  3255   3263   		  };
  3256   3264   		ox++;
  3257   3265   	    }
  3258   3266   	  oy++;
  3259   3267         }
  3260   3268   
................................................................................
  4036   4044   					   out_height, factor,
  4037   4045   					   (unsigned char *) buf_in,
  4038   4046   					   (unsigned char *) buf, mask, x, y,
  4039   4047   					   ox, oy, no_data_u8);
  4040   4048   		      break;
  4041   4049   		  case RL2_SAMPLE_INT16:
  4042   4050   		      rescale_datagrid_16 (tileWidth, tileHeight, out_width,
  4043         -					   out_height, factor, (short *) buf_in,
  4044         -					   (short *) buf, mask, x, y, ox, oy,
  4045         -					   no_data_16);
         4051  +					   out_height, factor,
         4052  +					   (short *) buf_in, (short *) buf,
         4053  +					   mask, x, y, ox, oy, no_data_16);
  4046   4054   		      break;
  4047   4055   		  case RL2_SAMPLE_UINT16:
  4048   4056   		      rescale_datagrid_u16 (tileWidth, tileHeight, out_width,
  4049   4057   					    out_height, factor,
  4050   4058   					    (unsigned short *) buf_in,
  4051         -					    (unsigned short *) buf, mask, x, y,
  4052         -					    ox, oy, no_data_u16);
         4059  +					    (unsigned short *) buf, mask, x,
         4060  +					    y, ox, oy, no_data_u16);
  4053   4061   		      break;
  4054   4062   		  case RL2_SAMPLE_INT32:
  4055   4063   		      rescale_datagrid_32 (tileWidth, tileHeight, out_width,
  4056   4064   					   out_height, factor, (int *) buf_in,
  4057   4065   					   (int *) buf, mask, x, y, ox, oy,
  4058   4066   					   no_data_32);
  4059   4067   		      break;
................................................................................
  4089   4097       return raster;
  4090   4098   }
  4091   4099   
  4092   4100   static int
  4093   4101   rescale_monolithic_multiband (int id_level,
  4094   4102   			      unsigned int tileWidth, unsigned int tileHeight,
  4095   4103   			      unsigned char sample_type,
  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,
         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,
  4100   4109   			      rl2PixelPtr no_data, sqlite3_stmt * stmt_geo,
  4101   4110   			      sqlite3_stmt * stmt_data)
  4102   4111   {
  4103   4112   /* rescaling monolithic MultiBand */
  4104   4113       rl2RasterPtr raster = NULL;
  4105   4114       rl2RasterPtr base_tile = NULL;
  4106   4115       rl2PrivRasterPtr rst;
................................................................................
  4118   4127       p_out = mask;
  4119   4128       for (y = 0; y < tileHeight; y++)
  4120   4129         {
  4121   4130   	  /* priming full transparency */
  4122   4131   	  for (x = 0; x < tileWidth; x++)
  4123   4132   	      *p_out++ = 0;
  4124   4133         }
  4125         -    rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type, num_bands,
  4126         -			 no_data);
         4134  +    rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type,
         4135  +			 num_bands, no_data);
  4127   4136   /* creating the output raster */
  4128   4137       raster =
  4129   4138   	rl2_create_raster (tileWidth, tileHeight, sample_type,
  4130   4139   			   RL2_PIXEL_MULTIBAND, num_bands, buffer, buf_size,
  4131   4140   			   NULL, mask, *mask_size, nd);
  4132   4141       if (raster == NULL)
  4133   4142   	goto error;
................................................................................
  4329   4338   	  rl2_destroy_raster (raster);
  4330   4339         }
  4331   4340       return 0;
  4332   4341   }
  4333   4342   
  4334   4343   static int
  4335   4344   prepare_section_pyramid_stmts (sqlite3 * handle, const char *coverage,
  4336         -			       int mixed_resolutions, sqlite3_stmt ** xstmt_rd,
         4345  +			       int mixed_resolutions,
         4346  +			       sqlite3_stmt ** xstmt_rd,
  4337   4347   			       sqlite3_stmt ** xstmt_levl,
  4338   4348   			       sqlite3_stmt ** xstmt_tils,
  4339   4349   			       sqlite3_stmt ** xstmt_data)
  4340   4350   {
  4341   4351   /* preparing the section pyramid related SQL statements */
  4342   4352       char *table_tile_data;
  4343   4353       char *xtable_tile_data;
................................................................................
  4500   4510   
  4501   4511       if (!get_section_infos
  4502   4512   	(handle, coverage, section_id, &sect_width, &sect_height, &minx,
  4503   4513   	 &miny, &maxx, &maxy, &palette, &no_data))
  4504   4514   	goto error;
  4505   4515   
  4506   4516       if (!prepare_section_pyramid_stmts
  4507         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
  4508         -	 &stmt_data))
         4517  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
         4518  +	 &stmt_tils, &stmt_data))
  4509   4519   	goto error;
  4510   4520   
  4511   4521       while (1)
  4512   4522         {
  4513   4523   	  /* looping on pyramid levels */
  4514   4524   	  if (mixed_resolutions)
  4515   4525   	      table_levels = sqlite3_mprintf ("%s_section_levels", coverage);
................................................................................
  4580   4590   		      scale = 8;
  4581   4591   		      if (first)
  4582   4592   			{
  4583   4593   			    pyr =
  4584   4594   				alloc_sect_pyramid (section_id, sect_width,
  4585   4595   						    sect_height, sample_type,
  4586   4596   						    pixel_type, num_samples,
  4587         -						    compression, quality, srid,
  4588         -						    new_res_x, new_res_y,
         4597  +						    compression, quality,
         4598  +						    srid, new_res_x,
         4599  +						    new_res_y,
  4589   4600   						    (double) tileWidth *
  4590   4601   						    new_res_x,
  4591   4602   						    (double) tileHeight *
  4592         -						    new_res_y, minx, miny, maxx,
  4593         -						    maxy, scale);
         4603  +						    new_res_y, minx, miny,
         4604  +						    maxx, maxy, scale);
  4594   4605   			    first = 0;
  4595   4606   			    if (pyr == NULL)
  4596   4607   				goto error;
  4597   4608   			}
  4598   4609   		      if (!insert_tile_into_section_pyramid
  4599   4610   			  (pyr, tile_id, tminx, tminy, tmaxx, tmaxy))
  4600   4611   			  goto error;
................................................................................
  4954   4965   }
  4955   4966   
  4956   4967   static int
  4957   4968   get_section_raw_raster_data (sqlite3 * handle, int max_threads,
  4958   4969   			     const char *coverage, sqlite3_int64 sect_id,
  4959   4970   			     unsigned int width, unsigned int height,
  4960   4971   			     unsigned char sample_type,
  4961         -			     unsigned char pixel_type, unsigned char num_bands,
  4962         -			     double minx, double maxy, double x_res,
  4963         -			     double y_res, unsigned char **buffer,
  4964         -			     int *buf_size, rl2PalettePtr palette,
  4965         -			     rl2PixelPtr no_data)
         4972  +			     unsigned char pixel_type,
         4973  +			     unsigned char num_bands, double minx,
         4974  +			     double maxy, double x_res, double y_res,
         4975  +			     unsigned char **buffer, int *buf_size,
         4976  +			     rl2PalettePtr palette, rl2PixelPtr no_data)
  4966   4977   {
  4967   4978   /* attempting to return a buffer containing raw pixels from the whole DBMS Section */
  4968   4979       unsigned char *bufpix = NULL;
  4969   4980       int bufpix_size;
  4970   4981       char *xtiles;
  4971   4982       char *xxtiles;
  4972   4983       char *xdata;
................................................................................
  5000   5011         }
  5001   5012       memset (bufpix, 0, bufpix_size);
  5002   5013   
  5003   5014   /* preparing the "tiles" SQL query */
  5004   5015       xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  5005   5016       xxtiles = rl2_double_quoted_sql (xtiles);
  5006   5017       sql =
  5007         -	sqlite3_mprintf ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
  5008         -			 "FROM \"%s\" "
  5009         -			 "WHERE pyramid_level = 0 AND section_id = ?", xxtiles);
         5018  +	sqlite3_mprintf
         5019  +	("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
         5020  +	 "FROM \"%s\" " "WHERE pyramid_level = 0 AND section_id = ?", xxtiles);
  5010   5021       sqlite3_free (xtiles);
  5011   5022       free (xxtiles);
  5012   5023       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL);
  5013   5024       sqlite3_free (sql);
  5014   5025       if (ret != SQLITE_OK)
  5015   5026         {
  5016   5027   	  printf ("SELECT section raw tiles SQL error: %s\n",
................................................................................
  5059   5070       if (bufpix != NULL)
  5060   5071   	free (bufpix);
  5061   5072       return 0;
  5062   5073   }
  5063   5074   
  5064   5075   static void
  5065   5076   raster_tile_124_rescaled (unsigned char *outbuf,
  5066         -			  unsigned char pixel_type, const unsigned char *inbuf,
         5077  +			  unsigned char pixel_type,
         5078  +			  const unsigned char *inbuf,
  5067   5079   			  unsigned int section_width,
  5068   5080   			  unsigned int section_height, unsigned int out_width,
  5069   5081   			  unsigned int out_height, rl2PalettePtr palette)
  5070   5082   {
  5071   5083   /* 
  5072   5084   / this function builds an high quality rescaled sub-image by applying pixel interpolation
  5073   5085   /
................................................................................
  5357   5369   do_build_124_bit_section_pyramid (sqlite3 * handle, int max_threads,
  5358   5370   				  const char *coverage, int mixed_resolutions,
  5359   5371   				  sqlite3_int64 section_id,
  5360   5372   				  unsigned char sample_type,
  5361   5373   				  unsigned char pixel_type,
  5362   5374   				  unsigned char num_samples, int srid,
  5363   5375   				  unsigned int tileWidth,
  5364         -				  unsigned int tileHeight, unsigned char bgRed,
  5365         -				  unsigned char bgGreen, unsigned char bgBlue)
         5376  +				  unsigned int tileHeight,
         5377  +				  unsigned char bgRed, unsigned char bgGreen,
         5378  +				  unsigned char bgBlue)
  5366   5379   {
  5367   5380   /* attempting to (re)build a 1,2,4-bit section pyramid from scratch */
  5368   5381       double base_res_x;
  5369   5382       double base_res_y;
  5370   5383       unsigned int sect_width;
  5371   5384       unsigned int sect_height;
  5372   5385       int id_level = 0;
................................................................................
  5425   5438       if (!get_section_raw_raster_data
  5426   5439   	(handle, max_threads, coverage, section_id, sect_width, sect_height,
  5427   5440   	 sample_type, pixel_type, num_samples, minx, maxy, base_res_x,
  5428   5441   	 base_res_y, &inbuf, &inbuf_size, palette, no_data))
  5429   5442   	goto error;
  5430   5443   
  5431   5444       if (!prepare_section_pyramid_stmts
  5432         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
  5433         -	 &stmt_data))
         5445  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
         5446  +	 &stmt_tils, &stmt_data))
  5434   5447   	goto error;
  5435   5448   
  5436   5449       id_level = 1;
  5437   5450       scale = 2;
  5438   5451       x_res = base_res_x * 2.0;
  5439   5452       y_res = base_res_y * 2.0;
  5440   5453       while (1)
................................................................................
  5528   5541   			    if (no_data == NULL)
  5529   5542   				nd = NULL;
  5530   5543   			    else
  5531   5544   			      {
  5532   5545   				  /* converting the NO-DATA pixel */
  5533   5546   				  nd = rl2_create_pixel (RL2_SAMPLE_UINT8,
  5534   5547   							 RL2_PIXEL_RGB, 3);
  5535         -				  rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND,
         5548  +				  rl2_set_pixel_sample_uint8 (nd,
         5549  +							      RL2_RED_BAND,
  5536   5550   							      bgRed);
  5537   5551   				  rl2_set_pixel_sample_uint8 (nd,
  5538   5552   							      RL2_GREEN_BAND,
  5539   5553   							      bgGreen);
  5540         -				  rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
         5554  +				  rl2_set_pixel_sample_uint8 (nd,
         5555  +							      RL2_BLUE_BAND,
  5541   5556   							      bgBlue);
  5542   5557   			      }
  5543   5558   			}
  5544   5559   		      t_maxx = t_minx + (tileWidth * x_res);
  5545   5560   		      if (!copy_124_tile
  5546   5561   			  (out_pixel_type, outbuf, &tilebuf,
  5547   5562   			   &tilebuf_sz, &tilemask, &tilemask_sz, row, col,
................................................................................
  5563   5578   		      if (raster == NULL)
  5564   5579   			{
  5565   5580   			    fprintf (stderr,
  5566   5581   				     "ERROR: unable to create a Pyramid Tile\n");
  5567   5582   			    goto error;
  5568   5583   			}
  5569   5584   		      if (rl2_raster_encode
  5570         -			  (raster, RL2_COMPRESSION_PNG, &blob_odd, &blob_odd_sz,
  5571         -			   &blob_even, &blob_even_sz, 100, 1) != RL2_OK)
         5585  +			  (raster, RL2_COMPRESSION_PNG, &blob_odd,
         5586  +			   &blob_odd_sz, &blob_even, &blob_even_sz, 100,
         5587  +			   1) != RL2_OK)
  5572   5588   			{
  5573   5589   			    fprintf (stderr,
  5574   5590   				     "ERROR: unable to encode a Pyramid tile\n");
  5575   5591   			    goto error;
  5576   5592   			}
  5577   5593   
  5578   5594   		      /* INSERTing the tile */
................................................................................
  5634   5650   }
  5635   5651   
  5636   5652   static int
  5637   5653   do_build_palette_section_pyramid (sqlite3 * handle, int max_threads,
  5638   5654   				  const char *coverage, int mixed_resolutions,
  5639   5655   				  sqlite3_int64 section_id, int srid,
  5640   5656   				  unsigned int tileWidth,
  5641         -				  unsigned int tileHeight, unsigned char bgRed,
  5642         -				  unsigned char bgGreen, unsigned char bgBlue)
         5657  +				  unsigned int tileHeight,
         5658  +				  unsigned char bgRed, unsigned char bgGreen,
         5659  +				  unsigned char bgBlue)
  5643   5660   {
  5644   5661   /* attempting to (re)build a Palette section pyramid from scratch */
  5645   5662       double base_res_x;
  5646   5663       double base_res_y;
  5647   5664       unsigned int sect_width;
  5648   5665       unsigned int sect_height;
  5649   5666       int id_level = 0;
................................................................................
  5704   5721       if (!get_section_raw_raster_data
  5705   5722   	(handle, max_threads, coverage, section_id, sect_width, sect_height,
  5706   5723   	 RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE, 1, minx, maxy, base_res_x,
  5707   5724   	 base_res_y, &inbuf, &inbuf_size, palette, no_data))
  5708   5725   	goto error;
  5709   5726   
  5710   5727       if (!prepare_section_pyramid_stmts
  5711         -	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils,
  5712         -	 &stmt_data))
         5728  +	(handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl,
         5729  +	 &stmt_tils, &stmt_data))
  5713   5730   	goto error;
  5714   5731   
  5715   5732       id_level = 1;
  5716   5733       scale = 2;
  5717   5734       x_res = base_res_x * 2.0;
  5718   5735       y_res = base_res_y * 2.0;
  5719   5736       while (1)
................................................................................
  5780   5797   							RL2_GREEN_BAND,
  5781   5798   							bgGreen);
  5782   5799   			    rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
  5783   5800   							bgBlue);
  5784   5801   			}
  5785   5802   		      t_maxx = t_minx + (tileWidth * x_res);
  5786   5803   		      if (!copy_124_tile (out_pixel_type, outbuf, &tilebuf,
  5787         -					  &tilebuf_sz, &tilemask, &tilemask_sz,
  5788         -					  row, col, out_width, out_height,
  5789         -					  tileWidth, tileHeight, no_data))
         5804  +					  &tilebuf_sz, &tilemask,
         5805  +					  &tilemask_sz, row, col, out_width,
         5806  +					  out_height, tileWidth, tileHeight,
         5807  +					  no_data))
  5790   5808   			{
  5791   5809   			    fprintf (stderr,
  5792   5810   				     "ERROR: unable to extract a Pyramid Tile\n");
  5793   5811   			    goto error;
  5794   5812   			}
  5795   5813   
  5796   5814   		      raster =
................................................................................
  6049   6067   		    goto error;
  6050   6068   	    }
  6051   6069   	  else
  6052   6070   	    {
  6053   6071   		/* ordinary RGB, Grayscale, MultiBand or DataGrid Pyramid */
  6054   6072   		if (!do_build_section_pyramid
  6055   6073   		    (handle, coverage, section_id, sample_type, pixel_type,
  6056         -		     num_bands, compression, ptrcvg->mixedResolutions, quality,
  6057         -		     srid, tileWidth, tileHeight))
         6074  +		     num_bands, compression, ptrcvg->mixedResolutions,
         6075  +		     quality, srid, tileWidth, tileHeight))
  6058   6076   		    goto error;
  6059   6077   	    }
  6060   6078   	  if (verbose)
  6061   6079   	    {
  6062   6080   		printf ("  ----------\n");
  6063   6081   #if defined(_WIN32) && !defined(__MINGW32__)
  6064   6082   		printf
................................................................................
  6107   6125   	  ret = sqlite3_step (stmt);
  6108   6126   	  if (ret == SQLITE_DONE)
  6109   6127   	      break;
  6110   6128   	  if (ret == SQLITE_ROW)
  6111   6129   	    {
  6112   6130   		sqlite3_int64 section_id = sqlite3_column_int64 (stmt, 0);
  6113   6131   		if (rl2_build_section_pyramid
  6114         -		    (handle, max_threads, coverage, section_id, forced_rebuild,
  6115         -		     verbose) != RL2_OK)
         6132  +		    (handle, max_threads, coverage, section_id,
         6133  +		     forced_rebuild, verbose) != RL2_OK)
  6116   6134   		    goto error;
  6117   6135   	    }
  6118   6136   	  else
  6119   6137   	    {
  6120   6138   		fprintf (stderr,
  6121   6139   			 "SELECT section_id; sqlite3_step() error: %s\n",
  6122   6140   			 sqlite3_errmsg (handle));
................................................................................
  6281   6299   	  out_sample_type = RL2_SAMPLE_UINT8;
  6282   6300   	  out_pixel_type = RL2_PIXEL_RGB;
  6283   6301   	  out_num_bands = 3;
  6284   6302   	  out_compression = RL2_COMPRESSION_PNG;
  6285   6303   	  out_quality = 100;
  6286   6304   	  virt_levels = 1;
  6287   6305         }
  6288         -    else if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE
  6289         -	     && num_bands == 1)
         6306  +    else if (sample_type == RL2_SAMPLE_UINT8
         6307  +	     && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1)
  6290   6308         {
  6291   6309   	  /* palette 8: output colorspace is RGB compression PNG */
  6292   6310   	  out_sample_type = RL2_SAMPLE_UINT8;
  6293   6311   	  out_pixel_type = RL2_PIXEL_RGB;
  6294   6312   	  out_num_bands = 3;
  6295   6313   	  out_compression = RL2_COMPRESSION_PNG;
  6296   6314   	  out_quality = 100;
................................................................................
  6403   6421   		      if (tile_miny < miny)
  6404   6422   			  end_y = miny;
  6405   6423   
  6406   6424   		      if ((sample_type == RL2_SAMPLE_UINT8
  6407   6425   			   && pixel_type == RL2_PIXEL_GRAYSCALE
  6408   6426   			   && num_bands == 1)
  6409   6427   			  || (sample_type == RL2_SAMPLE_UINT8
  6410         -			      && pixel_type == RL2_PIXEL_RGB && num_bands == 3)
         6428  +			      && pixel_type == RL2_PIXEL_RGB
         6429  +			      && num_bands == 3)
  6411   6430   			  || (sample_type == RL2_SAMPLE_UINT8
  6412   6431   			      && pixel_type == RL2_PIXEL_PALETTE
  6413   6432   			      && num_bands == 1))
  6414   6433   			{
  6415   6434   			    /* RGB, PALETTE or GRAYSCALE datasource (UINT8) */
  6416   6435   			    if (!rescale_monolithic_rgba
  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))
         6436  +				(id_level, tileWidth, tileHeight,
         6437  +				 resize_factor, res_x, res_y, tile_minx,
         6438  +				 tile_miny, tile_maxx, tile_maxy, buffer,
         6439  +				 buf_size, mask, &mask_size, palette, no_data,
         6440  +				 stmt_geo, stmt_rd))
  6422   6441   				goto error;
  6423   6442   			    if (mask_size == 0)
  6424   6443   				mask = NULL;
  6425   6444   			}
  6426   6445   		      else if (((sample_type == RL2_SAMPLE_1_BIT
  6427   6446   				 || sample_type == RL2_SAMPLE_2_BIT
  6428   6447   				 || sample_type == RL2_SAMPLE_4_BIT)
................................................................................
  6460   6479   		      else if (pixel_type == RL2_PIXEL_DATAGRID)
  6461   6480   			{
  6462   6481   			    /* DataGrid */
  6463   6482   			    if (!rescale_monolithic_datagrid
  6464   6483   				(id_level, tileWidth, tileHeight, sample_type,
  6465   6484   				 resize_factor, res_x, res_y, tile_minx,
  6466   6485   				 tile_miny, tile_maxx, tile_maxy, buffer,
  6467         -				 buf_size, mask, &mask_size, no_data, stmt_geo,
  6468         -				 stmt_rd))
         6486  +				 buf_size, mask, &mask_size, no_data,
         6487  +				 stmt_geo, stmt_rd))
  6469   6488   				goto error;
  6470   6489   			    if (mask_size == 0)
  6471   6490   				mask = NULL;
  6472   6491   			}
  6473   6492   		      else
  6474   6493   			{
  6475   6494   			    /* unknown */
................................................................................
  6513   6532   			{
  6514   6533   			    if (no_data == NULL)
  6515   6534   				nd = NULL;
  6516   6535   			    else
  6517   6536   			      {
  6518   6537   				  nd = rl2_create_pixel (RL2_SAMPLE_UINT8,
  6519   6538   							 RL2_PIXEL_RGB, 3);
  6520         -				  rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND,
         6539  +				  rl2_set_pixel_sample_uint8 (nd,
         6540  +							      RL2_RED_BAND,
  6521   6541   							      255);
  6522   6542   				  rl2_set_pixel_sample_uint8 (nd,
  6523   6543   							      RL2_GREEN_BAND,
  6524   6544   							      255);
  6525         -				  rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND,
         6545  +				  rl2_set_pixel_sample_uint8 (nd,
         6546  +							      RL2_BLUE_BAND,
  6526   6547   							      255);
  6527   6548   			      }
  6528   6549   			}
  6529   6550   		      else
  6530   6551   			  nd = rl2_clone_pixel (no_data);
  6531   6552   
  6532   6553   		      raster =
................................................................................
  6606   6627       sqlite3_finalize (stmt_rd);
  6607   6628       sqlite3_finalize (stmt_levl);
  6608   6629       sqlite3_finalize (stmt_tils);
  6609   6630       sqlite3_finalize (stmt_data);
  6610   6631       if (verbose)
  6611   6632         {
  6612   6633   	  printf ("  ----------\n");
  6613         -	  printf ("    Monolithic Pyramid levels successfully built for: %s\n",
  6614         -		  coverage);
         6634  +	  printf
         6635  +	      ("    Monolithic Pyramid levels successfully built for: %s\n",
         6636  +	       coverage);
  6615   6637         }
  6616   6638       free (buffer);
  6617   6639       free (mask);
  6618   6640       rl2_destroy_coverage (cvg);
  6619   6641   
  6620   6642       return RL2_OK;
  6621   6643   

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, mono_band,
          697  +				mono_int8_pixel_handler (p_in, p_out,
          698  +							 mono_band,
   698    699   							 mono_handling);
   699    700   			}
   700    701   		  }
   701    702   		else
   702    703   		  {
   703    704   		      /* testing for NO-DATA values */
   704    705   		      int match = 0;
................................................................................
   707    708   		      rl2_get_pixel_sample_int8 (no_data, &sample);
   708    709   		      if (sample == *p_save++)
   709    710   			  match++;
   710    711   		      if (match != 1)
   711    712   			{
   712    713   			    /* opaque pixel */
   713    714   			    p_out =
   714         -				mono_int8_pixel_handler (p_in, p_out, mono_band,
          715  +				mono_int8_pixel_handler (p_in, p_out,
          716  +							 mono_band,
   715    717   							 mono_handling);
   716    718   			}
   717    719   		      else
   718    720   			{
   719    721   			    /* NO-DATA pixel */
   720    722   			    for (ib = 0; ib < out_num_bands; ib++)
   721    723   				p_out++;
................................................................................
   758    760         {
   759    761   	  ignore_no_data = 0;
   760    762   	  if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands)
   761    763   	      != RL2_OK)
   762    764   	      ignore_no_data = 1;
   763    765   	  if (nbands != num_bands)
   764    766   	      ignore_no_data = 1;
   765         -	  if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT
          767  +	  if (sample_type == RL2_SAMPLE_1_BIT
          768  +	      || sample_type == RL2_SAMPLE_2_BIT
   766    769   	      || sample_type == RL2_SAMPLE_4_BIT
   767    770   	      || sample_type == RL2_SAMPLE_UINT8)
   768    771   	      ;
   769    772   	  else
   770    773   	      ignore_no_data = 1;
   771    774         }
   772    775   
................................................................................
   877    880       return apply_contrast_enhancement ((double) mono, p_out, mono_handling);
   878    881   }
   879    882   
   880    883   static void
   881    884   copy_uint8_raw_selected_pixels (const unsigned char *buffer,
   882    885   				const unsigned char *mask,
   883    886   				unsigned char *outbuf, unsigned short width,
   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,
          887  +				unsigned short height,
          888  +				unsigned char num_bands, double x_res,
          889  +				double y_res, double minx, double maxy,
          890  +				double tile_minx, double tile_maxy,
   887    891   				unsigned short tile_width,
   888         -				unsigned short tile_height, rl2PixelPtr no_data,
   889         -				unsigned char red_band,
          892  +				unsigned short tile_height,
          893  +				rl2PixelPtr no_data, unsigned char red_band,
   890    894   				unsigned char green_band,
   891    895   				unsigned char blue_band,
   892    896   				rl2BandHandlingPtr red_handling,
   893    897   				rl2BandHandlingPtr green_handling,
   894    898   				rl2BandHandlingPtr blue_handling)
   895    899   {
   896    900   /* copying UINT8 raw pixels from the DBMS tile into the output image */
................................................................................
   965    969   			    /* skipping a transparent pixel */
   966    970   			    p_out += 3;
   967    971   			}
   968    972   		      else
   969    973   			{
   970    974   			    /* opaque pixel */
   971    975   			    p_out =
   972         -				mono_uint8_pixel_handler (p_in, p_out, red_band,
          976  +				mono_uint8_pixel_handler (p_in, p_out,
          977  +							  red_band,
   973    978   							  red_handling);
   974    979   			    p_out =
   975    980   				mono_uint8_pixel_handler (p_in, p_out,
   976    981   							  green_band,
   977    982   							  green_handling);
   978    983   			    p_out =
   979    984   				mono_uint8_pixel_handler (p_in, p_out,
................................................................................
   993    998   			    if (sample == *p_save++)
   994    999   				match++;
   995   1000   			}
   996   1001   		      if (match != num_bands)
   997   1002   			{
   998   1003   			    /* opaque pixel */
   999   1004   			    p_out =
  1000         -				mono_uint8_pixel_handler (p_in, p_out, red_band,
         1005  +				mono_uint8_pixel_handler (p_in, p_out,
         1006  +							  red_band,
  1001   1007   							  red_handling);
  1002   1008   			    p_out =
  1003   1009   				mono_uint8_pixel_handler (p_in, p_out,
  1004   1010   							  green_band,
  1005   1011   							  green_handling);
  1006   1012   			    p_out =
  1007   1013   				mono_uint8_pixel_handler (p_in, p_out,
................................................................................
  1020   1026   }
  1021   1027   
  1022   1028   static void
  1023   1029   copy_uint8_raw_mono_pixels (const unsigned char *buffer,
  1024   1030   			    const unsigned char *mask, unsigned char *outbuf,
  1025   1031   			    unsigned short width, unsigned short height,
  1026   1032   			    unsigned char out_num_bands,
  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,
         1033  +			    unsigned char num_bands, double x_res,
         1034  +			    double y_res, double minx, double maxy,
         1035  +			    double tile_minx, double tile_maxy,
         1036  +			    unsigned short tile_width,
  1030   1037   			    unsigned short tile_height, rl2PixelPtr no_data,
  1031   1038   			    unsigned char mono_band,
  1032   1039   			    rl2BandHandlingPtr mono_handling)
  1033   1040   {
  1034   1041   /* copying UINT8 raw pixels from the DBMS tile into the output image */
  1035   1042       int x;
  1036   1043       int y;
................................................................................
  1393   1400   		  }
  1394   1401   		p_in++;
  1395   1402   	    }
  1396   1403         }
  1397   1404   }
  1398   1405   
  1399   1406   static void
  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)
         1407  +copy_uint16_raw_pixels (const unsigned short *buffer,
         1408  +			const unsigned char *mask, unsigned short *outbuf,
         1409  +			unsigned short width, unsigned short height,
         1410  +			unsigned char num_bands, double x_res, double y_res,
         1411  +			double minx, double maxy, double tile_minx,
         1412  +			double tile_maxy, unsigned short tile_width,
         1413  +			unsigned short tile_height, rl2PixelPtr no_data)
  1407   1414   {
  1408   1415   /* copying UINT16 raw pixels from the DBMS tile into the output image */
  1409   1416       int x;
  1410   1417       int y;
  1411   1418       int b;
  1412   1419       int out_x;
  1413   1420       int out_y;
................................................................................
  1530   1537       return apply_contrast_enhancement ((double) mono, p_out, mono_handling);
  1531   1538   }
  1532   1539   
  1533   1540   static void
  1534   1541   copy_uint16_raw_selected_pixels (const unsigned short *buffer,
  1535   1542   				 const unsigned char *mask,
  1536   1543   				 unsigned char *outbuf, unsigned short 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,
         1544  +				 unsigned short height,
         1545  +				 unsigned char num_bands, double x_res,
         1546  +				 double y_res, double minx, double maxy,
         1547  +				 double tile_minx, double tile_maxy,
         1548  +				 unsigned short tile_width,
  1541   1549   				 unsigned short tile_height,
  1542   1550   				 rl2PixelPtr no_data, unsigned char red_band,
  1543   1551   				 unsigned char green_band,
  1544   1552   				 unsigned char blue_band,
  1545   1553   				 rl2BandHandlingPtr red_handling,
  1546   1554   				 rl2BandHandlingPtr green_handling,
  1547   1555   				 rl2BandHandlingPtr blue_handling)
................................................................................
  3075   3083   		if (style->contrastEnhancement ==
  3076   3084   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3077   3085   		  {
  3078   3086   		      r = malloc (sizeof (rl2BandHandling));
  3079   3087   		      r->colorMap = NULL;
  3080   3088   		      r->contrastEnhancement =
  3081   3089   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3082         -		      compute_stretching (band, &(r->minValue), &(r->maxValue),
  3083         -					  &(r->scaleFactor));
         3090  +		      compute_stretching (band, &(r->minValue),
         3091  +					  &(r->maxValue), &(r->scaleFactor));
  3084   3092   		  }
  3085   3093   		else if (style->contrastEnhancement ==
  3086   3094   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3087   3095   		  {
  3088   3096   		      r = malloc (sizeof (rl2BandHandling));
  3089   3097   		      r->colorMap = NULL;
  3090   3098   		      r->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3161   3169   		if (style->contrastEnhancement ==
  3162   3170   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3163   3171   		  {
  3164   3172   		      g = malloc (sizeof (rl2BandHandling));
  3165   3173   		      g->colorMap = NULL;
  3166   3174   		      g->contrastEnhancement =
  3167   3175   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3168         -		      compute_stretching (band, &(g->minValue), &(g->maxValue),
  3169         -					  &(g->scaleFactor));
         3176  +		      compute_stretching (band, &(g->minValue),
         3177  +					  &(g->maxValue), &(g->scaleFactor));
  3170   3178   		  }
  3171   3179   		else if (style->contrastEnhancement ==
  3172   3180   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3173   3181   		  {
  3174   3182   		      g = malloc (sizeof (rl2BandHandling));
  3175   3183   		      g->colorMap = NULL;
  3176   3184   		      g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3247   3255   		if (style->contrastEnhancement ==
  3248   3256   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3249   3257   		  {
  3250   3258   		      b = malloc (sizeof (rl2BandHandling));
  3251   3259   		      b->colorMap = NULL;
  3252   3260   		      b->contrastEnhancement =
  3253   3261   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3254         -		      compute_stretching (band, &(b->minValue), &(b->maxValue),
  3255         -					  &(b->scaleFactor));
         3262  +		      compute_stretching (band, &(b->minValue),
         3263  +					  &(b->maxValue), &(b->scaleFactor));
  3256   3264   		  }
  3257   3265   		else if (style->contrastEnhancement ==
  3258   3266   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3259   3267   		  {
  3260   3268   		      b = malloc (sizeof (rl2BandHandling));
  3261   3269   		      b->colorMap = NULL;
  3262   3270   		      b->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3599   3607   		if (style->contrastEnhancement ==
  3600   3608   		    RL2_CONTRAST_ENHANCEMENT_NORMALIZE)
  3601   3609   		  {
  3602   3610   		      g = malloc (sizeof (rl2BandHandling));
  3603   3611   		      g->colorMap = NULL;
  3604   3612   		      g->contrastEnhancement =
  3605   3613   			  RL2_CONTRAST_ENHANCEMENT_NORMALIZE;
  3606         -		      compute_stretching (band, &(g->minValue), &(g->maxValue),
  3607         -					  &(g->scaleFactor));
         3614  +		      compute_stretching (band, &(g->minValue),
         3615  +					  &(g->maxValue), &(g->scaleFactor));
  3608   3616   		  }
  3609   3617   		else if (style->contrastEnhancement ==
  3610   3618   			 RL2_CONTRAST_ENHANCEMENT_NONE)
  3611   3619   		  {
  3612   3620   		      g = malloc (sizeof (rl2BandHandling));
  3613   3621   		      g->colorMap = NULL;
  3614   3622   		      g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NONE;
................................................................................
  3893   3901   }
  3894   3902   
  3895   3903   static int
  3896   3904   do_copy_raw_selected_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf,
  3897   3905   			     unsigned int width, unsigned int height,
  3898   3906   			     double x_res, double y_res, double minx,
  3899   3907   			     double maxy, double tile_minx, double tile_maxy,
  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,
         3908  +			     unsigned int tile_width,
         3909  +			     unsigned int tile_height, rl2PixelPtr no_data,
         3910  +			     unsigned char red_band, unsigned char green_band,
         3911  +			     unsigned char blue_band,
  3903   3912   			     rl2BandHandlingPtr red_handling,
  3904   3913   			     rl2BandHandlingPtr green_handling,
  3905   3914   			     rl2BandHandlingPtr blue_handling)
  3906   3915   {
  3907   3916       switch (rst->sampleType)
  3908   3917         {
  3909   3918         case RL2_SAMPLE_UINT8:
................................................................................
  4159   4168   }
  4160   4169   
  4161   4170   static int
  4162   4171   do_copy_raw_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf,
  4163   4172   		    unsigned int width, unsigned int height,
  4164   4173   		    unsigned char sample_type, unsigned char num_bands,
  4165   4174   		    double x_res, double y_res, double minx, double maxy,
  4166         -		    double tile_minx, double tile_maxy, unsigned int tile_width,
  4167         -		    unsigned int tile_height, rl2PixelPtr no_data)
         4175  +		    double tile_minx, double tile_maxy,
         4176  +		    unsigned int tile_width, unsigned int tile_height,
         4177  +		    rl2PixelPtr no_data)
  4168   4178   {
  4169   4179   
  4170   4180   
  4171   4181       switch (sample_type)
  4172   4182         {
  4173   4183         case RL2_SAMPLE_INT8:
  4174   4184   	  copy_int8_raw_pixels ((const char *) (rst->rasterBuffer),
................................................................................
  4181   4191   	  copy_int16_raw_pixels ((const short *) (rst->rasterBuffer),
  4182   4192   				 (const unsigned char *) (rst->maskBuffer),
  4183   4193   				 (short *) outbuf, width, height,
  4184   4194   				 x_res, y_res, minx, maxy, tile_minx,
  4185   4195   				 tile_maxy, tile_width, tile_height, no_data);
  4186   4196   	  return 1;
  4187   4197         case RL2_SAMPLE_UINT16:
  4188         -	  copy_uint16_raw_pixels ((const unsigned short *) (rst->rasterBuffer),
         4198  +	  copy_uint16_raw_pixels ((const unsigned short
         4199  +				   *) (rst->rasterBuffer),
  4189   4200   				  (const unsigned char *) (rst->maskBuffer),
  4190   4201   				  (unsigned short *) outbuf, width, height,
  4191   4202   				  num_bands, x_res, y_res, minx, maxy,
  4192   4203   				  tile_minx, tile_maxy, tile_width,
  4193   4204   				  tile_height, no_data);
  4194   4205   	  return 1;
  4195   4206         case RL2_SAMPLE_INT32:
................................................................................
  4222   4233   				  tile_minx, tile_maxy, tile_width,
  4223   4234   				  tile_height, no_data);
  4224   4235   	  return 1;
  4225   4236         default:
  4226   4237   	  copy_uint8_raw_pixels ((const unsigned char *) (rst->rasterBuffer),
  4227   4238   				 (const unsigned char *) (rst->maskBuffer),
  4228   4239   				 (unsigned char *) outbuf, width, height,
  4229         -				 num_bands, x_res, y_res, minx, maxy, tile_minx,
  4230         -				 tile_maxy, tile_width, tile_height, no_data);
         4240  +				 num_bands, x_res, y_res, minx, maxy,
         4241  +				 tile_minx, tile_maxy, tile_width,
         4242  +				 tile_height, no_data);
  4231   4243   	  return 1;
  4232   4244         };
  4233   4245       return 0;
  4234   4246   }
  4235   4247   
  4236   4248   RL2_PRIVATE int
  4237   4249   rl2_copy_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf,
  4238   4250   		     unsigned int width,
  4239   4251   		     unsigned int height, unsigned char sample_type,
  4240   4252   		     unsigned char num_bands, unsigned char auto_ndvi,
  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,
         4253  +		     unsigned char red_band_index,
         4254  +		     unsigned char nir_band_index, double x_res, double y_res,
         4255  +		     double minx, double maxy, double tile_minx,
         4256  +		     double tile_maxy, rl2PixelPtr no_data,
  4244   4257   		     rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats)
  4245   4258   {
  4246   4259   /* copying raw pixels into the output buffer */
  4247   4260       unsigned int tile_width;
  4248   4261       unsigned int tile_height;
  4249   4262       rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster;
  4250   4263   
................................................................................
  4252   4265   	return 0;
  4253   4266       if (style != NULL && stats != NULL)
  4254   4267         {
  4255   4268   	  /* attempting to apply a RasterSymbolizer */
  4256   4269   	  int yes_no;
  4257   4270   	  int categorize;
  4258   4271   	  int interpolate;
  4259         -	  if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no) ==
  4260         -	      RL2_OK)
         4272  +	  if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no)
         4273  +	      == RL2_OK)
  4261   4274   	    {
  4262   4275   		if ((rst->sampleType == RL2_SAMPLE_UINT8
  4263   4276   		     || rst->sampleType == RL2_SAMPLE_UINT16)
  4264   4277   		    && (rst->pixelType == RL2_PIXEL_RGB
  4265   4278   			|| rst->pixelType == RL2_PIXEL_MULTIBAND) && yes_no)
  4266   4279   		  {
  4267   4280   		      /* triple band selection - false color RGB */
................................................................................
  4287   4300   						  blue_band, &red_handling,
  4288   4301   						  &green_handling,
  4289   4302   						  &blue_handling);
  4290   4303   		      if (red_handling == NULL || green_handling == NULL
  4291   4304   			  || blue_handling == NULL)
  4292   4305   			  return 0;
  4293   4306   		      if (do_copy_raw_selected_pixels
  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))
         4307  +			  (rst, outbuf, width, height, x_res, y_res, minx,
         4308  +			   maxy, tile_minx, tile_maxy, tile_width,
         4309  +			   tile_height, no_data, red_band, green_band,
         4310  +			   blue_band, red_handling, green_handling,
         4311  +			   blue_handling))
  4298   4312   			  return 1;
  4299   4313   		      if (red_handling != NULL)
  4300   4314   			  free (red_handling);
  4301   4315   		      if (green_handling != NULL)
  4302   4316   			  free (green_handling);
  4303   4317   		      if (blue_handling != NULL)
  4304   4318   			  free (blue_handling);
................................................................................
  4316   4330   		      /* applying Auto NDVI */
  4317   4331   		      rl2BandHandlingPtr ndvi_handling = NULL;
  4318   4332   		      build_ndvi_handling ((rl2PrivRasterSymbolizerPtr)
  4319   4333   					   style, &ndvi_handling);
  4320   4334   		      if (ndvi_handling == NULL)
  4321   4335   			  return 0;
  4322   4336   		      if (do_auto_ndvi_pixels
  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))
         4337  +			  (rst, outbuf, width, height, num_bands, x_res,
         4338  +			   y_res, minx, maxy, tile_minx, tile_maxy,
         4339  +			   tile_width, tile_height, no_data, red_band_index,
         4340  +			   nir_band_index, ndvi_handling))
  4327   4341   			  return 1;
  4328   4342   		      if (ndvi_handling != NULL)
  4329   4343   			  destroy_ndvi_handling (ndvi_handling);
  4330   4344   		  }
  4331   4345   		if (((rst->sampleType == RL2_SAMPLE_UINT8
  4332   4346   		      || rst->sampleType == RL2_SAMPLE_UINT16)
  4333   4347   		     || rst->pixelType == RL2_PIXEL_DATAGRID) && yes_no)
................................................................................
  4344   4358   						style,
  4345   4359   						(rl2PrivRasterStatisticsPtr)
  4346   4360   						stats, mono_band,
  4347   4361   						&mono_handling);
  4348   4362   		      if (mono_handling == NULL)
  4349   4363   			  return 0;
  4350   4364   		      if (do_copy_raw_mono_pixels
  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))
         4365  +			  (rst, outbuf, width, height, num_bands, x_res,
         4366  +			   y_res, minx, maxy, tile_minx, tile_maxy,
         4367  +			   tile_width, tile_height, no_data, mono_band,
         4368  +			   mono_handling))
  4354   4369   			  return 1;
  4355   4370   		      if (mono_handling != NULL)
  4356   4371   			  destroy_mono_handling (mono_handling);
  4357   4372   		  }
  4358   4373   	    }
  4359   4374         }
  4360   4375   
  4361   4376       if (do_copy_raw_pixels
  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))
         4377  +	(rst, outbuf, width, height, sample_type, num_bands, x_res, y_res,
         4378  +	 minx, maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data))
  4364   4379   	return 1;
  4365   4380   
  4366   4381       return 0;
  4367   4382   }
  4368   4383   
  4369   4384   static void
  4370   4385   get_int8_ennuple (const char *rawbuf, unsigned short row, unsigned short col,
................................................................................
  4451   4466   	  /* checking for NoData values */
  4452   4467   	  if (ennuple[i] == nd_val)
  4453   4468   	      *has_no_data = 1;
  4454   4469         }
  4455   4470   }
  4456   4471   
  4457   4472   static void
  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)
         4473  +get_int16_ennuple (const short *rawbuf, unsigned short row,
         4474  +		   unsigned short col, unsigned short row_stride,
         4475  +		   rl2PixelPtr no_data, double ennuple[], int *has_no_data)
  4461   4476   {
  4462   4477   /* extracting a 3x3 "super-pixel" - INT16 */
  4463   4478       const short *p_in;
  4464   4479       short nd_val = 0;
  4465   4480       int i;
  4466   4481   
  4467   4482       if (no_data != NULL)
................................................................................
  4627   4642   	  /* checking for NoData values */
  4628   4643   	  if (ennuple[i] == nd_val)
  4629   4644   	      *has_no_data = 1;
  4630   4645         }
  4631   4646   }
  4632   4647   
  4633   4648   static void
  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)
         4649  +get_float_ennuple (const float *rawbuf, unsigned short row,
         4650  +		   unsigned short col, unsigned short row_stride,
         4651  +		   rl2PixelPtr no_data, double ennuple[], int *has_no_data)
  4637   4652   {
  4638   4653   /* extracting a 3x3 "super-pixel" - FLOAT */
  4639   4654       const float *p_in;
  4640   4655       float nd_val = 0.0;
  4641   4656       int i;
  4642   4657   
  4643   4658       if (no_data != NULL)
................................................................................
  4996   5011       if (no_data == NULL)
  4997   5012   	goto error;
  4998   5013   
  4999   5014   /* preparing the "tiles" SQL query */
  5000   5015       xtiles = sqlite3_mprintf ("%s_tiles", coverage);
  5001   5016       xxtiles = rl2_double_quoted_sql (xtiles);
  5002   5017       sql =
  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);
         5018  +	sqlite3_mprintf
         5019  +	("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) "
         5020  +	 "FROM \"%s\" " "WHERE pyramid_level = ? AND ROWID IN ( "
         5021  +	 "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q "
         5022  +	 "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles);
  5009   5023       sqlite3_free (xtiles);
  5010   5024       free (xxtiles);
  5011   5025       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL);
  5012   5026       sqlite3_free (sql);
  5013   5027       if (ret != SQLITE_OK)
  5014   5028         {
  5015   5029   	  printf ("SELECT shadedRelief tiles SQL error: %s\n",
................................................................................
  5112   5126   	  /* executing in a single thread */
  5113   5127   	  p_out = sr_mask;
  5114   5128   	  for (row = 0; row < height; row++)
  5115   5129   	    {
  5116   5130   		for (col = 0; col < width; col++)
  5117   5131   		    *p_out++ =
  5118   5132   			shaded_relief_value (relief_factor, scale_factor,
  5119         -					     altRadians, azRadians, rawbuf, row,
  5120         -					     col, row_stride, sample_type,
  5121         -					     no_data);
         5133  +					     altRadians, azRadians, rawbuf,
         5134  +					     row, col, row_stride,
         5135  +					     sample_type, no_data);
  5122   5136   	    }
  5123   5137         }
  5124   5138       else
  5125   5139         {
  5126   5140   	  /* executing as many concurrent threads */
  5127   5141   	  rl2AuxShadowerPtr aux = NULL;
  5128   5142   	  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, RL2_RED_BAND,
   375         -					    &transpR);
          374  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
          375  +					    RL2_RED_BAND, &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, RL2_RED_BAND,
   609         -					    &transpR);
          608  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
          609  +					    RL2_RED_BAND, &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, RL2_RED_BAND,
   897         -					    &transpR);
          896  +		rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data,
          897  +					    RL2_RED_BAND, &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, unsigned short **buffer,
  1514         -			   int *buf_size)
         1513  +rl2_raster_band_to_uint16 (rl2RasterPtr ptr, int band,
         1514  +			   unsigned short **buffer, 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, unsigned char num_bands,
  1979         -			    int big_endian)
         1978  +			    unsigned char sample_type,
         1979  +			    unsigned char num_bands, 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, width,
  2030         -			       height, num_bands, big_endian);
         2029  +	  copy_endian_raw_i16 ((short *) outbuf, (const short *) pixels,
         2030  +			       width, 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, width,
  2048         -			       height, num_bands, big_endian);
         2047  +	  copy_endian_raw_flt ((float *) outbuf, (const float *) pixels,
         2048  +			       width, 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, 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)
         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)
  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, 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)
         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)
  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, unsigned char sample_type,
         2316  +			    unsigned int tileHeight,
         2317  +			    unsigned char sample_type,
  2317   2318   			    unsigned char num_bands, unsigned int startRow,
  2318   2319   			    unsigned int startCol, rl2PixelPtr no_data,
  2319   2320   			    unsigned char **pixels, int *pixels_sz)
  2320   2321   {
  2321   2322   /* extracting a Tile from the RAW buffer */
  2322   2323       unsigned char *out;
  2323   2324       int outsz = tileWidth * tileHeight * num_bands;
................................................................................
  2349   2350         case RL2_SAMPLE_INT8:
  2350   2351   	  copy_tile_raw_i8 ((const char *) (origin->rasterBuffer),
  2351   2352   			    origin->width, origin->height, startRow, startCol,
  2352   2353   			    (char *) out, tileWidth, tileHeight, num_bands);
  2353   2354   	  break;
  2354   2355         case RL2_SAMPLE_INT16:
  2355   2356   	  copy_tile_raw_i16 ((const short *) (origin->rasterBuffer),
  2356         -			     origin->width, origin->height, startRow, startCol,
  2357         -			     (short *) out, tileWidth, tileHeight, num_bands);
         2357  +			     origin->width, origin->height, startRow,
         2358  +			     startCol, (short *) out, tileWidth, tileHeight,
         2359  +			     num_bands);
  2358   2360   	  break;
  2359   2361         case RL2_SAMPLE_UINT16:
  2360   2362   	  copy_tile_raw_u16 ((const unsigned short *) (origin->rasterBuffer),
  2361         -			     origin->width, origin->height, startRow, startCol,
  2362         -			     (unsigned short *) out, tileWidth, tileHeight,
  2363         -			     num_bands);
         2363  +			     origin->width, origin->height, startRow,
         2364  +			     startCol, (unsigned short *) out, tileWidth,
         2365  +			     tileHeight, num_bands);
  2364   2366   	  break;
  2365   2367         case RL2_SAMPLE_INT32:
  2366   2368   	  copy_tile_raw_i32 ((const int *) (origin->rasterBuffer),
  2367         -			     origin->width, origin->height, startRow, startCol,
  2368         -			     (int *) out, tileWidth, tileHeight, num_bands);
         2369  +			     origin->width, origin->height, startRow,
         2370  +			     startCol, (int *) out, tileWidth, tileHeight,
         2371  +			     num_bands);
  2369   2372   	  break;
  2370   2373         case RL2_SAMPLE_UINT32:
  2371   2374   	  copy_tile_raw_u32 ((const unsigned int *) (origin->rasterBuffer),
  2372         -			     origin->width, origin->height, startRow, startCol,
  2373         -			     (unsigned int *) out, tileWidth, tileHeight,
  2374         -			     num_bands);
         2375  +			     origin->width, origin->height, startRow,
         2376  +			     startCol, (unsigned int *) out, tileWidth,
         2377  +			     tileHeight, num_bands);
  2375   2378   	  break;
  2376   2379         case RL2_SAMPLE_FLOAT:
  2377   2380   	  copy_tile_raw_flt ((const float *) (origin->rasterBuffer),
  2378         -			     origin->width, origin->height, startRow, startCol,
  2379         -			     (float *) out, tileWidth, tileHeight, num_bands);
         2381  +			     origin->width, origin->height, startRow,
         2382  +			     startCol, (float *) out, tileWidth, tileHeight,
         2383  +			     num_bands);
  2380   2384   	  break;
  2381   2385         case RL2_SAMPLE_DOUBLE:
  2382   2386   	  copy_tile_raw_dbl ((const double *) (origin->rasterBuffer),
  2383         -			     origin->width, origin->height, startRow, startCol,
  2384         -			     (double *) out, tileWidth, tileHeight, num_bands);
         2387  +			     origin->width, origin->height, startRow,
         2388  +			     startCol, (double *) out, tileWidth, tileHeight,
         2389  +			     num_bands);
  2385   2390   	  break;
  2386   2391         default:
  2387   2392   	  copy_tile_raw_u8 ((const unsigned char *) (origin->rasterBuffer),
  2388   2393   			    origin->width, origin->height, startRow, startCol,
  2389   2394   			    (unsigned char *) out, tileWidth, tileHeight,
  2390   2395   			    num_bands);
  2391   2396   	  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, &pixel_type,
   665         -	 &num_bands, &compression))
          664  +	(sqlite, coverage, &tile_width, &tile_height, &sample_type,
          665  +	 &pixel_type, &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, blob_odd,
   672         -				       blob_odd_sz, blob_even, blob_even_sz,
   673         -				       sample_type, pixel_type, num_bands,
   674         -				       compression);
          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);
   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, int argc,
  1541         -					    sqlite3_value ** argv)
         1540  +fnct_GetRasterStatistics_NoDataPixelsCount (sqlite3_context * context,
         1541  +					    int argc, 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, int argc,
  1576         -					   sqlite3_value ** argv)
         1575  +fnct_GetRasterStatistics_ValidPixelsCount (sqlite3_context * context,
         1576  +					   int argc, 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 (coverage, &sample_type, &pixel_type, &num_bands)
  3891         -	!= RL2_OK)
         3890  +    if (rl2_get_coverage_type
         3891  +	(coverage, &sample_type, &pixel_type, &num_bands) != 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, wms_layer,
         4054  +		    do_wms_GetMap_get (NULL, url, proxy, wms_version,
         4055  +				       wms_layer,
  4055   4056   				       wms_crs, swap_xy, x, y - tileh,
  4056   4057   				       x + tilew, y, tile_width, tile_height,
  4057   4058   				       wms_style, wms_format, opaque, 0,
  4058   4059   				       &err_msg);
  4059   4060   		if (rgba_tile == NULL)
  4060   4061   		  {
  4061   4062   		      add_retry (retry_list, x, y - tileh, x + tilew, y);
................................................................................
  4109   4110   		if (retry->done)
  4110   4111   		  {
  4111   4112   		      retry = retry->next;
  4112   4113   		      continue;
  4113   4114   		  }
  4114   4115   		retry->count += 1;
  4115   4116   		rgba_tile =
  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);
         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);
  4121   4123   		if (rgba_tile == NULL)
  4122   4124   		  {
  4123   4125   		      retry = retry->next;
  4124   4126   		      continue;
  4125   4127   		  }
  4126   4128   
  4127   4129   		params.sqlite = sqlite;
................................................................................
  4485   4487   	  double ext_x = (double) width * horz_res;
  4486   4488   	  double ext_y = (double) height * vert_res;
  4487   4489   	  minx = pt_x - ext_x / 2.0;
  4488   4490   	  maxx = minx + ext_x;
  4489   4491   	  miny = pt_y - ext_y / 2.0;
  4490   4492   	  maxy = miny + ext_y;
  4491   4493         }
  4492         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  4493         -	     != RL2_OK)
         4494  +    else if (rl2_parse_bbox
         4495  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  4494   4496         {
  4495   4497   	  errcode = -1;
  4496   4498   	  goto error;
  4497   4499         }
  4498   4500   
  4499   4501   /* attempting to load the Coverage definitions from the DBMS */
  4500   4502       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  4515   4517   						    height, compression,
  4516   4518   						    tile_sz, worldfile);
  4517   4519         }
  4518   4520       else
  4519   4521         {
  4520   4522   	  /* whole Coverage */
  4521   4523   	  ret =
  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);
         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);
  4526   4529         }
  4527   4530       if (ret != RL2_OK)
  4528   4531         {
  4529   4532   	  errcode = 0;
  4530   4533   	  goto error;
  4531   4534         }
  4532   4535       rl2_destroy_coverage (coverage);
................................................................................
  4864   4867   	  double ext_x = (double) width * horz_res;
  4865   4868   	  double ext_y = (double) height * vert_res;
  4866   4869   	  minx = pt_x - ext_x / 2.0;
  4867   4870   	  maxx = minx + ext_x;
  4868   4871   	  miny = pt_y - ext_y / 2.0;
  4869   4872   	  maxy = miny + ext_y;
  4870   4873         }
  4871         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  4872         -	     != RL2_OK)
         4874  +    else if (rl2_parse_bbox
         4875  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  4873   4876         {
  4874   4877   	  errcode = -1;
  4875   4878   	  goto error;
  4876   4879         }
  4877   4880   
  4878   4881   /* attempting to load the Coverage definitions from the DBMS */
  4879   4882       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  4887   4890         {
  4888   4891   	  /* single Section */
  4889   4892   	  ret =
  4890   4893   	      rl2_export_section_triple_band_geotiff_from_dbms (sqlite, path,
  4891   4894   								coverage,
  4892   4895   								section_id,
  4893   4896   								horz_res,
  4894         -								vert_res, minx,
  4895         -								miny, maxx,
  4896         -								maxy, width,
  4897         -								height,
         4897  +								vert_res,
         4898  +								minx, miny,
         4899  +								maxx, maxy,
         4900  +								width, height,
  4898   4901   								red_band,
  4899   4902   								green_band,
  4900   4903   								blue_band,
  4901   4904   								compression,
  4902   4905   								tile_sz,
  4903   4906   								worldfile);
  4904   4907         }
  4905   4908       else
  4906   4909         {
  4907   4910   	  /* whole Coverage */
  4908   4911   
  4909   4912   	  ret =
  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,
         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,
  4914   4918   							green_band, blue_band,
  4915   4919   							compression, tile_sz,
  4916   4920   							worldfile);
  4917   4921         }
  4918   4922       if (ret != RL2_OK)
  4919   4923         {
  4920   4924   	  errcode = 0;
................................................................................
  5244   5248   	  double ext_x = (double) width * horz_res;
  5245   5249   	  double ext_y = (double) height * vert_res;
  5246   5250   	  minx = pt_x - ext_x / 2.0;
  5247   5251   	  maxx = minx + ext_x;
  5248   5252   	  miny = pt_y - ext_y / 2.0;
  5249   5253   	  maxy = miny + ext_y;
  5250   5254         }
  5251         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  5252         -	     != RL2_OK)
         5255  +    else if (rl2_parse_bbox
         5256  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  5253   5257         {
  5254   5258   	  errcode = -1;
  5255   5259   	  goto error;
  5256   5260         }
  5257   5261   
  5258   5262   /* attempting to load the Coverage definitions from the DBMS */
  5259   5263       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5268   5272   	  /* single Section */
  5269   5273   	  ret =
  5270   5274   	      rl2_export_section_mono_band_geotiff_from_dbms (sqlite, path,
  5271   5275   							      coverage,
  5272   5276   							      section_id,
  5273   5277   							      horz_res,
  5274   5278   							      vert_res, minx,
  5275         -							      miny, maxx, maxy,
  5276         -							      width, height,
         5279  +							      miny, maxx,
         5280  +							      maxy, width,
         5281  +							      height,
  5277   5282   							      mono_band,
  5278   5283   							      compression,
  5279   5284   							      tile_sz,
  5280   5285   							      worldfile);
  5281   5286         }
  5282   5287       else
  5283   5288         {
  5284   5289   	  /* whole Coverage */
  5285   5290   	  ret =
  5286   5291   	      rl2_export_mono_band_geotiff_from_dbms (sqlite, path, coverage,
  5287         -						      horz_res, vert_res, minx,
  5288         -						      miny, maxx, maxy, width,
  5289         -						      height, mono_band,
  5290         -						      compression, tile_sz,
  5291         -						      worldfile);
         5292  +						      horz_res, vert_res,
         5293  +						      minx, miny, maxx, maxy,
         5294  +						      width, height,
         5295  +						      mono_band, compression,
         5296  +						      tile_sz, worldfile);
  5292   5297         }
  5293   5298   
  5294   5299       if (ret != RL2_OK)
  5295   5300         {
  5296   5301   	  errcode = 0;
  5297   5302   	  goto error;
  5298   5303         }
................................................................................
  5598   5603   	  double ext_x = (double) width * horz_res;
  5599   5604   	  double ext_y = (double) height * vert_res;
  5600   5605   	  minx = pt_x - ext_x / 2.0;
  5601   5606   	  maxx = minx + ext_x;
  5602   5607   	  miny = pt_y - ext_y / 2.0;
  5603   5608   	  maxy = miny + ext_y;
  5604   5609         }
  5605         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  5606         -	     != RL2_OK)
         5610  +    else if (rl2_parse_bbox
         5611  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  5607   5612         {
  5608   5613   	  errcode = -1;
  5609   5614   	  goto error;
  5610   5615         }
  5611   5616   
  5612   5617   /* attempting to load the Coverage definitions from the DBMS */
  5613   5618       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5621   5626   	  /* only a single Section */
  5622   5627   	  if (with_worldfile)
  5623   5628   	    {
  5624   5629   		/* TIFF + Worldfile */
  5625   5630   		ret =
  5626   5631   		    rl2_export_section_tiff_worldfile_from_dbms (sqlite,
  5627   5632   								 max_threads,
  5628         -								 path, coverage,
         5633  +								 path,
         5634  +								 coverage,
  5629   5635   								 section_id,
  5630   5636   								 horz_res,
  5631         -								 vert_res, minx,
  5632         -								 miny, maxx,
  5633         -								 maxy, width,
         5637  +								 vert_res,
         5638  +								 minx, miny,
         5639  +								 maxx, maxy,
         5640  +								 width,
  5634   5641   								 height,
  5635   5642   								 compression,
  5636   5643   								 tile_sz);
  5637   5644   	    }
  5638   5645   	  else
  5639   5646   	    {
  5640   5647   		/* plain TIFF, no Worldfile */
................................................................................
  5654   5661   	  if (with_worldfile)
  5655   5662   	    {
  5656   5663   		/* TIFF + Worldfile */
  5657   5664   		ret =
  5658   5665   		    rl2_export_tiff_worldfile_from_dbms (sqlite, max_threads,
  5659   5666   							 path, coverage,
  5660   5667   							 horz_res, vert_res,
  5661         -							 minx, miny, maxx, maxy,
  5662         -							 width, height,
         5668  +							 minx, miny, maxx,
         5669  +							 maxy, width, height,
  5663   5670   							 compression, tile_sz);
  5664   5671   	    }
  5665   5672   	  else
  5666   5673   	    {
  5667   5674   		/* plain TIFF, no Worldfile */
  5668   5675   		ret =
  5669   5676   		    rl2_export_tiff_from_dbms (sqlite, max_threads, path,
................................................................................
  5969   5976   	  double ext_x = (double) width * horz_res;
  5970   5977   	  double ext_y = (double) height * vert_res;
  5971   5978   	  minx = pt_x - ext_x / 2.0;
  5972   5979   	  maxx = minx + ext_x;
  5973   5980   	  miny = pt_y - ext_y / 2.0;
  5974   5981   	  maxy = miny + ext_y;
  5975   5982         }
  5976         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  5977         -	     != RL2_OK)
         5983  +    else if (rl2_parse_bbox
         5984  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  5978   5985         {
  5979   5986   	  errcode = -1;
  5980   5987   	  goto error;
  5981   5988         }
  5982   5989   
  5983   5990   /* attempting to load the Coverage definitions from the DBMS */
  5984   5991       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  5989   5996         }
  5990   5997   
  5991   5998       if (by_section)
  5992   5999         {
  5993   6000   	  /* single Section */
  5994   6001   	  ret =
  5995   6002   	      rl2_export_section_jpeg_from_dbms (sqlite, max_threads, path,
  5996         -						 coverage, section_id, horz_res,
  5997         -						 vert_res, minx, miny, maxx,
  5998         -						 maxy, width, height, quality,
         6003  +						 coverage, section_id,
         6004  +						 horz_res, vert_res, minx,
         6005  +						 miny, maxx, maxy, width,
         6006  +						 height, quality,
  5999   6007   						 with_worldfile);
  6000   6008         }
  6001   6009       else
  6002   6010         {
  6003   6011   	  /* whole Coverage */
  6004   6012   	  ret =
  6005   6013   	      rl2_export_jpeg_from_dbms (sqlite, max_threads, path, coverage,
................................................................................
  6366   6374   	  double ext_x = (double) width * horz_res;
  6367   6375   	  double ext_y = (double) height * vert_res;
  6368   6376   	  minx = pt_x - ext_x / 2.0;
  6369   6377   	  maxx = minx + ext_x;
  6370   6378   	  miny = pt_y - ext_y / 2.0;
  6371   6379   	  maxy = miny + ext_y;
  6372   6380         }
  6373         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  6374         -	     != RL2_OK)
         6381  +    else if (rl2_parse_bbox
         6382  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  6375   6383         {
  6376   6384   	  errcode = -1;
  6377   6385   	  goto error;
  6378   6386         }
  6379   6387   
  6380   6388   /* attempting to load the Coverage definitions from the DBMS */
  6381   6389       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  6397   6405   		     minx, miny, maxx, maxy, width, height, red_band,
  6398   6406   		     green_band, blue_band, compression, tile_sz);
  6399   6407   	    }
  6400   6408   	  else
  6401   6409   	    {
  6402   6410   		/* plain TIFF, no Worldfile */
  6403   6411   		ret =
  6404         -		    rl2_export_section_triple_band_tiff_from_dbms (sqlite, path,
         6412  +		    rl2_export_section_triple_band_tiff_from_dbms (sqlite,
         6413  +								   path,
  6405   6414   								   coverage,
  6406   6415   								   section_id,
  6407   6416   								   horz_res,
  6408   6417   								   vert_res,
  6409   6418   								   minx, miny,
  6410   6419   								   maxx, maxy,
  6411   6420   								   width,
................................................................................
  6425   6434   		/* TIFF + Worldfile */
  6426   6435   		ret =
  6427   6436   		    rl2_export_triple_band_tiff_worldfile_from_dbms (sqlite,
  6428   6437   								     path,
  6429   6438   								     coverage,
  6430   6439   								     horz_res,
  6431   6440   								     vert_res,
  6432         -								     minx, miny,
  6433         -								     maxx, maxy,
         6441  +								     minx,
         6442  +								     miny,
         6443  +								     maxx,
         6444  +								     maxy,
  6434   6445   								     width,
  6435   6446   								     height,
  6436   6447   								     red_band,
  6437   6448   								     green_band,
  6438   6449   								     blue_band,
  6439   6450   								     compression,
  6440   6451   								     tile_sz);
................................................................................
  6441   6452   	    }
  6442   6453   	  else
  6443   6454   	    {
  6444   6455   		/* plain TIFF, no Worldfile */
  6445   6456   		ret =
  6446   6457   		    rl2_export_triple_band_tiff_from_dbms (sqlite, path,
  6447   6458   							   coverage, horz_res,
  6448         -							   vert_res, minx, miny,
  6449         -							   maxx, maxy, width,
  6450         -							   height, red_band,
         6459  +							   vert_res, minx,
         6460  +							   miny, maxx, maxy,
         6461  +							   width, height,
         6462  +							   red_band,
  6451   6463   							   green_band,
  6452   6464   							   blue_band,
  6453   6465   							   compression,
  6454   6466   							   tile_sz);
  6455   6467   	    }
  6456   6468         }
  6457   6469       if (ret != RL2_OK)
................................................................................
  6815   6827   	  double ext_x = (double) width * horz_res;
  6816   6828   	  double ext_y = (double) height * vert_res;
  6817   6829   	  minx = pt_x - ext_x / 2.0;
  6818   6830   	  maxx = minx + ext_x;
  6819   6831   	  miny = pt_y - ext_y / 2.0;
  6820   6832   	  maxy = miny + ext_y;
  6821   6833         }
  6822         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  6823         -	     != RL2_OK)
         6834  +    else if (rl2_parse_bbox
         6835  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  6824   6836         {
  6825   6837   	  errcode = -1;
  6826   6838   	  goto error;
  6827   6839         }
  6828   6840   
  6829   6841   /* attempting to load the Coverage definitions from the DBMS */
  6830   6842       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  6850   6862   	    {
  6851   6863   		/* plain TIFF, no Worldfile */
  6852   6864   		ret =
  6853   6865   		    rl2_export_section_mono_band_tiff_from_dbms (sqlite, path,
  6854   6866   								 coverage,
  6855   6867   								 section_id,
  6856   6868   								 horz_res,
  6857         -								 vert_res, minx,
  6858         -								 miny, maxx,
  6859         -								 maxy, width,
         6869  +								 vert_res,
         6870  +								 minx, miny,
         6871  +								 maxx, maxy,
         6872  +								 width,
  6860   6873   								 height,
  6861   6874   								 mono_band,
  6862   6875   								 compression,
  6863   6876   								 tile_sz);
  6864   6877   	    }
  6865   6878         }
  6866   6879       else
  6867   6880         {
  6868   6881   	  /* whole Coverage */
  6869   6882   	  if (with_worldfile)
  6870   6883   	    {
  6871   6884   		/* TIFF + Worldfile */
  6872   6885   		ret =
  6873         -		    rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite, path,
         6886  +		    rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite,
         6887  +								   path,
  6874   6888   								   coverage,
  6875   6889   								   horz_res,
  6876   6890   								   vert_res,
  6877   6891   								   minx, miny,
  6878   6892   								   maxx, maxy,
  6879   6893   								   width,
  6880   6894   								   height,
................................................................................
  6882   6896   								   compression,
  6883   6897   								   tile_sz);
  6884   6898   	    }
  6885   6899   	  else
  6886   6900   	    {
  6887   6901   		/* plain TIFF, no Worldfile */
  6888   6902   		ret =
  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);
         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);
  6895   6909   	    }
  6896   6910         }
  6897   6911       if (ret != RL2_OK)
  6898   6912         {
  6899   6913   	  errcode = 0;
  6900   6914   	  goto error;
  6901   6915         }
................................................................................
  7188   7202   	  double ext_x = (double) width * resolution;
  7189   7203   	  double ext_y = (double) height * resolution;
  7190   7204   	  minx = pt_x - ext_x / 2.0;
  7191   7205   	  maxx = minx + ext_x;
  7192   7206   	  miny = pt_y - ext_y / 2.0;
  7193   7207   	  maxy = miny + ext_y;
  7194   7208         }
  7195         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  7196         -	     != RL2_OK)
         7209  +    else if (rl2_parse_bbox
         7210  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  7197   7211         {
  7198   7212   	  errcode = -1;
  7199   7213   	  goto error;
  7200   7214         }
  7201   7215   
  7202   7216   /* attempting to load the Coverage definitions from the DBMS */
  7203   7217       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  7220   7234   						       decimal_digits);
  7221   7235         }
  7222   7236       else
  7223   7237         {
  7224   7238   	  /* whole Coverage */
  7225   7239   	  ret =
  7226   7240   	      rl2_export_ascii_grid_from_dbms (sqlite, max_threads, path,
  7227         -					       coverage, resolution, minx, miny,
  7228         -					       maxx, maxy, width, height,
  7229         -					       is_centered, decimal_digits);
         7241  +					       coverage, resolution, minx,
         7242  +					       miny, maxx, maxy, width,
         7243  +					       height, is_centered,
         7244  +					       decimal_digits);
  7230   7245         }
  7231   7246       if (ret != RL2_OK)
  7232   7247         {
  7233   7248   	  errcode = 0;
  7234   7249   	  goto error;
  7235   7250         }
  7236   7251       rl2_destroy_coverage (coverage);
................................................................................
  7477   7492   	  double ext_x = (double) width * resolution;
  7478   7493   	  double ext_y = (double) height * resolution;
  7479   7494   	  minx = pt_x - ext_x / 2.0;
  7480   7495   	  maxx = minx + ext_x;
  7481   7496   	  miny = pt_y - ext_y / 2.0;
  7482   7497   	  maxy = miny + ext_y;
  7483   7498         }
  7484         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  7485         -	     != RL2_OK)
         7499  +    else if (rl2_parse_bbox
         7500  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  7486   7501         {
  7487   7502   	  errcode = -1;
  7488   7503   	  goto error;
  7489   7504         }
  7490   7505   
  7491   7506   /* attempting to load the Coverage definitions from the DBMS */
  7492   7507       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
................................................................................
  7496   7511   	  return;
  7497   7512         }
  7498   7513   
  7499   7514       if (by_section)
  7500   7515         {
  7501   7516   	  /* single Section */
  7502   7517   	  ret =
  7503         -	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite, max_threads,
  7504         -							    path, coverage,
         7518  +	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite,
         7519  +							    max_threads, path,
         7520  +							    coverage,
  7505   7521   							    section_id,
  7506   7522   							    resolution, minx,
  7507   7523   							    miny, maxx, maxy,
  7508   7524   							    width, height,
  7509         -							    red_band, nir_band,
         7525  +							    red_band,
         7526  +							    nir_band,
  7510   7527   							    is_centered,
  7511   7528   							    decimal_digits);
  7512   7529         }
  7513   7530       else
  7514   7531         {
  7515   7532   	  /* whole Coverage */
  7516   7533   	  ret =
  7517   7534   	      rl2_export_ndvi_ascii_grid_from_dbms (sqlite, max_threads, path,
  7518         -						    coverage, resolution, minx,
  7519         -						    miny, maxx, maxy, width,
  7520         -						    height, red_band, nir_band,
  7521         -						    is_centered,
         7535  +						    coverage, resolution,
         7536  +						    minx, miny, maxx, maxy,
         7537  +						    width, height, red_band,
         7538  +						    nir_band, is_centered,
  7522   7539   						    decimal_digits);
  7523   7540         }
  7524   7541       if (ret != RL2_OK)
  7525   7542         {
  7526   7543   	  errcode = 0;
  7527   7544   	  goto error;
  7528   7545         }
................................................................................
  7579   7596   /
  7580   7597   / will return 1 (TRUE, success) or 0 (FALSE, failure)
  7581   7598   / or -1 (INVALID ARGS)
  7582   7599   /
  7583   7600   */
  7584   7601       common_write_ndvi_ascii_grid (1, context, argc, argv);
  7585   7602   }
         7603  +
         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  +}
  7586   7658   
  7587   7659   static void
  7588   7660   fnct_GetMapImageFromRaster (sqlite3_context * context, int argc,
  7589   7661   			    sqlite3_value ** argv)
  7590   7662   {
  7591   7663   /* SQL function:
  7592   7664   / GetMapImageFromRaster(text coverage, BLOB geom, int width, int height)
................................................................................
  7641   7713       double ext_y;
  7642   7714       double x_res;
  7643   7715       double y_res;
  7644   7716       int srid;
  7645   7717       int level_id;
  7646   7718       int scale;
  7647   7719       int xscale;
         7720  +    double map_scale;
  7648   7721       double xx_res;
  7649   7722       double yy_res;
  7650   7723       double aspect_org;
  7651   7724       double aspect_dst;
  7652   7725       int ok_style;
  7653   7726       int ok_format;
  7654   7727       unsigned char *outbuf = NULL;
................................................................................
  7790   7863   	  aux.reaspect = reaspect;
  7791   7864   	  rl2_aux_group_renderer (&aux);
  7792   7865   	  return;
  7793   7866         }
  7794   7867   
  7795   7868       x_res = ext_x / (double) width;
  7796   7869       y_res = ext_y / (double) height;
         7870  +    map_scale = standard_scale (sqlite, out_srid, width, height, ext_x, ext_y);
  7797   7871   /* validating the style */
  7798   7872       ok_style = 0;
  7799   7873       if (strcasecmp (style, "default") == 0)
  7800   7874   	ok_style = 1;
  7801   7875       else
  7802   7876         {
  7803   7877   	  /* attempting to get a Coverage Style */
  7804   7878   	  cvg_stl =
  7805   7879   	      rl2_create_coverage_style_from_dbms (sqlite, cvg_name, style);
  7806   7880   	  if (cvg_stl == NULL)
  7807   7881   	      goto error;
  7808         -	  symbolizer = rl2_get_symbolizer_from_coverage_style (cvg_stl, 1.0);
         7882  +	  symbolizer =
         7883  +	      rl2_get_symbolizer_from_coverage_style (cvg_stl, map_scale);
  7809   7884   	  if (symbolizer == NULL)
  7810         -	      goto error;
         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  +	    }
  7811   7893   	  stats = rl2_create_raster_statistics_from_dbms (sqlite, cvg_name);
  7812   7894   	  if (stats == NULL)
  7813   7895   	      goto error;
  7814   7896   	  ok_style = 1;
  7815   7897         }
  7816   7898       if (!ok_style)
  7817   7899   	goto error;
................................................................................
  7976   8058         }
  7977   8059       else
  7978   8060         {
  7979   8061   	  /* ordinary Coverage */
  7980   8062   	  by_section = 0;
  7981   8063   	  /* retrieving the optimal resolution level */
  7982   8064   	  if (!rl2_find_best_resolution_level
  7983         -	      (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale, &xscale,
  7984         -	       &xx_res, &yy_res))
         8065  +	      (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale,
         8066  +	       &xscale, &xx_res, &yy_res))
  7985   8067   	      goto error;
  7986   8068         }
  7987   8069       base_width = (int) (ext_x / xx_res);
  7988   8070       base_height = (int) (ext_y / yy_res);
  7989   8071       if ((base_width <= 0 && base_width >= USHRT_MAX)
  7990   8072   	|| (base_height <= 0 && base_height >= USHRT_MAX))
  7991   8073   	goto error;
................................................................................
  8096   8178       aux.symbolizer = symbolizer;
  8097   8179       aux.stats = stats;
  8098   8180       aux.outbuf = outbuf;
  8099   8181       aux.palette = palette;
  8100   8182       aux.out_pixel = out_pixel;
  8101   8183       if (!rl2_aux_render_image (&aux, &image, &image_size))
  8102   8184   	goto error;
         8185  +
         8186  +  done:
  8103   8187       sqlite3_result_blob (context, image, image_size, free);
  8104   8188       rl2_destroy_coverage (coverage);
  8105   8189       if (palette != NULL)
  8106   8190   	rl2_destroy_palette (palette);
  8107   8191       if (cvg_stl != NULL)
  8108   8192   	rl2_destroy_coverage_style (cvg_stl);
  8109   8193       if (stats != NULL)
................................................................................
  8118   8202       if (cvg_stl != NULL)
  8119   8203   	rl2_destroy_coverage_style (cvg_stl);
  8120   8204       if (stats != NULL)
  8121   8205   	rl2_destroy_raster_statistics (stats);
  8122   8206       sqlite3_result_null (context);
  8123   8207   }
  8124   8208   
  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         -}
  8179         -
  8180   8209   static void
  8181   8210   fnct_GetMapImageFromVector (sqlite3_context * context, int argc,
  8182   8211   			    sqlite3_value ** argv)
  8183   8212   {
  8184   8213   /* SQL function:
  8185   8214   / GetMapImageFromVector(text coverage, BLOB geom, int width, int height)
  8186   8215   / GetMapImageFromVector(text coverage, BLOB geom, int width, int height,
................................................................................
  8219   8248       unsigned char bg_green;
  8220   8249       unsigned char bg_blue;
  8221   8250       int transparent = 0;
  8222   8251       int quality = 80;
  8223   8252       int reaspect = 0;
  8224   8253       sqlite3 *sqlite;
  8225   8254       sqlite3_stmt *stmt = NULL;
         8255  +    const void *data;
  8226   8256       double minx;
  8227   8257       double maxx;
  8228   8258       double miny;
  8229   8259       double maxy;
  8230   8260       double ext_x;
  8231   8261       double ext_y;
  8232   8262       double x_res;
................................................................................
  8300   8330       if (argc > 8)
  8301   8331   	quality = sqlite3_value_int (argv[8]);
  8302   8332       if (argc > 9)
  8303   8333   	reaspect = sqlite3_value_int (argv[9]);
  8304   8334   
  8305   8335   /* coarse args validation */
  8306   8336       sqlite = sqlite3_context_db_handle (context);
         8337  +    data = sqlite3_user_data (context);
  8307   8338       if (width < 64)
  8308   8339   	goto error;
  8309   8340       if (height < 64)
  8310   8341   	goto error;
  8311   8342   /* validating the format */
  8312   8343       ok_format = 0;
  8313   8344       if (strcmp (format, "image/png") == 0)
................................................................................
  8501   8532   			      {
  8502   8533   			      case SQLITE_INTEGER:
  8503   8534   				  rl2_set_variant_int (variant, i, col_name,
  8504   8535   						       sqlite3_column_int64
  8505   8536   						       (stmt, i + 1));
  8506   8537   				  break;
  8507   8538   			      case SQLITE_FLOAT:
  8508         -				  rl2_set_variant_double (variant, i, col_name,
         8539  +				  rl2_set_variant_double (variant, i,
         8540  +							  col_name,
  8509   8541   							  sqlite3_column_double
  8510   8542   							  (stmt, i + 1));
  8511   8543   				  break;
  8512   8544   			      case SQLITE_TEXT:
  8513   8545   				  rl2_set_variant_text (variant, i, col_name,
  8514   8546   							(const char *)
  8515   8547   							sqlite3_column_text
................................................................................
  8529   8561   				  break;
  8530   8562   			      };
  8531   8563   			}
  8532   8564   		  }
  8533   8565   		if (geom != NULL)
  8534   8566   		  {
  8535   8567   		      /* drawing a styled Feature */
  8536         -		      int scale_forbidden;
         8568  +		      int scale_forbidden = 0;
  8537   8569   		      symbolizer = NULL;
  8538   8570   		      if (lyr_stl != NULL)
  8539   8571   			  symbolizer =
  8540   8572   			      rl2_get_symbolizer_from_feature_type_style
  8541   8573   			      (lyr_stl, scale, variant, &scale_forbidden);
  8542   8574   		      if (!scale_forbidden)
  8543         -			  rl2_draw_vector_feature (ctx, sqlite, symbolizer,
  8544         -						   height, minx, miny, x_res,
         8575  +			  rl2_draw_vector_feature (ctx, sqlite, data,
         8576  +						   symbolizer, height, minx,
         8577  +						   miny, maxx, maxy, x_res,
  8545   8578   						   y_res, geom, variant);
  8546   8579   		      rl2_destroy_geometry (geom);
  8547   8580   		  }
  8548   8581   	    }
  8549   8582         }
  8550   8583       sqlite3_finalize (stmt);
  8551   8584   
................................................................................
  8805   8838   			    *p_rgba++ = 0;	/* transparent */
  8806   8839   			}
  8807   8840   		  }
  8808   8841   		switch (pixel_type)
  8809   8842   		  {
  8810   8843   		  case RL2_PIXEL_MONOCHROME:
  8811   8844   		      ret =
  8812         -			  get_rgba_from_monochrome_mask (width, height, buffer,
  8813         -							 mask, no_data, rgba);
         8845  +			  get_rgba_from_monochrome_mask (width, height,
         8846  +							 buffer, mask,
         8847  +							 no_data, rgba);
  8814   8848   		      buffer = NULL;
  8815   8849   		      mask = NULL;
  8816   8850   		      if (!ret)
  8817   8851   			  goto error;
  8818   8852   		      if (!build_rgb_alpha
  8819         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  8820         -			   bg_blue))
         8853  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         8854  +			   bg_green, bg_blue))
  8821   8855   			  goto error;
  8822   8856   		      free (rgba);
  8823   8857   		      rgba = NULL;
  8824   8858   		      if (transparent)
  8825   8859   			{
  8826   8860   			    if (!get_payload_from_gray_rgba_transparent
  8827   8861   				(width, height, rgb, alpha,
................................................................................
  8847   8881   						      mask, palette, no_data,
  8848   8882   						      rgba);
  8849   8883   		      buffer = NULL;
  8850   8884   		      mask = NULL;
  8851   8885   		      if (!ret)
  8852   8886   			  goto error;
  8853   8887   		      if (!build_rgb_alpha
  8854         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  8855         -			   bg_blue))
         8888  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         8889  +			   bg_green, bg_blue))
  8856   8890   			  goto error;
  8857   8891   		      free (rgba);
  8858   8892   		      rgba = NULL;
  8859   8893   		      if (transparent)
  8860   8894   			{
  8861   8895   			    if (!get_payload_from_rgb_rgba_transparent
  8862   8896   				(width, height, rgb, alpha,
................................................................................
  8881   8915   			  get_rgba_from_grayscale_mask (width, height, buffer,
  8882   8916   							mask, no_data, rgba);
  8883   8917   		      buffer = NULL;
  8884   8918   		      mask = NULL;
  8885   8919   		      if (!ret)
  8886   8920   			  goto error;
  8887   8921   		      if (!build_rgb_alpha
  8888         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  8889         -			   bg_blue))
         8922  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         8923  +			   bg_green, bg_blue))
  8890   8924   			  goto error;
  8891   8925   		      free (rgba);
  8892   8926   		      rgba = NULL;
  8893   8927   		      if (transparent)
  8894   8928   			{
  8895   8929   			    if (!get_payload_from_gray_rgba_transparent
  8896   8930   				(width, height, rgb, alpha,
................................................................................
  8916   8950   						       sample_type, buffer,
  8917   8951   						       mask, no_data, rgba);
  8918   8952   		      buffer = NULL;
  8919   8953   		      mask = NULL;
  8920   8954   		      if (!ret)
  8921   8955   			  goto error;
  8922   8956   		      if (!build_rgb_alpha
  8923         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  8924         -			   bg_blue))
         8957  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         8958  +			   bg_green, bg_blue))
  8925   8959   			  goto error;
  8926   8960   		      free (rgba);
  8927   8961   		      rgba = NULL;
  8928   8962   		      if (transparent)
  8929   8963   			{
  8930   8964   			    if (!get_payload_from_gray_rgba_transparent
  8931   8965   				(width, height, rgb, alpha,
................................................................................
  8945   8979   			}
  8946   8980   		      sqlite3_result_blob (context, image, image_size, free);
  8947   8981   		      break;
  8948   8982   		  case RL2_PIXEL_RGB:
  8949   8983   		      if (sample_type == RL2_SAMPLE_UINT16)
  8950   8984   			{
  8951   8985   			    ret =
  8952         -				get_rgba_from_multiband16 (width, height, 0, 1,
  8953         -							   2, 3,
         8986  +				get_rgba_from_multiband16 (width, height, 0,
         8987  +							   1, 2, 3,
  8954   8988   							   (unsigned short *)
  8955   8989   							   buffer, mask,
  8956   8990   							   no_data, rgba);
  8957   8991   			}
  8958   8992   		      else
  8959   8993   			{
  8960   8994   			    ret =
................................................................................
  8962   8996   							mask, no_data, rgba);
  8963   8997   			}
  8964   8998   		      buffer = NULL;
  8965   8999   		      mask = NULL;
  8966   9000   		      if (!ret)
  8967   9001   			  goto error;
  8968   9002   		      if (!build_rgb_alpha
  8969         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  8970         -			   bg_blue))
         9003  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         9004  +			   bg_green, bg_blue))
  8971   9005   			  goto error;
  8972   9006   		      free (rgba);
  8973   9007   		      rgba = NULL;
  8974   9008   		      if (transparent)
  8975   9009   			{
  8976   9010   			    if (!get_payload_from_rgb_rgba_transparent
  8977   9011   				(width, height, rgb, alpha,
................................................................................
  8990   9024   				goto error;
  8991   9025   			}
  8992   9026   		      sqlite3_result_blob (context, image, image_size, free);
  8993   9027   		      break;
  8994   9028   		  case RL2_PIXEL_MULTIBAND:
  8995   9029   		      ret =
  8996   9030   			  get_rgba_from_multiband_mask (width, height,
  8997         -							sample_type, num_bands,
  8998         -							buffer, mask, no_data,
  8999         -							rgba);
         9031  +							sample_type,
         9032  +							num_bands, buffer,
         9033  +							mask, no_data, rgba);
  9000   9034   		      buffer = NULL;
  9001   9035   		      mask = NULL;
  9002   9036   		      if (!ret)
  9003   9037   			  goto error;
  9004   9038   		      if (!build_rgb_alpha
  9005         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  9006         -			   bg_blue))
         9039  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         9040  +			   bg_green, bg_blue))
  9007   9041   			  goto error;
  9008   9042   		      free (rgba);
  9009   9043   		      rgba = NULL;
  9010   9044   		      if (transparent)
  9011   9045   			{
  9012   9046   			    if (!get_payload_from_gray_rgba_transparent
  9013   9047   				(width, height, rgb, alpha,
................................................................................
  9238   9272   						    num_bands, buffer, mask,
  9239   9273   						    no_data, rgba);
  9240   9274   		      buffer = NULL;
  9241   9275   		      mask = NULL;
  9242   9276   		      if (!ret)
  9243   9277   			  goto error;
  9244   9278   		      if (!build_rgb_alpha
  9245         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  9246         -			   bg_blue))
         9279  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         9280  +			   bg_green, bg_blue))
  9247   9281   			  goto error;
  9248   9282   		      free (rgba);
  9249   9283   		      rgba = NULL;
  9250   9284   		      if (transparent)
  9251   9285   			{
  9252   9286   			    if (!get_payload_from_rgb_rgba_transparent
  9253   9287   				(width, height, rgb, alpha,
................................................................................
  9268   9302   		      sqlite3_result_blob (context, image, image_size, free);
  9269   9303   		      break;
  9270   9304   		  case RL2_SAMPLE_UINT16:
  9271   9305   		      ret =
  9272   9306   			  get_rgba_from_multiband16 (width, height, red_band,
  9273   9307   						     green_band, blue_band,
  9274   9308   						     num_bands,
  9275         -						     (unsigned short *) buffer,
  9276         -						     mask, no_data, rgba);
         9309  +						     (unsigned short *)
         9310  +						     buffer, mask, no_data,
         9311  +						     rgba);
  9277   9312   		      if (!build_rgb_alpha
  9278         -			  (width, height, rgba, &rgb, &alpha, bg_red, bg_green,
  9279         -			   bg_blue))
         9313  +			  (width, height, rgba, &rgb, &alpha, bg_red,
         9314  +			   bg_green, bg_blue))
  9280   9315   			  goto error;
  9281   9316   		      free (rgba);
  9282   9317   		      rgba = NULL;
  9283   9318   		      if (transparent)
  9284   9319   			{
  9285   9320   			    if (!get_payload_from_rgb_rgba_transparent
  9286   9321   				(width, height, rgb, alpha,
................................................................................
  9661   9696   	  double ext_x = (double) width * horz_res;
  9662   9697   	  double ext_y = (double) height * vert_res;
  9663   9698   	  minx = pt_x - ext_x / 2.0;
  9664   9699   	  maxx = minx + ext_x;
  9665   9700   	  miny = pt_y - ext_y / 2.0;
  9666   9701   	  maxy = miny + ext_y;
  9667   9702         }
  9668         -    else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy)
  9669         -	     != RL2_OK)
         9703  +    else if (rl2_parse_bbox
         9704  +	     (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK)
  9670   9705   	goto error;
  9671   9706   
  9672   9707   /* attempting to load the Coverage definitions from the DBMS */
  9673   9708       coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name);
  9674   9709       if (coverage == NULL)
  9675   9710   	goto error;
  9676   9711       if (by_section)
  9677   9712         {
  9678   9713   	  /* only a single Section */
  9679   9714   	  ret =
  9680   9715   	      rl2_export_section_raw_pixels_from_dbms (sqlite, max_threads,
  9681   9716   						       coverage, section_id,
  9682         -						       horz_res, vert_res, minx,
  9683         -						       miny, maxx, maxy, width,
  9684         -						       height, big_endian,
  9685         -						       &xblob, &xblob_sz);
         9717  +						       horz_res, vert_res,
         9718  +						       minx, miny, maxx, maxy,
         9719  +						       width, height,
         9720  +						       big_endian, &xblob,
         9721  +						       &xblob_sz);
  9686   9722         }
  9687   9723       else
  9688   9724         {
  9689   9725   	  /* whole Coverage */
  9690   9726   	  ret =
  9691   9727   	      rl2_export_raw_pixels_from_dbms (sqlite, max_threads, coverage,
  9692   9728   					       horz_res, vert_res, minx, miny,
................................................................................
  9878   9914       if (rl2_parse_bbox_srid
  9879   9915   	(sqlite, blob, blob_sz, &srid, &minx, &miny, &maxx, &maxy) != RL2_OK)
  9880   9916         {
  9881   9917   	  errcode = -1;
  9882   9918   	  goto error;
  9883   9919         }
  9884   9920   
  9885         -    if (rl2_get_coverage_type (coverage, &sample_type, &pixel_type, &num_bands)
  9886         -	!= RL2_OK)
         9921  +    if (rl2_get_coverage_type
         9922  +	(coverage, &sample_type, &pixel_type, &num_bands) != RL2_OK)
  9887   9923         {
  9888   9924   	  errcode = -1;
  9889   9925   	  goto error;
  9890   9926         }
  9891   9927       if (rl2_get_coverage_srid (coverage, &cov_srid) != RL2_OK)
  9892   9928         {
  9893   9929   	  errcode = -1;
................................................................................
  9947   9983       no_data = NULL;
  9948   9984       if (raster == NULL)
  9949   9985         {
  9950   9986   	  errcode = -1;
  9951   9987   	  goto error;
  9952   9988         }
  9953   9989   /* georeferencing the raster */
  9954         -    if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy) !=
  9955         -	RL2_OK)
         9990  +    if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy)
         9991  +	!= RL2_OK)
  9956   9992         {
  9957   9993   	  errcode = -1;
  9958   9994   	  goto error;
  9959   9995         }
  9960   9996   
  9961   9997   /* attempting to load the Raster into the DBMS */
  9962   9998       if (transaction)
................................................................................
  9967  10003   	    {
  9968  10004   		rl2_destroy_coverage (coverage);
  9969  10005   		sqlite3_result_int (context, -1);
  9970  10006   		return;
  9971  10007   	    }
  9972  10008         }
  9973  10009       ret =
  9974         -	rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage, sctn_name,
  9975         -				       raster, pyramidize);
        10010  +	rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage,
        10011  +				       sctn_name, raster, pyramidize);
  9976  10012       rl2_destroy_coverage (coverage);
  9977  10013       rl2_destroy_raster (raster);
  9978  10014       if (ret != RL2_OK)
  9979  10015         {
  9980  10016   	  if (transaction)
  9981  10017   	    {
  9982  10018   		/* invalidating the pending transaction */
................................................................................
 10137  10173   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10138  10174       sqlite3_create_function (db, "DropRasterCoverage", 2,
 10139  10175   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10140  10176       sqlite3_create_function (db, "RL2_DropRasterCoverage", 2,
 10141  10177   			     SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0);
 10142  10178       sqlite3_create_function (db, "SetRasterCoverageInfos", 3,
 10143  10179   			     SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0);
 10144         -    sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3,
 10145         -			     SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0);
        10180  +    sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3, SQLITE_UTF8,
        10181  +			     0, fnct_SetRasterCoverageInfos, 0, 0);
 10146  10182       sqlite3_create_function (db, "SetRasterCoverageDefaultBands", 5,
 10147         -			     SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands,
 10148         -			     0, 0);
        10183  +			     SQLITE_UTF8, 0,
        10184  +			     fnct_SetRasterCoverageDefaultBands, 0, 0);
 10149  10185       sqlite3_create_function (db, "RL2_SetRasterCoverageDefaultBands", 5,
 10150         -			     SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands,
 10151         -			     0, 0);
        10186  +			     SQLITE_UTF8, 0,
        10187  +			     fnct_SetRasterCoverageDefaultBands, 0, 0);
 10152  10188       sqlite3_create_function (db, "EnableRasterCoverageAutoNDVI", 2,
 10153         -			     SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI,
 10154         -			     0, 0);
        10189  +			     SQLITE_UTF8, 0,
        10190  +			     fnct_EnableRasterCoverageAutoNDVI, 0, 0);
 10155  10191       sqlite3_create_function (db, "RL2_EnableRasterCoverageAutoNDVI", 2,
 10156         -			     SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI,
 10157         -			     0, 0);
        10192  +			     SQLITE_UTF8, 0,
        10193  +			     fnct_EnableRasterCoverageAutoNDVI, 0, 0);
 10158  10194       sqlite3_create_function (db, "IsRasterCoverageAutoNdviEnabled", 1,
 10159  10195   			     SQLITE_UTF8, 0,
 10160  10196   			     fnct_IsRasterCoverageAutoNdviEnabled, 0, 0);
 10161  10197       sqlite3_create_function (db, "RL2_IsRasterCoverageAutoNdviEnabled", 1,
 10162  10198   			     SQLITE_UTF8, 0,
 10163  10199   			     fnct_IsRasterCoverageAutoNdviEnabled, 0, 0);
 10164  10200       sqlite3_create_function (db, "GetPaletteNumEntries", 1,
................................................................................
 10286  10322   			     fnct_IsFontItalic, 0, 0);
 10287  10323       sqlite3_create_function (db, "RL2_IsFontItalic", 1,
 10288  10324   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10289  10325   			     fnct_IsFontItalic, 0, 0);
 10290  10326       sqlite3_create_function (db, "GetRasterStatistics_NoDataPixelsCount", 1,
 10291  10327   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10292  10328   			     fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0);
 10293         -    sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount", 1,
 10294         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10329  +    sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount",
        10330  +			     1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10295  10331   			     fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0);
 10296  10332       sqlite3_create_function (db, "GetRasterStatistics_ValidPixelsCount", 1,
 10297  10333   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10298  10334   			     fnct_GetRasterStatistics_ValidPixelsCount, 0, 0);
 10299         -    sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount", 1,
 10300         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10335  +    sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount",
        10336  +			     1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10301  10337   			     fnct_GetRasterStatistics_ValidPixelsCount, 0, 0);
 10302  10338       sqlite3_create_function (db, "GetRasterStatistics_SampleType", 1,
 10303  10339   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10304  10340   			     fnct_GetRasterStatistics_SampleType, 0, 0);
 10305  10341       sqlite3_create_function (db, "RL2_GetRasterStatistics_SampleType", 1,
 10306  10342   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
 10307  10343   			     fnct_GetRasterStatistics_SampleType, 0, 0);
................................................................................
 10368  10404   			     fnct_Pyramidize, 0, 0);
 10369  10405       sqlite3_create_function (db, "Pyramidize", 4, SQLITE_UTF8, priv_data,
 10370  10406   			     fnct_Pyramidize, 0, 0);
 10371  10407       sqlite3_create_function (db, "RL2_Pyramidize", 4, SQLITE_UTF8, priv_data,
 10372  10408   			     fnct_Pyramidize, 0, 0);
 10373  10409       sqlite3_create_function (db, "PyramidizeMonolithic", 1, SQLITE_UTF8, 0,
 10374  10410   			     fnct_PyramidizeMonolithic, 0, 0);
 10375         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8, 0,
 10376         -			     fnct_PyramidizeMonolithic, 0, 0);
        10411  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8,
        10412  +			     0, fnct_PyramidizeMonolithic, 0, 0);
 10377  10413       sqlite3_create_function (db, "PyramidizeMonolithic", 2, SQLITE_UTF8, 0,
 10378  10414   			     fnct_PyramidizeMonolithic, 0, 0);
 10379         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8, 0,
 10380         -			     fnct_PyramidizeMonolithic, 0, 0);
        10415  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8,
        10416  +			     0, fnct_PyramidizeMonolithic, 0, 0);
 10381  10417       sqlite3_create_function (db, "PyramidizeMonolithic", 3, SQLITE_UTF8, 0,
 10382  10418   			     fnct_PyramidizeMonolithic, 0, 0);
 10383         -    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8, 0,
 10384         -			     fnct_PyramidizeMonolithic, 0, 0);
        10419  +    sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8,
        10420  +			     0, fnct_PyramidizeMonolithic, 0, 0);
 10385  10421       sqlite3_create_function (db, "DePyramidize", 1, SQLITE_UTF8, 0,
 10386  10422   			     fnct_DePyramidize, 0, 0);
 10387  10423       sqlite3_create_function (db, "RL2_DePyramidize", 1, SQLITE_UTF8, 0,
 10388  10424   			     fnct_DePyramidize, 0, 0);
 10389  10425       sqlite3_create_function (db, "DePyramidize", 2, SQLITE_UTF8, 0,
 10390  10426   			     fnct_DePyramidize, 0, 0);
 10391  10427       sqlite3_create_function (db, "RL2_DePyramidize", 2, SQLITE_UTF8, 0,
................................................................................
 10439  10475       sqlite3_create_function (db, "GetMapImageFromRaster", 11,
 10440  10476   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10441  10477   			     fnct_GetMapImageFromRaster, 0, 0);
 10442  10478       sqlite3_create_function (db, "RL2_GetMapImageFromRaster", 11,
 10443  10479   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10444  10480   			     fnct_GetMapImageFromRaster, 0, 0);
 10445  10481       sqlite3_create_function (db, "GetMapImageFromVector", 4,
 10446         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10482  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10447  10483   			     fnct_GetMapImageFromVector, 0, 0);
 10448  10484       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 4,
 10449         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10485  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10450  10486   			     fnct_GetMapImageFromVector, 0, 0);
 10451  10487       sqlite3_create_function (db, "GetMapImageFromVector", 5,
 10452         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10488  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10453  10489   			     fnct_GetMapImageFromVector, 0, 0);
 10454  10490       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 5,
 10455         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10491  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10456  10492   			     fnct_GetMapImageFromVector, 0, 0);
 10457  10493       sqlite3_create_function (db, "GetMapImageFromVector", 6,
 10458         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10494  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10459  10495   			     fnct_GetMapImageFromVector, 0, 0);
 10460  10496       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 6,
 10461         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10497  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10462  10498   			     fnct_GetMapImageFromVector, 0, 0);
 10463  10499       sqlite3_create_function (db, "GetMapImageFromVector", 7,
 10464         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10500  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10465  10501   			     fnct_GetMapImageFromVector, 0, 0);
 10466  10502       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 7,
 10467         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10503  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10468  10504   			     fnct_GetMapImageFromVector, 0, 0);
 10469  10505       sqlite3_create_function (db, "GetMapImageFromVector", 8,
 10470         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10506  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10471  10507   			     fnct_GetMapImageFromVector, 0, 0);
 10472  10508       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 8,
 10473         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10509  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10474  10510   			     fnct_GetMapImageFromVector, 0, 0);
 10475  10511       sqlite3_create_function (db, "GetMapImageFromVector", 9,
 10476         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10512  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10477  10513   			     fnct_GetMapImageFromVector, 0, 0);
 10478  10514       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 9,
 10479         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10515  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10480  10516   			     fnct_GetMapImageFromVector, 0, 0);
 10481  10517       sqlite3_create_function (db, "GetMapImageFromVector", 10,
 10482         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10518  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10483  10519   			     fnct_GetMapImageFromVector, 0, 0);
 10484  10520       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 10,
 10485         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10521  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10486  10522   			     fnct_GetMapImageFromVector, 0, 0);
 10487  10523       sqlite3_create_function (db, "GetMapImageFromVector", 11,
 10488         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10524  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10489  10525   			     fnct_GetMapImageFromVector, 0, 0);
 10490  10526       sqlite3_create_function (db, "RL2_GetMapImageFromVector", 11,
 10491         -			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
        10527  +			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10492  10528   			     fnct_GetMapImageFromVector, 0, 0);
 10493  10529       sqlite3_create_function (db, "GetTileImage", 2,
 10494  10530   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10495  10531   			     fnct_GetTileImage, 0, 0);
 10496  10532       sqlite3_create_function (db, "RL2_GetTileImage", 2,
 10497  10533   			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
 10498  10534   			     fnct_GetTileImage, 0, 0);
................................................................................
 10635  10671   				   fnct_LoadFontFromFile, 0, 0);
 10636  10672   	  sqlite3_create_function (db, "RL2_LoadFontFromFile", 1, SQLITE_UTF8,
 10637  10673   				   0, fnct_LoadFontFromFile, 0, 0);
 10638  10674   	  sqlite3_create_function (db, "ExportFontToFile", 2, SQLITE_UTF8, 0,
 10639  10675   				   fnct_ExportFontToFile, 0, 0);
 10640  10676   	  sqlite3_create_function (db, "RL2_ExportFontToFile", 2, SQLITE_UTF8,
 10641  10677   				   0, fnct_ExportFontToFile, 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);
        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);
 10652  10688   	  sqlite3_create_function (db, "RL2_LoadRaster", 2, SQLITE_UTF8,
 10653  10689   				   priv_data, fnct_LoadRaster, 0, 0);
 10654  10690   	  sqlite3_create_function (db, "RL2_LoadRaster", 3, SQLITE_UTF8,
 10655  10691   				   priv_data, fnct_LoadRaster, 0, 0);
 10656  10692   	  sqlite3_create_function (db, "RL2_LoadRaster", 4, SQLITE_UTF8,
 10657  10693   				   priv_data, fnct_LoadRaster, 0, 0);
 10658  10694   	  sqlite3_create_function (db, "RL2_LoadRaster", 5, SQLITE_UTF8,
................................................................................
 10667  10703   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10668  10704   	  sqlite3_create_function (db, "LoadRastersFromDir", 5, SQLITE_UTF8,
 10669  10705   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10670  10706   	  sqlite3_create_function (db, "LoadRastersFromDir", 6, SQLITE_UTF8,
 10671  10707   				   priv_data, fnct_LoadRastersFromDir, 0, 0);
 10672  10708   	  sqlite3_create_function (db, "LoadRastersFromDir", 7, SQLITE_UTF8,
 10673  10709   				   priv_data, 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);
        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);
 10686  10728   	  sqlite3_create_function (db, "LoadRasterFromWMS", 9, SQLITE_UTF8,
 10687  10729   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10688         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9, SQLITE_UTF8,
 10689         -				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
        10730  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9,
        10731  +				   SQLITE_UTF8, priv_data,
        10732  +				   fnct_LoadRasterFromWMS, 0, 0);
 10690  10733   	  sqlite3_create_function (db, "LoadRasterFromWMS", 10, SQLITE_UTF8,
 10691  10734   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10692         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10, SQLITE_UTF8,
 10693         -				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
        10735  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10,
        10736  +				   SQLITE_UTF8, priv_data,
        10737  +				   fnct_LoadRasterFromWMS, 0, 0);
 10694  10738   	  sqlite3_create_function (db, "LoadRasterFromWMS", 11, SQLITE_UTF8,
 10695  10739   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10696         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11, SQLITE_UTF8,
 10697         -				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
        10740  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11,
        10741  +				   SQLITE_UTF8, priv_data,
        10742  +				   fnct_LoadRasterFromWMS, 0, 0);
 10698  10743   	  sqlite3_create_function (db, "LoadRasterFromWMS", 12, SQLITE_UTF8,
 10699  10744   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10700         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12, SQLITE_UTF8,
 10701         -				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
        10745  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12,
        10746  +				   SQLITE_UTF8, priv_data,
        10747  +				   fnct_LoadRasterFromWMS, 0, 0);
 10702  10748   	  sqlite3_create_function (db, "LoadRasterFromWMS", 13, SQLITE_UTF8,
 10703  10749   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10704         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13, SQLITE_UTF8,
 10705         -				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
        10750  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13,
        10751  +				   SQLITE_UTF8, priv_data,
        10752  +				   fnct_LoadRasterFromWMS, 0, 0);
 10706  10753   	  sqlite3_create_function (db, "LoadRasterFromWMS", 14, SQLITE_UTF8,
 10707  10754   				   priv_data, fnct_LoadRasterFromWMS, 0, 0);
 10708         -	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14, SQLITE_UTF8,
 10709         -				   0, fnct_LoadRasterFromWMS, 0, 0);
        10755  +	  sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14,
        10756  +				   SQLITE_UTF8, 0, fnct_LoadRasterFromWMS, 0,
        10757  +				   0);
 10710  10758   	  sqlite3_create_function (db, "WriteGeoTiff", 6, SQLITE_UTF8,
 10711  10759   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10712  10760   	  sqlite3_create_function (db, "RL2_WriteGeoTiff", 6, SQLITE_UTF8,
 10713  10761   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10714  10762   	  sqlite3_create_function (db, "WriteGeoTiff", 7, SQLITE_UTF8,
 10715  10763   				   priv_data, fnct_WriteGeoTiff, 0, 0);
 10716  10764   	  sqlite3_create_function (db, "RL2_WriteGeoTiff", 7, SQLITE_UTF8,
................................................................................
 10813  10861   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10814  10862   	  sqlite3_create_function (db, "WriteSectionTiff", 9, SQLITE_UTF8,
 10815  10863   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10816  10864   	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 9, SQLITE_UTF8,
 10817  10865   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10818  10866   	  sqlite3_create_function (db, "WriteSectionTiff", 10, SQLITE_UTF8,
 10819  10867   				   priv_data, fnct_WriteSectionTiff, 0, 0);
 10820         -	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 10, SQLITE_UTF8,
 10821         -				   priv_data, fnct_WriteSectionTiff, 0, 0);
        10868  +	  sqlite3_create_function (db, "RL2_WriteSectionTiff", 10,
        10869  +				   SQLITE_UTF8, priv_data,
        10870  +				   fnct_WriteSectionTiff, 0, 0);
 10822  10871   	  sqlite3_create_function (db, "WriteJpegJgw", 6, SQLITE_UTF8,
 10823  10872   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10824  10873   	  sqlite3_create_function (db, "RL2_WriteJpegJgw", 6, SQLITE_UTF8,
 10825  10874   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10826  10875   	  sqlite3_create_function (db, "WriteJpegJgw", 7, SQLITE_UTF8,
 10827  10876   				   priv_data, fnct_WriteJpegJgw, 0, 0);
 10828  10877   	  sqlite3_create_function (db, "RL2_WriteJpegJgw", 7, SQLITE_UTF8,
................................................................................
 10866  10915   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10867  10916   	  sqlite3_create_function (db, "RL2_WriteSectionJpeg", 8, SQLITE_UTF8,
 10868  10917   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10869  10918   	  sqlite3_create_function (db, "WriteSectionJpeg", 9, SQLITE_UTF8,
 10870  10919   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10871  10920   	  sqlite3_create_function (db, "RL2_WriteSectionJpeg", 9, SQLITE_UTF8,
 10872  10921   				   priv_data, fnct_WriteSectionJpeg, 0, 0);
 10873         -	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9, SQLITE_UTF8,
 10874         -				   priv_data, fnct_WriteTripleBandGeoTiff, 0,
 10875         -				   0);
        10922  +	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9,
        10923  +				   SQLITE_UTF8, priv_data,
        10924  +				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10876  10925   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 9,
 10877  10926   				   SQLITE_UTF8, priv_data,
 10878  10927   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10879  10928   	  sqlite3_create_function (db, "WriteTripleBandGeoTiff", 10,
 10880  10929   				   SQLITE_UTF8, priv_data,
 10881  10930   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10882  10931   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 10,
................................................................................
 10899  10948   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10900  10949   	  sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 13,
 10901  10950   				   SQLITE_UTF8, priv_data,
 10902  10951   				   fnct_WriteTripleBandGeoTiff, 0, 0);
 10903  10952   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 10,
 10904  10953   				   SQLITE_UTF8, 0,
 10905  10954   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10906         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 10,
 10907         -				   SQLITE_UTF8, priv_data,
        10955  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
        10956  +				   10, SQLITE_UTF8, priv_data,
 10908  10957   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10909  10958   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 11,
 10910  10959   				   SQLITE_UTF8, priv_data,
 10911  10960   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10912         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 11,
 10913         -				   SQLITE_UTF8, priv_data,
        10961  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
        10962  +				   11, SQLITE_UTF8, priv_data,
 10914  10963   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10915  10964   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 12,
 10916  10965   				   SQLITE_UTF8, priv_data,
 10917  10966   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10918         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 12,
 10919         -				   SQLITE_UTF8, priv_data,
        10967  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
        10968  +				   12, SQLITE_UTF8, priv_data,
 10920  10969   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10921  10970   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 13,
 10922  10971   				   SQLITE_UTF8, priv_data,
 10923  10972   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10924         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 13,
 10925         -				   SQLITE_UTF8, priv_data,
        10973  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
        10974  +				   13, SQLITE_UTF8, priv_data,
 10926  10975   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10927  10976   	  sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 14,
 10928  10977   				   SQLITE_UTF8, priv_data,
 10929  10978   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10930         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 14,
 10931         -				   SQLITE_UTF8, priv_data,
        10979  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff",
        10980  +				   14, SQLITE_UTF8, priv_data,
 10932  10981   				   fnct_WriteSectionTripleBandGeoTiff, 0, 0);
 10933  10982   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 7, SQLITE_UTF8,
 10934  10983   				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 10935  10984   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 7,
 10936  10985   				   SQLITE_UTF8, priv_data,
 10937  10986   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10938  10987   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 8, SQLITE_UTF8,
................................................................................
 10941  10990   				   SQLITE_UTF8, priv_data,
 10942  10991   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10943  10992   	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 9, SQLITE_UTF8,
 10944  10993   				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
 10945  10994   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 9,
 10946  10995   				   SQLITE_UTF8, priv_data,
 10947  10996   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10948         -	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10, SQLITE_UTF8,
 10949         -				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
        10997  +	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10,
        10998  +				   SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff,
        10999  +				   0, 0);
 10950  11000   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 10,
 10951  11001   				   SQLITE_UTF8, priv_data,
 10952  11002   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10953         -	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11, SQLITE_UTF8,
 10954         -				   0, fnct_WriteMonoBandGeoTiff, 0, 0);
        11003  +	  sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11,
        11004  +				   SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff,
        11005  +				   0, 0);
 10955  11006   	  sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 11,
 10956  11007   				   SQLITE_UTF8, priv_data,
 10957  11008   				   fnct_WriteMonoBandGeoTiff, 0, 0);
 10958  11009   	  sqlite3_create_function (db, "WriteSectionMonoBandGeoTiff", 8,
 10959  11010   				   SQLITE_UTF8, priv_data,
 10960  11011   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 10961  11012   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandGeoTiff", 8,
................................................................................
 10981  11032   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 10982  11033   	  sqlite3_create_function (db, "WriteSectionMonoBandGeoTiff", 12,
 10983  11034   				   SQLITE_UTF8, priv_data,
 10984  11035   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 10985  11036   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandGeoTiff", 12,
 10986  11037   				   SQLITE_UTF8, priv_data,
 10987  11038   				   fnct_WriteSectionMonoBandGeoTiff, 0, 0);
 10988         -	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9, SQLITE_UTF8,
 10989         -				   priv_data, fnct_WriteTripleBandTiffTfw, 0,
 10990         -				   0);
        11039  +	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9,
        11040  +				   SQLITE_UTF8, priv_data,
        11041  +				   fnct_WriteTripleBandTiffTfw, 0, 0);
 10991  11042   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 9,
 10992  11043   				   SQLITE_UTF8, priv_data,
 10993  11044   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 10994  11045   	  sqlite3_create_function (db, "WriteTripleBandTiffTfw", 10,
 10995  11046   				   SQLITE_UTF8, priv_data,
 10996  11047   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 10997  11048   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 10,
................................................................................
 11008  11059   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11009  11060   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 12,
 11010  11061   				   SQLITE_UTF8, priv_data,
 11011  11062   				   fnct_WriteTripleBandTiffTfw, 0, 0);
 11012  11063   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 10,
 11013  11064   				   SQLITE_UTF8, priv_data,
 11014  11065   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11015         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 10,
 11016         -				   SQLITE_UTF8, priv_data,
        11066  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
        11067  +				   10, SQLITE_UTF8, priv_data,
 11017  11068   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11018  11069   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 11,
 11019  11070   				   SQLITE_UTF8, priv_data,
 11020  11071   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11021         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 11,
 11022         -				   SQLITE_UTF8, priv_data,
        11072  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
        11073  +				   11, SQLITE_UTF8, priv_data,
 11023  11074   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11024  11075   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 12,
 11025  11076   				   SQLITE_UTF8, priv_data,
 11026  11077   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11027         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 12,
 11028         -				   SQLITE_UTF8, priv_data,
        11078  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
        11079  +				   12, SQLITE_UTF8, priv_data,
 11029  11080   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11030  11081   	  sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 13,
 11031  11082   				   SQLITE_UTF8, priv_data,
 11032  11083   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11033         -	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 13,
 11034         -				   SQLITE_UTF8, priv_data,
        11084  +	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw",
        11085  +				   13, SQLITE_UTF8, priv_data,
 11035  11086   				   fnct_WriteSectionTripleBandTiffTfw, 0, 0);
 11036  11087   	  sqlite3_create_function (db, "WriteSectionMonoBandTiffTfw", 8,
 11037  11088   				   SQLITE_UTF8, priv_data,
 11038  11089   				   fnct_WriteSectionMonoBandTiffTfw, 0, 0);
 11039  11090   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiffTfw", 8,
 11040  11091   				   SQLITE_UTF8, priv_data,
 11041  11092   				   fnct_WriteSectionMonoBandTiffTfw, 0, 0);
................................................................................
 11068  11119   				   SQLITE_UTF8, priv_data,
 11069  11120   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11070  11121   	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 9, SQLITE_UTF8,
 11071  11122   				   priv_data, fnct_WriteMonoBandTiffTfw, 0, 0);
 11072  11123   	  sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 9,
 11073  11124   				   SQLITE_UTF8, priv_data,
 11074  11125   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11075         -	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10, SQLITE_UTF8,
 11076         -				   priv_data, fnct_WriteMonoBandTiffTfw, 0, 0);
        11126  +	  sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10,
        11127  +				   SQLITE_UTF8, priv_data,
        11128  +				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11077  11129   	  sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 10,
 11078  11130   				   SQLITE_UTF8, priv_data,
 11079  11131   				   fnct_WriteMonoBandTiffTfw, 0, 0);
 11080         -	  sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8, 0,
 11081         -				   fnct_WriteTripleBandTiff, 0, 0);
        11132  +	  sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8,
        11133  +				   0, fnct_WriteTripleBandTiff, 0, 0);
 11082  11134   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiff", 9,
 11083  11135   				   SQLITE_UTF8, priv_data,
 11084  11136   				   fnct_WriteTripleBandTiff, 0, 0);
 11085  11137   	  sqlite3_create_function (db, "WriteTripleBandTiff", 10, SQLITE_UTF8,
 11086  11138   				   0, fnct_WriteTripleBandTiff, 0, 0);
 11087  11139   	  sqlite3_create_function (db, "RL2_WriteTripleBandTiff", 10,
 11088  11140   				   SQLITE_UTF8, priv_data,
................................................................................
 11119  11171   				   SQLITE_UTF8, priv_data,
 11120  11172   				   fnct_WriteSectionTripleBandTiff, 0, 0);
 11121  11173   	  sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiff", 13,
 11122  11174   				   SQLITE_UTF8, priv_data,
 11123  11175   				   fnct_WriteSectionTripleBandTiff, 0, 0);
 11124  11176   	  sqlite3_create_function (db, "WriteMonoBandTiff", 7, SQLITE_UTF8, 0,
 11125  11177   				   fnct_WriteMonoBandTiff, 0, 0);
 11126         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7, SQLITE_UTF8,
 11127         -				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
        11178  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7,
        11179  +				   SQLITE_UTF8, priv_data,
        11180  +				   fnct_WriteMonoBandTiff, 0, 0);
 11128  11181   	  sqlite3_create_function (db, "WriteMonoBandTiff", 8, SQLITE_UTF8, 0,
 11129  11182   				   fnct_WriteMonoBandTiff, 0, 0);
 11130         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8, SQLITE_UTF8,
 11131         -				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
        11183  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8,
        11184  +				   SQLITE_UTF8, priv_data,
        11185  +				   fnct_WriteMonoBandTiff, 0, 0);
 11132  11186   	  sqlite3_create_function (db, "WriteMonoBandTiff", 9, SQLITE_UTF8,
 11133  11187   				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11134         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9, SQLITE_UTF8,
 11135         -				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
        11188  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9,
        11189  +				   SQLITE_UTF8, priv_data,
        11190  +				   fnct_WriteMonoBandTiff, 0, 0);
 11136  11191   	  sqlite3_create_function (db, "WriteMonoBandTiff", 10, SQLITE_UTF8,
 11137  11192   				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
 11138         -	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10, SQLITE_UTF8,
 11139         -				   priv_data, fnct_WriteMonoBandTiff, 0, 0);
        11193  +	  sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10,
        11194  +				   SQLITE_UTF8, priv_data,
        11195  +				   fnct_WriteMonoBandTiff, 0, 0);
 11140  11196   	  sqlite3_create_function (db, "WriteSectionMonoBandTiff", 8,
 11141  11197   				   SQLITE_UTF8, priv_data,
 11142  11198   				   fnct_WriteSectionMonoBandTiff, 0, 0);
 11143  11199   	  sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiff", 8,
 11144  11200   				   SQLITE_UTF8, priv_data,
 11145  11201   				   fnct_WriteSectionMonoBandTiff, 0, 0);
 11146  11202   	  sqlite3_create_function (db, "WriteSectionMonoBandTiff", 9,
................................................................................
 11169  11225   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11170  11226   	  sqlite3_create_function (db, "RL2_WriteAsciiGrid", 7, SQLITE_UTF8,
 11171  11227   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11172  11228   	  sqlite3_create_function (db, "WriteAsciiGrid", 8, SQLITE_UTF8,
 11173  11229   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11174  11230   	  sqlite3_create_function (db, "RL2_WriteAsciiGrid", 8, SQLITE_UTF8,
 11175  11231   				   priv_data, fnct_WriteAsciiGrid, 0, 0);
 11176         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 7, SQLITE_UTF8,
 11177         -				   priv_data, fnct_WriteSectionAsciiGrid, 0, 0);
        11232  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 7,
        11233  +				   SQLITE_UTF8, priv_data,
        11234  +				   fnct_WriteSectionAsciiGrid, 0, 0);
 11178  11235   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 7,
 11179  11236   				   SQLITE_UTF8, priv_data,
 11180  11237   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11181         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 8, SQLITE_UTF8,
 11182         -				   0, fnct_WriteSectionAsciiGrid, 0, 0);
        11238  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 8,
        11239  +				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
        11240  +				   0, 0);
 11183  11241   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 8,
 11184  11242   				   SQLITE_UTF8, priv_data,
 11185  11243   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11186         -	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 9, SQLITE_UTF8,
 11187         -				   0, fnct_WriteSectionAsciiGrid, 0, 0);
        11244  +	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 9,
        11245  +				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
        11246  +				   0, 0);
 11188  11247   	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 9,
 11189  11248   				   SQLITE_UTF8, priv_data,
 11190  11249   				   fnct_WriteSectionAsciiGrid, 0, 0);
 11191  11250   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 8, SQLITE_UTF8,
 11192  11251   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11193         -	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8, SQLITE_UTF8,
 11194         -				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
        11252  +	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8,
        11253  +				   SQLITE_UTF8, priv_data,
        11254  +				   fnct_WriteNdviAsciiGrid, 0, 0);
 11195  11255   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 9, SQLITE_UTF8,
 11196  11256   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11197         -	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9, SQLITE_UTF8,
 11198         -				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
        11257  +	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9,
        11258  +				   SQLITE_UTF8, priv_data,
        11259  +				   fnct_WriteNdviAsciiGrid, 0, 0);
 11199  11260   	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 10, SQLITE_UTF8,
 11200  11261   				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
 11201  11262   	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 10,
 11202  11263   				   SQLITE_UTF8, priv_data,
 11203  11264   				   fnct_WriteNdviAsciiGrid, 0, 0);
 11204  11265   	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 9,
 11205  11266   				   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 ("SELECT sample_type, num_bands FROM raster_coverages "
    89         -			 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
           88  +	sqlite3_mprintf
           89  +	("SELECT sample_type, num_bands FROM raster_coverages "
           90  +	 "WHERE Lower(coverage_name) = Lower(%Q)", coverage);
    90     91       ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL);
    91     92       sqlite3_free (sql);
    92     93       if (ret != SQLITE_OK)
    93     94   	return 0;
    94     95       if (rows < 1)
    95     96   	;
    96     97       else
................................................................................
   734    735     error:
   735    736       if (stmt != NULL)
   736    737   	sqlite3_finalize (stmt);
   737    738       return RL2_ERROR;
   738    739   }
   739    740   
   740    741   static int
   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,
          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,
   749    751   		    rl2RasterStatisticsPtr section_stats)
   750    752   {
   751    753   /* INSERTing the tile */
   752    754       int ret;
   753    755       sqlite3_int64 tile_id;
   754    756       rl2RasterStatisticsPtr stats = NULL;
   755    757   
................................................................................
   999   1001   }
  1000   1002   
  1001   1003   RL2_PRIVATE int
  1002   1004   rl2_do_insert_section (sqlite3 * handle, const char *src_path,
  1003   1005   		       const char *section, int srid, unsigned int width,
  1004   1006   		       unsigned int height, double minx, double miny,
  1005   1007   		       double maxx, double maxy, char *xml_summary,
  1006         -		       int section_paths, int section_md5, int section_summary,
  1007         -		       sqlite3_stmt * stmt_sect, sqlite3_int64 * id)
         1008  +		       int section_paths, int section_md5,
         1009  +		       int section_summary, sqlite3_stmt * stmt_sect,
         1010  +		       sqlite3_int64 * id)
  1008   1011   {
  1009   1012   /* INSERTing the section */
  1010   1013       int ret;
  1011   1014       unsigned char *blob;
  1012   1015       int blob_size;
  1013   1016       sqlite3_int64 section_id;
  1014   1017   
................................................................................
  1051   1054         {
  1052   1055   	  sqlite3_bind_null (stmt_sect, 4);
  1053   1056   	  if (xml_summary != NULL)
  1054   1057   	      free (xml_summary);
  1055   1058         }
  1056   1059       sqlite3_bind_int (stmt_sect, 5, width);
  1057   1060       sqlite3_bind_int (stmt_sect, 6, height);
  1058         -    if (rl2_build_bbox (handle, srid, minx, miny, maxx, maxy, &blob, &blob_size)
  1059         -	!= RL2_OK)
         1061  +    if (rl2_build_bbox
         1062  +	(handle, srid, minx, miny, maxx, maxy, &blob, &blob_size) != RL2_OK)
  1060   1063   	goto error;
  1061   1064       sqlite3_bind_blob (stmt_sect, 7, blob, blob_size, free);
  1062   1065       ret = sqlite3_step (stmt_sect);
  1063   1066       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1064   1067   	section_id = sqlite3_last_insert_rowid (handle);
  1065   1068       else
  1066   1069         {
................................................................................
  1213   1216       int blob_odd_sz;
  1214   1217       unsigned char *blob_even;
  1215   1218       int blob_even_sz;
  1216   1219       rl2RasterPtr raster = NULL;
  1217   1220       double base_res_x;
  1218   1221       double base_res_y;
  1219   1222   
  1220         -    if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y) !=
  1221         -	RL2_OK)
         1223  +    if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y)
         1224  +	!= RL2_OK)
  1222   1225   	goto error;
  1223   1226       if (*first)
  1224   1227         {
  1225   1228   	  /* INSERTing the section */
  1226   1229   	  *first = 0;
  1227   1230   	  if (!rl2_do_insert_section
  1228   1231   	      (ptr->sqlite, "WMS Service", ptr->sect_name, ptr->srid,
  1229   1232   	       ptr->width, ptr->height, ptr->minx, ptr->miny, ptr->maxx,
  1230         -	       ptr->maxy, ptr->xml_summary, ptr->sectionPaths, ptr->sectionMD5,
  1231         -	       ptr->sectionSummary, ptr->stmt_sect, section_id))
         1233  +	       ptr->maxy, ptr->xml_summary, ptr->sectionPaths,
         1234  +	       ptr->sectionMD5, ptr->sectionSummary, ptr->stmt_sect,
         1235  +	       section_id))
  1232   1236   	      goto error;
  1233   1237   	  *section_stats =
  1234   1238   	      rl2_create_raster_statistics (ptr->sample_type, ptr->num_bands);
  1235   1239   	  if (*section_stats == NULL)
  1236   1240   	      goto error;
  1237   1241   	  /* INSERTing the base-levels */
  1238   1242   	  if (ptr->mixedResolutions)
................................................................................
  1271   1275       /* INSERTing the tile */
  1272   1276       tile_minx = ptr->x;
  1273   1277       tile_maxx = tile_minx + ptr->tilew;
  1274   1278       tile_maxy = ptr->y;
  1275   1279       tile_miny = tile_maxy - ptr->tileh;
  1276   1280       if (!do_insert_wms_tile
  1277   1281   	(ptr->sqlite, blob_odd, blob_odd_sz, blob_even, blob_even_sz,
  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,
         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,
  1281   1285   	 ptr->stmt_data, *section_stats))
  1282   1286   	goto error;
  1283   1287       blob_odd = NULL;
  1284   1288       blob_even = NULL;
  1285   1289       rl2_destroy_raster (raster);
  1286   1290       free (ptr->rgba_tile);
  1287   1291       ptr->rgba_tile = NULL;
................................................................................
  1401   1405   	  xxcoverage = rl2_double_quoted_sql (xcoverage);
  1402   1406   	  sqlite3_free (xcoverage);
  1403   1407   	  sql =
  1404   1408   	      sqlite3_mprintf
  1405   1409   	      ("SELECT pyramid_level, x_resolution_1_8, y_resolution_1_8, "
  1406   1410   	       "x_resolution_1_4, y_resolution_1_4, x_resolution_1_2, y_resolution_1_2, "
  1407   1411   	       "x_resolution_1_1, y_resolution_1_1 FROM \"%s\" "
  1408         -	       "WHERE section_id = %s ORDER BY pyramid_level DESC", xxcoverage,
  1409         -	       sctn);
         1412  +	       "WHERE section_id = %s ORDER BY pyramid_level DESC",
         1413  +	       xxcoverage, sctn);
  1410   1414         }
  1411   1415       else
  1412   1416         {
  1413   1417   	  /* ordinary Coverage */
  1414   1418   	  xcoverage = sqlite3_mprintf ("%s_levels", coverage);
  1415   1419   	  xxcoverage = rl2_double_quoted_sql (xcoverage);
  1416   1420   	  sqlite3_free (xcoverage);
................................................................................
  1612   1616   	    }
  1613   1617         }
  1614   1618       return rgba;
  1615   1619   }
  1616   1620   
  1617   1621   RL2_PRIVATE int
  1618   1622   get_payload_from_monochrome_opaque (unsigned int width, unsigned int height,
  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)
         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)
  1624   1628   {
  1625   1629   /* input: Monochrome    output: Grayscale */
  1626   1630       int ret;
  1627   1631       unsigned char *p_in;
  1628   1632       unsigned char *p_out;
  1629   1633       unsigned char *gray = NULL;
  1630   1634       unsigned int row;
................................................................................
  1660   1664   	      goto error;
  1661   1665         }
  1662   1666       else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1663   1667         {
  1664   1668   	  if (srid > 0)
  1665   1669   	    {
  1666   1670   		if (rl2_gray_to_geotiff
  1667         -		    (width, height, handle, minx, miny, maxx, maxy, srid, gray,
  1668         -		     image, image_sz) != RL2_OK)
         1671  +		    (width, height, handle, minx, miny, maxx, maxy, srid,
         1672  +		     gray, image, image_sz) != RL2_OK)
  1669   1673   		    goto error;
  1670   1674   	    }
  1671   1675   	  else
  1672   1676   	    {
  1673   1677   		if (rl2_gray_to_tiff (width, height, gray, image, image_sz) !=
  1674   1678   		    RL2_OK)
  1675   1679   		    goto error;
................................................................................
  1829   1833   		    goto error;
  1830   1834   	    }
  1831   1835   	  else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1832   1836   	    {
  1833   1837   		if (srid > 0)
  1834   1838   		  {
  1835   1839   		      if (rl2_rgb_to_geotiff
  1836         -			  (width, height, handle, minx, miny, maxx, maxy, srid,
  1837         -			   rgb, image, image_sz) != RL2_OK)
         1840  +			  (width, height, handle, minx, miny, maxx, maxy,
         1841  +			   srid, rgb, image, image_sz) != RL2_OK)
  1838   1842   			  goto error;
  1839   1843   		  }
  1840   1844   		else
  1841   1845   		  {
  1842         -		      if (rl2_rgb_to_tiff (width, height, rgb, image, image_sz)
  1843         -			  != RL2_OK)
         1846  +		      if (rl2_rgb_to_tiff
         1847  +			  (width, height, rgb, image, image_sz) != RL2_OK)
  1844   1848   			  goto error;
  1845   1849   		  }
  1846   1850   	    }
  1847   1851   	  else if (format == RL2_OUTPUT_FORMAT_PDF)
  1848   1852   	    {
  1849   1853   		rgba = rgb_to_rgba (width, height, rgb);
  1850   1854   		if (rgba == NULL)
................................................................................
  1892   1896   		    goto error;
  1893   1897   	    }
  1894   1898   	  else if (format == RL2_OUTPUT_FORMAT_TIFF)
  1895   1899   	    {
  1896   1900   		if (srid > 0)
  1897   1901   		  {
  1898   1902   		      if (rl2_gray_to_geotiff
  1899         -			  (width, height, handle, minx, miny, maxx, maxy, srid,
  1900         -			   gray, image, image_sz) != RL2_OK)
         1903  +			  (width, height, handle, minx, miny, maxx, maxy,
         1904  +			   srid, gray, image, image_sz) != RL2_OK)
  1901   1905   			  goto error;
  1902   1906   		  }
  1903   1907   		else
  1904   1908   		  {
  1905   1909   		      if (rl2_gray_to_tiff
  1906   1910   			  (width, height, gray, image, image_sz) != RL2_OK)
  1907   1911   			  goto error;
................................................................................
  2070   2074       return 0;
  2071   2075   }
  2072   2076   
  2073   2077   RL2_PRIVATE int
  2074   2078   get_payload_from_grayscale_opaque (unsigned int width, unsigned int height,
  2075   2079   				   sqlite3 * handle, double minx, double miny,
  2076   2080   				   double maxx, double maxy, int srid,
  2077         -				   unsigned char *pixels, unsigned char format,
  2078         -				   int quality, unsigned char **image,
  2079         -				   int *image_sz)
         2081  +				   unsigned char *pixels,
         2082  +				   unsigned char format, int quality,
         2083  +				   unsigned char **image, int *image_sz)
  2080   2084   {
  2081   2085   /* input: Grayscale    output: Grayscale */
  2082   2086       int ret;
  2083   2087       unsigned char *rgba = NULL;
  2084   2088   
  2085   2089       if (format == RL2_OUTPUT_FORMAT_JPEG)
  2086   2090         {
  2087         -	  if (rl2_gray_to_jpeg (width, height, pixels, quality, image, image_sz)
  2088         -	      != RL2_OK)
         2091  +	  if (rl2_gray_to_jpeg
         2092  +	      (width, height, pixels, quality, image, image_sz) != RL2_OK)
  2089   2093   	      goto error;
  2090   2094         }
  2091   2095       else if (format == RL2_OUTPUT_FORMAT_PNG)
  2092   2096         {
  2093   2097   	  if (rl2_gray_to_png (width, height, pixels, image, image_sz) !=
  2094   2098   	      RL2_OK)
  2095   2099   	      goto error;
................................................................................
  2101   2105   		if (rl2_gray_to_geotiff
  2102   2106   		    (width, height, handle, minx, miny, maxx, maxy, srid,
  2103   2107   		     pixels, image, image_sz) != RL2_OK)
  2104   2108   		    goto error;
  2105   2109   	    }
  2106   2110   	  else
  2107   2111   	    {
  2108         -		if (rl2_gray_to_tiff (width, height, pixels, image, image_sz) !=
  2109         -		    RL2_OK)
         2112  +		if (rl2_gray_to_tiff (width, height, pixels, image, image_sz)
         2113  +		    != RL2_OK)
  2110   2114   		    goto error;
  2111   2115   	    }
  2112   2116         }
  2113   2117       else if (format == RL2_OUTPUT_FORMAT_PDF)
  2114   2118         {
  2115   2119   	  rgba = gray_to_rgba (width, height, pixels);
  2116   2120   	  if (rgba == NULL)
................................................................................
  2192   2196   {
  2193   2197   /* input: RGB    output: RGB */
  2194   2198       int ret;
  2195   2199       unsigned char *rgba = NULL;
  2196   2200   
  2197   2201       if (format == RL2_OUTPUT_FORMAT_JPEG)
  2198   2202         {
  2199         -	  if (rl2_rgb_to_jpeg (width, height, pixels, quality, image, image_sz)
  2200         -	      != RL2_OK)
         2203  +	  if (rl2_rgb_to_jpeg
         2204  +	      (width, height, pixels, quality, image, image_sz) != RL2_OK)
  2201   2205   	      goto error;
  2202   2206         }
  2203   2207       else if (format == RL2_OUTPUT_FORMAT_PNG)
  2204   2208         {
  2205   2209   	  if (rl2_rgb_to_png (width, height, pixels, image, image_sz) != RL2_OK)
  2206   2210   	      goto error;
  2207   2211         }
................................................................................
  2212   2216   		if (rl2_rgb_to_geotiff
  2213   2217   		    (width, height, handle, minx, miny, maxx, maxy, srid,
  2214   2218   		     pixels, image, image_sz) != RL2_OK)
  2215   2219   		    goto error;
  2216   2220   	    }
  2217   2221   	  else
  2218   2222   	    {
  2219         -		if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz) !=
  2220         -		    RL2_OK)
         2223  +		if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz)
         2224  +		    != RL2_OK)
  2221   2225   		    goto error;
  2222   2226   	    }
  2223   2227         }
  2224   2228       else if (format == RL2_OUTPUT_FORMAT_PDF)
  2225   2229         {
  2226   2230   	  rgba = rgb_to_rgba (width, height, pixels);
  2227   2231   	  if (rgba == NULL)
................................................................................
  2244   2248   }
  2245   2249   
  2246   2250   RL2_PRIVATE int
  2247   2251   get_payload_from_rgb_transparent (unsigned int width, unsigned int height,
  2248   2252   				  unsigned char *pixels, unsigned char format,
  2249   2253   				  int quality, unsigned char **image,
  2250   2254   				  int *image_sz, unsigned char bg_red,
  2251         -				  unsigned char bg_green, unsigned char bg_blue,
  2252         -				  double opacity)
         2255  +				  unsigned char bg_green,
         2256  +				  unsigned char bg_blue, double opacity)
  2253   2257   {
  2254   2258   /* input: RGB    output: RGB */
  2255   2259       unsigned char *p_in;
  2256   2260       unsigned char *p_msk;
  2257   2261       unsigned char *mask = NULL;
  2258   2262       unsigned int row;
  2259   2263       unsigned int col;
................................................................................
  2768   2772     error:
  2769   2773       free (pixels);
  2770   2774       return 0;
  2771   2775   }
  2772   2776   
  2773   2777   RL2_PRIVATE int
  2774   2778   get_rgba_from_palette_transparent (unsigned int width, unsigned int height,
  2775         -				   unsigned char *pixels, rl2PalettePtr palette,
  2776         -				   unsigned char *rgba, unsigned char bg_red,
         2779  +				   unsigned char *pixels,
         2780  +				   rl2PalettePtr palette, unsigned char *rgba,
         2781  +				   unsigned char bg_red,
  2777   2782   				   unsigned char bg_green,
  2778   2783   				   unsigned char bg_blue)
  2779   2784   {
  2780   2785   /* input: Palette    output: Grayscale or RGB */
  2781   2786       rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette;
  2782   2787       unsigned char *p_in;
  2783   2788       unsigned char *p_out;
................................................................................
  2925   2930       free (pixels);
  2926   2931       return 1;
  2927   2932   }
  2928   2933   
  2929   2934   RL2_PRIVATE int
  2930   2935   get_rgba_from_grayscale_transparent (unsigned int width,
  2931   2936   				     unsigned int height,
  2932         -				     unsigned char *pixels, unsigned char *rgba,
  2933         -				     unsigned char bg_gray)
         2937  +				     unsigned char *pixels,
         2938  +				     unsigned char *rgba, unsigned char bg_gray)
  2934   2939   {
  2935   2940   /* input: Grayscale    output: Grayscale */
  2936   2941       unsigned char *p_in;
  2937   2942       unsigned char *p_out;
  2938   2943       unsigned int row;
  2939   2944       unsigned int col;
  2940   2945   
................................................................................
  3888   3893       if (mask != NULL)
  3889   3894   	free (mask);
  3890   3895       return 1;
  3891   3896   }
  3892   3897   
  3893   3898   RL2_PRIVATE int
  3894   3899   rgba_from_double (unsigned int width, unsigned int height,
  3895         -		  double *pixels, unsigned char *mask, rl2PrivPixelPtr no_data,
  3896         -		  unsigned char *rgba)
         3900  +		  double *pixels, unsigned char *mask,
         3901  +		  rl2PrivPixelPtr no_data, unsigned char *rgba)
  3897   3902   {
  3898   3903   /* input: DataGrid DOUBLE   output: Grayscale */
  3899   3904       double *p_in;
  3900   3905       unsigned char *p_out;
  3901   3906       unsigned char *p_msk;
  3902   3907       unsigned int row;
  3903   3908       unsigned int col;
................................................................................
  4059   4064         case RL2_SAMPLE_INT16:
  4060   4065   	  ret =
  4061   4066   	      rgba_from_int16 (width, height, (short *) pixels, mask, no_data,
  4062   4067   			       rgba);
  4063   4068   	  break;
  4064   4069         case RL2_SAMPLE_UINT16:
  4065   4070   	  ret =
  4066         -	      rgba_from_uint16 (width, height, (unsigned short *) pixels, mask,
  4067         -				no_data, rgba);
         4071  +	      rgba_from_uint16 (width, height, (unsigned short *) pixels,
         4072  +				mask, no_data, rgba);
  4068   4073   	  break;
  4069   4074         case RL2_SAMPLE_INT32:
  4070   4075   	  ret =
  4071   4076   	      rgba_from_int32 (width, height, (int *) pixels, mask, no_data,
  4072   4077   			       rgba);
  4073   4078   	  break;
  4074   4079         case RL2_SAMPLE_UINT32:
................................................................................
  4079   4084         case RL2_SAMPLE_FLOAT:
  4080   4085   	  ret =
  4081   4086   	      rgba_from_float (width, height, (float *) pixels, mask, no_data,
  4082   4087   			       rgba);
  4083   4088   	  break;
  4084   4089         case RL2_SAMPLE_DOUBLE:
  4085   4090   	  ret =
  4086         -	      rgba_from_double (width, height, (double *) pixels, mask, no_data,
  4087         -				rgba);
         4091  +	      rgba_from_double (width, height, (double *) pixels, mask,
         4092  +				no_data, rgba);
  4088   4093   	  break;
  4089   4094         };
  4090   4095       return ret;
  4091   4096   }
  4092   4097   
  4093   4098   RL2_PRIVATE int
  4094   4099   rgba_from_multi_uint8 (unsigned int width, unsigned int height,
................................................................................
  4305   4310   	      rgba_from_multi_uint8 (width, height, num_bands,
  4306   4311   				     (unsigned char *) pixels, mask, no_data,
  4307   4312   				     rgba);
  4308   4313   	  break;
  4309   4314         case RL2_SAMPLE_UINT16:
  4310   4315   	  ret =
  4311   4316   	      rgba_from_multi_uint16 (width, height, num_bands,
  4312         -				      (unsigned short *) pixels, mask, no_data,
  4313         -				      rgba);
         4317  +				      (unsigned short *) pixels, mask,
         4318  +				      no_data, rgba);
  4314   4319   	  break;
  4315   4320         };
  4316   4321       return ret;
  4317   4322   }
  4318   4323   
  4319   4324   RL2_PRIVATE int
  4320   4325   get_payload_from_gray_rgba_opaque (unsigned int width, unsigned int height,
................................................................................
  4357   4362   	      goto error;
  4358   4363         }
  4359   4364       else if (format == RL2_OUTPUT_FORMAT_TIFF)
  4360   4365         {
  4361   4366   	  if (srid > 0)
  4362   4367   	    {
  4363   4368   		if (rl2_gray_to_geotiff
  4364         -		    (width, height, handle, minx, miny, maxx, maxy, srid, gray,
  4365         -		     image, image_sz) != RL2_OK)
         4369  +		    (width, height, handle, minx, miny, maxx, maxy, srid,
         4370  +		     gray, image, image_sz) != RL2_OK)
  4366   4371   		    goto error;
  4367   4372   	    }
  4368   4373   	  else
  4369   4374   	    {
  4370   4375   		if (rl2_gray_to_tiff (width, height, gray, image, image_sz) !=
  4371   4376   		    RL2_OK)
  4372   4377   		    goto error;
................................................................................
  4464   4469   {
  4465   4470   /* RGB, Opaque */
  4466   4471       int ret;
  4467   4472       unsigned char *rgba = NULL;
  4468   4473   
  4469   4474       if (format == RL2_OUTPUT_FORMAT_JPEG)
  4470   4475         {
  4471         -	  if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz) !=
  4472         -	      RL2_OK)
         4476  +	  if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz)
         4477  +	      != RL2_OK)
  4473   4478   	      goto error;
  4474   4479         }
  4475   4480       else if (format == RL2_OUTPUT_FORMAT_PNG)
  4476   4481         {
  4477   4482   	  if (rl2_rgb_to_png (width, height, rgb, image, image_sz) != RL2_OK)
  4478   4483   	      goto error;
  4479   4484         }
................................................................................
  4511   4516   	free (rgba);
  4512   4517       return 0;
  4513   4518   }
  4514   4519   
  4515   4520   RL2_PRIVATE int
  4516   4521   get_payload_from_rgb_rgba_transparent (unsigned int width,
  4517   4522   				       unsigned int height,
  4518         -				       unsigned char *rgb, unsigned char *alpha,
         4523  +				       unsigned char *rgb,
         4524  +				       unsigned char *alpha,
  4519   4525   				       unsigned char format, int quality,
  4520   4526   				       unsigned char **image, int *image_sz,
  4521   4527   				       double opacity, int half_transparency)
  4522   4528   {
  4523   4529   /* RGB, Transparent */
  4524   4530       int ret;
  4525   4531       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, stop->offset,
   235         -							 stop->red, stop->green,
          234  +		      cairo_pattern_add_color_stop_rgba (pattern,
          235  +							 stop->offset,
          236  +							 stop->red,
          237  +							 stop->green,
   236    238   							 stop->blue,
   237    239   							 stop->opacity *
   238    240   							 style->opacity);
   239    241   		      stop = stop->next;
   240    242   		  }
   241    243   		cairo_set_source (cairo, pattern);
   242    244   		cairo_set_line_cap (cairo, style->stroke_linecap);
................................................................................
   257    259   		pattern =
   258    260   		    cairo_pattern_create_radial (grad->cx, grad->cy, 0.0,
   259    261   						 grad->fx, grad->fy, grad->r);
   260    262   		svg_apply_gradient_transformations (pattern, grad);
   261    263   		stop = grad->first_stop;
   262    264   		while (stop)
   263    265   		  {
   264         -		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
   265         -							 stop->red, stop->green,
          266  +		      cairo_pattern_add_color_stop_rgba (pattern,
          267  +							 stop->offset,
          268  +							 stop->red,
          269  +							 stop->green,
   266    270   							 stop->blue,
   267    271   							 stop->opacity *
   268    272   							 style->opacity);
   269    273   		      stop = stop->next;
   270    274   		  }
   271    275   		cairo_set_source (cairo, pattern);
   272    276   		cairo_set_line_cap (cairo, style->stroke_linecap);
................................................................................
   288    292   			   style->stroke_opacity * style->opacity);
   289    293       cairo_set_line_cap (cairo, style->stroke_linecap);
   290    294       cairo_set_line_join (cairo, style->stroke_linejoin);
   291    295       cairo_set_miter_limit (cairo, style->stroke_miterlimit);
   292    296       if (style->stroke_dashitems == 0 || style->stroke_dasharray == NULL)
   293    297   	cairo_set_dash (cairo, lengths, 0, 0.0);
   294    298       else
   295         -	cairo_set_dash (cairo, style->stroke_dasharray, style->stroke_dashitems,
   296         -			style->stroke_dashoffset);
          299  +	cairo_set_dash (cairo, style->stroke_dasharray,
          300  +			style->stroke_dashitems, style->stroke_dashoffset);
   297    301   }
   298    302   
   299    303   static void
   300    304   svg_set_brush (cairo_t * cairo, rl2PrivSvgStylePtr style)
   301    305   {
   302    306   /* setting up a Brush for Cairo */
   303    307       cairo_pattern_t *pattern;
................................................................................
   310    314   		pattern =
   311    315   		    cairo_pattern_create_linear (grad->x1, grad->y1, grad->x2,
   312    316   						 grad->y2);
   313    317   		svg_apply_gradient_transformations (pattern, grad);
   314    318   		stop = grad->first_stop;
   315    319   		while (stop)
   316    320   		  {
   317         -		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
   318         -							 stop->red, stop->green,
          321  +		      cairo_pattern_add_color_stop_rgba (pattern,
          322  +							 stop->offset,
          323  +							 stop->red,
          324  +							 stop->green,
   319    325   							 stop->blue,
   320    326   							 stop->opacity *
   321    327   							 style->opacity);
   322    328   		      stop = stop->next;
   323    329   		  }
   324    330   		cairo_set_source (cairo, pattern);
   325    331   		cairo_pattern_destroy (pattern);
................................................................................
   330    336   		pattern =
   331    337   		    cairo_pattern_create_radial (grad->cx, grad->cy, 0.0,
   332    338   						 grad->fx, grad->fy, grad->r);
   333    339   		svg_apply_gradient_transformations (pattern, grad);
   334    340   		stop = grad->first_stop;
   335    341   		while (stop)
   336    342   		  {
   337         -		      cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
   338         -							 stop->red, stop->green,
          343  +		      cairo_pattern_add_color_stop_rgba (pattern,
          344  +							 stop->offset,
          345  +							 stop->red,
          346  +							 stop->green,
   339    347   							 stop->blue,
   340    348   							 stop->opacity *
   341    349   							 style->opacity);
   342    350   		      stop = stop->next;
   343    351   		  }
   344    352   		cairo_set_source (cairo, pattern);
   345    353   		cairo_pattern_destroy (pattern);
................................................................................
   846    854   		bezier = item->data;
   847    855   		cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2,
   848    856   				bezier->y2, bezier->x, bezier->y);
   849    857   		break;
   850    858   	    case RL2_SVG_CURVE_4:
   851    859   		bezier = item->data;
   852    860   		cairo_get_current_point (cairo, &x0, &y0);
   853         -		cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
          861  +		cairo_curve_to (cairo,
          862  +				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
   854    863   				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0,
   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);
          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);
   858    868   		break;
   859    869   	    case RL2_SVG_ELLIPT_ARC:
   860    870   		arc = item->data;
   861    871   		cairo_get_current_point (cairo, &x0, &y0);
   862    872   		svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation,
   863    873   				  &radii_ratio, &angle1, &angle2);
   864    874   		cairo_save (cairo);
................................................................................
   943    953   		bezier = item->data;
   944    954   		cairo_curve_to (cairo, bezier->x1, bezier->y1, bezier->x2,
   945    955   				bezier->y2, bezier->x, bezier->y);
   946    956   		break;
   947    957   	    case RL2_SVG_CURVE_4:
   948    958   		bezier = item->data;
   949    959   		cairo_get_current_point (cairo, &x0, &y0);
   950         -		cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
          960  +		cairo_curve_to (cairo,
          961  +				2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0,
   951    962   				2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0,
   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);
          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);
   955    967   		break;
   956    968   	    case RL2_SVG_ELLIPT_ARC:
   957    969   		arc = item->data;
   958    970   		cairo_get_current_point (cairo, &x0, &y0);
   959    971   		svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation,
   960    972   				  &radii_ratio, &angle1, &angle2);
   961    973   		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 == NULL || var == NULL)
   790         -	return 1;
          789  +    if (rule->column_name == NULL)
          790  +	return 1;		/* there is no comparison: surely true */
          791  +    if (var == NULL)
          792  +	return 0;
   791    793       for (i = 0; i < var->count; i++)
   792    794         {
   793    795   	  rl2PrivVariantValuePtr val = *(var->array + i);
   794    796   	  if (val == NULL)
   795    797   	      return 0;
   796         -	  if (rule->column_name == NULL || val->column_name == NULL)
          798  +	  if (val->column_name == NULL)
   797    799   	      return 0;
   798    800   	  if (strcasecmp (rule->column_name, val->column_name) != 0)
   799    801   	      continue;
   800    802   	  switch (rule->comparison_op)
   801    803   	    {
   802    804   	    case RL2_COMPARISON_EQ:
   803    805   		return eval_filter_eq (rule, val);
................................................................................
   824    826         }
   825    827       return 0;
   826    828   }
   827    829   
   828    830   RL2_DECLARE rl2VectorSymbolizerPtr
   829    831   rl2_get_symbolizer_from_feature_type_style (rl2FeatureTypeStylePtr style,
   830    832   					    double scale,
   831         -					    rl2VariantArrayPtr variant, int *scale_forbidden)
          833  +					    rl2VariantArrayPtr variant,
          834  +					    int *scale_forbidden)
   832    835   {
   833    836   /* return the VectorSymbolizer matching a given scale/filter from a FeatureTypeStyle */
   834    837       rl2PrivVectorSymbolizerPtr symbolizer = NULL;
   835    838       rl2PrivStyleRulePtr pR;
   836    839       rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style;
   837    840       *scale_forbidden = 0;
   838    841       if (stl == NULL)
................................................................................
   845    848   	      ;
   846    849   	  else
   847    850   	    {
   848    851   		/* skipping any invalid rule */
   849    852   		pR = pR->next;
   850    853   		continue;
   851    854   	    }
          855  +
   852    856   	  if (eval_filter (pR, variant))
   853    857   	    {
          858  +		*scale_forbidden = 0;
   854    859   		if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX)
   855    860   		  {
   856    861   		      if (scale >= pR->min_scale && scale < pR->max_scale)
   857    862   			  symbolizer = pR->style;
   858    863   		  }
   859    864   		else if (pR->min_scale != DBL_MAX)
   860    865   		  {
................................................................................
   864    869   		else if (pR->max_scale != DBL_MAX)
   865    870   		  {
   866    871   		      if (scale < pR->max_scale)
   867    872   			  symbolizer = pR->style;
   868    873   		  }
   869    874   		else
   870    875   		    symbolizer = pR->style;
   871         -		    if (symbolizer == NULL)
          876  +		if (symbolizer == NULL)
   872    877   		    *scale_forbidden = 1;
   873         -		return (rl2VectorSymbolizerPtr) symbolizer;
          878  +		else
          879  +		    return (rl2VectorSymbolizerPtr) symbolizer;
   874    880   	    }
   875    881   	  pR = pR->next;
   876    882         }
   877    883       if (stl->else_rule != NULL)
   878    884         {
   879    885   	  /* applyhing the ELSE rule */
          886  +	  *scale_forbidden = 0;
   880    887   	  pR = stl->else_rule;
   881    888   	  if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX)
   882    889   	    {
   883    890   		if (scale >= pR->min_scale && scale < pR->max_scale)
   884    891   		    symbolizer = pR->style;
   885    892   	    }
   886    893   	  else if (pR->min_scale != DBL_MAX)
................................................................................
   891    898   	  else if (pR->max_scale != DBL_MAX)
   892    899   	    {
   893    900   		if (scale < pR->max_scale)
   894    901   		    symbolizer = pR->style;
   895    902   	    }
   896    903   	  else
   897    904   	      symbolizer = pR->style;
   898         -		    if (symbolizer == NULL)
   899         -		    *scale_forbidden = 1;
          905  +	  if (symbolizer == NULL)
          906  +	      *scale_forbidden = 1;
   900    907         }
   901    908       return (rl2VectorSymbolizerPtr) symbolizer;
   902    909   }
   903    910   
   904    911   RL2_DECLARE int
   905    912   rl2_is_visible_style (rl2FeatureTypeStylePtr style, double scale)
   906    913   {
................................................................................
   907    914   /* test visibility at a given scale/filter from a FeatureTypeStyle */
   908    915       int count = 0;
   909    916       int visible;
   910    917       rl2PrivStyleRulePtr pR;
   911    918       rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style;
   912    919       if (stl == NULL)
   913    920   	return 0;
          921  +    if (stl->first_rule == NULL)
          922  +      {
          923  +	  /* there are no rules: unconditional visibility */
          924  +	  return 1;
          925  +      }
   914    926   
   915    927       pR = stl->first_rule;
   916    928       while (pR != NULL)
   917    929         {
   918    930   	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
   919    931   	      ;
   920    932   	  else
................................................................................
  1102   1114   	    {
  1103   1115   		/* Interpolate Color Map */
  1104   1116   		*selected = 1;
  1105   1117   		*categorize = 0;
  1106   1118   		*interpolate = 1;
  1107   1119   		return RL2_OK;
  1108   1120   	    }
  1109         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
  1110         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
  1111         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1121  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
         1122  +	      || stl->contrastEnhancement ==
         1123  +	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
         1124  +	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1112   1125   	    {
  1113   1126   		/* Contrast Enhancement */
  1114   1127   		*selected = 1;
  1115   1128   		*categorize = 0;
  1116   1129   		*interpolate = 0;
  1117   1130   		return RL2_OK;
  1118   1131   	    }
................................................................................
  1171   1184   {
  1172   1185   /* return if the RasterSymbolizer has a TripleBand selection */
  1173   1186       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1174   1187       if (stl == NULL)
  1175   1188   	return RL2_ERROR;
  1176   1189       if (stl->bandSelection == NULL)
  1177   1190         {
  1178         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
  1179         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
  1180         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1191  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
         1192  +	      || stl->contrastEnhancement ==
         1193  +	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
         1194  +	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1181   1195   	    {
  1182   1196   		/* Contrast Enhancement */
  1183   1197   		*selected = 1;
  1184   1198   		return RL2_OK;
  1185   1199   	    }
  1186   1200         }
  1187   1201       if (stl->bandSelection == NULL)
................................................................................
  1201   1215   {
  1202   1216   /* return the RasterSymbolizer TripleBand selection */
  1203   1217       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1204   1218       if (stl == NULL)
  1205   1219   	return RL2_ERROR;
  1206   1220       if (stl->bandSelection == NULL)
  1207   1221         {
  1208         -	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE ||
  1209         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM ||
  1210         -	      stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
         1222  +	  if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE
         1223  +	      || stl->contrastEnhancement ==
         1224  +	      RL2_CONTRAST_ENHANCEMENT_HISTOGRAM
         1225  +	      || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA)
  1211   1226   	    {
  1212   1227   		/* Contrast Enhancement */
  1213   1228   		*red_band = 0;
  1214   1229   		*green_band = 1;
  1215   1230   		*blue_band = 2;
  1216   1231   		return RL2_OK;
  1217   1232   	    }
................................................................................
  1242   1257   	return RL2_ERROR;
  1243   1258       *contrast_enhancement = stl->contrastEnhancement;
  1244   1259       *gamma_value = stl->gammaValue;
  1245   1260       return RL2_OK;
  1246   1261   }
  1247   1262   
  1248   1263   RL2_DECLARE int
  1249         -rl2_get_raster_symbolizer_red_band_contrast_enhancement (rl2RasterSymbolizerPtr
  1250         -							 style,
  1251         -							 unsigned char
  1252         -							 *contrast_enhancement,
  1253         -							 double *gamma_value)
         1264  +    rl2_get_raster_symbolizer_red_band_contrast_enhancement
         1265  +    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
         1266  +     double *gamma_value)
  1254   1267   {
  1255   1268   /* return the RasterSymbolizer RedBand ContrastEnhancement */
  1256   1269       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1257   1270       if (stl == NULL)
  1258   1271   	return RL2_ERROR;
  1259   1272       if (stl->bandSelection == NULL)
  1260   1273   	return RL2_ERROR;
................................................................................
  1284   1297   	  *gamma_value = stl->bandSelection->greenGamma;
  1285   1298   	  return RL2_OK;
  1286   1299         }
  1287   1300       return RL2_ERROR;
  1288   1301   }
  1289   1302   
  1290   1303   RL2_DECLARE int
  1291         -rl2_get_raster_symbolizer_blue_band_contrast_enhancement (rl2RasterSymbolizerPtr
  1292         -							  style,
  1293         -							  unsigned char
  1294         -							  *contrast_enhancement,
  1295         -							  double *gamma_value)
         1304  +    rl2_get_raster_symbolizer_blue_band_contrast_enhancement
         1305  +    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
         1306  +     double *gamma_value)
  1296   1307   {
  1297   1308   /* return the RasterSymbolizer BlueBand ContrastEnhancement */
  1298   1309       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1299   1310       if (stl == NULL)
  1300   1311   	return RL2_ERROR;
  1301   1312       if (stl->bandSelection == NULL)
  1302   1313   	return RL2_ERROR;
................................................................................
  1306   1317   	  *gamma_value = stl->bandSelection->blueGamma;
  1307   1318   	  return RL2_OK;
  1308   1319         }
  1309   1320       return RL2_ERROR;
  1310   1321   }
  1311   1322   
  1312   1323   RL2_DECLARE int
  1313         -rl2_get_raster_symbolizer_gray_band_contrast_enhancement (rl2RasterSymbolizerPtr
  1314         -							  style,
  1315         -							  unsigned char
  1316         -							  *contrast_enhancement,
  1317         -							  double *gamma_value)
         1324  +    rl2_get_raster_symbolizer_gray_band_contrast_enhancement
         1325  +    (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement,
         1326  +     double *gamma_value)
  1318   1327   {
  1319   1328   /* return the RasterSymbolizer GrayBand ContrastEnhancement */
  1320   1329       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1321   1330       if (stl == NULL)
  1322   1331   	return RL2_ERROR;
  1323   1332       if (stl->bandSelection == NULL)
  1324   1333   	return RL2_ERROR;
................................................................................
  1358   1367   	  *relief_factor = stl->reliefFactor;
  1359   1368   	  return RL2_OK;
  1360   1369         }
  1361   1370       return RL2_ERROR;
  1362   1371   }
  1363   1372   
  1364   1373   RL2_DECLARE int
  1365         -rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr style,
  1366         -						  int *interpolated)
         1374  +rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr
         1375  +						  style, int *interpolated)
  1367   1376   {
  1368   1377   /* return if the RasterSymbolizer has an Interpolated ColorMap */
  1369   1378       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1370   1379       if (stl == NULL)
  1371   1380   	return RL2_ERROR;
  1372   1381       if (stl->interpolate != NULL)
  1373   1382   	*interpolated = 1;
................................................................................
  1415   1424   	  *blue = stl->categorize->dfltBlue;
  1416   1425   	  return RL2_OK;
  1417   1426         }
  1418   1427       return RL2_ERROR;
  1419   1428   }
  1420   1429   
  1421   1430   RL2_DECLARE int
  1422         -rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr style,
  1423         -						   unsigned char *red,
         1431  +rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr
         1432  +						   style, unsigned char *red,
  1424   1433   						   unsigned char *green,
  1425   1434   						   unsigned char *blue)
  1426   1435   {
  1427   1436   /* return the RasterSymbolizer ColorMap Category base-color */
  1428   1437       rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style;
  1429   1438       if (stl == NULL)
  1430   1439   	return RL2_ERROR;
................................................................................
  1577   1586   /* creating a default Graphic object) */
  1578   1587       rl2PrivGraphicPtr graphic = malloc (sizeof (rl2PrivGraphic));
  1579   1588       graphic->first = NULL;
  1580   1589       graphic->last = NULL;
  1581   1590       graphic->opacity = 1.0;
  1582   1591       graphic->size = 10.0;
  1583   1592       graphic->rotation = 0.0;
  1584         -    graphic->anchor_point_x = 0.0;
  1585         -    graphic->anchor_point_y = 0.0;
         1593  +    graphic->anchor_point_x = 0.5;
         1594  +    graphic->anchor_point_y = 0.5;
  1586   1595       graphic->displacement_x = 0.0;
  1587   1596       graphic->displacement_y = 0.0;
  1588   1597       return graphic;
  1589   1598   }
  1590   1599   
  1591   1600   RL2_PRIVATE rl2PrivStrokePtr
  1592   1601   rl2_create_default_stroke ()
................................................................................
  1608   1617   }
  1609   1618   
  1610   1619   RL2_PRIVATE rl2PrivPointPlacementPtr
  1611   1620   rl2_create_default_point_placement ()
  1612   1621   {
  1613   1622   /* creating a default PointPlacement object */
  1614   1623       rl2PrivPointPlacementPtr place = malloc (sizeof (rl2PrivPointPlacement));
  1615         -    place->anchor_point_x = 0.0;
  1616         -    place->anchor_point_y = 0.0;
         1624  +    place->anchor_point_x = 0.5;
         1625  +    place->anchor_point_y = 0.5;
  1617   1626       place->displacement_x = 0.0;
  1618   1627       place->displacement_y = 0.0;
  1619   1628       place->rotation = 0.0;
  1620   1629       return place;
  1621   1630   }
  1622   1631   
  1623   1632   RL2_PRIVATE rl2PrivLinePlacementPtr
................................................................................
  2263   2272       if (sym->stroke->graphic->first->type != RL2_EXTERNAL_GRAPHIC)
  2264   2273   	return NULL;
  2265   2274       ext = (rl2PrivExternalGraphicPtr) (sym->stroke->graphic->first->item);
  2266   2275       return ext->xlink_href;
  2267   2276   }
  2268   2277   
  2269   2278   RL2_DECLARE int
  2270         -rl2_polygon_symbolizer_get_graphic_stroke_recode_count (rl2PolygonSymbolizerPtr
  2271         -							symbolizer, int *count)
         2279  +    rl2_polygon_symbolizer_get_graphic_stroke_recode_count
         2280  +    (rl2PolygonSymbolizerPtr symbolizer, int *count)
  2272   2281   {
  2273   2282   /* return how many ColorReplacement items are in a Graphic Stroke (PolygonSymbolizer) */
  2274   2283       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2275   2284       if (sym == NULL)
  2276   2285   	return RL2_ERROR;
  2277   2286       *count = 0;
  2278   2287       if (sym->stroke != NULL)
................................................................................
  2301   2310   		  }
  2302   2311   	    }
  2303   2312         }
  2304   2313       return RL2_OK;
  2305   2314   }
  2306   2315   
  2307   2316   RL2_DECLARE int
  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)
         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)
  2314   2320   {
  2315   2321   /* return a ColorReplacement item from a Graphic Stroke (PolygonSymbolizer) */
  2316   2322       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2317   2323       if (sym == NULL)
  2318   2324   	return RL2_ERROR;
  2319   2325       if (sym->stroke != NULL)
  2320   2326         {
................................................................................
  2395   2401       if (sym->stroke == NULL)
  2396   2402   	return RL2_ERROR;
  2397   2403       *width = sym->stroke->width;
  2398   2404       return RL2_OK;
  2399   2405   }
  2400   2406   
  2401   2407   RL2_DECLARE int
  2402         -rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr symbolizer,
  2403         -					    unsigned char *linejoin)
         2408  +rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr
         2409  +					    symbolizer, unsigned char *linejoin)
  2404   2410   {
  2405   2411   /* return the Polygon Symbolizer Stroke Linejoin mode */
  2406   2412       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2407   2413       if (sym == NULL)
  2408   2414   	return RL2_ERROR;
  2409   2415       if (sym->stroke == NULL)
  2410   2416   	return RL2_ERROR;
................................................................................
  2437   2443       if (sym->stroke == NULL)
  2438   2444   	return RL2_ERROR;
  2439   2445       *count = sym->stroke->dash_count;
  2440   2446       return RL2_OK;
  2441   2447   }
  2442   2448   
  2443   2449   RL2_DECLARE int
  2444         -rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr symbolizer,
  2445         -					     int index, double *item)
         2450  +rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr
         2451  +					     symbolizer, int index,
         2452  +					     double *item)
  2446   2453   {
  2447   2454   /* return a Polygon Symbolizer Stroke Dash item */
  2448   2455       rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer;
  2449   2456       if (sym == NULL)
  2450   2457   	return RL2_ERROR;
  2451   2458       if (sym->stroke == NULL)
  2452   2459   	return RL2_ERROR;
................................................................................
  3111   3118         }
  3112   3119       return NULL;
  3113   3120   }
  3114   3121   
  3115   3122   RL2_DECLARE int
  3116   3123   rl2_point_symbolizer_get_graphic_recode_color (rl2PointSymbolizerPtr
  3117   3124   					       symbolizer, int index,
  3118         -					       int repl_index, int *color_index,
         3125  +					       int repl_index,
         3126  +					       int *color_index,
  3119   3127   					       unsigned char *red,
  3120   3128   					       unsigned char *green,
  3121   3129   					       unsigned char *blue)
  3122   3130   {
  3123   3131   /* return a ColorReplacement item from an External Graphic (PointSymbolizer) */
  3124   3132       int count = 0;
  3125   3133       rl2PrivExternalGraphicPtr ext;
................................................................................
  3188   3196   	  count++;
  3189   3197   	  item = item->next;
  3190   3198         }
  3191   3199       return RL2_ERROR;
  3192   3200   }
  3193   3201   
  3194   3202   RL2_DECLARE int
  3195         -rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr symbolizer,
  3196         -					       int index, unsigned char *type)
         3203  +rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr
         3204  +					       symbolizer, int index,
         3205  +					       unsigned char *type)
  3197   3206   {
  3198   3207   /* return the Point Symbolizer Mark WellKnownType */
  3199   3208       int count = 0;
  3200   3209       rl2PrivMarkPtr mark;
  3201   3210       rl2PrivGraphicItemPtr item;
  3202   3211       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3203   3212       if (sym == NULL)
................................................................................
  3336   3345   	  count++;
  3337   3346   	  item = item->next;
  3338   3347         }
  3339   3348       return RL2_ERROR;
  3340   3349   }
  3341   3350   
  3342   3351   RL2_DECLARE int
  3343         -rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr symbolizer,
  3344         -					       int index,
         3352  +rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr
         3353  +					       symbolizer, int index,
  3345   3354   					       unsigned char *linejoin)
  3346   3355   {
  3347   3356   /* return the Point Symbolizer Mark Stroke Linejoin mode */
  3348   3357       int count = 0;
  3349   3358       rl2PrivMarkPtr mark;
  3350   3359       rl2PrivGraphicItemPtr item;
  3351   3360       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
................................................................................
  3370   3379   	  count++;
  3371   3380   	  item = item->next;
  3372   3381         }
  3373   3382       return RL2_ERROR;
  3374   3383   }
  3375   3384   
  3376   3385   RL2_DECLARE int
  3377         -rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr symbolizer,
  3378         -					      int index, unsigned char *linecap)
         3386  +rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr
         3387  +					      symbolizer, int index,
         3388  +					      unsigned char *linecap)
  3379   3389   {
  3380   3390   /* return the Point Symbolizer Stroke Mark Linecap mode */
  3381   3391       int count = 0;
  3382   3392       rl2PrivMarkPtr mark;
  3383   3393       rl2PrivGraphicItemPtr item;
  3384   3394       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3385   3395       if (sym == NULL)
................................................................................
  3511   3521   	  count++;
  3512   3522   	  itm = itm->next;
  3513   3523         }
  3514   3524       return RL2_ERROR;
  3515   3525   }
  3516   3526   
  3517   3527   RL2_DECLARE int
  3518         -rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer, int index,
  3519         -				    int *fill)
         3528  +rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer,
         3529  +				    int index, int *fill)
  3520   3530   {
  3521   3531   /* checks if a Point Symbolizer Mark has a Fill */
  3522   3532       int count = 0;
  3523   3533       rl2PrivMarkPtr mark;
  3524   3534       rl2PrivGraphicItemPtr item;
  3525   3535       rl2PrivPointSymbolizerPtr sym = (rl2PrivPointSymbolizerPtr) symbolizer;
  3526   3536       if (sym == NULL)
................................................................................
  4194   4204       if (*(var->array + index) != NULL)
  4195   4205   	rl2_destroy_variant_value (*(var->array + index));
  4196   4206       *(var->array + index) = val;
  4197   4207       return RL2_OK;
  4198   4208   }
  4199   4209   
  4200   4210   RL2_DECLARE int
  4201         -rl2_set_variant_double (rl2VariantArrayPtr variant, int index, const char *name,
  4202         -			double value)
         4211  +rl2_set_variant_double (rl2VariantArrayPtr variant, int index,
         4212  +			const char *name, double value)
  4203   4213   {
  4204   4214   /* setting a DOUBLE VariantValue into a VariantArray object */
  4205   4215       rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant;
  4206   4216       rl2PrivVariantValuePtr val;
  4207   4217       if (var == NULL)
  4208   4218   	return RL2_ERROR;
  4209   4219       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, unsigned char *green,
   548         -		    unsigned char *blue)
          547  +parse_sld_se_color (const char *color, unsigned char *red,
          548  +		    unsigned char *green, 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->
   668         -							categorize->baseGreen =
   669         -							green;
          667  +						    style->categorize->baseGreen
          668  +							= green;
   670    669   						    style->
   671    670   							categorize->baseBlue =
   672    671   							blue;
   673    672   						}
   674    673   					      else
   675    674   						{
   676    675   						    style->categorize->
................................................................................
   976    975   					  {
   977    976   					      if (text->type == XML_TEXT_NODE)
   978    977   						{
   979    978   						    const char *value =
   980    979   							(const char
   981    980   							 *) (text->content);
   982    981   						    if (value != NULL)
   983         -							style->brightnessOnly =
   984         -							    atoi (value);
          982  +							style->brightnessOnly
          983  +							    = atoi (value);
   985    984   						}
   986    985   					      text = text->next;
   987    986   					  }
   988    987   				    }
   989    988   				  if (strcmp (xmode, "ReliefFactor") == 0)
   990    989   				    {
   991    990   					text = child->children;
................................................................................
  1056   1055   			    if (child->type == XML_ELEMENT_NODE)
  1057   1056   			      {
  1058   1057   				  name = (const char *) (child->name);
  1059   1058   				  if (strcmp (name, "RasterSymbolizer") == 0)
  1060   1059   				    {
  1061   1060   					rl2PrivStyleRulePtr rule =
  1062   1061   					    rl2_create_default_style_rule ();
  1063         -					rl2PrivRasterSymbolizerPtr symbolizer =
         1062  +					rl2PrivRasterSymbolizerPtr symbolizer
         1063  +					    =
  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, &green,
  1380         -				 &blue))
         1379  +				((const char *) (child->content), &red,
         1380  +				 &green, &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 (svg_name, "stroke-linejoin")
  1558         -					    == 0)
         1557  +					if (strcmp
         1558  +					    (svg_name, "stroke-linejoin") == 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 (svg_name, "stroke-linecap")
  1574         -					    == 0)
         1573  +					if (strcmp
         1574  +					    (svg_name, "stroke-linecap") == 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 (svg_name, "stroke-opacity")
  1833         -					    == 0)
         1832  +					if (strcmp
         1833  +					    (svg_name, "stroke-opacity") == 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 (svg_name, "stroke-linejoin")
  1841         -					    == 0)
         1840  +					if (strcmp
         1841  +					    (svg_name, "stroke-linejoin") == 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 (svg_name, "stroke-linecap")
  1857         -					    == 0)
         1856  +					if (strcmp
         1857  +					    (svg_name, "stroke-linecap") == 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 (svg_name, "stroke-opacity")
  2032         -					    == 0)
         2031  +					if (strcmp
         2032  +					    (svg_name, "stroke-opacity") == 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 (svg_name, "stroke-linejoin")
  2040         -					    == 0)
         2039  +					if (strcmp
         2040  +					    (svg_name, "stroke-linejoin") == 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 (svg_name, "stroke-linecap")
  2056         -					    == 0)
         2055  +					if (strcmp
         2056  +					    (svg_name, "stroke-linecap") == 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 (svg_value, "bold")
  2665         -						  == 0)
         2664  +					      if (strcasecmp
         2665  +						  (svg_value, "bold") == 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 == RL2_LABEL_PLACEMENT_POINT
         3023  +		      if (sym->label_placement_type ==
         3024  +			  RL2_LABEL_PLACEMENT_POINT
  3024   3025   			  && sym->label_placement != NULL)
  3025   3026   			  rl2_destroy_point_placement ((rl2PrivPointPlacementPtr) (sym->label_placement));
  3026         -		      if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE
         3027  +		      if (sym->label_placement_type ==
         3028  +			  RL2_LABEL_PLACEMENT_LINE
  3027   3029   			  && sym->label_placement != NULL)
  3028   3030   			  rl2_destroy_line_placement ((rl2PrivLinePlacementPtr)
  3029   3031   						      (sym->label_placement));
  3030   3032   		      sym->label_placement_type = RL2_LABEL_PLACEMENT_UNKNOWN;
  3031   3033   		      sym->label_placement = NULL;
  3032   3034   		      while (child)
  3033   3035   			{
................................................................................
  3993   3995       rl2PrivTextSymbolizerPtr text;
  3994   3996   
  3995   3997       pR = style->first_rule;
  3996   3998       while (pR != NULL)
  3997   3999         {
  3998   4000   	  /* counting max column names */
  3999   4001   	  if (pR->column_name != NULL)
         4002  +	      count++;
         4003  +	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4000   4004   	    {
  4001         -		count++;
  4002         -		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
         4005  +		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4006  +		item = pV->first;
         4007  +		while (item != NULL)
  4003   4008   		  {
  4004         -		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4005         -		      item = pV->first;
  4006         -		      while (item != NULL)
         4009  +		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4010  +			  && item->symbolizer != NULL)
  4007   4011   			{
  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;
         4012  +			    text =
         4013  +				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
         4014  +			    if (text->label != NULL)
         4015  +				count++;
  4018   4016   			}
         4017  +		      item = item->next;
  4019   4018   		  }
  4020   4019   	    }
  4021   4020   	  pR = pR->next;
  4022   4021         }
  4023   4022       pR = style->else_rule;
  4024   4023       if (pR != NULL)
  4025   4024         {
  4026   4025   	  if (pR->column_name != NULL)
         4026  +	      count++;
         4027  +	  if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
  4027   4028   	    {
  4028         -		count++;
  4029         -		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
         4029  +		pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
         4030  +		item = pV->first;
         4031  +		while (item != NULL)
  4030   4032   		  {
  4031         -		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4032         -		      item = pV->first;
  4033         -		      while (item != NULL)
         4033  +		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4034  +			  && item->symbolizer != NULL)
  4034   4035   			{
  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;
         4036  +			    text =
         4037  +				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
         4038  +			    if (text->label != NULL)
         4039  +				count++;
  4045   4040   			}
         4041  +		      item = item->next;
  4046   4042   		  }
  4047   4043   	    }
  4048   4044         }
  4049   4045       if (count == 0)
  4050   4046   	return;
  4051   4047   
  4052   4048       strings = malloc (sizeof (char *) * count);
................................................................................
  4059   4055   	  if (pR->column_name != NULL)
  4060   4056   	    {
  4061   4057   		len = strlen (pR->column_name);
  4062   4058   		*(strings + i) = malloc (len + 1);
  4063   4059   		strcpy (*(strings + i), pR->column_name);
  4064   4060   		*(dupl + i) = 'N';
  4065   4061   		i++;
  4066         -		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
         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)
  4067   4068   		  {
  4068         -		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4069         -		      item = pV->first;
  4070         -		      while (item != NULL)
         4069  +		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4070  +			  && item->symbolizer != NULL)
  4071   4071   			{
  4072         -			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4073         -				&& item->symbolizer != NULL)
         4072  +			    text =
         4073  +				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
         4074  +			    if (text->label != NULL)
  4074   4075   			      {
  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         -				    }
         4076  +				  len = strlen (text->label);
         4077  +				  *(strings + i) = malloc (len + 1);
         4078  +				  strcpy (*(strings + i), text->label);
         4079  +				  *(dupl + i) = 'N';
         4080  +				  i++;
  4086   4081   			      }
  4087         -			    item = item->next;
  4088   4082   			}
         4083  +		      item = item->next;
  4089   4084   		  }
  4090   4085   	    }
  4091   4086   	  pR = pR->next;
  4092   4087         }
  4093   4088       pR = style->else_rule;
  4094   4089       if (pR != NULL)
  4095   4090         {
................................................................................
  4096   4091   	  if (pR->column_name != NULL)
  4097   4092   	    {
  4098   4093   		len = strlen (pR->column_name);
  4099   4094   		*(strings + i) = malloc (len + 1);
  4100   4095   		strcpy (*(strings + i), pR->column_name);
  4101   4096   		*(dupl + i) = 'N';
  4102   4097   		i++;
  4103         -		if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL)
         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)
  4104   4104   		  {
  4105         -		      pV = (rl2PrivVectorSymbolizerPtr) (pR->style);
  4106         -		      item = pV->first;
  4107         -		      while (item != NULL)
         4105  +		      if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
         4106  +			  && item->symbolizer != NULL)
  4108   4107   			{
  4109         -			    if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
  4110         -				&& item->symbolizer != NULL)
         4108  +			    text =
         4109  +				(rl2PrivTextSymbolizerPtr) (item->symbolizer);
         4110  +			    if (text->label != NULL)
  4111   4111   			      {
  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         -				    }
         4112  +				  len = strlen (text->label);
         4113  +				  *(strings + i) = malloc (len + 1);
         4114  +				  strcpy (*(strings + i), text->label);
         4115  +				  *(dupl + i) = 'N';
         4116  +				  i++;
  4123   4117   			      }
  4124         -			    item = item->next;
  4125   4118   			}
         4119  +		      item = item->next;
  4126   4120   		  }
  4127   4121   	    }
  4128   4122         }
  4129   4123   
  4130   4124       for (i = 0; i < count; i++)
  4131   4125         {
  4132   4126   	  /* identifying all duplicates */
................................................................................
  4434   4428   	  lyr->raster_stats = NULL;
  4435   4429         }
  4436   4430       return ptr;
  4437   4431   }
  4438   4432   
  4439   4433   static int
  4440   4434   rl2_group_renderer_set_raster (rl2PrivGroupRendererPtr group, int index,
  4441         -			       const char *layer_name, rl2CoveragePtr coverage,
         4435  +			       const char *layer_name,
         4436  +			       rl2CoveragePtr coverage,
  4442   4437   			       sqlite3_int64 style_id,
  4443   4438   			       rl2RasterSymbolizerPtr symbolizer,
  4444   4439   			       rl2RasterStatisticsPtr stats)
  4445   4440   {
  4446   4441   /* setting up one of the Layers within the Group */
  4447   4442       int len;
  4448   4443       rl2PrivGroupRendererLayerPtr lyr;

Changes to src/rl2tiff.c.

  1415   1415         {
  1416   1416   	  /* attempting to recover badly formatted TIFFs */
  1417   1417   	  origin->planarConfig = PLANARCONFIG_CONTIG;
  1418   1418         }
  1419   1419       else
  1420   1420   	origin->planarConfig = value16;
  1421   1421   
  1422         -    if (origin->bitsPerSample == 16 && origin->sampleFormat == SAMPLEFORMAT_UINT
         1422  +    if (origin->bitsPerSample == 16
         1423  +	&& origin->sampleFormat == SAMPLEFORMAT_UINT
  1423   1424   	&& origin->planarConfig == PLANARCONFIG_SEPARATE)
  1424   1425   	;
  1425   1426       else if (origin->bitsPerSample == 8
  1426   1427   	     && origin->sampleFormat == SAMPLEFORMAT_UINT
  1427   1428   	     && origin->planarConfig == PLANARCONFIG_SEPARATE)
  1428   1429   	;
  1429   1430       else if (origin->planarConfig != PLANARCONFIG_CONTIG)
................................................................................
  2732   2733   		if (tiff_max_x < startCol)
  2733   2734   		    skip = 1;
  2734   2735   		if (skip)
  2735   2736   		  {
  2736   2737   		      /* skipping any not required tile */
  2737   2738   		      continue;
  2738   2739   		  }
  2739         -		if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0) <
  2740         -		    0)
         2740  +		if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0)
         2741  +		    < 0)
  2741   2742   		    goto error;
  2742   2743   		if (convert != RL2_CONVERT_NO)
  2743   2744   		  {
  2744   2745   		      /* applying some format conversion */
  2745   2746   		      copy_convert_tile (origin, tiff_tile, pixels, startRow,
  2746   2747   					 startCol, width, height, tile_y,
  2747   2748   					 tile_x, convert);
................................................................................
  2762   2763   			      {
  2763   2764   			      case RL2_SAMPLE_INT8:
  2764   2765   				  p_in_8 = (char *) tiff_tile;
  2765   2766   				  p_in_8 += y * origin->tileWidth;
  2766   2767   				  p_in_8 += x;
  2767   2768   				  p_out_8 = (char *) pixels;
  2768   2769   				  p_out_8 +=
  2769         -				      ((dest_y - startRow) * width) + (dest_x -
  2770         -								       startCol);
         2770  +				      ((dest_y - startRow) * width) +
         2771  +				      (dest_x - startCol);
  2771   2772   				  break;
  2772   2773   			      case RL2_SAMPLE_UINT8:
  2773   2774   				  p_in_u8 = (unsigned char *) tiff_tile;
  2774   2775   				  p_in_u8 += y * origin->tileWidth * num_bands;
  2775   2776   				  p_in_u8 += x * num_bands;
  2776   2777   				  p_out_u8 = (unsigned char *) pixels;
  2777   2778   				  p_out_u8 +=
................................................................................
  2781   2782   				  break;
  2782   2783   			      case RL2_SAMPLE_INT16:
  2783   2784   				  p_in_16 = (short *) tiff_tile;
  2784   2785   				  p_in_16 += y * origin->tileWidth;
  2785   2786   				  p_in_16 += x;
  2786   2787   				  p_out_16 = (short *) pixels;
  2787   2788   				  p_out_16 +=
  2788         -				      ((dest_y - startRow) * width) + (dest_x -
  2789         -								       startCol);
         2789  +				      ((dest_y - startRow) * width) +
         2790  +				      (dest_x - startCol);
  2790   2791   				  break;
  2791   2792   			      case RL2_SAMPLE_UINT16:
  2792   2793   				  p_in_u16 = (unsigned short *) tiff_tile;
  2793   2794   				  p_in_u16 += y * origin->tileWidth * num_bands;
  2794   2795   				  p_in_u16 += x * num_bands;
  2795   2796   				  p_out_u16 = (unsigned short *) pixels;
  2796   2797   				  p_out_u16 +=
................................................................................
  2800   2801   				  break;
  2801   2802   			      case RL2_SAMPLE_INT32:
  2802   2803   				  p_in_32 = (int *) tiff_tile;
  2803   2804   				  p_in_32 += y * origin->tileWidth;
  2804   2805   				  p_in_32 += x;
  2805   2806   				  p_out_32 = (int *) pixels;
  2806   2807   				  p_out_32 +=
  2807         -				      ((dest_y - startRow) * width) + (dest_x -
  2808         -								       startCol);
         2808  +				      ((dest_y - startRow) * width) +
         2809  +				      (dest_x - startCol);
  2809   2810   				  break;
  2810   2811   			      case RL2_SAMPLE_UINT32:
  2811   2812   				  p_in_u32 = (unsigned int *) tiff_tile;
  2812   2813   				  p_in_u32 += y * origin->tileWidth;
  2813   2814   				  p_in_u32 += x;
  2814   2815   				  p_out_u32 = (unsigned int *) pixels;
  2815   2816   				  p_out_u32 +=
  2816         -				      ((dest_y - startRow) * width) + (dest_x -
  2817         -								       startCol);
         2817  +				      ((dest_y - startRow) * width) +
         2818  +				      (dest_x - startCol);
  2818   2819   				  break;
  2819   2820   			      case RL2_SAMPLE_FLOAT:
  2820   2821   				  p_in_flt = (float *) tiff_tile;
  2821   2822   				  p_in_flt += y * origin->tileWidth;
  2822   2823   				  p_in_flt += x;
  2823   2824   				  p_out_flt = (float *) pixels;
  2824   2825   				  p_out_flt +=
  2825         -				      ((dest_y - startRow) * width) + (dest_x -
  2826         -								       startCol);
         2826  +				      ((dest_y - startRow) * width) +
         2827  +				      (dest_x - startCol);
  2827   2828   				  break;
  2828   2829   			      case RL2_SAMPLE_DOUBLE:
  2829   2830   				  p_in_dbl = (double *) tiff_tile;
  2830   2831   				  p_in_dbl += y * origin->tileWidth;
  2831   2832   				  p_in_dbl += x;
  2832   2833   				  p_out_dbl = (double *) pixels;
  2833   2834   				  p_out_dbl +=
  2834         -				      ((dest_y - startRow) * width) + (dest_x -
  2835         -								       startCol);
         2835  +				      ((dest_y - startRow) * width) +
         2836  +				      (dest_x - startCol);
  2836   2837   				  break;
  2837   2838   			      };
  2838   2839   			    for (bnd = 0; bnd < num_bands; bnd++)
  2839   2840   			      {
  2840   2841   				  switch (sample_type)
  2841   2842   				    {
  2842   2843   				    case RL2_SAMPLE_INT8:
................................................................................
  3641   3642   					p_in_u16 = (unsigned short *) tiff_tile;
  3642   3643   					p_in_u16 += y * origin->tileWidth;
  3643   3644   					p_in_u16 += x;
  3644   3645   					p_out_u16 = (unsigned short *) pixels;
  3645   3646   					p_out_u16 +=
  3646   3647   					    ((dest_y -
  3647   3648   					      startRow) * width * num_bands) +
  3648         -					    ((dest_x - startCol) * num_bands) +
  3649         -					    band;
         3649  +					    ((dest_x -
         3650  +					      startCol) * num_bands) + band;
  3650   3651   					*p_out_u16 = *p_in_u16;
  3651   3652   				    }
  3652   3653   				  if (sample_type == RL2_SAMPLE_UINT8)
  3653   3654   				    {
  3654   3655   					p_in_u8 = (unsigned char *) tiff_tile;
  3655   3656   					p_in_u8 += y * origin->tileWidth;
  3656   3657   					p_in_u8 += x;
  3657   3658   					p_out_u8 = (unsigned char *) pixels;
  3658   3659   					p_out_u8 +=
  3659   3660   					    ((dest_y -
  3660   3661   					      startRow) * width * num_bands) +
  3661         -					    ((dest_x - startCol) * num_bands) +
  3662         -					    band;
         3662  +					    ((dest_x -
         3663  +					      startCol) * num_bands) + band;
  3663   3664   					*p_out_u8 = *p_in_u8;
  3664   3665   				    }
  3665   3666   			      }
  3666   3667   			}
  3667   3668   		  }
  3668   3669   	    }
  3669   3670         }
................................................................................
  3673   3674     error:
  3674   3675       if (tiff_tile != NULL)
  3675   3676   	free (tiff_tile);
  3676   3677       return RL2_ERROR;
  3677   3678   }
  3678   3679   
  3679   3680   static int
  3680         -read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin, unsigned short width,
  3681         -			     unsigned short height, unsigned char sample_type,
         3681  +read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin,
         3682  +			     unsigned short width, unsigned short height,
         3683  +			     unsigned char sample_type,
  3682   3684   			     unsigned char num_bands, unsigned int startRow,
  3683   3685   			     unsigned int startCol, void *pixels)
  3684   3686   {
  3685   3687   /* reading TIFF raw strips - separate planes */
  3686   3688       uint32 line_no;
  3687   3689       uint32 x;
  3688   3690       uint32 y;
................................................................................
  4172   4174   	      goto error;
  4173   4175         }
  4174   4176       else
  4175   4177         {
  4176   4178   	  /* contiguous planar configuration */
  4177   4179   	  if (origin->bitsPerSample <= 8
  4178   4180   	      && origin->sampleFormat == SAMPLEFORMAT_UINT
  4179         -	      && (origin->samplesPerPixel == 1 || origin->samplesPerPixel == 3)
         4181  +	      && (origin->samplesPerPixel == 1
         4182  +		  || origin->samplesPerPixel == 3)
  4180   4183   	      && (pixel_type == RL2_PIXEL_MONOCHROME
  4181   4184   		  || pixel_type == RL2_PIXEL_PALETTE
  4182   4185   		  || pixel_type == RL2_PIXEL_GRAYSCALE
  4183   4186   		  || pixel_type == RL2_PIXEL_RGB))
  4184   4187   	    {
  4185   4188   		/* using the TIFF RGBA methods */
  4186   4189   		if (origin->isTiled)
................................................................................
  4202   4205   		if (origin->isTiled)
  4203   4206   		    ret =
  4204   4207   			read_raw_tiles (origin, width, height, sample_type,
  4205   4208   					num_bands, startRow, startCol,
  4206   4209   					bufPixels);
  4207   4210   		else
  4208   4211   		    ret =
  4209         -			read_raw_scanlines (origin, width, height, sample_type,
  4210         -					    num_bands, startRow, startCol,
  4211         -					    bufPixels);
         4212  +			read_raw_scanlines (origin, width, height,
         4213  +					    sample_type, num_bands, startRow,
         4214  +					    startCol, bufPixels);
  4212   4215   		if (ret != RL2_OK)
  4213   4216   		    goto error;
  4214   4217   	    }
  4215   4218         }
  4216   4219   
  4217   4220       *pixels = bufPixels;
  4218   4221       *pixels_sz = bufPixelsSz;
................................................................................
  4382   4385   		  }
  4383   4386   	    }
  4384   4387         }
  4385   4388   
  4386   4389   /* attempting to create the tile */
  4387   4390       if (read_from_tiff
  4388   4391   	(origin, coverage->tileWidth, coverage->tileHeight,
  4389         -	 coverage->sampleType, coverage->pixelType, coverage->nBands, startRow,
  4390         -	 startCol, &pixels, &pixels_sz, palette) != RL2_OK)
         4392  +	 coverage->sampleType, coverage->pixelType, coverage->nBands,
         4393  +	 startRow, startCol, &pixels, &pixels_sz, palette) != RL2_OK)
  4391   4394   	goto error;
  4392   4395       if (startCol + coverage->tileWidth > origin->width)
  4393   4396   	unused_width = (startCol + coverage->tileWidth) - origin->width;
  4394   4397       if (startRow + coverage->tileHeight > origin->height)
  4395   4398   	unused_height = (startRow + coverage->tileHeight) - origin->height;
  4396   4399       if (unused_width || unused_height)
  4397   4400         {
................................................................................
  5078   5081     error:
  5079   5082       return 0;
  5080   5083   }
  5081   5084   
  5082   5085   RL2_DECLARE rl2TiffDestinationPtr
  5083   5086   rl2_create_tiff_destination (const char *path, unsigned int width,
  5084   5087   			     unsigned int height, unsigned char sample_type,
  5085         -			     unsigned char pixel_type, unsigned char num_bands,
  5086         -			     rl2PalettePtr plt, unsigned char tiff_compression,
  5087         -			     int tiled, unsigned int tile_size)
         5088  +			     unsigned char pixel_type,
         5089  +			     unsigned char num_bands, rl2PalettePtr plt,
         5090  +			     unsigned char tiff_compression, int tiled,
         5091  +			     unsigned int tile_size)
  5088   5092   {
  5089   5093   /* attempting to create a file-based TIFF destination (no georeferencing) */
  5090   5094       rl2PrivTiffDestinationPtr destination = NULL;
  5091   5095       if (!check_color_model
  5092   5096   	(sample_type, pixel_type, num_bands, plt, tiff_compression))
  5093   5097         {
  5094   5098   	  fprintf (stderr, "RL2-TIFF writer: unsupported pixel format\n");
................................................................................
  5760   5764         }
  5761   5765       if (TIFFWriteScanline (tiff->out, tiff->tiffBuffer, row, 0) < 0)
  5762   5766   	return 0;
  5763   5767       return 1;
  5764   5768   }
  5765   5769   
  5766   5770   static int
  5767         -tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster,
  5768         -		       unsigned int row)
         5771  +tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff,
         5772  +		       rl2PrivRasterPtr raster, unsigned int row)
  5769   5773   {
  5770   5774   /* writing a TIFF Grayscale scanline */
  5771   5775       unsigned int x;
  5772   5776       unsigned char *p_in = raster->rasterBuffer;
  5773   5777       unsigned char *p_out = tiff->tiffBuffer;
  5774   5778   
  5775   5779       for (x = 0; x < raster->width; x++)
................................................................................
  6163   6167   	      0)
  6164   6168   	      return 0;
  6165   6169         }
  6166   6170       return 1;
  6167   6171   }
  6168   6172   
  6169   6173   static int
  6170         -tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster,
  6171         -			unsigned int row, unsigned int col)
         6174  +tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff,
         6175  +			rl2PrivRasterPtr raster, unsigned int row,
         6176  +			unsigned int col)
  6172   6177   {
  6173   6178   /* writing a TIFF RGB tile - UINT8 */
  6174   6179       unsigned int y;
  6175   6180       unsigned int x;
  6176   6181       unsigned char *p_in = raster->rasterBuffer;
  6177   6182       unsigned char *p_out = tiff->tiffBuffer;
  6178   6183   
................................................................................
  6539   6544   	     && rst->nBands == destination->samplesPerPixel
  6540   6545   	     && destination->tileWidth == rst->width
  6541   6546   	     && destination->tileHeight == rst->height)
  6542   6547   	ret =
  6543   6548   	    tiff_write_tile_multiband16 (destination, rst, startRow, startCol);
  6544   6549       else if (destination->sampleFormat == SAMPLEFORMAT_UINT
  6545   6550   	     && destination->samplesPerPixel == 1
  6546         -	     && destination->photometric < 2 && destination->bitsPerSample == 8
         6551  +	     && destination->photometric < 2
         6552  +	     && destination->bitsPerSample == 8
  6547   6553   	     && rst->sampleType == RL2_SAMPLE_UINT8
  6548   6554   	     && rst->pixelType == RL2_PIXEL_GRAYSCALE && rst->nBands == 1
  6549   6555   	     && destination->tileWidth == rst->width
  6550   6556   	     && destination->tileHeight == rst->height)
  6551   6557   	ret = tiff_write_tile_gray (destination, rst, startRow, startCol);
  6552   6558       else if (destination->sampleFormat == SAMPLEFORMAT_UINT
  6553   6559   	     && destination->samplesPerPixel == 1
................................................................................
  6658   6664   	return RL2_ERROR;
  6659   6665       if (destination->tfw_path == NULL)
  6660   6666   	return RL2_ERROR;
  6661   6667   
  6662   6668       tfw = fopen (destination->tfw_path, "w");
  6663   6669       if (tfw == NULL)
  6664   6670         {
  6665         -	  fprintf (stderr, "RL2-TIFF writer: unable to open Worldfile \"%s\"\n",
         6671  +	  fprintf (stderr,
         6672  +		   "RL2-TIFF writer: unable to open Worldfile \"%s\"\n",
  6666   6673   		   destination->tfw_path);
  6667   6674   	  return RL2_ERROR;
  6668   6675         }
  6669   6676       fprintf (tfw, "        %1.16f\n", destination->hResolution);
  6670   6677       fprintf (tfw, "        0.0\n");
  6671   6678       fprintf (tfw, "        0.0\n");
  6672   6679       fprintf (tfw, "        -%1.16f\n", destination->vResolution);
................................................................................
  6975   6982       TIFFClose (in);
  6976   6983       if (tiff_buffer != NULL)
  6977   6984   	free (tiff_buffer);
  6978   6985       return RL2_ERROR;
  6979   6986   }
  6980   6987   
  6981   6988   static int
  6982         -rgb_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width,
  6983         -		 unsigned short height)
         6989  +rgb_tiff_common (TIFF * out, const unsigned char *buffer,
         6990  +		 unsigned short width, unsigned short height)
  6984   6991   {
  6985   6992   /* common implementation of RGB TIFF export */
  6986   6993       tsize_t buf_size;
  6987   6994       void *tiff_buffer = NULL;
  6988   6995       int y;
  6989   6996       int x;
  6990   6997       const unsigned char *p_in;
................................................................................
  7258   7265       return 0;
  7259   7266   }
  7260   7267   
  7261   7268   static int
  7262   7269   output_palette_tiff (const unsigned char *buffer,
  7263   7270   		     unsigned short width,
  7264   7271   		     unsigned short height, unsigned char *red,
  7265         -		     unsigned char *green, unsigned char *blue, int max_palette,
  7266         -		     unsigned char **blob, int *blob_size)
         7272  +		     unsigned char *green, unsigned char *blue,
         7273  +		     int max_palette, unsigned char **blob, int *blob_size)
  7267   7274   {
  7268   7275   /* generating a PALETTE TIFF - actual work */
  7269   7276       struct memfile clientdata;
  7270   7277       TIFF *out = (TIFF *) 0;
  7271   7278   
  7272   7279   /* suppressing TIFF warnings */
  7273   7280       TIFFSetWarningHandler (NULL);
................................................................................
  7507   7514   	       tiff_size))
  7508   7515   	      return RL2_ERROR;
  7509   7516         }
  7510   7517       return RL2_OK;
  7511   7518   }
  7512   7519   
  7513   7520   static int
  7514         -gray_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width,
  7515         -		  unsigned short height)
         7521  +gray_tiff_common (TIFF * out, const unsigned char *buffer,
         7522  +		  unsigned short width, unsigned short height)
  7516   7523   {
  7517   7524   /* common implementation of Grayscale TIFF export */
  7518   7525       tsize_t buf_size;
  7519   7526       void *tiff_buffer = NULL;
  7520   7527       int y;
  7521   7528       int x;
  7522   7529       const unsigned char *p_in;
................................................................................
  7987   7994   	xml =
  7988   7995   	    sqlite3_mprintf ("%s<Compression>%u</Compression>", prev,
  7989   7996   			     org->compression);
  7990   7997       sqlite3_free (prev);
  7991   7998       prev = xml;
  7992   7999       if (org->sampleFormat == SAMPLEFORMAT_UINT)
  7993   8000   	xml =
  7994         -	    sqlite3_mprintf ("%s<SampleFormat>unsigned integer</SampleFormat>",
  7995         -			     prev);
         8001  +	    sqlite3_mprintf
         8002  +	    ("%s<SampleFormat>unsigned integer</SampleFormat>", prev);
  7996   8003       else if (org->sampleFormat == SAMPLEFORMAT_INT)
  7997   8004   	xml =
  7998   8005   	    sqlite3_mprintf ("%s<SampleFormat>signed integer</SampleFormat>",
  7999   8006   			     prev);
  8000   8007       else if (org->sampleFormat == SAMPLEFORMAT_IEEEFP)
  8001   8008   	xml =
  8002   8009   	    sqlite3_mprintf ("%s<SampleFormat>floating point</SampleFormat>",
................................................................................
  8082   8089   	  xml = sqlite3_mprintf ("%s</BoundingBox>", prev);
  8083   8090   	  sqlite3_free (prev);
  8084   8091   	  prev = xml;
  8085   8092   	  xml = sqlite3_mprintf ("%s<Extent>", prev);
  8086   8093   	  sqlite3_free (prev);
  8087   8094   	  prev = xml;
  8088   8095   	  xml =
  8089         -	      sqlite3_mprintf ("%s<HorizontalExtent>%1.10f</HorizontalExtent>",
  8090         -			       prev, org->maxX - org->minX);
         8096  +	      sqlite3_mprintf
         8097  +	      ("%s<HorizontalExtent>%1.10f</HorizontalExtent>", prev,
         8098  +	       org->maxX - org->minX);
  8091   8099   	  sqlite3_free (prev);
  8092   8100   	  prev = xml;
  8093   8101   	  xml =
  8094   8102   	      sqlite3_mprintf ("%s<VerticalExtent>%1.10f</VerticalExtent>",
  8095   8103   			       prev, org->maxY - org->minY);
  8096   8104   	  sqlite3_free (prev);
  8097   8105   	  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, int height,
   162         -	     int num_bands)
          161  +copy_pixels (unsigned char *out, const unsigned char *in, int width,
          162  +	     int height, 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, quality,
   301         -			&output);
          300  +	WebPEncodeRGBA (rgba, rst->width, rst->height, rst->width * 4,
          301  +			quality, &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, sizeof (wmsCachedItemPtr),
   542         -	   compare_url);
          541  +    qsort (cache->SortedByUrl, cache->NumCachedItems,
          542  +	   sizeof (wmsCachedItemPtr), 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, const unsigned char *item,
   600         -		  int size, const char *image_format)
          599  +wmsAddCachedItem (wmsCachePtr cache, const char *url,
          600  +		  const unsigned char *item, 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, double *maxx,
  1107         -		    double *maxy)
         1106  +parse_pattern_bbox (const char *value, double *minx, double *miny,
         1107  +		    double *maxx, 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, (const unsigned char *) "&lt;",
  2035         -					4);
         2034  +		    wmsMemBufferAppend (&outbuf,
         2035  +					(const unsigned char *) "&lt;", 4);
  2036   2036   		else if (*(p_in + i) == '>')
  2037         -		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&gt;",
  2038         -					4);
         2037  +		    wmsMemBufferAppend (&outbuf,
         2038  +					(const unsigned char *) "&gt;", 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, (const unsigned char *) "&lt;",
  2127         -					4);
         2126  +		    wmsMemBufferAppend (&outbuf,
         2127  +					(const unsigned char *) "&lt;", 4);
  2128   2128   		else if (*(p_in + i) == '>')
  2129         -		    wmsMemBufferAppend (&outbuf, (const unsigned char *) "&gt;",
  2130         -					4);
         2129  +		    wmsMemBufferAppend (&outbuf,
         2130  +					(const unsigned char *) "&gt;", 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 ((const char *) (cur_node->name), "StateOrProvince")
  2760         -		    == 0)
         2759  +		if (strcmp
         2760  +		    ((const char *) (cur_node->name), "StateOrProvince") == 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 ((const char *) (cur_node->name), "ContactPosition")
  2813         -		    == 0)
         2812  +		if (strcmp
         2813  +		    ((const char *) (cur_node->name), "ContactPosition") == 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, &post_code,
  2942         -						   &country, &voice_telephone,
         2941  +						   &state_province,
         2942  +						   &post_code, &country,
         2943  +						   &voice_telephone,
  2943   2944   						   &fax_telephone,
  2944   2945   						   &email_address);
  2945   2946   		if (strcmp ((const char *) (cur_node->name), "Fees") == 0)
  2946   2947   		  {
  2947   2948   		      child_node = cur_node->children;
  2948   2949   		      if (child_node != NULL)
  2949   2950   			{
................................................................................
  3245   3246   						    cap->GetMapURLGet = NULL;
  3246   3247   						}
  3247   3248   					      p = (const char
  3248   3249   						   *) (text->content);
  3249   3250   					      len = strlen (p);
  3250   3251   					      cap->GetTileServiceURLGet =
  3251   3252   						  malloc (len + 1);
  3252         -					      strcpy (cap->GetTileServiceURLGet,
  3253         -						      p);
         3253  +					      strcpy
         3254  +						  (cap->GetTileServiceURLGet,
         3255  +						   p);
  3254   3256   					  }
  3255   3257   				    }
  3256   3258   			      }
  3257   3259   			    attr = attr->next;
  3258   3260   			}
  3259   3261   		  }
  3260   3262   	    }
................................................................................
  3284   3286   				  if (strcmp
  3285   3287   				      ((const char *) (attr->name),
  3286   3288   				       "href") == 0)
  3287   3289   				    {
  3288   3290   					xmlNodePtr text = attr->children;
  3289   3291   					if (text->type == XML_TEXT_NODE)
  3290   3292   					  {
  3291         -					      if (cap->GetTileServiceURLPost !=
  3292         -						  NULL)
         3293  +					      if (cap->GetTileServiceURLPost
         3294  +						  != NULL)
  3293   3295   						{
  3294   3296   						    free (cap->
  3295   3297   							  GetTileServiceURLPost);
  3296   3298   						    cap->GetTileServiceURLPost =
  3297   3299   							NULL;
  3298   3300   						}
  3299   3301   					      p = (const char
................................................................................
  3349   3351   							NULL;
  3350   3352   						}
  3351   3353   					      p = (const char
  3352   3354   						   *) (text->content);
  3353   3355   					      len = strlen (p);
  3354   3356   					      cap->GetFeatureInfoURLGet =
  3355   3357   						  malloc (len + 1);
  3356         -					      strcpy (cap->GetFeatureInfoURLGet,
  3357         -						      p);
         3358  +					      strcpy
         3359  +						  (cap->GetFeatureInfoURLGet,
         3360  +						   p);
  3358   3361   					  }
  3359   3362   				    }
  3360   3363   			      }
  3361   3364   			    attr = attr->next;
  3362   3365   			}
  3363   3366   		  }
  3364   3367   	    }
................................................................................
  3388   3391   				  if (strcmp
  3389   3392   				      ((const char *) (attr->name),
  3390   3393   				       "href") == 0)
  3391   3394   				    {
  3392   3395   					xmlNodePtr text = attr->children;
  3393   3396   					if (text->type == XML_TEXT_NODE)
  3394   3397   					  {
  3395         -					      if (cap->GetFeatureInfoURLPost !=
  3396         -						  NULL)
         3398  +					      if (cap->GetFeatureInfoURLPost
         3399  +						  != NULL)
  3397   3400   						{
  3398   3401   						    free (cap->GetFeatureInfoURLPost);
  3399   3402   						    cap->GetFeatureInfoURLPost =
  3400   3403   							NULL;
  3401   3404   						}
  3402   3405   					      p = (const char
  3403   3406   						   *) (text->content);
................................................................................
  3582   3585   					    ok = 1;
  3583   3586   					if (strcmp
  3584   3587   					    (format,
  3585   3588   					     "application/vnd.ogc.gml") == 0)
  3586   3589   					    ok = 1;
  3587   3590   					if (strcmp
  3588   3591   					    (format,
  3589         -					     "application/vnd.ogc.gml/3.1.1") ==
  3590         -					    0)
         3592  +					     "application/vnd.ogc.gml/3.1.1")
         3593  +					    == 0)
  3591   3594   					    ok = 1;
  3592   3595   					if (ok)
  3593   3596   					  {
  3594   3597   					      int len = strlen (format);
  3595   3598   					      cap->GmlMimeType =
  3596   3599   						  malloc (len + 1);
  3597   3600   					      strcpy (cap->GmlMimeType, format);
................................................................................
  4377   4380   
  4378   4381       for (; cur_node; cur_node = cur_node->next)
  4379   4382         {
  4380   4383   	  if (cur_node->type == XML_ELEMENT_NODE)
  4381   4384   	    {
  4382   4385   		if (strcmp ((const char *) (cur_node->name), "Service") == 0)
  4383   4386   		    parse_tile_service_info (cur_node, cap);
  4384         -		if (strcmp ((const char *) (cur_node->name), "TiledPatterns") ==
  4385         -		    0)
         4387  +		if (strcmp ((const char *) (cur_node->name), "TiledPatterns")
         4388  +		    == 0)
  4386   4389   		    parse_tiled_patterns (cur_node, cap);
  4387   4390   	    }
  4388   4391         }
  4389   4392   }
  4390   4393   
  4391   4394   static void
  4392   4395   parse_wms_get_tile_service (wmsCapabilitiesPtr capabilities, const char *buf)
................................................................................
  4759   4762       else
  4760   4763   	return;
  4761   4764   
  4762   4765       for (; cur_node; cur_node = cur_node->next)
  4763   4766         {
  4764   4767   	  if (cur_node->type == XML_ELEMENT_NODE)
  4765   4768   	    {
  4766         -		if (strcmp ((const char *) (cur_node->name), "featureMember") ==
  4767         -		    0)
         4769  +		if (strcmp ((const char *) (cur_node->name), "featureMember")
         4770  +		    == 0)
  4768   4771   		    parse_wms_feature_member (cur_node->children, coll);
  4769   4772   	    }
  4770   4773         }
  4771   4774   }
  4772   4775   
  4773   4776   static wmsFeatureCollectionPtr
  4774   4777   parse_wms_feature_collection (const char *buf)
................................................................................
  4829   4832   	    }
  4830   4833         }
  4831   4834   
  4832   4835       return coll;
  4833   4836   }
  4834   4837   
  4835   4838   static int
  4836         -query_TileService (rl2WmsCachePtr cache_handle, wmsCapabilitiesPtr capabilities,
  4837         -		   const char *proxy)
         4839  +query_TileService (rl2WmsCachePtr cache_handle,
         4840  +		   wmsCapabilitiesPtr capabilities, const char *proxy)
  4838   4841   {
  4839   4842   /* attempting to get and parse a WMS GetTileService request */
  4840   4843       CURL *curl = NULL;
  4841   4844       CURLcode res;
  4842   4845       wmsMemBuffer headerBuf;
  4843   4846       wmsMemBuffer bodyBuf;
  4844   4847       int http_status;
................................................................................
  6945   6948   	  attr = attr->next;
  6946   6949         }
  6947   6950       return NULL;
  6948   6951   }
  6949   6952   
  6950   6953   RL2_DECLARE int
  6951   6954   get_wms_feature_attribute_blob_geometry (rl2WmsFeatureMemberPtr handle,
  6952         -					 int index, const unsigned char **blob,
         6955  +					 int index,
         6956  +					 const unsigned char **blob,
  6953   6957   					 int *blob_size)
  6954   6958   {
  6955   6959   /* attempting to get the Nth FeatureAttribute (Geometry) from some WMS-FeatureMember object */
  6956   6960       int count = 0;
  6957   6961       wmsFeatureAttributePtr attr;
  6958   6962       wmsFeatureMemberPtr ptr = (wmsFeatureMemberPtr) handle;
  6959   6963       if (ptr == NULL)
................................................................................
  7063   7067   	  /* "?" marker not declared */
  7064   7068   	  if (swap_xy)
  7065   7069   	      request =
  7066   7070   		  sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7067   7071   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7068   7072   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7069   7073   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7070         -				   version, layer, crs_prefix, crs, miny, minx,
  7071         -				   maxy, maxx, width, height, style, format,
  7072         -				   (opaque == 0) ? "TRUE" : "FALSE");
         7074  +				   version, layer, crs_prefix, crs, miny,
         7075  +				   minx, maxy, maxx, width, height, style,
         7076  +				   format, (opaque == 0) ? "TRUE" : "FALSE");
  7073   7077   	  else
  7074   7078   	      request =
  7075   7079   		  sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7076   7080   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7077   7081   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7078   7082   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7079         -				   version, layer, crs_prefix, crs, minx, miny,
  7080         -				   maxx, maxy, width, height, style, format,
  7081         -				   (opaque == 0) ? "TRUE" : "FALSE");
         7083  +				   version, layer, crs_prefix, crs, minx,
         7084  +				   miny, maxx, maxy, width, height, style,
         7085  +				   format, (opaque == 0) ? "TRUE" : "FALSE");
  7082   7086         }
  7083   7087       else
  7084   7088         {
  7085   7089   	  /* "?" marker already defined */
  7086   7090   	  if (swap_xy)
  7087   7091   	      request =
  7088   7092   		  sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7089   7093   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7090   7094   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7091   7095   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7092         -				   version, layer, crs_prefix, crs, miny, minx,
  7093         -				   maxy, maxx, width, height, style, format,
  7094         -				   (opaque == 0) ? "TRUE" : "FALSE");
         7096  +				   version, layer, crs_prefix, crs, miny,
         7097  +				   minx, maxy, maxx, width, height, style,
         7098  +				   format, (opaque == 0) ? "TRUE" : "FALSE");
  7095   7099   	  else
  7096   7100   	      request =
  7097   7101   		  sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s"
  7098   7102   				   "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7099   7103   				   "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s"
  7100   7104   				   "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url,
  7101         -				   version, layer, crs_prefix, crs, minx, miny,
  7102         -				   maxx, maxy, width, height, style, format,
  7103         -				   (opaque == 0) ? "TRUE" : "FALSE");
         7105  +				   version, layer, crs_prefix, crs, minx,
         7106  +				   miny, maxx, maxy, width, height, style,
         7107  +				   format, (opaque == 0) ? "TRUE" : "FALSE");
  7104   7108         }
  7105   7109   
  7106   7110       if (cache != NULL)
  7107   7111         {
  7108   7112   	  /* checks if it's already stored into the WMS Cache */
  7109   7113   	  wmsCachedItemPtr cachedItem = getWmsCachedItem (cache, request);
  7110   7114   	  if (cachedItem != NULL)
................................................................................
  7271   7275   		    double maxx, double maxy, int width, int height,
  7272   7276   		    const char *style, const char *format, int opaque,
  7273   7277   		    int from_cache, char **err_msg)
  7274   7278   {
  7275   7279   /* attempting to execute a WMS GepMap request [method POST] */
  7276   7280   
  7277   7281   /* not yet implemented: just a stupid placeholder always returning NULL */
  7278         -    if (cache_handle == NULL || url == NULL || proxy == NULL || version == NULL
  7279         -	|| layer == NULL || crs == NULL)
         7282  +    if (cache_handle == NULL || url == NULL || proxy == NULL
         7283  +	|| version == NULL || layer == NULL || crs == NULL)
  7280   7284   	return NULL;
  7281         -    if (minx == miny || maxx == maxy || width == height || opaque == from_cache
  7282         -	|| width == swap_xy)
         7285  +    if (minx == miny || maxx == maxy || width == height
         7286  +	|| opaque == from_cache || width == swap_xy)
  7283   7287   	return NULL;
  7284   7288       if (style == NULL || format == NULL || err_msg == NULL)
  7285   7289   	return NULL;
  7286   7290       return NULL;
  7287   7291   }
  7288   7292   
  7289   7293   RL2_DECLARE unsigned char *
................................................................................
  7529   7533         {
  7530   7534   	  if (swap_xy)
  7531   7535   	      request =
  7532   7536   		  sqlite3_mprintf
  7533   7537   		  ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7534   7538   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7535   7539   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7536         -		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
  7537         -		   crs, miny, minx, maxy, maxx, width, height, mouse_x,
  7538         -		   mouse_y, format);
         7540  +		   "&FEATURE_COUNT=50", url, version, layer, layer,
         7541  +		   crs_prefix, crs, miny, minx, maxy, maxx, width, height,
         7542  +		   mouse_x, mouse_y, format);
  7539   7543   	  else
  7540   7544   	      request =
  7541   7545   		  sqlite3_mprintf
  7542   7546   		  ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7543   7547   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7544   7548   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7545         -		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
  7546         -		   crs, minx, miny, maxx, maxy, width, height, mouse_x,
  7547         -		   mouse_y, format);
         7549  +		   "&FEATURE_COUNT=50", url, version, layer, layer,
         7550  +		   crs_prefix, crs, minx, miny, maxx, maxy, width, height,
         7551  +		   mouse_x, mouse_y, format);
  7548   7552         }
  7549   7553       else
  7550   7554         {
  7551   7555   	  if (swap_xy)
  7552   7556   	      request =
  7553   7557   		  sqlite3_mprintf
  7554   7558   		  ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7555   7559   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7556   7560   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7557         -		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
  7558         -		   crs, miny, minx, maxy, maxx, width, height, mouse_x,
  7559         -		   mouse_y, format);
         7561  +		   "&FEATURE_COUNT=50", url, version, layer, layer,
         7562  +		   crs_prefix, crs, miny, minx, maxy, maxx, width, height,
         7563  +		   mouse_x, mouse_y, format);
  7560   7564   	  else
  7561   7565   	      request =
  7562   7566   		  sqlite3_mprintf
  7563   7567   		  ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s"
  7564   7568   		   "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f"
  7565   7569   		   "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s"
  7566         -		   "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix,
  7567         -		   crs, minx, miny, maxx, maxy, width, height, mouse_x,
  7568         -		   mouse_y, format);
         7570  +		   "&FEATURE_COUNT=50", url, version, layer, layer,
         7571  +		   crs_prefix, crs, minx, miny, maxx, maxy, width, height,
         7572  +		   mouse_x, mouse_y, format);
  7569   7573         }
  7570   7574   
  7571   7575       curl = curl_easy_init ();
  7572   7576       if (curl)
  7573   7577         {
  7574   7578   	  /* setting the URL */
  7575   7579   	  curl_easy_setopt (curl, CURLOPT_URL, request);
................................................................................
  7699   7703       return (rl2WmsFeatureCollectionPtr) coll;
  7700   7704   }
  7701   7705   
  7702   7706   RL2_DECLARE rl2WmsFeatureCollectionPtr
  7703   7707   do_wms_GetFeatureInfo_post (const char *url, const char *proxy,
  7704   7708   			    const char *version, const char *format,
  7705   7709   			    const char *layer, const char *crs, int swap_xy,
  7706         -			    double minx, double miny, double maxx, double maxy,
  7707         -			    int width, int height, int mouse_x, int mouse_y,
  7708         -			    char **err_msg)
         7710  +			    double minx, double miny, double maxx,
         7711  +			    double maxy, int width, int height, int mouse_x,
         7712  +			    int mouse_y, char **err_msg)
  7709   7713   {
  7710   7714   /* attempting to execute a WMS GepFeatureInfo request [method POST] */
  7711   7715   
  7712   7716   /* not yet implemented: just a stupid placeholder always returning NULL */
  7713   7717       if (url == NULL || proxy == NULL || version == NULL || format == NULL
  7714   7718   	|| layer == NULL || crs == NULL)
  7715   7719   	return NULL;

Changes to test/Makefile.in.

     1         -# Makefile.in generated by automake 1.14.1 from Makefile.am.
            1  +# Makefile.in generated by automake 1.15 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2013 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2014 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 = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
           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  +}
    18     28   am__make_running_with_option = \
    19     29     case $${target_option-} in \
    20     30         ?) ;; \
    21     31         *) echo "am__make_running_with_option: internal error: invalid" \
    22     32                 "target option '$${target_option-}' specified" >&2; \
    23     33            exit 1;; \
    24     34     esac; \
................................................................................
   100    110   	test_map_orbetello$(EXEEXT) test_raster_symbolizer$(EXEEXT) \
   101    111   	test_svg$(EXEEXT) test_raw$(EXEEXT) test_openjpeg$(EXEEXT) \
   102    112   	test_line_symbolizer$(EXEEXT) test_polygon_symbolizer$(EXEEXT) \
   103    113   	test_point_symbolizer$(EXEEXT) test_text_symbolizer$(EXEEXT) \
   104    114   	test_vectors$(EXEEXT) test_font$(EXEEXT) \
   105    115   	test_copy_rastercov$(EXEEXT)
   106    116   subdir = test
   107         -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
   108         -	$(top_srcdir)/depcomp $(top_srcdir)/test-driver
   109    117   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
   110    118   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
   111    119   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
   112    120   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
   113    121   	$(top_srcdir)/configure.ac
   114    122   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
   115    123   	$(ACLOCAL_M4)
          124  +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
   116    125   mkinstalldirs = $(install_sh) -d
   117    126   CONFIG_HEADER = $(top_builddir)/config.h
   118    127   CONFIG_CLEAN_FILES =
   119    128   CONFIG_CLEAN_VPATH_FILES =
   120    129   check_sql_stmt_SOURCES = check_sql_stmt.c
   121    130   check_sql_stmt_OBJECTS = check_sql_stmt.$(OBJEXT)
   122    131   check_sql_stmt_LDADD = $(LDADD)
................................................................................
   618    627   am__test_logs1 = $(TESTS:=.log)
   619    628   am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
   620    629   TEST_LOGS = $(am__test_logs2:.test.log=.log)
   621    630   TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
   622    631   TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
   623    632   	$(TEST_LOG_FLAGS)
   624    633   DIST_SUBDIRS = $(SUBDIRS)
          634  +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
          635  +	$(top_srcdir)/test-driver
   625    636   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   626    637   am__relativize = \
   627    638     dir0=`pwd`; \
   628    639     sed_first='s,^\([^/]*\)/.*$$,\1,'; \
   629    640     sed_rest='s,^[^/]*/*,,'; \
   630    641     sed_last='s,^.*/\([^/]*\)$$,\1,'; \
   631    642     sed_butlast='s,/*[^/]*$$,,'; \
................................................................................
   885    896   	        && { if test -f $@; then exit 0; else break; fi; }; \
   886    897   	      exit 1;; \
   887    898   	  esac; \
   888    899   	done; \
   889    900   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
   890    901   	$(am__cd) $(top_srcdir) && \
   891    902   	  $(AUTOMAKE) --gnu test/Makefile
   892         -.PRECIOUS: Makefile
   893    903   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   894    904   	@case '$?' in \
   895    905   	  *config.status*) \
   896    906   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   897    907   	  *) \
   898    908   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   899    909   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1391   1401   	  if $(am__make_dryrun); then :; else \
  1392   1402   	    rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
  1393   1403   	  fi; \
  1394   1404   	fi; \
  1395   1405   	if test -n "$$am__remaking_logs"; then \
  1396   1406   	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
  1397   1407   	       "recursion detected" >&2; \
  1398         -	else \
         1408  +	elif test -n "$$redo_logs"; then \
  1399   1409   	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
  1400   1410   	fi; \
  1401   1411   	if $(am__make_dryrun); then :; else \
  1402   1412   	  st=0;  \
  1403   1413   	  errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
  1404   1414   	  for i in $$redo_bases; do \
  1405   1415   	    test -f $$i.trs && test -r $$i.trs \
................................................................................
  2141   2151   	install-html-am install-info install-info-am install-man \
  2142   2152   	install-pdf install-pdf-am install-ps install-ps-am \
  2143   2153   	install-strip installcheck installcheck-am installdirs \
  2144   2154   	installdirs-am maintainer-clean maintainer-clean-generic \
  2145   2155   	mostlyclean mostlyclean-compile mostlyclean-generic \
  2146   2156   	mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
  2147   2157   	uninstall uninstall-am
         2158  +
         2159  +.PRECIOUS: Makefile
  2148   2160   
  2149   2161   
  2150   2162   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  2151   2163   # Otherwise a system limit (for SysV at least) may be exceeded.
  2152   2164   .NOEXPORT:

Changes to test/sql_stmt_security_tests/Makefile.in.

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

Changes to test/sql_stmt_tests/Makefile.in.

     1         -# Makefile.in generated by automake 1.14.1 from Makefile.am.
            1  +# Makefile.in generated by automake 1.15 from Makefile.am.
     2      2   # @configure_input@
     3      3   
     4         -# Copyright (C) 1994-2013 Free Software Foundation, Inc.
            4  +# Copyright (C) 1994-2014 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 = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
           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  +}
    18     28   am__make_running_with_option = \
    19     29     case $${target_option-} in \
    20     30         ?) ;; \
    21     31         *) echo "am__make_running_with_option: internal error: invalid" \
    22     32                 "target option '$${target_option-}' specified" >&2; \
    23     33            exit 1;; \
    24     34     esac; \
................................................................................
    74     84   POST_INSTALL = :
    75     85   NORMAL_UNINSTALL = :
    76     86   PRE_UNINSTALL = :
    77     87   POST_UNINSTALL = :
    78     88   build_triplet = @build@
    79     89   host_triplet = @host@
    80     90   subdir = test/sql_stmt_tests
    81         -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
    82     91   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    83     92   am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    84     93   	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    85     94   	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    86     95   	$(top_srcdir)/configure.ac
    87     96   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    88     97   	$(ACLOCAL_M4)
           98  +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
    89     99   mkinstalldirs = $(install_sh) -d
    90    100   CONFIG_HEADER = $(top_builddir)/config.h
    91    101   CONFIG_CLEAN_FILES =
    92    102   CONFIG_CLEAN_VPATH_FILES =
    93    103   AM_V_P = $(am__v_P_@AM_V@)
    94    104   am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
    95    105   am__v_P_0 = false
................................................................................
   106    116   DIST_SOURCES =
   107    117   am__can_run_installinfo = \
   108    118     case $$AM_UPDATE_INFO_DIR in \
   109    119       n|no|NO) false;; \
   110    120       *) (install-info --version) >/dev/null 2>&1;; \
   111    121     esac
   112    122   am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
          123  +am__DIST_COMMON = $(srcdir)/Makefile.in
   113    124   DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   114    125   ACLOCAL = @ACLOCAL@
   115    126   AMTAR = @AMTAR@
   116    127   AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
   117    128   AR = @AR@
   118    129   AS = @AS@
   119    130   AUTOCONF = @AUTOCONF@
................................................................................
   868    879   	        && { if test -f $@; then exit 0; else break; fi; }; \
   869    880   	      exit 1;; \
   870    881   	  esac; \
   871    882   	done; \
   872    883   	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile'; \
   873    884   	$(am__cd) $(top_srcdir) && \
   874    885   	  $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile
   875         -.PRECIOUS: Makefile
   876    886   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   877    887   	@case '$?' in \
   878    888   	  *config.status*) \
   879    889   	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   880    890   	  *) \
   881    891   	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   882    892   	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
................................................................................
  1042   1052   	install-dvi-am install-exec install-exec-am install-html \
  1043   1053   	install-html-am install-info install-info-am install-man \
  1044   1054   	install-pdf install-pdf-am install-ps install-ps-am \
  1045   1055   	install-strip installcheck installcheck-am installdirs \
  1046   1056   	maintainer-clean maintainer-clean-generic mostlyclean \
  1047   1057   	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
  1048   1058   	tags-am uninstall uninstall-am
         1059  +
         1060  +.PRECIOUS: Makefile
  1049   1061   
  1050   1062   	version.testcase 
  1051   1063   
  1052   1064   # Tell versions [3.59,3.63) of GNU make to not export all variables.
  1053   1065   # Otherwise a system limit (for SysV at least) may be exceeded.
  1054   1066   .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 != 0x00 || green != 0x00 || blue != 0xff)
         1079  +    if (red != 0x80 || green != 0x80 || blue != 0x80)
  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 != 0x00 || green != 0x00 || blue != 0xff)
         1318  +    if (red != 0x80 || green != 0x80 || blue != 0x80)
  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 != 0x00 || green != 0x00 || blue != 0xff)
         1366  +    if (red != 0x80 || green != 0x80 || blue != 0x80)
  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 != 0x00 || green != 0x00 || blue != 0xff)
         1414  +    if (red != 0x80 || green != 0x80 || blue != 0x80)
  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.0 && dblval2 == 0.0)
          793  +	  if (dblval == 0.5 && dblval2 == 0.5)
   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, 0);
         1513  +    polyg = rl2_get_polygon_symbolizer (symbolizer, 1);
  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 != 0x70 || green != 0xff || blue != 0xc0)
         1528  +    if (red != 0x37 || green != 0x81 || blue != 0xf2)
  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         }

Changes to tools/Makefile.in.

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

Changes to tools/wmslite.c.

  3399   3399   	  wms_get_capabilities (req->socket, req->cached_capabilities,
  3400   3400   				req->cached_capabilities_len, req->log);
  3401   3401         }
  3402   3402       if (args->request_type == WMS_GET_MAP)
  3403   3403         {
  3404   3404   	  /* preparing the WMS GetMap payload */
  3405   3405   	  args->db_handle = req->conn->handle;
  3406         -	  args->stmt_get_map = req->conn->stmt_get_map;
         3406  +	  args->stmt_get_map_raster = req->conn->stmt_get_map_raster;
         3407  +	  args->stmt_get_map_vector = req->conn->stmt_get_map_vector;
  3407   3408   	  log_get_map_1 (req->log, timestamp, http_status, method, url, args);
  3408   3409   	  wms_get_map (args, req->socket, req->log);
  3409   3410         }
  3410   3411       goto end_request;
  3411   3412   
  3412   3413   /* preparing an HTTP error code */
  3413   3414     http_error:
................................................................................
  4440   4441   static void
  4441   4442   get_raster_styles (sqlite3 * handle, struct wms_list *list)
  4442   4443   {
  4443   4444   /* retrieving all declared Raster Styles */
  4444   4445       int ret;
  4445   4446       sqlite3_stmt *stmt;
  4446   4447       const char *sql = "SELECT coverage_name, name, title, abstract "
  4447         -	"FROM SE_raster_styled_layers_view ORDER BY coverage_name, style_id";
         4448  +	"FROM SE_raster_styled_layers_view ORDER BY coverage_name, name";
  4448   4449       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  4449   4450       if (ret != SQLITE_OK)
  4450   4451   	return;
  4451   4452       while (1)
  4452   4453         {
  4453   4454   	  /* scrolling the result set rows */
  4454   4455   	  ret = sqlite3_step (stmt);
................................................................................
  4475   4476   static void
  4476   4477   get_vector_styles (sqlite3 * handle, struct wms_list *list)
  4477   4478   {
  4478   4479   /* retrieving all declared Vector Styles */
  4479   4480       int ret;
  4480   4481       sqlite3_stmt *stmt;
  4481   4482       const char *sql = "SELECT coverage_name, name, title, abstract "
  4482         -	"FROM SE_vector_styled_layers_view ORDER BY coverage_name, style_id";
         4483  +	"FROM SE_vector_styled_layers_view ORDER BY coverage_name, name";
  4483   4484       ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  4484   4485       if (ret != SQLITE_OK)
  4485   4486   	return;
  4486   4487       while (1)
  4487   4488         {
  4488   4489   	  /* scrolling the result set rows */
  4489   4490   	  ret = sqlite3_step (stmt);