DELETED Android_R4.2.0.mk Index: Android_R4.2.0.mk ================================================================== --- Android_R4.2.0.mk +++ Android_R4.2.0.mk @@ -1,50 +0,0 @@ -# ------------------- -# Android_R4.2.0.mk -# ndk-build clean -# ndk-build -# ------------------- -LOCAL_PATH := $(call my-dir) -JSQLITE_PATH := javasqlite-20120209 -SPATIALITE_PATH := libspatialite-4.2.0-rc1 -GEOS_PATH := geos-3.4.2 -PROJ4_PATH := proj-4.8.0 -SQLITE_PATH := sqlite-amalgamation-3080403 -ICONV_PATH := libiconv-1.13.1 -RASTERLITE2_PATH := librasterlite2-4.2.0 -GEOTIFF_PATH := libgeotiff-1.4.0 -TIFF_PATH := tiff-4.0.3/libtiff -JPEG_PATH := jpeg-8d -GIF_PATH := giflib-5.0.6/lib -CAIRO_PATH := cairo-1.12.14/src -FREETYPE_PATH := freetype-2.5.3 -FONTCONFIG_PATH := fontconfig-2.11.1 -EXPAT_PATH := expat-2.1.0 -PIXMAN_PATH := pixman-0.32.4 -PNG_PATH := libpng-1.6.10 -WEBP_PATH := libwebp-0.4.0 -XML2_PATH := libxml2-2.9.1 -CURL_PATH := curl-7.36.0 -LZMA_PATH := xz-5.1.3alpha - -include $(LOCAL_PATH)/jsqlite-R4.2.0.mk -include $(LOCAL_PATH)/iconv-1.13.1.mk -include $(LOCAL_PATH)/sqlite-3080403.mk -include $(LOCAL_PATH)/proj4-4.8.0.mk -include $(LOCAL_PATH)/geos-3.4.2.mk -include $(LOCAL_PATH)/spatialite-4.2.0.mk -include $(LOCAL_PATH)/libjpeg-8d.mk -include $(LOCAL_PATH)/giflib-5.0.6.mk -include $(LOCAL_PATH)/libpng-1.6.10.mk -include $(LOCAL_PATH)/libtiff-4.0.3.mk -include $(LOCAL_PATH)/libwebp-0.4.0.mk -include $(LOCAL_PATH)/pixman-0.32.4.mk -include $(LOCAL_PATH)/freetype-2.5.3.mk -include $(LOCAL_PATH)/fontconfig-2.11.1.mk -include $(LOCAL_PATH)/expat-2.1.0.mk -include $(LOCAL_PATH)/cairo-1.12.14.mk -include $(LOCAL_PATH)/libgeotiff-1.4.0.mk -include $(LOCAL_PATH)/libxml2-2.9.1.mk -include $(LOCAL_PATH)/libcurl-7.36.0.mk -include $(LOCAL_PATH)/lzma-xz-5.1.3a.mk -include $(LOCAL_PATH)/rasterlite2-4.2.0.mk -$(call import-module,android/cpufeatures) ADDED Android_R4.3.0.mk Index: Android_R4.3.0.mk ================================================================== --- Android_R4.3.0.mk +++ Android_R4.3.0.mk @@ -0,0 +1,54 @@ +# ------------------- +# Android_R4.3.0.mk +# ndk-build clean +# ndk-build +# ------------------- +LOCAL_PATH := $(call my-dir) +JSQLITE_PATH := javasqlite-20120209 +SPATIALITE_PATH := libspatialite-4.3.0 +GEOS_PATH := geos-3.4.2 +PROJ4_PATH := proj-4.9.1 +SQLITE_PATH := sqlite-amalgamation-3081002 +ICONV_PATH := libiconv-1.13.1 +RASTERLITE2_PATH := librasterlite2-4.3.0 +GEOTIFF_PATH := libgeotiff-1.4.0 +TIFF_PATH := tiff-4.0.3/libtiff +JPEG_PATH := jpeg-8d +GIF_PATH := giflib-5.0.6/lib +CAIRO_PATH := cairo-1.12.14/src +FREETYPE_PATH := freetype-2.5.3 +FONTCONFIG_PATH := fontconfig-2.11.1 +EXPAT_PATH := expat-2.1.0 +PIXMAN_PATH := pixman-0.32.4 +PNG_PATH := libpng-1.6.10 +WEBP_PATH := libwebp-0.4.0 +XML2_PATH := libxml2-2.9.1 +CURL_PATH := curl-7.36.0 +LZMA_PATH := xz-5.1.3alpha +CHARLS_PATH := charls-1.0 +OPENJPEG_PATH := openjpeg-2.0.0 + +include $(LOCAL_PATH)/charls-1.0.mk +include $(LOCAL_PATH)/jsqlite-R4.2.0.mk +include $(LOCAL_PATH)/iconv-1.13.1.mk +include $(LOCAL_PATH)/sqlite-3081002.mk +include $(LOCAL_PATH)/proj4-4.9.1.mk +include $(LOCAL_PATH)/geos-3.4.2.mk +include $(LOCAL_PATH)/spatialite-4.3.0.mk +include $(LOCAL_PATH)/libjpeg-8d.mk +include $(LOCAL_PATH)/openjpeg-2.0.0.mk +include $(LOCAL_PATH)/giflib-5.0.6.mk +include $(LOCAL_PATH)/libpng-1.6.10.mk +include $(LOCAL_PATH)/libtiff-4.0.3.mk +include $(LOCAL_PATH)/libwebp-0.4.0.mk +include $(LOCAL_PATH)/pixman-0.32.4.mk +include $(LOCAL_PATH)/freetype-2.5.3.mk +include $(LOCAL_PATH)/fontconfig-2.11.1.mk +include $(LOCAL_PATH)/expat-2.1.0.mk +include $(LOCAL_PATH)/cairo-1.12.14.mk +include $(LOCAL_PATH)/libgeotiff-1.4.0.mk +include $(LOCAL_PATH)/libxml2-2.9.1.mk +include $(LOCAL_PATH)/libcurl-7.36.0.mk +include $(LOCAL_PATH)/lzma-xz-5.1.3a.mk +include $(LOCAL_PATH)/rasterlite2-4.3.0.mk +$(call import-module,android/cpufeatures) Index: Makefile.am ================================================================== --- Makefile.am +++ Makefile.am @@ -1,13 +1,13 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = headers src test tools -EXTRA_DIST = mainpage.doxy Android_R4.2.0.mk rasterlite2-4.2.0.mk \ +EXTRA_DIST = mainpage.doxy Android_R4.3.0.mk rasterlite2-4.3.0.mk \ Makefile-static-MinGW -AUTOMAKE_OPTIONS = dist-zip +AUTOMAKE_OPTIONS = dist-zip foreign pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = rasterlite2.pc coverage-init: Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,11 +13,21 @@ # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -77,23 +87,19 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . -DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ - $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(srcdir)/config.h.in $(srcdir)/Doxyfile.in \ - $(srcdir)/rasterlite2.pc.in COPYING compile config.guess \ - config.sub depcomp install-sh missing ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = Doxyfile rasterlite2.pc @@ -182,10 +188,14 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Doxyfile.in $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(srcdir)/rasterlite2.pc.in AUTHORS \ + COPYING ChangeLog INSTALL NEWS README compile config.guess \ + config.sub depcomp install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ @@ -368,14 +378,14 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = headers src test tools -EXTRA_DIST = mainpage.doxy Android_R4.2.0.mk rasterlite2-4.2.0.mk \ +EXTRA_DIST = mainpage.doxy Android_R4.3.0.mk rasterlite2-4.3.0.mk \ Makefile-static-MinGW -AUTOMAKE_OPTIONS = dist-zip +AUTOMAKE_OPTIONS = dist-zip foreign pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = rasterlite2.pc MOSTLYCLEANFILES = rasterlite2_cov.info all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -385,20 +395,19 @@ @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile + $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ @@ -650,19 +659,19 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip @@ -693,21 +702,21 @@ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ @@ -883,10 +892,12 @@ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-pkgconfigDATA + +.PRECIOUS: Makefile coverage-init: lcov --directory src --capture --initial --output-file rasterlite2_cov.info Index: aclocal.m4 ================================================================== --- aclocal.m4 +++ aclocal.m4 @@ -1,8 +1,8 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- +# generated automatically by aclocal 1.15 -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -233,11 +233,11 @@ AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -245,14 +245,14 @@ # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.14' +[am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.14.1], [], +m4_if([$1], [1.15], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- @@ -264,18 +264,18 @@ # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.14.1])dnl +[AM_AUTOMAKE_VERSION([1.15])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -316,19 +316,18 @@ # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -355,11 +354,11 @@ [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -546,11 +545,11 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -622,11 +621,11 @@ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -712,12 +711,12 @@ # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], @@ -786,11 +785,15 @@ to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi -fi]) +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -815,11 +818,11 @@ _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -826,21 +829,21 @@ # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -858,11 +861,11 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -893,11 +896,11 @@ ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -943,11 +946,11 @@ rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -984,11 +987,11 @@ # -*- Autoconf -*- # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1011,11 +1014,11 @@ [AC_FATAL([automatic de-ANSI-fication support has been removed])]) AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1040,11 +1043,11 @@ # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1087,11 +1090,11 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1106,11 +1109,11 @@ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1187,11 +1190,11 @@ fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1247,11 +1250,11 @@ AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1275,11 +1278,11 @@ AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1294,11 +1297,11 @@ # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. Index: configure ================================================================== --- configure +++ configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for librasterlite2 1.0.0-rc1. +# Generated by GNU Autoconf 2.69 for librasterlite2 1.0.0-devel. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -588,12 +588,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='librasterlite2' PACKAGE_TARNAME='librasterlite2' -PACKAGE_VERSION='1.0.0-rc1' -PACKAGE_STRING='librasterlite2 1.0.0-rc1' +PACKAGE_VERSION='1.0.0-devel' +PACKAGE_STRING='librasterlite2 1.0.0-devel' PACKAGE_BUGREPORT='a.furieri@lqt.it' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ @@ -1370,11 +1370,11 @@ # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures librasterlite2 1.0.0-rc1 to adapt to many kinds of systems. +\`configure' configures librasterlite2 1.0.0-devel to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. @@ -1440,11 +1440,11 @@ _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of librasterlite2 1.0.0-rc1:";; + short | recursive ) echo "Configuration of librasterlite2 1.0.0-devel:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options @@ -1592,11 +1592,11 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -librasterlite2 configure 1.0.0-rc1 +librasterlite2 configure 1.0.0-devel generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -2136,11 +2136,11 @@ } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by librasterlite2 $as_me 1.0.0-rc1, which was +It was created by librasterlite2 $as_me 1.0.0-devel, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF @@ -2521,11 +2521,11 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -am__api_version='1.14' +am__api_version='1.15' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install @@ -2693,12 +2693,12 @@ # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; @@ -2713,11 +2713,11 @@ am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" @@ -3007,11 +3007,11 @@ fi # Define the identity of the package. PACKAGE='librasterlite2' - VERSION='1.0.0-rc1' + VERSION='1.0.0-devel' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF @@ -3041,12 +3041,12 @@ # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' @@ -3099,10 +3099,11 @@ END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : @@ -19158,11 +19159,11 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by librasterlite2 $as_me 1.0.0-rc1, which was +This file was extended by librasterlite2 $as_me 1.0.0-devel, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -19224,11 +19225,11 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -librasterlite2 config.status 1.0.0-rc1 +librasterlite2 config.status 1.0.0-devel configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1,10 +1,10 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT(librasterlite2, 1.0.0-rc1, a.furieri@lqt.it) +AC_INIT(librasterlite2, 1.0.0-devel, a.furieri@lqt.it) AC_LANG(C) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE Index: headers/Makefile.in ================================================================== --- headers/Makefile.in +++ headers/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,11 +13,21 @@ # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -77,19 +87,19 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = headers -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(nobase_include_HEADERS) $(noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(nobase_include_HEADERS) \ + $(noinst_HEADERS) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -157,10 +167,11 @@ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ @@ -323,11 +334,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu headers/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu headers/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -572,10 +582,12 @@ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-nobase_includeHEADERS + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: headers/rasterlite2_private.h ================================================================== --- headers/rasterlite2_private.h +++ headers/rasterlite2_private.h @@ -1099,18 +1099,26 @@ typedef struct rl2_linestring { int points; double *coords; + double minx; + double miny; + double maxx; + double maxy; struct rl2_linestring *next; } rl2Linestring; typedef rl2Linestring *rl2LinestringPtr; typedef struct rl2_ring { int points; double *coords; + double minx; + double miny; + double maxx; + double maxy; struct rl2_ring *next; } rl2Ring; typedef rl2Ring *rl2RingPtr; typedef struct rl2_polygon @@ -1255,16 +1263,16 @@ unsigned char pixel_type, unsigned char num_bands, unsigned char **pixels, int *pixels_sz); RL2_PRIVATE int - rl2_data_to_png (const unsigned char *pixels, const unsigned char *mask, - double opacity, rl2PalettePtr plt, - unsigned int width, unsigned int height, - unsigned char sample_type, unsigned char pixel_type, - unsigned char num_bands, unsigned char **compr_data, - int *compressed_size); + rl2_data_to_png (const unsigned char *pixels, + const unsigned char *mask, double opacity, + rl2PalettePtr plt, unsigned int width, + unsigned int height, unsigned char sample_type, + unsigned char pixel_type, unsigned char num_bands, + unsigned char **compr_data, int *compressed_size); RL2_PRIVATE int rl2_decode_png (const unsigned char *png, int png_sz, unsigned int *width, unsigned int *height, unsigned char *sample_type, unsigned char *pixel_type, @@ -1280,12 +1288,13 @@ RL2_PRIVATE int rl2_decode_charls (const unsigned char *charls, int charls_sz, unsigned int *width, unsigned int *height, unsigned char *sample_type, - unsigned char *pixel_type, unsigned char *num_bands, - unsigned char **pixels, int *pixels_sz); + unsigned char *pixel_type, + unsigned char *num_bands, unsigned char **pixels, + int *pixels_sz); RL2_PRIVATE int rl2_data_to_gif (const unsigned char *pixels, rl2PalettePtr plt, unsigned int width, unsigned int height, unsigned char sample_type, @@ -1345,13 +1354,13 @@ unsigned char num_bands, unsigned char auto_ndvi, unsigned char red_band_index, unsigned char nir_band_index, double x_res, double y_res, - double minx, double miny, double maxx, - double maxy, int level, int scale, - rl2PalettePtr palette, + double minx, double miny, + double maxx, double maxy, int level, + int scale, rl2PalettePtr palette, rl2PixelPtr no_data, rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats); RL2_PRIVATE int rl2_load_dbms_tiles_section (sqlite3 * handle, @@ -1449,11 +1458,12 @@ RL2_PRIVATE int rl2_find_best_resolution_level (sqlite3 * handle, const char *coverage, int by_section, sqlite3_int64 section_id, - double x_res, double y_res, + double x_res, + double y_res, int *level_id, int *scale, int *real_scale, double *xx_res, double *yy_res); @@ -1499,29 +1509,34 @@ unsigned char **image, int *image_sz); RL2_PRIVATE int get_payload_from_palette_transparent (unsigned int width, unsigned int height, - unsigned char *pixels, - rl2PalettePtr palette, - unsigned char format, - int quality, - unsigned char **image, + unsigned char + *pixels, + rl2PalettePtr + palette, + unsigned char + format, int quality, + unsigned char + **image, int *image_sz, - unsigned char bg_red, + unsigned char + bg_red, unsigned char bg_green, unsigned char bg_blue, double opacity); RL2_PRIVATE int get_payload_from_grayscale_opaque (unsigned int width, unsigned int height, sqlite3 * handle, - double minx, double miny, - double maxx, double maxy, - int srid, + double minx, + double miny, + double maxx, + double maxy, int srid, unsigned char *pixels, unsigned char format, int quality, unsigned char **image, int *image_sz); @@ -1531,23 +1546,25 @@ unsigned int height, unsigned char *pixels, unsigned char - format, int quality, + format, + int quality, unsigned char **image, int *image_sz, unsigned char bg_gray, double opacity); RL2_PRIVATE int get_payload_from_rgb_opaque (unsigned int width, unsigned int height, - sqlite3 * handle, double minx, - double miny, double maxx, - double maxy, int srid, + sqlite3 * handle, + double minx, double miny, + double maxx, double maxy, + int srid, unsigned char *pixels, unsigned char format, int quality, unsigned char **image, int *image_sz); @@ -1576,11 +1593,12 @@ unsigned char *pixels, unsigned char *rgba); RL2_PRIVATE int get_rgba_from_monochrome_transparent (unsigned int width, unsigned int height, - unsigned char *pixels, + unsigned char + *pixels, unsigned char *rgba); RL2_PRIVATE int get_rgba_from_palette_mask (unsigned int base_width, unsigned int base_height, unsigned char *pixels, @@ -1616,11 +1634,12 @@ unsigned char *pixels, unsigned char *rgba); RL2_PRIVATE int get_rgba_from_grayscale_transparent (unsigned int width, unsigned int height, - unsigned char *pixels, + unsigned char + *pixels, unsigned char *rgba, unsigned char bg_gray); RL2_PRIVATE int get_rgba_from_rgb_mask (unsigned int width, unsigned int height, @@ -1660,13 +1679,14 @@ unsigned char *rgba); RL2_PRIVATE int get_payload_from_gray_rgba_opaque (unsigned int width, unsigned int height, sqlite3 * handle, - double minx, double miny, - double maxx, double maxy, - int srid, + double minx, + double miny, + double maxx, + double maxy, int srid, unsigned char *rgb, unsigned char format, int quality, unsigned char **image, int *image_sz); @@ -1673,26 +1693,29 @@ RL2_PRIVATE int get_payload_from_gray_rgba_transparent (unsigned int width, unsigned int height, - unsigned char *rgb, + unsigned char + *rgb, unsigned char *alpha, unsigned char - format, int quality, + format, + int quality, unsigned char **image, int *image_sz, double opacity); RL2_PRIVATE int get_payload_from_rgb_rgba_opaque (unsigned int width, unsigned int height, sqlite3 * handle, - double minx, double miny, - double maxx, double maxy, - int srid, + double minx, + double miny, + double maxx, + double maxy, int srid, unsigned char *rgb, unsigned char format, int quality, unsigned char **image, int *image_sz); @@ -1699,12 +1722,14 @@ RL2_PRIVATE int get_payload_from_rgb_rgba_transparent (unsigned int width, unsigned int height, unsigned char *rgb, - unsigned char *alpha, - unsigned char format, + unsigned char + *alpha, + unsigned char + format, int quality, unsigned char **image, int *image_sz, double opacity, @@ -1711,11 +1736,12 @@ int half_transparent); RL2_PRIVATE int build_rgb_alpha (unsigned int width, unsigned int height, unsigned char *rgba, - unsigned char **rgb, unsigned char **alpha, + unsigned char **rgb, + unsigned char **alpha, unsigned char bg_red, unsigned char bg_green, unsigned char bg_blue); RL2_PRIVATE int get_rgba_from_multiband8 (unsigned int width, @@ -1744,11 +1770,12 @@ RL2_PRIVATE rl2CoverageStylePtr coverage_style_from_xml (char *name, unsigned char *xml); - RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char *name, + RL2_PRIVATE rl2FeatureTypeStylePtr feature_type_style_from_xml (char + *name, unsigned char *xml); RL2_PRIVATE rl2GroupStylePtr group_style_from_sld_xml (char *name, unsigned char *xml); @@ -1833,12 +1860,12 @@ symbolizer); RL2_PRIVATE void rl2_destroy_line_symbolizer (rl2PrivLineSymbolizerPtr symbolizer); - RL2_PRIVATE void rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr - symbolizer); + RL2_PRIVATE void + rl2_destroy_polygon_symbolizer (rl2PrivPolygonSymbolizerPtr symbolizer); RL2_PRIVATE void rl2_destroy_text_symbolizer (rl2PrivTextSymbolizerPtr symbolizer); RL2_PRIVATE rl2PrivRuleSingleArgPtr @@ -1883,11 +1910,12 @@ RL2_PRIVATE unsigned char *rl2_copy_endian_raw_pixels (const unsigned char *pixels, int pixels_sz, unsigned int width, - unsigned int height, + unsigned int + height, unsigned char sample_type, unsigned char num_bands, int big_endian); @@ -1912,19 +1940,28 @@ RL2_PRIVATE int rl2_test_layer_group (sqlite3 * handle, const char *group_name); RL2_PRIVATE int rl2_rgba_raster_data (sqlite3 * handle, - const char *coverage_name, void *ctx, - int level, double minx, double miny, - double maxx, double maxy, - rl2PalettePtr palette, + const char *coverage_name, + void *ctx, int level, double minx, + double miny, double maxx, + double maxy, rl2PalettePtr palette, rl2PixelPtr no_data); RL2_PRIVATE int rl2_aux_render_image (struct aux_renderer *aux, unsigned char **ximage, int *ximage_size); + + RL2_PRIVATE int rl2_aux_default_image (unsigned int width, + unsigned int height, + unsigned char red, + unsigned char green, + unsigned char blue, int format_id, + int transparent, int quality, + unsigned char **ximage, + int *ximage_size); RL2_PRIVATE void rl2_aux_group_renderer (struct aux_group_renderer *auxgrp); RL2_PRIVATE double rl2_get_shaded_relief_scale_factor (sqlite3 * handle, const char @@ -1952,11 +1989,12 @@ sqlite3_int64 section_id, unsigned int width, unsigned int height, double minx, double miny, double maxx, double maxy, - double x_res, double y_res, + double x_res, + double y_res, unsigned char **buffer, int *buf_size, rl2PalettePtr * palette, unsigned char out_pixel, rl2PixelPtr bgcolor, @@ -1974,17 +2012,19 @@ RL2_PRIVATE int rl2_parse_point_generic (sqlite3 * sqlite, const unsigned char *blob, int blob_sz, double *x, double *y); RL2_PRIVATE int rl2_parse_bbox_srid (sqlite3 * sqlite, - const unsigned char *blob, int blob_sz, - int *srid, double *minx, double *miny, - double *maxx, double *maxy); + const unsigned char *blob, + int blob_sz, int *srid, double *minx, + double *miny, double *maxx, + double *maxy); - RL2_PRIVATE int rl2_parse_bbox (sqlite3 * sqlite, const unsigned char *blob, - int blob_sz, double *minx, double *miny, - double *maxx, double *maxy); + RL2_PRIVATE int rl2_parse_bbox (sqlite3 * sqlite, + const unsigned char *blob, int blob_sz, + double *minx, double *miny, double *maxx, + double *maxy); RL2_PRIVATE int rl2_build_bbox (sqlite3 * sqlite, int srid, double minx, double miny, double maxx, double maxy, unsigned char **blob, int *blob_sz); @@ -1992,11 +2032,12 @@ int distance); RL2_PRIVATE int rl2_delta_decode (unsigned char *buffer, int size, int distance); - RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char *name, + RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_int (const char + *name, sqlite3_int64 value); RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_double (const char *name, @@ -2014,14 +2055,16 @@ *name); RL2_PRIVATE void rl2_destroy_variant_value (rl2PrivVariantValuePtr value); RL2_PRIVATE void rl2_draw_vector_feature (void *ctx, sqlite3 * handle, - rl2VectorSymbolizerPtr symbolizer, - int height, double minx, - double miny, double x_res, - double y_res, + const void *priv_data, + rl2VectorSymbolizerPtr + symbolizer, int height, + double minx, double miny, + double maxx, double maxy, + double x_res, double y_res, rl2GeometryPtr geom, rl2VariantArrayPtr variant); RL2_PRIVATE rl2GeometryPtr rl2_geometry_from_blob (const unsigned char *blob, int blob_sz); @@ -2035,16 +2078,20 @@ unsigned char **blob, int *blob_sz); RL2_PRIVATE int rl2_serialize_ring (rl2RingPtr ring, unsigned char **blob, int *blob_sz); + + RL2_PRIVATE int rl2_serialize_ring_as_linestring (rl2RingPtr ring, + unsigned char **blob, + int *blob_sz); RL2_PRIVATE double rl2_compute_curve_length (rl2GeometryPtr geom); RL2_PRIVATE rl2GeometryPtr - rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom, double from, - double to); + rl2_curve_substring (sqlite3 * handle, rl2GeometryPtr geom, + double from, double to); RL2_PRIVATE rl2GeometryPtr rl2_clone_curve (rl2GeometryPtr in); RL2_PRIVATE rl2GeometryPtr rl2_clone_linestring (rl2LinestringPtr in); @@ -2055,11 +2102,26 @@ unsigned char *blob, int blob_sz); RL2_PRIVATE int rl2_get_font_from_dbms (sqlite3 * handle, const char *facename, unsigned char **font, int *font_sz); + + RL2_PRIVATE rl2LinestringPtr rl2_linestring_to_image (rl2LinestringPtr line, + int height, + double minx, + double miny, + double x_res, + double y_res); + + RL2_PRIVATE rl2RingPtr rl2_ring_to_image (rl2RingPtr ring, int height, + double minx, double miny, + double x_res, double y_res); + + RL2_PRIVATE void rl2DestroyLinestring (rl2LinestringPtr ptr); + + RL2_PRIVATE void rl2DestroyRing (rl2RingPtr ptr); #ifdef __cplusplus } #endif #endif /* _RASTERLITE2_PRIVATE_H */ Index: headers/rl2svg_private.h ================================================================== --- headers/rl2svg_private.h +++ headers/rl2svg_private.h @@ -504,26 +504,26 @@ RL2_PRIVATE rl2PrivSvgLinePtr svg_alloc_line (double x1, double y1, double x2, double y2); RL2_PRIVATE rl2PrivSvgLinePtr svg_clone_line (rl2PrivSvgLinePtr in); - RL2_PRIVATE rl2PrivSvgPolylinePtr svg_alloc_polyline (int points, double *x, - double *y); + RL2_PRIVATE rl2PrivSvgPolylinePtr svg_alloc_polyline (int points, + double *x, double *y); - RL2_PRIVATE rl2PrivSvgPolylinePtr svg_clone_polyline (rl2PrivSvgPolylinePtr - in); + RL2_PRIVATE rl2PrivSvgPolylinePtr + svg_clone_polyline (rl2PrivSvgPolylinePtr in); RL2_PRIVATE rl2PrivSvgPolygonPtr svg_alloc_polygon (int points, double *x, double *y); RL2_PRIVATE rl2PrivSvgPolygonPtr svg_clone_polygon (rl2PrivSvgPolygonPtr in); RL2_PRIVATE rl2PrivSvgPathMovePtr svg_alloc_path_move (double x, double y); - RL2_PRIVATE rl2PrivSvgPathMovePtr svg_clone_path_move (rl2PrivSvgPathMovePtr - in); + RL2_PRIVATE rl2PrivSvgPathMovePtr + svg_clone_path_move (rl2PrivSvgPathMovePtr in); RL2_PRIVATE rl2PrivSvgPathBezierPtr svg_alloc_path_bezier (double x1, double y1, double x2, double y2, @@ -608,24 +608,25 @@ rl2PrivSvgGroupPtr grp); RL2_PRIVATE rl2PrivSvgGradientStopPtr svg_alloc_gradient_stop (double offset, double red, - double green, - double blue, + double + green, + double + blue, double opacity); RL2_PRIVATE rl2PrivSvgGradientStopPtr svg_clone_gradient_stop (rl2PrivSvgGradientStopPtr in); RL2_PRIVATE rl2PrivSvgGradientPtr svg_alloc_gradient (void); - RL2_PRIVATE rl2PrivSvgGradientPtr svg_clone_gradient (rl2PrivSvgGradientPtr - in, - rl2PrivSvgGradientPtr - old); + RL2_PRIVATE rl2PrivSvgGradientPtr + svg_clone_gradient (rl2PrivSvgGradientPtr in, + rl2PrivSvgGradientPtr old); RL2_PRIVATE rl2PrivSvgDocumentPtr svg_alloc_document (void); RL2_PRIVATE void svg_close_group (rl2PrivSvgDocumentPtr svg_doc); @@ -633,40 +634,41 @@ RL2_PRIVATE void svg_close_clip (rl2PrivSvgDocumentPtr svg_doc); RL2_PRIVATE void svg_insert_clip (rl2PrivSvgDocumentPtr svg_doc); - RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr svg_doc, + RL2_PRIVATE rl2PrivSvgUsePtr svg_insert_use (rl2PrivSvgDocumentPtr + svg_doc, const char *xlink_href, double x, double y, double width, double height); - RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc, int type, - void *data); + RL2_PRIVATE void svg_insert_shape (rl2PrivSvgDocumentPtr svg_doc, + int type, void *data); RL2_PRIVATE void svg_insert_gradient_stop (rl2PrivSvgGradientPtr gradient, double offset, double red, double green, double blue, double opacity); RL2_PRIVATE rl2PrivSvgGradientPtr svg_insert_linear_gradient (rl2PrivSvgDocumentPtr svg_doc, const char *id, const char *xlink_href, - double x1, double y1, double x2, double y2, - int units); + double x1, double y1, double x2, + double y2, int units); RL2_PRIVATE rl2PrivSvgGradientPtr svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc, const char *id, const char *xlink_href, - double cx, double cy, double fx, double fy, - double r, int units); + double cx, double cy, double fx, + double fy, double r, int units); RL2_PRIVATE rl2PrivSvgGradientPtr svg_insert_radial_gradient (rl2PrivSvgDocumentPtr svg_doc, const char *id, const char *xlink_href, - double cx, double cy, double fx, double fy, - double r, int units); + double cx, double cy, double fx, + double fy, double r, int units); RL2_PRIVATE void svg_init_style (rl2PrivSvgStylePtr style); RL2_PRIVATE void svg_style_cleanup (rl2PrivSvgStylePtr style); DELETED rasterlite2-4.2.0.mk Index: rasterlite2-4.2.0.mk ================================================================== --- rasterlite2-4.2.0.mk +++ rasterlite2-4.2.0.mk @@ -1,86 +0,0 @@ -include $(CLEAR_VARS) -# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi -LOCAL_MODULE := rasterlite2 - -# SQLite flags copied from ASOP [may not be needed for rasterlite2] -common_sqlite_flags := \ - -DHAVE_USLEEP=1 \ - -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \ - -DSQLITE_THREADSAFE=1 \ - -DNDEBUG=1 \ - -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \ - -DSQLITE_DEFAULT_AUTOVACUUM=1 \ - -DSQLITE_TEMP_STORE=3 \ - -DSQLITE_ENABLE_FTS3 \ - -DSQLITE_ENABLE_FTS3_BACKWARDS \ - -DSQLITE_ENABLE_RTREE=1 \ - -DSQLITE_DEFAULT_FILE_FORMAT=4 - -# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI -spatialite_flags := \ - -DOMIT_FREEXL \ - -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \ - -Dfdatasync=fsync \ - -DSQLITE_ENABLE_RTREE=1 \ - -DSQLITE_OMIT_BUILTIN_TEST=1 - -# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI -rasterlite2_flags := \ - -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \ - -O - -LOCAL_CFLAGS := \ - $(common_sqlite_flags) \ - $(spatialite_flags) \ - $(rasterlite2_flags) - -LOCAL_C_INCLUDES := \ - $(SQLITE_PATH) \ - $(GEOTIFF_PATH)/libxtiff \ - $(GEOTIFF_PATH) \ - $(TIFF_PATH) \ - $(JPEG_PATH) \ - $(GIF_PATH) \ - $(PNG_PATH) \ - $(WEBP_PATH)/src/webp \ - $(WEBP_PATH)/src/dec \ - $(WEBP_PATH)/src/dsp \ - $(WEBP_PATH)/src/enc \ - $(WEBP_PATH)/src/utils \ - $(WEBP_PATH)/src \ - $(WEBP_PATH) \ - $(CAIRO_PATH) \ - $(ICONV_PATH)/include \ - $(ICONV_PATH)/libcharset/include \ - $(XML2_PATH)/include \ - $(CURL_PATH) \ - $(CURL_PATH)/include \ - $(CURL_PATH)/lib \ - $(RASTERLITE2_PATH) \ - $(RASTERLITE2_PATH)/headers \ - $(SPATIALITE_PATH)/src/headers \ - $(LZMA_PATH)/src/liblzma/api -LOCAL_SRC_FILES := \ - $(RASTERLITE2_PATH)/src/rasterlite2.c \ - $(RASTERLITE2_PATH)/src/rl2ascii.c \ - $(RASTERLITE2_PATH)/src/rl2codec.c \ - $(RASTERLITE2_PATH)/src/rl2dbms.c \ - $(RASTERLITE2_PATH)/src/rl2gif.c \ - $(RASTERLITE2_PATH)/src/rl2import.c \ - $(RASTERLITE2_PATH)/src/rl2jpeg.c \ - $(RASTERLITE2_PATH)/src/rl2paint.c \ - $(RASTERLITE2_PATH)/src/rl2png.c \ - $(RASTERLITE2_PATH)/src/rl2rastersym.c \ - $(RASTERLITE2_PATH)/src/rl2raw.c \ - $(RASTERLITE2_PATH)/src/rl2sql.c \ - $(RASTERLITE2_PATH)/src/rl2sqlaux.c \ - $(RASTERLITE2_PATH)/src/rl2svg.c \ - $(RASTERLITE2_PATH)/src/rl2svgaux.c \ - $(RASTERLITE2_PATH)/src/rl2svgxml.c \ - $(RASTERLITE2_PATH)/src/rl2symbolizer.c \ - $(RASTERLITE2_PATH)/src/rl2tiff.c \ - $(RASTERLITE2_PATH)/src/rl2version.c \ - $(RASTERLITE2_PATH)/src/rl2webp.c \ - $(RASTERLITE2_PATH)/src/rl2wms.c -LOCAL_STATIC_LIBRARIES := libpng libwebp libxml2 spatialite libfreetype libcairo libcurl libgeotiff libtiff libgif libjpeg -include $(BUILD_STATIC_LIBRARY) ADDED rasterlite2-4.3.0.mk Index: rasterlite2-4.3.0.mk ================================================================== --- rasterlite2-4.3.0.mk +++ rasterlite2-4.3.0.mk @@ -0,0 +1,106 @@ +include $(CLEAR_VARS) +# ./configure --build=x86_64-pc-linux-gnu --host=arm-linux-eabi +LOCAL_MODULE := rasterlite2 + +# SQLite flags copied from ASOP [may not be needed for rasterlite2] +common_sqlite_flags := \ + -DHAVE_USLEEP=1 \ + -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \ + -DSQLITE_THREADSAFE=1 \ + -DNDEBUG=1 \ + -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \ + -DSQLITE_DEFAULT_AUTOVACUUM=1 \ + -DSQLITE_TEMP_STORE=3 \ + -DSQLITE_ENABLE_FTS3 \ + -DSQLITE_ENABLE_FTS3_BACKWARDS \ + -DSQLITE_ENABLE_RTREE=1 \ + -DSQLITE_DEFAULT_FILE_FORMAT=4 + +# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI +spatialite_flags := \ + -DOMIT_FREEXL \ + -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \ + -Dfdatasync=fsync \ + -DSQLITE_ENABLE_RTREE=1 \ + -DENABLE_GCP=1 \ + -DENABLE_GEOPACKAGE=1 \ + -DENABLE_LIBXML2=1 \ + -DSQLITE_OMIT_BUILTIN_TEST=1 + +# comment out TARGET_CPU in config.h - will be replaced with TARGET_ARCH_ABI +# comment out VERSION in config.h - manually set to avoid conflict with other packages +rasterlite2_flags := \ + -DTARGET_CPU=\"$(TARGET_ARCH_ABI)\" \ + -DVERSION=\"0.9\" \ + -O + +LOCAL_CFLAGS := \ + $(common_sqlite_flags) \ + $(spatialite_flags) \ + $(rasterlite2_flags) + +# 2014-10-03 - adapted based on ls -1 result +LOCAL_C_INCLUDES := \ + $(SQLITE_PATH) \ + $(GEOTIFF_PATH)/libxtiff \ + $(GEOTIFF_PATH) \ + $(TIFF_PATH) \ + $(JPEG_PATH) \ + $(GIF_PATH) \ + $(PNG_PATH) \ + $(WEBP_PATH)/src/webp \ + $(WEBP_PATH)/src/dec \ + $(WEBP_PATH)/src/dsp \ + $(WEBP_PATH)/src/enc \ + $(WEBP_PATH)/src/utils \ + $(WEBP_PATH)/src \ + $(WEBP_PATH) \ + $(CAIRO_PATH) \ + $(FONTCONFIG_PATH) \ + $(ICONV_PATH)/include \ + $(FREETYPE_PATH)/include \ + $(ICONV_PATH)/libcharset/include \ + $(XML2_PATH)/include \ + $(CURL_PATH) \ + $(CURL_PATH)/include \ + $(CURL_PATH)/lib \ + $(RASTERLITE2_PATH) \ + $(RASTERLITE2_PATH)/headers \ + $(SPATIALITE_PATH)/src/headers \ + $(LZMA_PATH)/src/liblzma/api \ + $(OPENJPEG_PATH)/src/lib/openjp2 \ + $(CHARLS_PATH) + +LOCAL_SRC_FILES := \ + $(RASTERLITE2_PATH)/src/md5.c \ + $(RASTERLITE2_PATH)/src/rasterlite2.c \ + $(RASTERLITE2_PATH)/src/rl2ascii.c \ + $(RASTERLITE2_PATH)/src/rl2auxfont.c \ + $(RASTERLITE2_PATH)/src/rl2auxgeom.c \ + $(RASTERLITE2_PATH)/src/rl2auxrender.c \ + $(RASTERLITE2_PATH)/src/rl2charls.c \ + $(RASTERLITE2_PATH)/src/rl2codec.c \ + $(RASTERLITE2_PATH)/src/rl2dbms.c \ + $(RASTERLITE2_PATH)/src/rl2gif.c \ + $(RASTERLITE2_PATH)/src/rl2import.c \ + $(RASTERLITE2_PATH)/src/rl2jpeg.c \ + $(RASTERLITE2_PATH)/src/rl2md5.c \ + $(RASTERLITE2_PATH)/src/rl2openjpeg.c \ + $(RASTERLITE2_PATH)/src/rl2paint.c \ + $(RASTERLITE2_PATH)/src/rl2png.c \ + $(RASTERLITE2_PATH)/src/rl2pyramid.c \ + $(RASTERLITE2_PATH)/src/rl2rastersym.c \ + $(RASTERLITE2_PATH)/src/rl2raw.c \ + $(RASTERLITE2_PATH)/src/rl2sql.c \ + $(RASTERLITE2_PATH)/src/rl2sqlaux.c \ + $(RASTERLITE2_PATH)/src/rl2svg.c \ + $(RASTERLITE2_PATH)/src/rl2svgaux.c \ + $(RASTERLITE2_PATH)/src/rl2svgxml.c \ + $(RASTERLITE2_PATH)/src/rl2symbaux.c \ + $(RASTERLITE2_PATH)/src/rl2symbolizer.c \ + $(RASTERLITE2_PATH)/src/rl2tiff.c \ + $(RASTERLITE2_PATH)/src/rl2version.c \ + $(RASTERLITE2_PATH)/src/rl2webp.c \ + $(RASTERLITE2_PATH)/src/rl2wms.c +LOCAL_STATIC_LIBRARIES := libcharls libopenjpeg libpng libwebp libxml2 spatialite libfreetype libcairo libcurl libgeotiff libtiff libgif libjpeg +include $(BUILD_STATIC_LIBRARY) Index: src/Makefile.am ================================================================== --- src/Makefile.am +++ src/Makefile.am @@ -23,11 +23,11 @@ if MINGW librasterlite2_la_LDFLAGS = -avoid-version -no-undefined librasterlite2_la_LIBADD += -lm else -librasterlite2_la_LDFLAGS = -version-info 0:0:0 +librasterlite2_la_LDFLAGS = -version-info 1:0:0 librasterlite2_la_LIBADD += -lpthread -lm endif mod_rasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \ rl2jpeg.c rl2png.c rl2gif.c rl2webp.c rl2tiff.c rl2wms.c \ @@ -48,10 +48,10 @@ if MINGW mod_rasterlite2_la_LDFLAGS = -module -avoid-version -no-undefined mod_rasterlite2_la_LIBADD += -lm else -mod_rasterlite2_la_LDFLAGS = -module -version-info 0:0:0 +mod_rasterlite2_la_LDFLAGS = -module -version-info 1:0:0 mod_rasterlite2_la_LIBADD += -lpthread -lm endif MOSTLYCLEANFILES = *.gcna *.gcno *.gcda Index: src/Makefile.in ================================================================== --- src/Makefile.in +++ src/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,11 +14,21 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -82,19 +92,19 @@ @MINGW_TRUE@am__append_1 = -lm @MINGW_FALSE@am__append_2 = -lpthread -lm @MINGW_TRUE@am__append_3 = -lm @MINGW_FALSE@am__append_4 = -lpthread -lm subdir = src -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; @@ -232,10 +242,11 @@ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ @@ -393,11 +404,11 @@ rl2auxgeom.c rl2auxfont.c librasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ @LIBLZMA_LIBS@ \ @LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \ @LIBFREETYPE2_LIBS@ $(am__append_1) $(am__append_2) -@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 0:0:0 +@MINGW_FALSE@librasterlite2_la_LDFLAGS = -version-info 1:0:0 @MINGW_TRUE@librasterlite2_la_LDFLAGS = -avoid-version -no-undefined mod_rasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \ rl2jpeg.c rl2png.c rl2gif.c rl2webp.c rl2tiff.c rl2wms.c \ rl2ascii.c rl2paint.c rl2dbms.c rl2import.c rl2pyramid.c \ rl2sql.c rl2sqlaux.c rl2auxrender.c rl2svg.c rl2svgxml.c \ @@ -409,11 +420,11 @@ @LIBLZMA_LIBS@ @LIBCAIRO_LIBS@ @LIBCURL_LIBS@ @LIBXML2_LIBS@ \ @LIBFREETYPE2_LIBS@ $(am__append_3) $(am__append_4) mod_rasterlite2_la_CPPFLAGS = @CFLAGS@ -I$(top_srcdir)/headers -I. \ -DLOADABLE_EXTENSION mod_rasterlite2_la_LIBTOOLFLAGS = --tag=disable-static -@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 0:0:0 +@MINGW_FALSE@mod_rasterlite2_la_LDFLAGS = -module -version-info 1:0:0 @MINGW_TRUE@mod_rasterlite2_la_LDFLAGS = -module -avoid-version -no-undefined MOSTLYCLEANFILES = *.gcna *.gcno *.gcda all: all-am .SUFFIXES: @@ -428,11 +439,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -998,10 +1008,12 @@ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: src/rasterlite2.c ================================================================== --- src/rasterlite2.c +++ src/rasterlite2.c @@ -512,12 +512,13 @@ }; return RL2_ERROR; } static int -check_coverage_no_data (rl2PrivPixelPtr pxl_no_data, unsigned char sample_type, - unsigned char pixel_type, unsigned char num_samples) +check_coverage_no_data (rl2PrivPixelPtr pxl_no_data, + unsigned char sample_type, unsigned char pixel_type, + unsigned char num_samples) { /* checking if the NoData pixel is consistent with the Coverage */ if (pxl_no_data == NULL) return 1; if (pxl_no_data->sampleType != sample_type) @@ -1253,12 +1254,12 @@ RL2_DECLARE rl2RasterPtr rl2_create_raster (unsigned int width, unsigned int height, unsigned char sample_type, unsigned char pixel_type, unsigned char num_samples, unsigned char *bufpix, - int bufpix_size, rl2PalettePtr palette, unsigned char *mask, - int mask_size, rl2PixelPtr no_data) + int bufpix_size, rl2PalettePtr palette, + unsigned char *mask, int mask_size, rl2PixelPtr no_data) { /* allocating and initializing a Raster object with an optional Transparency Mask */ return create_raster_common (width, height, sample_type, pixel_type, num_samples, bufpix, bufpix_size, palette, mask, mask_size, no_data, 0); @@ -1430,12 +1431,13 @@ rst->maxY = cy + vExt; return RL2_OK; } RL2_DECLARE int -rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid, double horz_res, - double vert_res, double x, double y) +rl2_raster_georeference_upper_left (rl2RasterPtr ptr, int srid, + double horz_res, double vert_res, + double x, double y) { /* setting the Raster's georeferencing infos - UpperLeft corner */ rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr; double hExt; double vExt; @@ -1453,12 +1455,12 @@ return RL2_OK; } RL2_DECLARE int rl2_raster_georeference_upper_right (rl2RasterPtr ptr, int srid, - double horz_res, double vert_res, double x, - double y) + double horz_res, double vert_res, + double x, double y) { /* setting the Raster's georeferencing infos - UpperRight corner */ rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr; double hExt; double vExt; @@ -1475,12 +1477,13 @@ rst->maxY = y; return RL2_OK; } RL2_DECLARE int -rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid, double horz_res, - double vert_res, double x, double y) +rl2_raster_georeference_lower_left (rl2RasterPtr ptr, int srid, + double horz_res, double vert_res, + double x, double y) { /* setting the Raster's georeferencing infos - LowerLeft corner */ rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr; double hExt; double vExt; @@ -1498,12 +1501,12 @@ return RL2_OK; } RL2_DECLARE int rl2_raster_georeference_lower_right (rl2RasterPtr ptr, int srid, - double horz_res, double vert_res, double x, - double y) + double horz_res, double vert_res, + double x, double y) { /* setting the Raster's georeferencing infos - LowerRight corner */ rl2PrivRasterPtr rst = (rl2PrivRasterPtr) ptr; double hExt; double vExt; @@ -1805,12 +1808,12 @@ entry->blue = b; return RL2_OK; } RL2_DECLARE int -rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index, unsigned char r, - unsigned char g, unsigned char b) +rl2_get_palette_index (rl2PalettePtr ptr, unsigned char *index, + unsigned char r, unsigned char g, unsigned char b) { /* finding the index corresponding to the given color (if any) */ int i; rl2PrivPaletteEntryPtr entry; rl2PrivPalettePtr plt = (rl2PrivPalettePtr) ptr; Index: src/rl2ascii.c ================================================================== --- src/rl2ascii.c +++ src/rl2ascii.c @@ -318,12 +318,12 @@ fprintf (stderr, "ASCII Origin: invalid Header found on %s\n", path); goto error; } ascii = - alloc_ascii_origin (path, srid, sample_type, width, height, minx, miny, - maxx, maxy, xres, yres, no_data); + alloc_ascii_origin (path, srid, sample_type, width, height, minx, + miny, maxx, maxy, xres, yres, no_data); if (ascii == NULL) goto error; *buf = '\0'; col_no = width; @@ -616,12 +616,12 @@ { if (verbose) fprintf (stderr, "Mismatching SRID !!!\n"); return RL2_FALSE; } - if (rl2_get_ascii_grid_origin_resolution (ascii, &hResolution, &vResolution) - != RL2_OK) + if (rl2_get_ascii_grid_origin_resolution + (ascii, &hResolution, &vResolution) != RL2_OK) return RL2_FALSE; confidence = coverage->hResolution / 100.0; if (hResolution < (coverage->hResolution - confidence) || hResolution > (coverage->hResolution + confidence)) { @@ -750,12 +750,12 @@ return 0; for (x = 0, col = startCol; x < width && col < origin->width; x++, col++) { unsigned short uint16; - if (fread (&uint16, sizeof (unsigned short), 1, origin->tmp) <= - 0) + if (fread (&uint16, sizeof (unsigned short), 1, origin->tmp) + <= 0) return 0; *p_out++ = uint16; } } return 1; @@ -1070,12 +1070,12 @@ } } } raster = rl2_create_raster (coverage->tileWidth, coverage->tileHeight, - coverage->sampleType, RL2_PIXEL_DATAGRID, 1, pixels, - pixels_sz, NULL, mask, mask_size, NULL); + coverage->sampleType, RL2_PIXEL_DATAGRID, 1, + pixels, pixels_sz, NULL, mask, mask_size, NULL); if (raster == NULL) goto error; return raster; error: if (pixels != NULL) Index: src/rl2auxfont.c ================================================================== --- src/rl2auxfont.c +++ src/rl2auxfont.c @@ -692,12 +692,12 @@ if (xfont != NULL) { free (xfont); xfont = NULL; } - if (rl2_font_decode (blob, blob_sz, &xfont, &xfont_sz) == - RL2_OK) + if (rl2_font_decode (blob, blob_sz, &xfont, &xfont_sz) + == RL2_OK) { *font = xfont; *font_sz = xfont_sz; } } @@ -725,11 +725,10 @@ /* attempting to fetch a BLOB-encoded TrueType Font */ const char *sql; int ret; sqlite3_stmt *stmt = NULL; unsigned char *xfont = NULL; - int xfont_sz; if (facename == NULL) return RL2_ERROR; *font = NULL; *font_sz = 0; Index: src/rl2auxgeom.c ================================================================== --- src/rl2auxgeom.c +++ src/rl2auxgeom.c @@ -124,15 +124,19 @@ { /* LINESTRING object constructor */ rl2LinestringPtr p = malloc (sizeof (rl2Linestring)); p->coords = malloc (sizeof (double) * (vert * 2)); p->points = vert; + p->minx = DBL_MAX; + p->miny = DBL_MAX; + p->maxx = 0.0 - DBL_MAX; + p->maxy = 0.0 - DBL_MAX; p->next = NULL; return p; } -static void +RL2_PRIVATE void rl2DestroyLinestring (rl2LinestringPtr ptr) { /* LINESTRING object desctructror */ if (ptr) { @@ -139,23 +143,83 @@ if (ptr->coords) free (ptr->coords); free (ptr); } } + +RL2_PRIVATE rl2LinestringPtr +rl2_linestring_to_image (rl2LinestringPtr line, int height, double minx, + double miny, double x_res, double y_res) +{ +/* creating a Linestring in image coordinates */ + rl2LinestringPtr out = NULL; + int iv; + double x; + double y; + double dx; + double dy; + + if (line == NULL) + return NULL; + out = rl2CreateLinestring (line->points); + if (out == NULL) + return out; + for (iv = 0; iv < line->points; iv++) + { + /* populating the X and Y arrays */ + rl2GetPoint (line->coords, iv, &x, &y); + dx = (x - minx) / x_res; + dy = (double) height - ((y - miny) / y_res); + rl2SetPoint (out->coords, iv, dx, dy); + } + return out; +} static rl2RingPtr rl2CreateRing (int vert) { /* ring object constructor */ rl2RingPtr p = malloc (sizeof (rl2Ring)); p->coords = malloc (sizeof (double) * (vert * 2)); p->points = vert; + p->minx = DBL_MAX; + p->miny = DBL_MAX; + p->maxx = 0.0 - DBL_MAX; + p->maxy = 0.0 - DBL_MAX; p->next = NULL; return p; } -static void +RL2_PRIVATE rl2RingPtr +rl2_ring_to_image (rl2RingPtr ring, int height, double minx, double miny, + double x_res, double y_res) +{ +/* creating a Ring in image coordinates */ + rl2RingPtr out = NULL; + int iv; + double x; + double y; + double dx; + double dy; + + if (ring == NULL) + return NULL; + out = rl2CreateRing (ring->points); + if (out == NULL) + return out; + for (iv = 0; iv < ring->points; iv++) + { + /* populating the X and Y arrays */ + rl2GetPoint (ring->coords, iv, &x, &y); + dx = (x - minx) / x_res; + dy = (double) height - ((y - miny) / y_res); + rl2SetPoint (out->coords, iv, dx, dy); + } + return out; +} + +RL2_PRIVATE void rl2DestroyRing (rl2RingPtr ptr) { /* ring object destructor */ if (ptr) { @@ -624,10 +688,18 @@ for (iv = 0; iv < points; iv++) { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; *offset += 16; } } static void @@ -650,10 +722,18 @@ for (iv = 0; iv < points; iv++) { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; *offset += 24; } } static void @@ -676,10 +756,18 @@ for (iv = 0; iv < points; iv++) { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; *offset += 24; } } static void @@ -702,10 +790,18 @@ for (iv = 0; iv < points; iv++) { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; *offset += 32; } } static rl2PolygonPtr @@ -767,10 +863,18 @@ { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); *offset += 16; rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; } } } static void @@ -809,10 +913,18 @@ { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); *offset += 24; rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; } } } static void @@ -851,10 +963,18 @@ { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); *offset += 24; rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; } } } static void @@ -893,10 +1013,18 @@ { x = rl2GeomImport64 (blob + *offset, endian, endian_arch); y = rl2GeomImport64 (blob + (*offset + 8), endian, endian_arch); *offset += 32; rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; } } } static void @@ -938,10 +1066,18 @@ x = last_x + fx; y = last_y + fy; *offset += 8; } rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; last_x = x; last_y = y; } } @@ -984,10 +1120,18 @@ x = last_x + fx; y = last_y + fy; *offset += 12; } rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; last_x = x; last_y = y; } } @@ -1030,10 +1174,18 @@ x = last_x + fx; y = last_y + fy; *offset += 16; } rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; last_x = x; last_y = y; } } @@ -1076,10 +1228,18 @@ x = last_x + fx; y = last_y + fy; *offset += 20; } rl2SetPoint (line->coords, iv, x, y); + if (x < line->minx) + line->minx = x; + if (x > line->maxx) + line->maxx = x; + if (y < line->miny) + line->miny = y; + if (y > line->maxy) + line->maxy = y; last_x = x; last_y = y; } } @@ -1139,10 +1299,18 @@ x = last_x + fx; y = last_y + fy; *offset += 8; } rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; last_x = x; last_y = y; } } } @@ -1203,10 +1371,18 @@ x = last_x + fx; y = last_y + fy; *offset += 12; } rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; last_x = x; last_y = y; } } } @@ -1267,10 +1443,18 @@ x = last_x + fx; y = last_y + fy; *offset += 16; } rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; last_x = x; last_y = y; } } } @@ -1331,10 +1515,18 @@ x = last_x + fx; y = last_y + fy; *offset += 20; } rl2SetPoint (ring->coords, iv, x, y); + if (x < ring->minx) + ring->minx = x; + if (x > ring->maxx) + ring->maxx = x; + if (y < ring->miny) + ring->miny = y; + if (y > ring->maxy) + ring->maxy = y; last_x = x; last_y = y; } } } @@ -1401,20 +1593,20 @@ case GAIA_COMPRESSED_LINESTRING: rl2ParseCompressedLine (geom, blob, size, endian, endian_arch, offset); break; case GAIA_COMPRESSED_LINESTRINGZ: - rl2ParseCompressedLineZ (geom, blob, size, endian, endian_arch, - offset); + rl2ParseCompressedLineZ (geom, blob, size, endian, + endian_arch, offset); break; case GAIA_COMPRESSED_LINESTRINGM: - rl2ParseCompressedLineM (geom, blob, size, endian, endian_arch, - offset); + rl2ParseCompressedLineM (geom, blob, size, endian, + endian_arch, offset); break; case GAIA_COMPRESSED_LINESTRINGZM: - rl2ParseCompressedLineZM (geom, blob, size, endian, endian_arch, - offset); + rl2ParseCompressedLineZM (geom, blob, size, endian, + endian_arch, offset); break; case GAIA_COMPRESSED_POLYGON: rl2ParseCompressedPolygon (geom, blob, size, endian, endian_arch, offset); break; @@ -1508,20 +1700,20 @@ case GAIA_POLYGONZM: rl2ParsePolygonZM (geom, blob, size, little_endian, endian_arch, &offset); break; case GAIA_COMPRESSED_LINESTRING: - rl2ParseCompressedLine (geom, blob, size, little_endian, endian_arch, - &offset); + rl2ParseCompressedLine (geom, blob, size, little_endian, + endian_arch, &offset); break; case GAIA_COMPRESSED_LINESTRINGZ: - rl2ParseCompressedLineZ (geom, blob, size, little_endian, endian_arch, - &offset); + rl2ParseCompressedLineZ (geom, blob, size, little_endian, + endian_arch, &offset); break; case GAIA_COMPRESSED_LINESTRINGM: - rl2ParseCompressedLineM (geom, blob, size, little_endian, endian_arch, - &offset); + rl2ParseCompressedLineM (geom, blob, size, little_endian, + endian_arch, &offset); break; case GAIA_COMPRESSED_LINESTRINGZM: rl2ParseCompressedLineZM (geom, blob, size, little_endian, endian_arch, &offset); break; @@ -1721,10 +1913,71 @@ ptr += 16; } *ptr = GAIA_MARK_END; /* END signature */ return 1; } + +RL2_PRIVATE int +rl2_serialize_ring_as_linestring (rl2RingPtr ring, unsigned char **result, + int *size) +{ +/* serializing a BLOB Geometry - polygon ring as linestring */ + int iv; + unsigned char *ptr; + int endian_arch = rl2GeomEndianArch (); + double minx = DBL_MAX; + double maxx = 0.0 - DBL_MAX; + double miny = DBL_MAX; + double maxy = 0.0 - DBL_MAX; + double x; + double y; + + *result = NULL; + *size = 0; + if (ring == NULL) + return 0; + +/* computing the MBR */ + for (iv = 0; iv < ring->points; iv++) + { + rl2GetPoint (ring->coords, iv, &x, &y); + if (x < minx) + minx = x; + if (x > maxx) + maxx = x; + if (y < miny) + miny = y; + if (y > maxy) + maxy = y; + } +/* computing the size of BLOB */ + *size = 44; /* header size */ + *size += (4 + ((sizeof (double) * 2) * ring->points)); /* # points + [x,y] for each vertex */ + *result = malloc (*size); + ptr = *result; +/* building the BLOB */ + *ptr = GAIA_MARK_START; /* START signature */ + *(ptr + 1) = GAIA_LITTLE_ENDIAN; /* byte ordering */ + rl2GeomExport32 (ptr + 2, 4326, 1, endian_arch); /* the SRID */ + rl2GeomExport64 (ptr + 6, minx, 1, endian_arch); /* MBR - minimum X */ + rl2GeomExport64 (ptr + 14, miny, 1, endian_arch); /* MBR - minimum Y */ + rl2GeomExport64 (ptr + 22, maxx, 1, endian_arch); /* MBR - maximum X */ + rl2GeomExport64 (ptr + 30, maxy, 1, endian_arch); /* MBR - maximum Y */ + *(ptr + 38) = GAIA_MARK_MBR; /* MBR signature */ + rl2GeomExport32 (ptr + 39, GAIA_LINESTRING, 1, endian_arch); /* class LINESTRING */ + rl2GeomExport32 (ptr + 43, ring->points, 1, endian_arch); /* # points */ + ptr += 47; + for (iv = 0; iv < ring->points; iv++) + { + rl2GetPoint (ring->coords, iv, &x, &y); + rl2GeomExport64 (ptr, x, 1, endian_arch); + rl2GeomExport64 (ptr + 8, y, 1, endian_arch); + ptr += 16; + } + *ptr = GAIA_MARK_END; /* END signature */ + return 1; +} RL2_PRIVATE rl2GeometryPtr rl2_curve_from_XY (int points, double *x, double *y) { /* creating a Linestring Geometry from X,Y coordinate arrays */ @@ -1736,10 +1989,18 @@ return 0; geom = rl2CreateGeometry (); ln = rl2AddLinestringToGeometry (geom, points); for (iv = 0; iv < points; iv++) rl2SetPoint (ln->coords, iv, *(x + iv), *(y + iv)); + if (*(x + iv) < ln->minx) + ln->minx = *(x + iv); + if (*(x + iv) > ln->maxx) + ln->maxx = *(x + iv); + if (*(y + iv) < ln->miny) + ln->miny = *(y + iv); + if (*(y + iv) > ln->maxy) + ln->maxy = *(y + iv); return geom; } RL2_PRIVATE double rl2_compute_curve_length (rl2GeometryPtr geom) @@ -1852,10 +2113,18 @@ { double x; double y; rl2GetPoint (ln_in->coords, iv, &x, &y); rl2SetPoint (ln_out->coords, iv, x, y); + if (x < ln_out->minx) + ln_out->minx = x; + if (x > ln_out->maxx) + ln_out->maxx = x; + if (y < ln_out->miny) + ln_out->miny = y; + if (y > ln_out->maxy) + ln_out->maxy = y; } return out; } RL2_PRIVATE rl2GeometryPtr @@ -1872,18 +2141,26 @@ { double x; double y; rl2GetPoint (in->coords, iv, &x, &y); rl2SetPoint (ln_out->coords, iv, x, y); + if (x < ln_out->minx) + ln_out->minx = x; + if (x > ln_out->maxx) + ln_out->maxx = x; + if (y < ln_out->miny) + ln_out->miny = y; + if (y > ln_out->maxy) + ln_out->maxy = y; } return out; } RL2_PRIVATE rl2GeometryPtr rl2_build_circle (double cx, double cy, double radius) { -/* creating a cicrle */ +/* creating a circle */ int iv = 0; double pi = 3.14159265359; double rads; double x; double y; @@ -1893,12 +2170,20 @@ for (rads = 0.0; rads <= (pi * 2.0); rads += pi / 64.0) { x = cx + (radius * cos (rads)); y = cy + (radius * sin (rads)); rl2SetPoint (ln->coords, iv, x, y); + if (x < ln->minx) + ln->minx = x; + if (x > ln->maxx) + ln->maxx = x; + if (y < ln->miny) + ln->miny = y; + if (y > ln->maxy) + ln->maxy = y; iv++; } /* closure */ rl2GetPoint (ln->coords, 0, &x, &y); rl2SetPoint (ln->coords, 128, x, y); return out; } Index: src/rl2auxrender.c ================================================================== --- src/rl2auxrender.c +++ src/rl2auxrender.c @@ -290,12 +290,13 @@ } } static void copy_palette (unsigned char *rgba, unsigned int width, unsigned int height, - unsigned char *inbuf, rl2PalettePtr palette, unsigned char bg_red, - unsigned char bg_green, unsigned char bg_blue) + unsigned char *inbuf, rl2PalettePtr palette, + unsigned char bg_red, unsigned char bg_green, + unsigned char bg_blue) { /* copying from Palette to RGBA */ unsigned int x; unsigned int y; rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette; @@ -452,12 +453,12 @@ if (aux->base_width == aux->width && aux->base_height == aux->height) { if (aux->out_pixel == RL2_PIXEL_MONOCHROME) { /* Monochrome */ - copy_monochrome (aggreg_rgba, aux->base_width, aux->base_height, - aux->outbuf); + copy_monochrome (aggreg_rgba, aux->base_width, + aux->base_height, aux->outbuf); aux->outbuf = NULL; } else if (aux->out_pixel == RL2_PIXEL_PALETTE) { /* Palette */ @@ -467,12 +468,12 @@ aux->outbuf = NULL; } else if (aux->out_pixel == RL2_PIXEL_GRAYSCALE) { /* Grayscale */ - copy_grayscale (aggreg_rgba, aux->base_width, aux->base_height, - aux->outbuf, aux->bg_red); + copy_grayscale (aggreg_rgba, aux->base_width, + aux->base_height, aux->outbuf, aux->bg_red); aux->outbuf = NULL; } else { /* RGB */ @@ -609,12 +610,12 @@ else { if (!get_payload_from_monochrome_opaque (aux->base_width, aux->base_height, aux->sqlite, aux->minx, aux->miny, aux->maxx, aux->maxy, - aux->srid, aux->outbuf, aux->format_id, aux->quality, - &image, &image_size)) + aux->srid, aux->outbuf, aux->format_id, + aux->quality, &image, &image_size)) { aux->outbuf = NULL; goto error; } } @@ -638,12 +639,12 @@ else { if (!get_payload_from_palette_opaque (aux->base_width, aux->base_height, aux->sqlite, aux->minx, aux->miny, aux->maxx, aux->maxy, - aux->srid, aux->outbuf, aux->palette, aux->format_id, - aux->quality, &image, &image_size)) + aux->srid, aux->outbuf, aux->palette, + aux->format_id, aux->quality, &image, &image_size)) { aux->outbuf = NULL; goto error; } } @@ -666,12 +667,12 @@ else { if (!get_payload_from_grayscale_opaque (aux->base_width, aux->base_height, aux->sqlite, aux->minx, aux->miny, aux->maxx, aux->maxy, - aux->srid, aux->outbuf, aux->format_id, aux->quality, - &image, &image_size)) + aux->srid, aux->outbuf, aux->format_id, + aux->quality, &image, &image_size)) { aux->outbuf = NULL; goto error; } } @@ -695,12 +696,12 @@ else { if (!get_payload_from_rgb_opaque (aux->base_width, aux->base_height, aux->sqlite, aux->minx, aux->miny, aux->maxx, aux->maxy, - aux->srid, aux->outbuf, aux->format_id, aux->quality, - &image, &image_size)) + aux->srid, aux->outbuf, aux->format_id, + aux->quality, &image, &image_size)) { aux->outbuf = NULL; goto error; } } @@ -771,12 +772,12 @@ { /* Grayscale */ if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG) { if (!get_rgba_from_grayscale_transparent - (aux->base_width, aux->base_height, aux->outbuf, rgba, - aux->bg_red)) + (aux->base_width, aux->base_height, aux->outbuf, + rgba, aux->bg_red)) { aux->outbuf = NULL; goto error; } } @@ -796,12 +797,12 @@ { /* RGB */ if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG) { if (!get_rgba_from_rgb_transparent - (aux->base_width, aux->base_height, aux->outbuf, rgba, - aux->bg_red, aux->bg_green, aux->bg_blue)) + (aux->base_width, aux->base_height, aux->outbuf, + rgba, aux->bg_red, aux->bg_green, aux->bg_blue)) { aux->outbuf = NULL; goto error; } } @@ -840,12 +841,13 @@ if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG) { if (alpha == NULL) goto error; if (!get_payload_from_gray_rgba_transparent - (aux->width, aux->height, rgb, alpha, aux->format_id, - aux->quality, &image, &image_size, aux->opacity)) + (aux->width, aux->height, rgb, alpha, + aux->format_id, aux->quality, &image, &image_size, + aux->opacity)) goto error; } else { if (alpha != NULL) @@ -864,12 +866,13 @@ if (aux->transparent && aux->format_id == RL2_OUTPUT_FORMAT_PNG) { if (alpha == NULL) goto error; if (!get_payload_from_rgb_rgba_transparent - (aux->width, aux->height, rgb, alpha, aux->format_id, - aux->quality, &image, &image_size, aux->opacity, 0)) + (aux->width, aux->height, rgb, alpha, + aux->format_id, aux->quality, &image, &image_size, + aux->opacity, 0)) goto error; } else { if (alpha != NULL) @@ -980,12 +983,12 @@ return 0; scale_factor = rl2_get_shaded_relief_scale_factor (aux->sqlite, coverage); if (rl2_build_shaded_relief_mask (aux->sqlite, aux->max_threads, aux->coverage, relief_factor, - scale_factor, aux->base_width, aux->base_height, aux->minx, aux->miny, - aux->maxx, aux->maxy, aux->xx_res, aux->yy_res, &shr_mask, + scale_factor, aux->base_width, aux->base_height, aux->minx, + aux->miny, aux->maxx, aux->maxy, aux->xx_res, aux->yy_res, &shr_mask, &shr_size) != RL2_OK) return 0; /* allocating the RGBA buffer */ rgba = malloc (aux->base_width * aux->base_height * 4); @@ -1536,11 +1539,12 @@ rl2CoveragePtr cvg, unsigned int width, unsigned int height, double minx, double miny, double maxx, double maxy, double x_res, - double y_res, unsigned char **buffer, + double y_res, + unsigned char **buffer, int *buf_size, rl2PalettePtr * palette, unsigned char *out_pixel, unsigned char bg_red, unsigned char bg_green, @@ -1747,201 +1751,31 @@ if (outbuf != NULL) free (outbuf); return RL2_ERROR; } -static rl2GraphicsPatternPtr -load_external_graphic_from_dbms (sqlite3 * handle, rl2PrivGraphicPtr graphic) -{ -/* attempting to load an External Graphic from the DBMS */ - int ret; - sqlite3_stmt *stmt = NULL; - const char *sql; - const char *xlink_href = NULL; - rl2GraphicsPatternPtr pattern = NULL; - rl2PrivGraphicItemPtr item; - - if (graphic == NULL) - return NULL; - /* searching for an xlink_href pseudo-URL */ - item = graphic->first; - while (item != NULL) - { - if (item->type == RL2_EXTERNAL_GRAPHIC && item->item != NULL) - { - rl2PrivExternalGraphicPtr ext = - (rl2PrivExternalGraphicPtr) (item->item); - if (ext->xlink_href != NULL) - { - xlink_href = ext->xlink_href; - break; - } - } - item = item->next; - } - if (xlink_href == NULL) - return NULL; - - sql = "SELECT resource, GetMimeType(resource) FROM SE_external_graphics " - "WHERE xlink_href = ?"; - ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); - if (ret != SQLITE_OK) - return NULL; - - sqlite3_reset (stmt); - sqlite3_clear_bindings (stmt); - sqlite3_bind_text (stmt, 1, xlink_href, strlen (xlink_href), SQLITE_STATIC); - while (1) - { - /* scrolling the result set rows */ - ret = sqlite3_step (stmt); - if (ret == SQLITE_DONE) - break; /* end of result set */ - if (ret == SQLITE_ROW) - { - rl2RasterPtr raster = NULL; - if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB - && sqlite3_column_type (stmt, 1) == SQLITE_TEXT) - { - const unsigned char *blob = sqlite3_column_blob (stmt, 0); - int blob_sz = sqlite3_column_bytes (stmt, 0); - const char *mime_type = - (const char *) sqlite3_column_text (stmt, 1); - if (strcmp (mime_type, "image/gif") == 0) - raster = rl2_raster_from_gif (blob, blob_sz); - if (strcmp (mime_type, "image/png") == 0) - raster = rl2_raster_from_png (blob, blob_sz, 1); - if (strcmp (mime_type, "image/jpeg") == 0) - raster = rl2_raster_from_jpeg (blob, blob_sz); - if (strcmp (mime_type, "image/tiff") == 0) - raster = rl2_raster_from_tiff (blob, blob_sz); - } - if (raster != NULL) - { - unsigned char *rgba; - int rgba_sz; - unsigned int width; - unsigned int height; - if (rl2_get_raster_size (raster, &width, &height) != - RL2_OK) - { - rl2_destroy_raster (raster); - goto error; - } - if (rl2_raster_data_to_RGBA (raster, &rgba, &rgba_sz) != - RL2_OK) - { - rl2_destroy_raster (raster); - goto error; - } - pattern = - rl2_graph_create_pattern (rgba, width, height, 0); - rl2_destroy_raster (raster); - } - } - else - { - fprintf (stderr, "SQL error: %s\n%s\n", sql, - sqlite3_errmsg (handle)); - goto error; - } - } - return pattern; - - error: - if (stmt != NULL) - sqlite3_finalize (stmt); - return NULL; -} - -static rl2GraphicsBitmapPtr -load_external_bitmap_from_dbms (sqlite3 * handle, const char *xlink_href) -{ -/* attempting to load an External Graphic from the DBMS */ - int ret; - sqlite3_stmt *stmt = NULL; - const char *sql; - rl2GraphicsBitmapPtr bitmap = NULL; - - if (xlink_href == NULL) - return NULL; - - sql = "SELECT resource, GetMimeType(resource) FROM SE_external_graphics " - "WHERE xlink_href = ?"; - ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); - if (ret != SQLITE_OK) - return NULL; - - sqlite3_reset (stmt); - sqlite3_clear_bindings (stmt); - sqlite3_bind_text (stmt, 1, xlink_href, strlen (xlink_href), SQLITE_STATIC); - while (1) - { - /* scrolling the result set rows */ - ret = sqlite3_step (stmt); - if (ret == SQLITE_DONE) - break; /* end of result set */ - if (ret == SQLITE_ROW) - { - rl2RasterPtr raster = NULL; - if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB - && sqlite3_column_type (stmt, 1) == SQLITE_TEXT) - { - const unsigned char *blob = sqlite3_column_blob (stmt, 0); - int blob_sz = sqlite3_column_bytes (stmt, 0); - const char *mime_type = - (const char *) sqlite3_column_text (stmt, 1); - if (strcmp (mime_type, "image/gif") == 0) - raster = rl2_raster_from_gif (blob, blob_sz); - if (strcmp (mime_type, "image/png") == 0) - raster = rl2_raster_from_png (blob, blob_sz, 1); - if (strcmp (mime_type, "image/jpeg") == 0) - raster = rl2_raster_from_jpeg (blob, blob_sz); - if (strcmp (mime_type, "image/tiff") == 0) - raster = rl2_raster_from_tiff (blob, blob_sz); - } - if (raster != NULL) - { - unsigned char *rgba; - int rgba_sz; - unsigned int width; - unsigned int height; - if (rl2_get_raster_size (raster, &width, &height) != - RL2_OK) - { - rl2_destroy_raster (raster); - goto error; - } - if (rl2_raster_data_to_RGBA (raster, &rgba, &rgba_sz) != - RL2_OK) - { - rl2_destroy_raster (raster); - goto error; - } - bitmap = rl2_graph_create_bitmap (rgba, width, height); - rl2_destroy_raster (raster); - } - } - else - { - fprintf (stderr, "SQL error: %s\n%s\n", sql, - sqlite3_errmsg (handle)); - goto error; - } - } - return bitmap; - - error: - if (stmt != NULL) - sqlite3_finalize (stmt); - return NULL; +static int +point_bbox_matches (rl2PointPtr point, double minx, double miny, double maxx, + double maxy) +{ +/* checks if the Point is visible */ + if (minx > point->x) + return 0; + if (maxx < point->x) + return 0; + if (miny > point->y) + return 0; + if (maxy < point->y) + return 0; + return 1; } static void draw_points (rl2GraphicsContextPtr ctx, sqlite3 * handle, rl2PrivVectorSymbolizerPtr sym, int height, double minx, - double miny, double x_res, double y_res, rl2GeometryPtr geom) + double miny, double maxx, double maxy, double x_res, + double y_res, rl2GeometryPtr geom) { /* drawing Point-type features */ rl2PrivVectorSymbolizerItemPtr item; rl2PointPtr point; @@ -1970,11 +1804,11 @@ int stroke = 0; int pen_cap; int pen_join; double opacity; unsigned char norm_opacity; - rl2GraphicsBitmapPtr pattern = NULL; + rl2GraphicsPatternPtr pattern = NULL; rl2GraphicsPatternPtr pattern_fill = NULL; rl2GraphicsPatternPtr pattern_stroke = NULL; if (graphic->type == RL2_MARK_GRAPHIC) { @@ -1987,19 +1821,101 @@ if (mark->fill != NULL) { if (mark->fill->graphic != NULL) { /* external Graphic fill */ - pattern_fill = - load_external_graphic_from_dbms - (handle, mark->fill->graphic); + const char *xlink_href = NULL; + int recolor = 0; + unsigned char red; + unsigned char green; + unsigned char blue; + pattern_fill = NULL; + if (mark->fill->graphic->first != + NULL) + { + if (mark->fill-> + graphic->first->type == + RL2_EXTERNAL_GRAPHIC) + { + rl2PrivExternalGraphicPtr + ext = + (rl2PrivExternalGraphicPtr) + (mark-> + fill->graphic-> + first->item); + xlink_href = + ext->xlink_href; + if (ext->first != + NULL) + { + recolor = 1; + red = + ext-> + first->red; + green = + ext-> + first->green; + blue = + ext-> + first->blue; + } + } + } + if (xlink_href != NULL) + pattern_fill = + rl2_create_pattern_from_external_graphic + (handle, xlink_href, 1); if (pattern_fill != NULL) { + if (recolor) + { + /* attempting to recolor the External Graphic resource */ + rl2_graph_pattern_recolor + (pattern_fill, + red, green, + blue); + } + if (mark->fill->opacity <= + 0.0) + norm_opacity = 0; + else if (mark-> + fill->opacity >= + 1.0) + norm_opacity = 255; + else + { + opacity = + 255.0 * + mark-> + fill->opacity; + if (opacity <= 0.0) + norm_opacity = 0; + else if (opacity >= + 255.0) + norm_opacity = + 255; + else + norm_opacity = + opacity; + } + if (norm_opacity < 1.0) + rl2_graph_pattern_transparency + (pattern_fill, + norm_opacity); rl2_graph_set_pattern_brush (ctx, pattern_fill); - fill = 1; + } + else + { + /* invalid Pattern: defaulting to a Gray brush */ + rl2_graph_set_brush (ctx, + 128, + 128, + 128, + 255); } + fill = 1; } else { /* solid RGB fill */ if (gr->opacity <= 0.0) @@ -2030,74 +1946,153 @@ } if (mark->stroke != NULL) { if (mark->stroke->graphic != NULL) { - /* external Graphic stroke */ - pattern_stroke = - load_external_graphic_from_dbms - (handle, - mark->stroke->graphic); - if (pattern_stroke != NULL) + const char *xlink_href = NULL; + int recolor = 0; + unsigned char red; + unsigned char green; + unsigned char blue; + pattern_stroke = NULL; + if (mark->stroke-> + graphic->first != NULL) { - switch (mark-> - stroke->linecap) + if (mark->stroke-> + graphic->first->type == + RL2_EXTERNAL_GRAPHIC) { - case RL2_STROKE_LINECAP_ROUND: - pen_cap = - RL2_PEN_CAP_ROUND; - break; - case RL2_STROKE_LINECAP_SQUARE: - pen_cap = - RL2_PEN_CAP_SQUARE; - break; - default: - pen_cap = - RL2_PEN_CAP_BUTT; - break; - }; - switch (mark-> - stroke->linejoin) + rl2PrivExternalGraphicPtr + ext = + (rl2PrivExternalGraphicPtr) + (mark-> + stroke->graphic-> + first->item); + xlink_href = + ext->xlink_href; + if (ext->first != + NULL) + { + recolor = 1; + red = + ext-> + first->red; + green = + ext-> + first->green; + blue = + ext-> + first->blue; + } + } + } + if (xlink_href != NULL) + pattern_stroke = + rl2_create_pattern_from_external_graphic + (handle, xlink_href, 1); + if (pattern != NULL) + { + if (recolor) { - case RL2_STROKE_LINEJOIN_BEVEL: - pen_join = - RL2_PEN_JOIN_BEVEL; - break; - case RL2_STROKE_LINEJOIN_ROUND: - pen_join = - RL2_PEN_JOIN_ROUND; - break; - default: - pen_join = - RL2_PEN_JOIN_MITER; - break; - }; - if (mark-> - stroke->dash_count > 0 - && mark-> - stroke->dash_list != - NULL) - rl2_graph_set_pattern_dashed_pen - (ctx, - pattern_stroke, - mark-> - stroke->width, - pen_cap, pen_join, - mark-> - stroke->dash_count, - mark-> - stroke->dash_list, - mark-> - stroke->dash_offset); + /* attempting to recolor the External Graphic resource */ + rl2_graph_pattern_recolor + (pattern_stroke, + red, green, + blue); + } + if (mark->stroke->opacity <= + 0.0) + norm_opacity = 0; + else if (mark-> + stroke->opacity >= + 1.0) + norm_opacity = 255; else - rl2_graph_set_pattern_solid_pen - (ctx, - pattern_stroke, - mark-> - stroke->width, - pen_cap, pen_join); - stroke = 1; + { + opacity = + 255.0 * + mark-> + stroke->opacity; + if (opacity <= 0.0) + norm_opacity = 0; + else if (opacity >= + 255.0) + norm_opacity = + 255; + else + norm_opacity = + opacity; + } + if (norm_opacity < 1.0) + rl2_graph_pattern_transparency + (pattern_stroke, + norm_opacity); + if (pattern_stroke != NULL) + { + switch + (mark-> + stroke->linecap) + { + case RL2_STROKE_LINECAP_ROUND: + pen_cap = + RL2_PEN_CAP_ROUND; + break; + case RL2_STROKE_LINECAP_SQUARE: + pen_cap = + RL2_PEN_CAP_SQUARE; + break; + default: + pen_cap = + RL2_PEN_CAP_BUTT; + break; + }; + switch + (mark-> + stroke->linejoin) + { + case RL2_STROKE_LINEJOIN_BEVEL: + pen_join = + RL2_PEN_JOIN_BEVEL; + break; + case RL2_STROKE_LINEJOIN_ROUND: + pen_join = + RL2_PEN_JOIN_ROUND; + break; + default: + pen_join = + RL2_PEN_JOIN_MITER; + break; + }; + if (mark-> + stroke->dash_count + > 0 + && mark-> + stroke->dash_list + != NULL) + rl2_graph_set_pattern_dashed_pen + (ctx, + pattern_stroke, + mark-> + stroke->width, + pen_cap, + pen_join, + mark-> + stroke->dash_count, + mark-> + stroke->dash_list, + mark-> + stroke->dash_offset); + else + rl2_graph_set_pattern_solid_pen + (ctx, + pattern_stroke, + mark-> + stroke->width, + pen_cap, + pen_join); + stroke = 1; + } } } else { /* solid RGB stroke */ @@ -2153,236 +2148,384 @@ mark->stroke->blue, norm_opacity, mark->stroke->width, pen_cap, pen_join, - mark->stroke->dash_count, - mark->stroke->dash_list, - mark->stroke->dash_offset); + mark-> + stroke->dash_count, + mark-> + stroke->dash_list, + mark-> + stroke->dash_offset); else - rl2_graph_set_solid_pen (ctx, - mark->stroke->red, - mark->stroke->green, - mark->stroke->blue, - norm_opacity, - mark->stroke->width, - pen_cap, - pen_join); + rl2_graph_set_solid_pen + (ctx, mark->stroke->red, + mark->stroke->green, + mark->stroke->blue, + norm_opacity, + mark->stroke->width, + pen_cap, pen_join); stroke = 1; } } } } if (graphic->type == RL2_EXTERNAL_GRAPHIC) { rl2PrivExternalGraphicPtr ext = (rl2PrivExternalGraphicPtr) (graphic->item); + const char *xlink_href = NULL; + int recolor = 0; + unsigned char red; + unsigned char green; + unsigned char blue; + pattern = NULL; if (ext != NULL) { is_external = 1; - pattern = - load_external_bitmap_from_dbms (handle, - ext->xlink_href); + if (ext->xlink_href != NULL) + xlink_href = ext->xlink_href; + if (ext->first != NULL) + { + recolor = 1; + red = ext->first->red; + green = ext->first->green; + blue = ext->first->blue; + } + if (xlink_href != NULL) + { + /* first attempt: Bitmap */ + pattern = + rl2_create_pattern_from_external_graphic + (handle, xlink_href, 1); + if (pattern == NULL) + { + /* second attempt: SVG */ + pattern = + rl2_create_pattern_from_external_svg + (handle, xlink_href, + point_sym->graphic->size); + } + } + } + if (pattern != NULL) + { + if (recolor) + { + /* attempting to recolor the External Graphic resource */ + rl2_graph_pattern_recolor (pattern, + red, green, + blue); + } + if (point_sym->graphic->opacity <= 0.0) + norm_opacity = 0; + else if (point_sym->graphic->opacity >= 1.0) + norm_opacity = 255; + else + { + opacity = + 255.0 * point_sym->graphic->opacity; + if (opacity <= 0.0) + norm_opacity = 0; + else if (opacity >= 255.0) + norm_opacity = 255; + else + norm_opacity = opacity; + } + if (norm_opacity < 1.0) + rl2_graph_pattern_transparency + (pattern, norm_opacity); + rl2_graph_set_pattern_brush (ctx, pattern); + } + else + { + /* invalid Pattern: defaulting to a Gray brush */ + rl2_graph_set_brush (ctx, 128, 128, 128, 255); } } /* actual Point rendering */ point = geom->first_point; while (point) { /* drawing a POINT */ - double x = (point->x - minx) / x_res; - double y = - (double) height - ((point->y - miny) / y_res); - double size2 = gr->size / 2.0; - double size4 = gr->size / 4.0; - double size6 = gr->size / 6.0; - double size13 = gr->size / 3.0; - double size23 = (gr->size / 3.0) * 2.0; - int i; - double rads; - if (size2 <= 0.0) - size2 = 1.0; - if (size4 <= 0.0) - size4 = 1.0; - if (size6 <= 0.0) - size6 = 1.0; - if (size13 <= 0.0) - size13 = 1.0; - if (size23 <= 0.0) - size23 = 1.0; - if (is_mark) - { - /* drawing a well-known Mark */ - switch (well_known_type) - { - case RL2_GRAPHIC_MARK_CIRCLE: - rads = 0.0; - for (i = 0; i < 32; i++) + if (point_bbox_matches + (point, minx, miny, maxx, maxy)) + { + double x = (point->x - minx) / x_res; + double y = + (double) height - + ((point->y - miny) / y_res); + double size2 = gr->size / 2.0; + double size4 = gr->size / 4.0; + double size6 = gr->size / 6.0; + double size13 = gr->size / 3.0; + double size23 = (gr->size / 3.0) * 2.0; + int i; + double rads; + if (size2 <= 0.0) + size2 = 1.0; + if (size4 <= 0.0) + size4 = 1.0; + if (size6 <= 0.0) + size6 = 1.0; + if (size13 <= 0.0) + size13 = 1.0; + if (size23 <= 0.0) + size23 = 1.0; + if (is_mark) + { + /* drawing a well-known Mark */ + switch (well_known_type) { - double tic = 6.28318530718 / 32.0; - double cx = - x + (size2 * sin (rads)); - double cy = - y + (size2 * cos (rads)); - if (i == 0) - rl2_graph_move_to_point (ctx, - cx, - cy); - else - rl2_graph_add_line_to_path - (ctx, cx, cy); - rads += tic; - } - rl2_graph_close_subpath (ctx); - break; - case RL2_GRAPHIC_MARK_TRIANGLE: - rl2_graph_move_to_point (ctx, x, - y - size23); - rl2_graph_add_line_to_path (ctx, - x - size2, - y + size13); - rl2_graph_add_line_to_path (ctx, - x + size2, - y + size13); - rl2_graph_close_subpath (ctx); - break; - case RL2_GRAPHIC_MARK_STAR: - rads = 3.14159265359; - for (i = 0; i < 10; i++) + case RL2_GRAPHIC_MARK_CIRCLE: + rads = 0.0; + for (i = 0; i < 32; i++) + { + double tic = + 6.28318530718 / 32.0; + double cx = + x + + (size2 * sin (rads)); + double cy = + y + + (size2 * cos (rads)); + if (i == 0) + rl2_graph_move_to_point + (ctx, cx, cy); + else + rl2_graph_add_line_to_path + (ctx, cx, cy); + rads += tic; + } + rl2_graph_close_subpath (ctx); + break; + case RL2_GRAPHIC_MARK_TRIANGLE: + rl2_graph_move_to_point (ctx, x, + y - + size23); + rl2_graph_add_line_to_path (ctx, + x - + size2, + y + + size13); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y + + size13); + rl2_graph_close_subpath (ctx); + break; + case RL2_GRAPHIC_MARK_STAR: + rads = 3.14159265359; + for (i = 0; i < 10; i++) + { + double tic = + (i % 2) ? size6 : size2; + double cx = + x + (tic * sin (rads)); + double cy = + y + (tic * cos (rads)); + if (i == 0) + rl2_graph_move_to_point + (ctx, cx, cy); + else + rl2_graph_add_line_to_path + (ctx, cx, cy); + rads += 0.628318530718; + } + rl2_graph_close_subpath (ctx); + break; + case RL2_GRAPHIC_MARK_CROSS: + rl2_graph_move_to_point (ctx, + x - + size6, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x + + size6, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x + + size6, + y - + size6); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y - + size6); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y + + size6); + rl2_graph_add_line_to_path (ctx, + x + + size6, + y + + size6); + rl2_graph_add_line_to_path (ctx, + x + + size6, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x - + size6, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x - + size6, + y + + size6); + rl2_graph_add_line_to_path (ctx, + x - + size2, + y + + size6); + rl2_graph_add_line_to_path (ctx, + x - + size2, + y - + size6); + rl2_graph_add_line_to_path (ctx, + x - + size6, + y - + size6); + rl2_graph_close_subpath (ctx); + break; + case RL2_GRAPHIC_MARK_X: + rl2_graph_move_to_point (ctx, + x - + size2, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x - + size4, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x, + y - + size6); + rl2_graph_add_line_to_path (ctx, + x + + size6, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x + + size4, + y); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x + + size4, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x, + y + + size6); + rl2_graph_add_line_to_path (ctx, + x - + size6, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x - + size2, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x - + size4, + y); + rl2_graph_close_subpath (ctx); + break; + case RL2_GRAPHIC_MARK_SQUARE: + default: + rl2_graph_move_to_point (ctx, + x - + size2, + y - + size2); + rl2_graph_add_line_to_path (ctx, + x - + size2, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y + + size2); + rl2_graph_add_line_to_path (ctx, + x + + size2, + y - + size2); + rl2_graph_close_subpath (ctx); + break; + }; + if (fill) { - double tic = - (i % 2) ? size6 : size2; - double cx = - x + (tic * sin (rads)); - double cy = - y + (tic * cos (rads)); - if (i == 0) - rl2_graph_move_to_point (ctx, - cx, - cy); + if (stroke) + rl2_graph_fill_path (ctx, + RL2_PRESERVE_PATH); else - rl2_graph_add_line_to_path - (ctx, cx, cy); - rads += 0.628318530718; + rl2_graph_fill_path (ctx, + RL2_CLEAR_PATH); } - rl2_graph_close_subpath (ctx); - break; - case RL2_GRAPHIC_MARK_CROSS: - rl2_graph_move_to_point (ctx, x - size6, - y - size2); - rl2_graph_add_line_to_path (ctx, - x + size6, - y - size2); - rl2_graph_add_line_to_path (ctx, - x + size6, - y - size6); - rl2_graph_add_line_to_path (ctx, - x + size2, - y - size6); - rl2_graph_add_line_to_path (ctx, - x + size2, - y + size6); - rl2_graph_add_line_to_path (ctx, - x + size6, - y + size6); - rl2_graph_add_line_to_path (ctx, - x + size6, - y + size2); - rl2_graph_add_line_to_path (ctx, - x - size6, - y + size2); - rl2_graph_add_line_to_path (ctx, - x - size6, - y + size6); - rl2_graph_add_line_to_path (ctx, - x - size2, - y + size6); - rl2_graph_add_line_to_path (ctx, - x - size2, - y - size6); - rl2_graph_add_line_to_path (ctx, - x - size6, - y - size6); - rl2_graph_close_subpath (ctx); - break; - case RL2_GRAPHIC_MARK_X: - rl2_graph_move_to_point (ctx, x - size2, - y - size2); - rl2_graph_add_line_to_path (ctx, - x - size4, - y - size2); - rl2_graph_add_line_to_path (ctx, x, - y - size6); - rl2_graph_add_line_to_path (ctx, - x + size6, - y - size2); - rl2_graph_add_line_to_path (ctx, - x + size2, - y - size2); - rl2_graph_add_line_to_path (ctx, - x + size4, - y); - rl2_graph_add_line_to_path (ctx, - x + size2, - y + size2); - rl2_graph_add_line_to_path (ctx, - x + size4, - y + size2); - rl2_graph_add_line_to_path (ctx, x, - y + size6); - rl2_graph_add_line_to_path (ctx, - x - size6, - y + size2); - rl2_graph_add_line_to_path (ctx, - x - size2, - y + size2); - rl2_graph_add_line_to_path (ctx, - x - size4, - y); - rl2_graph_close_subpath (ctx); - break; - case RL2_GRAPHIC_MARK_SQUARE: - default: - rl2_graph_move_to_point (ctx, x - size2, - y - size2); - rl2_graph_add_line_to_path (ctx, - x - size2, - y + size2); - rl2_graph_add_line_to_path (ctx, - x + size2, - y + size2); - rl2_graph_add_line_to_path (ctx, - x + size2, - y - size2); - rl2_graph_close_subpath (ctx); - break; - }; - if (fill) - { if (stroke) - rl2_graph_fill_path (ctx, - RL2_PRESERVE_PATH); - else - rl2_graph_fill_path (ctx, - RL2_CLEAR_PATH); + rl2_graph_stroke_path (ctx, + RL2_CLEAR_PATH); } - if (stroke) - rl2_graph_stroke_path (ctx, - RL2_CLEAR_PATH); - } - if (is_external && pattern != NULL) - { - /* drawing an External Graphic bitmap */ - rl2_graph_draw_bitmap (ctx, pattern, x, y); + if (is_external && pattern != NULL) + { + /* drawing an External Graphic pattern */ + unsigned int width; + unsigned int height; + rl2_graph_get_pattern_size (pattern, + &width, + &height); + double out_width = width; + double out_height = height; + rl2_graph_draw_graphic_symbol (ctx, + pattern, + out_width, + out_height, + x + + point_sym->graphic->displacement_x, + y - + point_sym->graphic->displacement_y, + point_sym->graphic->rotation, + point_sym->graphic->anchor_point_x, + point_sym->graphic->anchor_point_y); + } } point = point->next; } /* releasing Patterns */ if (pattern != NULL) - rl2_graph_destroy_bitmap (pattern); + rl2_graph_destroy_pattern (pattern); if (pattern_fill != NULL) { rl2_graph_release_pattern_pen (ctx); rl2_graph_destroy_pattern (pattern_fill); } @@ -2395,15 +2538,32 @@ } } item = item->next; } } + +static int +linestring_bbox_matches (rl2LinestringPtr ring, double minx, double miny, + double maxx, double maxy) +{ +/* checks if the Linestring BBOX is visible */ + if (minx > ring->maxx) + return 0; + if (maxx < ring->minx) + return 0; + if (miny > ring->maxy) + return 0; + if (maxy < ring->miny) + return 0; + return 1; +} static void draw_lines (rl2GraphicsContextPtr ctx, sqlite3 * handle, rl2PrivVectorSymbolizerPtr sym, int height, double minx, - double miny, double x_res, double y_res, rl2GeometryPtr geom) + double miny, double maxx, double maxy, double x_res, double y_res, + rl2GeometryPtr geom) { /* drawing Linear-type features */ rl2PrivVectorSymbolizerItemPtr item; int pen_cap; int pen_join; @@ -2423,38 +2583,66 @@ if (line_sym->stroke != NULL) { if (line_sym->stroke->graphic != NULL) { /* external Graphic stroke */ - pattern = load_external_graphic_from_dbms (handle, - line_sym->stroke->graphic); + const char *xlink_href = NULL; + int recolor = 0; + unsigned char red; + unsigned char green; + unsigned char blue; + pattern = NULL; + if (line_sym->stroke->graphic->first != NULL) + { + if (line_sym->stroke->graphic->first->type == + RL2_EXTERNAL_GRAPHIC) + { + rl2PrivExternalGraphicPtr ext = + (rl2PrivExternalGraphicPtr) + (line_sym->stroke->graphic-> + first->item); + xlink_href = ext->xlink_href; + if (ext->first != NULL) + { + recolor = 1; + red = ext->first->red; + green = ext->first->green; + blue = ext->first->blue; + } + } + } + if (xlink_href != NULL) + pattern = + rl2_create_pattern_from_external_graphic + (handle, xlink_href, 1); if (pattern != NULL) { - switch (line_sym->stroke->linecap) - { - case RL2_STROKE_LINECAP_ROUND: - pen_cap = RL2_PEN_CAP_ROUND; - break; - case RL2_STROKE_LINECAP_SQUARE: - pen_cap = RL2_PEN_CAP_SQUARE; - break; - default: - pen_cap = RL2_PEN_CAP_BUTT; - break; - }; - switch (line_sym->stroke->linejoin) - { - case RL2_STROKE_LINEJOIN_BEVEL: - pen_join = RL2_PEN_JOIN_BEVEL; - break; - case RL2_STROKE_LINEJOIN_ROUND: - pen_join = RL2_PEN_JOIN_ROUND; - break; - default: - pen_join = RL2_PEN_JOIN_MITER; - break; - }; + if (recolor) + { + /* attempting to recolor the External Graphic resource */ + rl2_graph_pattern_recolor (pattern, + red, green, + blue); + } + if (line_sym->stroke->opacity <= 0.0) + norm_opacity = 0; + else if (line_sym->stroke->opacity >= 1.0) + norm_opacity = 255; + else + { + opacity = + 255.0 * line_sym->stroke->opacity; + if (opacity <= 0.0) + norm_opacity = 0; + else if (opacity >= 255.0) + norm_opacity = 255; + else + norm_opacity = opacity; + } + if (norm_opacity < 1.0) + rl2_graph_pattern_transparency + (pattern, norm_opacity); if (line_sym->stroke->dash_count > 0 && line_sym->stroke->dash_list != NULL) rl2_add_pattern_to_multi_stroke_dash (multi_stroke, pattern, line_sym->stroke->width, pen_cap, @@ -2466,10 +2654,15 @@ rl2_add_pattern_to_multi_stroke (multi_stroke, pattern, line_sym->stroke->width, pen_cap, pen_join); } + else + { + /* invalid Pattern: defaulting to a Gray brush */ + rl2_graph_set_brush (ctx, 128, 128, 128, 255); + } } else { /* solid RGB stroke */ if (line_sym->stroke->opacity <= 0.0) @@ -2549,105 +2742,127 @@ line = geom->first_linestring; while (line) { /* drawing a LINESTRING */ - rl2PrivMultiStrokeItemPtr stroke_item; - int iv; - double dx; - double dy; - int x; - int y; - int lastX = 0; - int lastY = 0; - for (iv = 0; iv < line->points; iv++) - { - rl2GetPoint (line->coords, iv, &dx, &dy); - x = (int) ((dx - minx) / x_res); - y = height - (int) ((dy - miny) / y_res); - if (iv == 0) - { - rl2_graph_move_to_point (ctx, x, y); - lastX = x; - lastY = y; - } - else - { - if (x == lastX && y == lastY) - ; - else - { - rl2_graph_add_line_to_path (ctx, x, y); + if (linestring_bbox_matches (line, minx, miny, maxx, maxy)) + { + rl2PrivMultiStrokeItemPtr stroke_item; + int iv; + double dx; + double dy; + int x; + int y; + int lastX = 0; + int lastY = 0; + for (iv = 0; iv < line->points; iv++) + { + rl2GetPoint (line->coords, iv, &dx, &dy); + x = (int) ((dx - minx) / x_res); + y = height - (int) ((dy - miny) / y_res); + if (iv == 0) + { + rl2_graph_move_to_point (ctx, x, y); lastX = x; lastY = y; } - } - } - stroke_item = multi_stroke->first; - while (stroke_item != NULL) - { - /* applying all strokes, one after the other */ - if (stroke_item->dash_count > 0 - && stroke_item->dash_list != NULL) - { - if (stroke_item->pattern != NULL) - rl2_graph_set_pattern_dashed_pen (ctx, - stroke_item->pattern, - stroke_item->width, - stroke_item->pen_cap, - stroke_item->pen_join, - stroke_item->dash_count, - stroke_item->dash_list, - stroke_item->dash_offset); + else + { + if (x == lastX && y == lastY) + ; + else + { + rl2_graph_add_line_to_path (ctx, x, y); + lastX = x; + lastY = y; + } + } + } + stroke_item = multi_stroke->first; + while (stroke_item != NULL) + { + /* applying all strokes, one after the other */ + if (stroke_item->dash_count > 0 + && stroke_item->dash_list != NULL) + { + if (stroke_item->pattern != NULL) + rl2_graph_set_pattern_dashed_pen (ctx, + stroke_item->pattern, + stroke_item->width, + stroke_item->pen_cap, + stroke_item->pen_join, + stroke_item->dash_count, + stroke_item->dash_list, + stroke_item->dash_offset); + else + rl2_graph_set_dashed_pen (ctx, + stroke_item->red, + stroke_item->green, + stroke_item->blue, + stroke_item->opacity, + stroke_item->width, + stroke_item->pen_cap, + stroke_item->pen_join, + stroke_item->dash_count, + stroke_item->dash_list, + stroke_item->dash_offset); + } else - rl2_graph_set_dashed_pen (ctx, stroke_item->red, - stroke_item->green, - stroke_item->blue, - stroke_item->opacity, - stroke_item->width, - stroke_item->pen_cap, - stroke_item->pen_join, - stroke_item->dash_count, - stroke_item->dash_list, - stroke_item->dash_offset); - } - else - { - if (stroke_item->pattern != NULL) - rl2_graph_set_pattern_solid_pen (ctx, - stroke_item->pattern, - stroke_item->width, - stroke_item->pen_cap, - stroke_item->pen_join); + { + if (stroke_item->pattern != NULL) + rl2_graph_set_pattern_solid_pen (ctx, + stroke_item->pattern, + stroke_item->width, + stroke_item->pen_cap, + stroke_item->pen_join); + else + rl2_graph_set_solid_pen (ctx, + stroke_item->red, + stroke_item->green, + stroke_item->blue, + stroke_item->opacity, + stroke_item->width, + stroke_item->pen_cap, + stroke_item->pen_join); + } + + if (stroke_item == multi_stroke->last) + rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH); else - rl2_graph_set_solid_pen (ctx, stroke_item->red, - stroke_item->green, - stroke_item->blue, - stroke_item->opacity, - stroke_item->width, - stroke_item->pen_cap, - stroke_item->pen_join); + rl2_graph_stroke_path (ctx, RL2_PRESERVE_PATH); + + stroke_item = stroke_item->next; + if (stroke_item == multi_stroke->last) + rl2_graph_release_pattern_pen (ctx); } - - if (stroke_item == multi_stroke->last) - rl2_graph_stroke_path (ctx, RL2_CLEAR_PATH); - else - rl2_graph_stroke_path (ctx, RL2_PRESERVE_PATH); - - stroke_item = stroke_item->next; - if (stroke_item == multi_stroke->last) - rl2_graph_release_pattern_pen (ctx); } line = line->next; } rl2_destroy_multi_stroke (multi_stroke); } + +static int +ring_bbox_matches (rl2RingPtr ring, double minx, double miny, double maxx, + double maxy) +{ +/* checks if the Ring BBOX is visible */ + if (minx > ring->maxx) + return 0; + if (maxx < ring->minx) + return 0; + if (miny > ring->maxy) + return 0; + if (maxy < ring->miny) + return 0; + return 1; +} static void draw_polygons (rl2GraphicsContextPtr ctx, sqlite3 * handle, rl2PrivVectorSymbolizerPtr sym, int height, double minx, - double miny, double x_res, double y_res, rl2GeometryPtr geom) + double miny, double maxx, double maxy, double x_res, + double y_res, rl2GeometryPtr geom) { /* drawing Polygonal-type features */ rl2PrivVectorSymbolizerItemPtr item; int stroke = 0; int fill = 0; @@ -2706,13 +2921,12 @@ if (pattern_fill != NULL) { if (recolor) { /* attempting to recolor the External Graphic resource */ - rl2_graph_pattern_recolor (pattern_fill, - red, green, - blue); + rl2_graph_pattern_recolor + (pattern_fill, red, green, blue); } if (polyg_sym->fill->opacity <= 0.0) norm_opacity = 0; else if (polyg_sym->fill->opacity >= 1.0) norm_opacity = 255; @@ -2767,59 +2981,74 @@ if (polyg_sym->stroke != NULL) { if (polyg_sym->stroke->graphic != NULL) { /* external Graphic stroke */ - pattern_stroke = - load_external_graphic_from_dbms (handle, - polyg_sym->stroke->graphic); + const char *xlink_href = NULL; + int recolor = 0; + unsigned char red; + unsigned char green; + unsigned char blue; + pattern_stroke = NULL; + if (polyg_sym->stroke->graphic->first != NULL) + { + if (polyg_sym->stroke->graphic->first->type == + RL2_EXTERNAL_GRAPHIC) + { + rl2PrivExternalGraphicPtr ext = + (rl2PrivExternalGraphicPtr) + (polyg_sym->stroke->graphic-> + first->item); + xlink_href = ext->xlink_href; + if (ext->first != NULL) + { + recolor = 1; + red = ext->first->red; + green = ext->first->green; + blue = ext->first->blue; + } + } + } + if (xlink_href != NULL) + pattern_stroke = + rl2_create_pattern_from_external_graphic + (handle, xlink_href, 1); if (pattern_stroke != NULL) { - switch (polyg_sym->stroke->linecap) + if (recolor) { - case RL2_STROKE_LINECAP_ROUND: - pen_cap = RL2_PEN_CAP_ROUND; - break; - case RL2_STROKE_LINECAP_SQUARE: - pen_cap = RL2_PEN_CAP_SQUARE; - break; - default: - pen_cap = RL2_PEN_CAP_BUTT; - break; - }; - switch (polyg_sym->stroke->linejoin) + /* attempting to recolor the External Graphic resource */ + rl2_graph_pattern_recolor + (pattern_stroke, red, green, blue); + } + if (polyg_sym->stroke->opacity <= 0.0) + norm_opacity = 0; + else if (polyg_sym->stroke->opacity >= 1.0) + norm_opacity = 255; + else { - case RL2_STROKE_LINEJOIN_BEVEL: - pen_join = RL2_PEN_JOIN_BEVEL; - break; - case RL2_STROKE_LINEJOIN_ROUND: - pen_join = RL2_PEN_JOIN_ROUND; - break; - default: - pen_join = RL2_PEN_JOIN_MITER; - break; - }; - if (polyg_sym->stroke->dash_count > 0 - && polyg_sym->stroke->dash_list != NULL) - rl2_graph_set_pattern_dashed_pen (ctx, - pattern_stroke, - polyg_sym-> - stroke->width, - pen_cap, - pen_join, - polyg_sym->stroke->dash_count, - polyg_sym->stroke->dash_list, - polyg_sym->stroke->dash_offset); - else - rl2_graph_set_pattern_solid_pen (ctx, - pattern_stroke, - polyg_sym-> - stroke->width, - pen_cap, - pen_join); - stroke = 1; + opacity = + 255.0 * polyg_sym->stroke->opacity; + if (opacity <= 0.0) + norm_opacity = 0; + else if (opacity >= 255.0) + norm_opacity = 255; + else + norm_opacity = opacity; + } + if (norm_opacity < 1.0) + rl2_graph_pattern_transparency + (pattern_stroke, norm_opacity); + rl2_graph_set_pattern_brush (ctx, + pattern_stroke); + } + else + { + /* invalid Pattern: defaulting to a Gray brush */ + rl2_graph_set_brush (ctx, 128, 128, 128, 255); } + stroke = 1; } else { /* solid RGB stroke */ if (polyg_sym->stroke->opacity <= 0.0) @@ -2912,38 +3141,12 @@ int lastX = 0; int lastY = 0; int ib; rl2RingPtr ring = polyg->exterior; /* exterior border */ - for (iv = 0; iv < ring->points; iv++) + if (ring_bbox_matches (ring, minx, miny, maxx, maxy)) { - rl2GetPoint (ring->coords, iv, &dx, &dy); - x = (int) ((dx - minx) / x_res); - y = height - (int) ((dy - miny) / y_res); - if (iv == 0) - { - rl2_graph_move_to_point (ctx, x, y); - lastX = x; - lastY = y; - } - else - { - if (x == lastX && y == lastY) - ; - else - { - rl2_graph_add_line_to_path (ctx, x, y); - lastX = x; - lastY = y; - } - } - } - rl2_graph_close_subpath (ctx); - for (ib = 0; ib < polyg->num_interiors; ib++) - { - /* interior borders */ - ring = polyg->interiors + ib; for (iv = 0; iv < ring->points; iv++) { rl2GetPoint (ring->coords, iv, &dx, &dy); x = (int) ((dx - minx) / x_res); y = height - (int) ((dy - miny) / y_res); @@ -2964,10 +3167,49 @@ lastY = y; } } } rl2_graph_close_subpath (ctx); + } + else + { + /* if the exterior ring is invisible we'll ignore all internal rings */ + polyg = polyg->next; + continue; + } + for (ib = 0; ib < polyg->num_interiors; ib++) + { + /* interior borders */ + ring = polyg->interiors + ib; + if (ring_bbox_matches (ring, minx, miny, maxx, maxy)) + { + for (iv = 0; iv < ring->points; iv++) + { + rl2GetPoint (ring->coords, iv, &dx, &dy); + x = (int) ((dx - minx) / x_res); + y = height - (int) ((dy - miny) / y_res); + if (iv == 0) + { + rl2_graph_move_to_point (ctx, x, y); + lastX = x; + lastY = y; + } + else + { + if (x == lastX && y == lastY) + ; + else + { + rl2_graph_add_line_to_path (ctx, + x, y); + lastX = x; + lastY = y; + } + } + } + rl2_graph_close_subpath (ctx); + } } if (fill) { if (stroke) rl2_graph_fill_path (ctx, RL2_PRESERVE_PATH); @@ -2991,12 +3233,12 @@ item = item->next; } } static int -label_get_xy (sqlite3 * handle, const unsigned char *blob, int size, double *x, - double *y) +label_get_xy (sqlite3 * handle, const unsigned char *blob, int size, + double *x, double *y) { /* resolving Point XY coords */ const char *sql; int ret; sqlite3_stmt *stmt = NULL; @@ -3063,11 +3305,12 @@ if (ret == SQLITE_ROW) { if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) { const unsigned char *g_blob = - (const unsigned char *) sqlite3_column_blob (stmt, 0); + (const unsigned char *) sqlite3_column_blob (stmt, + 0); int g_size = sqlite3_column_bytes (stmt, 0); if (label_get_xy (handle, g_blob, g_size, x, y)) ok = 1; } } @@ -3110,26 +3353,517 @@ if (ret == SQLITE_ROW) { if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) { const unsigned char *g_blob = - (const unsigned char *) sqlite3_column_blob (stmt, 0); + (const unsigned char *) sqlite3_column_blob (stmt, + 0); + int g_size = sqlite3_column_bytes (stmt, 0); + if (label_get_xy (handle, g_blob, g_size, x, y)) + ok = 1; + } + } + } + sqlite3_finalize (stmt); + return ok; +} + +static int +label_get_ring_midpoint (sqlite3 * handle, rl2RingPtr ring, double *x, + double *y) +{ +/* computing a Ring MidPoint */ + unsigned char *blob; + int blob_sz; + const char *sql; + int ret; + sqlite3_stmt *stmt = NULL; + int ok = 0; + + if (ring == NULL) + return 0; + if (!rl2_serialize_ring_as_linestring (ring, &blob, &blob_sz)) + return 0; + + sql = "SELECT ST_Line_Interpolate_Point(?, 0.5)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return 0; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_blob (stmt, 1, blob, blob_sz, free); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + { + if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) + { + const unsigned char *g_blob = + (const unsigned char *) sqlite3_column_blob (stmt, + 0); int g_size = sqlite3_column_bytes (stmt, 0); if (label_get_xy (handle, g_blob, g_size, x, y)) ok = 1; } } } sqlite3_finalize (stmt); return ok; } + +static rl2GeometryPtr +do_generalize_linestring (sqlite3 * handle, rl2LinestringPtr line, + double generalize_factor) +{ +/* simplifying a Linestring */ + rl2GeometryPtr geom = NULL; + unsigned char *blob; + int blob_sz; + const char *sql; + int ret; + sqlite3_stmt *stmt = NULL; + + if (line == NULL) + return NULL; + if (line->points < 2) + return NULL; + if (!rl2_serialize_linestring (line, &blob, &blob_sz)) + return NULL; + + sql = "SELECT ST_Simplify(?, ?)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return NULL; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_blob (stmt, 1, blob, blob_sz, free); + sqlite3_bind_double (stmt, 2, generalize_factor); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + { + if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) + { + const unsigned char *g_blob = + (const unsigned char *) sqlite3_column_blob (stmt, + 0); + int g_blob_sz = sqlite3_column_bytes (stmt, 0); + geom = rl2_geometry_from_blob (g_blob, g_blob_sz); + } + } + } + sqlite3_finalize (stmt); + return geom; +} + +static rl2GeometryPtr +do_generalize_ring (sqlite3 * handle, rl2RingPtr ring, double generalize_factor) +{ +/* simplifying a Ring */ + rl2GeometryPtr geom = NULL; + unsigned char *blob; + int blob_sz; + const char *sql; + int ret; + sqlite3_stmt *stmt = NULL; + + if (ring == NULL) + return NULL; + if (ring->points < 2) + return NULL; + if (!rl2_serialize_ring (ring, &blob, &blob_sz)) + return NULL; + + sql = "SELECT ST_SimplifyPreserveTopology(?, ?)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return NULL; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_blob (stmt, 1, blob, blob_sz, free); + sqlite3_bind_double (stmt, 2, generalize_factor); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + { + if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) + { + const unsigned char *g_blob = + (const unsigned char *) sqlite3_column_blob (stmt, + 0); + int g_blob_sz = sqlite3_column_bytes (stmt, 0); + geom = rl2_geometry_from_blob (g_blob, g_blob_sz); + } + } + } + sqlite3_finalize (stmt); + return geom; +} + +static int +check_valid_line (rl2LinestringPtr line) +{ +/* testing for a valid linestring */ + int iv; + int pts = 0; + double x; + double y; + double x0; + double y0; + + if (line == NULL) + return 0; + if (line->points < 2) + return 0; + rl2GetPoint (line->coords, 0, &x0, &y0); + for (iv = 1; iv < line->points; iv++) + { + rl2GetPoint (line->coords, iv, &x, &y); + if (x != x0 || y != y0) + { + pts++; + break; + } + } + if (pts == 0) + return 0; + return 1; +} + +static rl2GeometryPtr +do_offset_linestring (sqlite3 * handle, rl2LinestringPtr line, + double perpendicular_offset) +{ +/* Offest Curve (from Linestring) */ + rl2GeometryPtr geom = NULL; + unsigned char *blob; + int blob_sz; + const char *sql; + int ret; + sqlite3_stmt *stmt = NULL; + + if (!check_valid_line (line)) + return NULL; + if (!rl2_serialize_linestring (line, &blob, &blob_sz)) + return NULL; + + sql = "SELECT ST_OffsetCurve(?, ?)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return NULL; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_blob (stmt, 1, blob, blob_sz, free); + sqlite3_bind_double (stmt, 2, perpendicular_offset); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + { + if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) + { + const unsigned char *g_blob = + (const unsigned char *) sqlite3_column_blob (stmt, + 0); + int g_blob_sz = sqlite3_column_bytes (stmt, 0); + geom = rl2_geometry_from_blob (g_blob, g_blob_sz); + } + } + } + sqlite3_finalize (stmt); + return geom; +} + +static int +check_valid_ring (rl2RingPtr ring) +{ +/* testing for a valid ring */ + int iv; + int pts = 0; + int last; + double x; + double y; + double x0; + double y0; + double x1; + double y1; + + if (ring == NULL) + return 0; + if (ring->points < 4) + return 0; + rl2GetPoint (ring->coords, 0, &x0, &y0); + for (iv = 1; iv < ring->points; iv++) + { + rl2GetPoint (ring->coords, iv, &x, &y); + if (pts == 0) + { + if (x != x0 || y != y0) + { + pts++; + x1 = x; + y1 = y; + } + } + else + { + if ((x != x0 || y != y0) && (x != x1 || y != y1)) + { + pts++; + break; + } + } + } + last = ring->points - 1; + rl2GetPoint (ring->coords, last, &x1, &y1); + if (pts == 2 && x0 == x1 && y0 == y1) + return 1; + return 0; +} + +static rl2GeometryPtr +do_buffered_ring (sqlite3 * handle, rl2RingPtr ring, + double perpendicular_offset) +{ +/* Buffer (from Ring) */ + rl2GeometryPtr geom = NULL; + unsigned char *blob; + int blob_sz; + const char *sql; + int ret; + sqlite3_stmt *stmt = NULL; + + if (!check_valid_ring (ring)) + return NULL; + if (!rl2_serialize_ring (ring, &blob, &blob_sz)) + return NULL; + + sql = "SELECT ST_Buffer(?, ?)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return NULL; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_blob (stmt, 1, blob, blob_sz, free); + sqlite3_bind_double (stmt, 2, perpendicular_offset); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + { + if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB) + { + const unsigned char *g_blob = + (const unsigned char *) sqlite3_column_blob (stmt, + 0); + int g_blob_sz = sqlite3_column_bytes (stmt, 0); + geom = rl2_geometry_from_blob (g_blob, g_blob_sz); + } + } + } + sqlite3_finalize (stmt); + return geom; +} + +static void +create_line_array_from_linestring (sqlite3 * handle, rl2LinestringPtr line, + double perpendicular_offset, int *points, + double **x_array, double **y_array, + int generalize_line, + double generalize_factor, int height, + double minx, double miny, double x_res, + double y_res) +{ +/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */ + rl2GeometryPtr geom = NULL; + rl2GeometryPtr geom2 = NULL; + rl2LinestringPtr aux_line; + rl2LinestringPtr in_line; + double *xx = NULL; + double *yy = NULL; + int iv; + double x; + double y; + + *points = 0; + *x_array = NULL; + *y_array = NULL; + if (line == NULL) + goto error; + + aux_line = rl2_linestring_to_image (line, height, minx, miny, x_res, y_res); + if (aux_line == NULL) + goto error; + in_line = aux_line; + if (generalize_line) + { + geom = do_generalize_linestring (handle, in_line, generalize_factor); + if (geom == NULL) + goto error; + in_line = geom->first_linestring; + if (in_line == NULL) + goto error; + } + if (perpendicular_offset != 0.0) + { + geom2 = do_offset_linestring (handle, in_line, perpendicular_offset); + if (geom2 == NULL) + goto error; + in_line = geom2->first_linestring; + if (in_line == NULL) + goto error; + } + +/* allocating the X and Y arrays */ + if (in_line->points < 2) + goto error; + xx = malloc (sizeof (double) * in_line->points); + yy = malloc (sizeof (double) * in_line->points); + if (xx == NULL || yy == NULL) + { + if (xx != NULL) + free (xx); + if (yy != NULL) + free (yy); + goto error; + } + for (iv = 0; iv < in_line->points; iv++) + { + /* populating the X and Y arrays */ + rl2GetPoint (in_line->coords, iv, &x, &y); + *(xx + iv) = x; + *(yy + iv) = y; + } + *points = in_line->points; + *x_array = xx; + *y_array = yy; + + error: + if (aux_line) + rl2DestroyLinestring (aux_line); + if (geom) + rl2_destroy_geometry (geom); + if (geom2) + rl2_destroy_geometry (geom2); +} + +static void +create_line_array_from_ring (sqlite3 * handle, rl2RingPtr ring, + double perpendicular_offset, int *points, + double **x_array, double **y_array, + int generalize_line, double generalize_factor, + int height, double minx, double miny, double x_res, + double y_res) +{ +/* creating the X and Y arrays required by rl2_graph_draw_warped_text() */ + rl2GeometryPtr geom = NULL; + rl2GeometryPtr geom2 = NULL; + rl2PolygonPtr pg; + rl2RingPtr aux_ring; + rl2RingPtr in_ring; + double *xx = NULL; + double *yy = NULL; + int iv; + double x; + double y; + + *points = 0; + *x_array = NULL; + *y_array = NULL; + if (ring == NULL) + goto error; + + aux_ring = rl2_ring_to_image (ring, height, minx, miny, x_res, y_res); + if (aux_ring == NULL) + goto error; + in_ring = aux_ring; + if (generalize_line) + { + geom = do_generalize_ring (handle, in_ring, generalize_factor); + if (geom == NULL) + goto error; + pg = geom->first_polygon; + if (pg == NULL) + goto error; + in_ring = pg->exterior; + if (in_ring == NULL) + goto error; + } + if (perpendicular_offset != 0.0) + { + geom2 = do_buffered_ring (handle, in_ring, perpendicular_offset); + if (geom2 == NULL) + goto error; + pg = geom2->first_polygon; + if (pg == NULL) + goto error; + in_ring = pg->exterior; + if (in_ring == NULL) + goto error; + } + +/* allocating the X and Y arrays */ + if (in_ring->points < 2) + goto error; + xx = malloc (sizeof (double) * in_ring->points); + yy = malloc (sizeof (double) * in_ring->points); + if (xx == NULL || yy == NULL) + { + if (xx != NULL) + free (xx); + if (yy != NULL) + free (yy); + goto error; + } + for (iv = 0; iv < in_ring->points; iv++) + { + /* populating the X and Y arrays */ + rl2GetPoint (in_ring->coords, iv, &x, &y); + *(xx + iv) = x; + *(yy + iv) = y; + } + *points = in_ring->points; + *x_array = xx; + *y_array = yy; + + error: + if (aux_ring) + rl2DestroyRing (aux_ring); + if (geom) + rl2_destroy_geometry (geom); + if (geom2) + rl2_destroy_geometry (geom2); +} static void draw_labels (rl2GraphicsContextPtr ctx, sqlite3 * handle, - rl2PrivTextSymbolizerPtr sym, int height, double minx, double miny, - double x_res, double y_res, rl2GeometryPtr geom, - rl2PrivVariantValuePtr value) + const void *priv_data, rl2PrivTextSymbolizerPtr sym, int height, + double minx, double miny, double maxx, double maxy, double x_res, + double y_res, rl2GeometryPtr geom, rl2PrivVariantValuePtr value) { /* drawing TextLabels */ rl2GraphicsFontPtr font = NULL; char *dummy = NULL; const char *label = NULL; @@ -3138,10 +3872,22 @@ double opacity; unsigned char norm_opacity; rl2PointPtr point; rl2LinestringPtr line; rl2PolygonPtr polyg; + double rotation = 0.0; + double anchor_point_x = 0.0; + double anchor_point_y = 0.0; + double displacement_x = 0.0; + double displacement_y = 0.0; + double perpendicular_offset = 0.0; + int is_repeated = 0; + double initial_gap = 0.0; + double gap = 0.0; + int is_aligned = 0; + int generalize_line = 0; + int i; /* preparing the Text */ if (value->sqlite3_type == SQLITE_INTEGER) { dummy = sqlite3_malloc (1024); @@ -3184,13 +3930,28 @@ case RL2_FONT_WEIGHT_NORMAL: default: font_weight = RL2_FONTWEIGHT_NORMAL; break; }; - font = - rl2_graph_create_toy_font (NULL, sym->font_size, font_style, - font_weight); + for (i = 0; i < RL2_MAX_FONT_FAMILIES; i++) + { + const char *facename = sym->font_families[i]; + if (facename != NULL) + font = + rl2_search_TrueType_font (handle, priv_data, facename, + sym->font_size); + if (font != NULL) + break; + } + if (font == NULL) + { + /* defaulting to a toy font */ + fprintf (stderr, "default toy font\n"); + font = + rl2_graph_create_toy_font (NULL, sym->font_size, font_style, + font_weight); + } if (font == NULL) goto stop; if (sym->fill != NULL) { if (sym->fill->opacity <= 0.0) @@ -3225,101 +3986,304 @@ norm_opacity = 255; else norm_opacity = opacity; } rl2_graph_font_set_halo (font, sym->halo->radius, - sym->halo->fill->red, sym->halo->fill->green, + sym->halo->fill->red, + sym->halo->fill->green, sym->halo->fill->blue, norm_opacity); } rl2_graph_set_font (ctx, font); - polyg = geom->first_polygon; - while (polyg) + if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT) + { + /* retrieving eventual Point Placement arguments */ + rl2PrivPointPlacementPtr ptpl = + (rl2PrivPointPlacementPtr) (sym->label_placement); + if (ptpl != NULL) + { + anchor_point_x = ptpl->anchor_point_x; + anchor_point_y = ptpl->anchor_point_y; + displacement_x = ptpl->displacement_x; + displacement_y = ptpl->displacement_y; + rotation = ptpl->rotation; + } + } + else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE) + { + /* retrieving eventual Lineo Placement arguments */ + rl2PrivLinePlacementPtr lnpl = + (rl2PrivLinePlacementPtr) (sym->label_placement); + if (lnpl != NULL) + { + perpendicular_offset = lnpl->perpendicular_offset; + is_repeated = lnpl->is_repeated; + initial_gap = lnpl->initial_gap; + gap = lnpl->gap; + is_aligned = lnpl->is_aligned; + generalize_line = lnpl->generalize_line; + } + } + + if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT) { - /* drawing a POLYGON-based text label */ - double pre_x; - double pre_y; - double lbl_width = 0.0; - double lbl_height = 0.0; - double post_x; - double post_y; - double shift_x; - double shift_y; + /* POINT PLACEMENT */ + rl2Point pt; double cx; double cy; double x; double y; - if (!label_get_centroid (handle, polyg, &cx, &cy)) + + polyg = geom->first_polygon; + while (polyg) { + /* drawing a POLYGON-based text label */ + if (!label_get_centroid (handle, polyg, &cx, &cy)) + { + polyg = polyg->next; + continue; + } + pt.x = cx; + pt.y = cy; + if (point_bbox_matches (&pt, minx, miny, maxx, maxy)) + { + x = (cx - minx) / x_res; + y = (double) height - ((cy - miny) / y_res); + rl2_graph_draw_text (ctx, label, x + displacement_x, + y - displacement_y, rotation, + anchor_point_x, anchor_point_y); + } polyg = polyg->next; - continue; + } + + line = geom->first_linestring; + while (line) + { + /* drawing a LINESTRING-based text label */ + label_get_midpoint (handle, line, &cx, &cy); + pt.x = cx; + pt.y = cy; + if (point_bbox_matches (&pt, minx, miny, maxx, maxy)) + { + x = (cx - minx) / x_res; + y = (double) height - ((cy - miny) / y_res); + rl2_graph_draw_text (ctx, label, x + displacement_x, + y - displacement_y, rotation, + anchor_point_x, anchor_point_y); + } + line = line->next; + } + + point = geom->first_point; + while (point) + { + /* drawing a POINT-based text label */ + if (point_bbox_matches (point, minx, miny, maxx, maxy)) + { + double x = (point->x - minx) / x_res; + double y = (double) height - ((point->y - miny) / y_res); + rl2_graph_draw_text (ctx, label, x + displacement_x, + y - displacement_y, rotation, + anchor_point_x, anchor_point_y); + } + point = point->next; } - x = (cx - minx) / x_res; - y = (double) height - ((cy - miny) / y_res); - rl2_graph_get_text_extent (ctx, label, &pre_x, &pre_y, &lbl_width, - &lbl_height, &post_x, &post_y); - shift_x = 0.0 - (lbl_width / 2.0); - shift_y = 0.0 + (lbl_height / 2.0); - rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0, - 0.0); - polyg = polyg->next; + } - - line = geom->first_linestring; - while (line) + else if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE) { - /* drawing a LINESTRING-based text label */ - double pre_x; - double pre_y; - double lbl_width = 0.0; - double lbl_height = 0.0; - double post_x; - double post_y; - double shift_x; - double shift_y; + /* LINE PLACEMENT */ + rl2Point pt; + int ib; double cx; double cy; double x; double y; - label_get_midpoint (handle, line, &cx, &cy); - if (!rl2_graph_get_text_extent - (ctx, label, &pre_x, &pre_y, &lbl_width, &lbl_height, &post_x, - &post_y)) + double generalize_factor = 8.0; + + line = geom->first_linestring; + while (line) { + /* drawing a LINESTRING-based text label */ + if (!is_aligned) + { + /* horizontal label aligned to center point */ + label_get_midpoint (handle, line, &cx, &cy); + pt.x = cx; + pt.y = cy; + if (point_bbox_matches (&pt, minx, miny, maxx, maxy)) + { + x = (cx - minx) / x_res; + y = (double) height - ((cy - miny) / y_res); + rl2_graph_draw_text (ctx, label, x, y, 0.0, 0.5, + 0.5); + } + } + else + { + /* label is warped along the line */ + double *x_array = NULL; + double *y_array = NULL; + int points; + if (linestring_bbox_matches + (line, minx, miny, maxx, maxy)) + { + create_line_array_from_linestring (handle, line, + perpendicular_offset, + &points, + &x_array, + &y_array, + generalize_line, + generalize_factor, + height, minx, + miny, x_res, + y_res); + if (x_array != NULL && y_array != NULL) + rl2_graph_draw_warped_text (handle, ctx, label, + points, x_array, + y_array, + initial_gap, gap, + is_repeated); + if (x_array) + free (x_array); + if (y_array) + free (y_array); + } + } line = line->next; - continue; } - x = (cx - minx) / x_res; - y = (double) height - ((cy - miny) / y_res); - shift_x = 0.0 - (lbl_width / 2.0); - shift_y = 0.0 + (lbl_height / 2.0); - rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0, - 0.0); - line = line->next; - } - - point = geom->first_point; - while (point) - { - /* drawing a POINT-based text label */ - double pre_x; - double pre_y; - double lbl_width = 0.0; - double lbl_height = 0.0; - double post_x; - double post_y; - double shift_x; - double shift_y; - double x = (point->x - minx) / x_res; - double y = (double) height - ((point->y - miny) / y_res); - rl2_graph_get_text_extent (ctx, label, &pre_x, &pre_y, &lbl_width, - &lbl_height, &post_x, &post_y); - shift_x = 0.0 - (lbl_width / 2.0); - shift_y = 0.0 + (lbl_height / 2.0); - rl2_graph_draw_text (ctx, label, x + shift_x, y + shift_y, 0.0, 0.0, - 0.0); - point = point->next; + + polyg = geom->first_polygon; + while (polyg) + { + /* drawing a POLYGON-based text label */ + rl2RingPtr ring = polyg->exterior; + /* exterior border */ + if (ring_bbox_matches (ring, minx, miny, maxx, maxy)) + { + if (!is_aligned) + { + /* horizontal label aligned to Ring's center point */ + label_get_ring_midpoint (handle, ring, &cx, &cy); + pt.x = cx; + pt.y = cy; + if (point_bbox_matches + (&pt, minx, miny, maxx, maxy)) + { + x = (cx - minx) / x_res; + y = (double) height - ((cy - miny) / y_res); + rl2_graph_draw_text (ctx, label, x, y, 0.0, + 0.5, 0.5); + } + } + else + { + /* label is warped along the Ring */ + double *x_array = NULL; + double *y_array = NULL; + int points; + if (ring_bbox_matches + (ring, minx, miny, maxx, maxy)) + { + create_line_array_from_ring (handle, ring, + perpendicular_offset, + &points, + &x_array, + &y_array, + generalize_line, + generalize_factor, + height, minx, + miny, x_res, + y_res); + if (x_array != NULL && y_array != NULL) + { + rl2_graph_draw_warped_text (handle, ctx, + label, + points, + x_array, + y_array, + initial_gap, + gap, + is_repeated); + } + if (x_array) + free (x_array); + if (y_array) + free (y_array); + } + } + } + else + { + /* if the exterior ring is invisible we'll ignore all internal rings */ + polyg = polyg->next; + continue; + } + for (ib = 0; ib < polyg->num_interiors; ib++) + { + /* interior borders */ + ring = polyg->interiors + ib; + if (ring_bbox_matches (ring, minx, miny, maxx, maxy)) + { + if (!is_aligned) + { + /* horizontal label aligned to Ring's center point */ + label_get_ring_midpoint (handle, ring, &cx, + &cy); + pt.x = cx; + pt.y = cy; + if (point_bbox_matches + (&pt, minx, miny, maxx, maxy)) + { + x = (cx - minx) / x_res; + y = (double) height - + ((cy - miny) / y_res); + rl2_graph_draw_text (ctx, label, x, y, + 0.0, 0.5, 0.5); + } + } + else + { + /* label is warped along the Ring */ + double *x_array = NULL; + double *y_array = NULL; + int points; + if (ring_bbox_matches + (ring, minx, miny, maxx, maxy)) + { + create_line_array_from_ring (handle, + ring, + perpendicular_offset, + &points, + &x_array, + &y_array, + generalize_line, + generalize_factor, + height, + minx, miny, + x_res, + y_res); + if (x_array != NULL && y_array != NULL) + rl2_graph_draw_warped_text (handle, + ctx, + label, + points, + x_array, + y_array, + initial_gap, + gap, + is_repeated); + if (x_array) + free (x_array); + if (y_array) + free (y_array); + } + } + } + } + polyg = polyg->next; + } } /* final cleanup - relasing resources */ stop: if (dummy != NULL) @@ -3327,14 +4291,15 @@ if (font != NULL) rl2_graph_destroy_font (font); } RL2_PRIVATE void -rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle, +rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle, const void *priv_data, rl2VectorSymbolizerPtr symbolizer, int height, - double minx, double miny, double x_res, double y_res, - rl2GeometryPtr geom, rl2VariantArrayPtr variant) + double minx, double miny, double maxx, double maxy, + double x_res, double y_res, rl2GeometryPtr geom, + rl2VariantArrayPtr variant) { /* drawing a vector feature on the current canvass */ rl2PrivVectorSymbolizerItemPtr item; rl2GraphicsContextPtr ctx = (rl2GraphicsContextPtr) p_ctx; rl2PrivVectorSymbolizerPtr sym = (rl2PrivVectorSymbolizerPtr) symbolizer; @@ -3421,16 +4386,18 @@ sym = default_symbolizer; } /* we'll render all geometries first */ if (geom->first_polygon != NULL) - draw_polygons (ctx, handle, sym, height, minx, miny, x_res, y_res, - geom); + draw_polygons (ctx, handle, sym, height, minx, miny, maxx, maxy, + x_res, y_res, geom); if (geom->first_linestring != NULL) - draw_lines (ctx, handle, sym, height, minx, miny, x_res, y_res, geom); + draw_lines (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res, + y_res, geom); if (geom->first_point != NULL) - draw_points (ctx, handle, sym, height, minx, miny, x_res, y_res, geom); + draw_points (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res, + y_res, geom); if (sym != NULL) { /* then we'll render any eventual TextSymbolizer */ item = sym->first; @@ -3444,23 +4411,29 @@ if (text->label != NULL) { int v; rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant; - for (v = 0; v < var->count; v++) + if (var != NULL) { - rl2PrivVariantValuePtr val = - *(var->array + v); - if (val == NULL) - continue; - if (val->column_name == NULL) - continue; - if (strcasecmp (text->label, val->column_name) - != 0) - continue; - draw_labels (ctx, handle, text, height, minx, - miny, x_res, y_res, geom, val); + for (v = 0; v < var->count; v++) + { + rl2PrivVariantValuePtr val = + *(var->array + v); + if (val == NULL) + continue; + if (val->column_name == NULL) + continue; + if (strcasecmp + (text->label, + val->column_name) != 0) + continue; + draw_labels (ctx, handle, priv_data, + text, height, minx, miny, + maxx, maxy, x_res, y_res, + geom, val); + } } } } item = item->next; } @@ -3467,5 +4440,85 @@ } if (default_symbolizer != NULL) rl2_destroy_vector_symbolizer (default_symbolizer); } + +RL2_PRIVATE int +rl2_aux_default_image (unsigned int width, unsigned int height, + unsigned char red, unsigned char green, + unsigned char blue, int format, int transparent, + int quality, unsigned char **ximage, int *ximage_sz) +{ +/* creating a default image */ + unsigned int x; + unsigned int y; + unsigned char *pixels = malloc (width * height * 3); + unsigned char *po = pixels; + unsigned char *mask = NULL; + unsigned char *pm; + + *ximage = NULL; + *ximage_sz = 0; + if (pixels == NULL) + return 0; + + mask = malloc (width * height); + if (mask == NULL) + goto error; + pm = mask; + +/* priming the image buffer to background color */ + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + *po++ = red; + *po++ = green; + *po++ = blue; + if (mask != NULL) + *pm++ = 0; + } + } + + if (format == RL2_OUTPUT_FORMAT_PNG) + { + if (transparent) + { + if (rl2_rgb_alpha_to_png + (width, height, pixels, mask, ximage, ximage_sz, + 1.0) != RL2_OK) + goto error; + } + else + { + if (rl2_rgb_to_png (width, height, pixels, ximage, ximage_sz) + != RL2_OK) + goto error; + } + } + else if (format == RL2_OUTPUT_FORMAT_JPEG) + { + if (rl2_rgb_to_jpeg + (width, height, pixels, quality, ximage, ximage_sz) != RL2_OK) + goto error; + } + else if (format == RL2_OUTPUT_FORMAT_TIFF) + { + if (rl2_rgb_to_tiff (width, height, pixels, ximage, ximage_sz) != + RL2_OK) + goto error; + } + else + goto error; + free (pixels); + if (mask != NULL) + free (mask); + return 1; + + error: + if (pixels != NULL) + free (pixels); + if (mask != NULL) + free (mask); + return 0; +} Index: src/rl2charls.c ================================================================== --- src/rl2charls.c +++ src/rl2charls.c @@ -54,11 +54,15 @@ #include "rasterlite2/rasterlite2.h" #include "rasterlite2_private.h" #ifndef OMIT_CHARLS /* only if CharLS is enabled */ +#ifdef __ANDROID__ /* Android specific */ +#include +#else #include +#endif static int endianness () { /* checking if target CPU is a little-endian one */ @@ -280,12 +284,12 @@ } } } static void -from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width, int height, - int num_bands) +from_ilv_buffer_8 (unsigned char *out, unsigned char *in, int width, + int height, int num_bands) { /* rearranging pixels from separate LINE components - UINT 8 */ int x; int y; int ib; @@ -451,12 +455,12 @@ from_ilv_buffer_16 ((unsigned short *) (*pixels), (unsigned short *) out_buffer, *width, *height, *num_bands); else from_ilv_buffer_8 ((unsigned char *) (*pixels), - (unsigned char *) out_buffer, *width, *height, - *num_bands); + (unsigned char *) out_buffer, *width, + *height, *num_bands); } free (out_buffer); return RL2_OK; error: Index: src/rl2codec.c ================================================================== --- src/rl2codec.c +++ src/rl2codec.c @@ -2020,13 +2020,14 @@ *size_even = e_size; return 1; } RL2_DECLARE int -rl2_raster_encode (rl2RasterPtr rst, int compression, unsigned char **blob_odd, - int *blob_odd_sz, unsigned char **blob_even, - int *blob_even_sz, int quality, int little_endian) +rl2_raster_encode (rl2RasterPtr rst, int compression, + unsigned char **blob_odd, int *blob_odd_sz, + unsigned char **blob_even, int *blob_even_sz, int quality, + int little_endian) { /* encoding a Raster into the internal RL2 binary format */ rl2PrivRasterPtr raster = (rl2PrivRasterPtr) rst; int odd_rows; unsigned char *pixels_odd = NULL; @@ -2124,12 +2125,12 @@ /* preparing the pixels buffers */ if (raster->sampleType == RL2_SAMPLE_1_BIT) { /* packing 1-BIT data */ if (!pack_1bit_rows - (raster, raster->rasterBuffer, &row_stride_odd, &pixels_odd, - &size_odd)) + (raster, raster->rasterBuffer, &row_stride_odd, + &pixels_odd, &size_odd)) return RL2_ERROR; odd_rows = raster->height; } else if (raster->sampleType == RL2_SAMPLE_2_BIT) { @@ -2149,13 +2150,13 @@ } else { /* Odd/Even raster */ if (!odd_even_rows - (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd, - &even_rows, &row_stride_even, &pixels_even, &size_even, - little_endian)) + (raster, &odd_rows, &row_stride_odd, &pixels_odd, + &size_odd, &even_rows, &row_stride_even, &pixels_even, + &size_even, little_endian)) return RL2_ERROR; } } else if (compression == RL2_COMPRESSION_PNG) { @@ -2167,13 +2168,13 @@ } else { /* Odd/Even raster */ if (!odd_even_rows - (raster, &odd_rows, &row_stride_odd, &pixels_odd, &size_odd, - &even_rows, &row_stride_even, &pixels_even, &size_even, - little_endian)) + (raster, &odd_rows, &row_stride_odd, &pixels_odd, + &size_odd, &even_rows, &row_stride_even, &pixels_even, + &size_even, little_endian)) return RL2_ERROR; } } else if (compression == RL2_COMPRESSION_CHARLS) { @@ -2469,12 +2470,12 @@ } else if (compression == RL2_COMPRESSION_LOSSY_WEBP) { #ifndef OMIT_WEBP /* only if WebP is enabled */ /* compressing as lossy WEBP */ - if (rl2_raster_to_lossy_webp (rst, &compr_data, &compressed, quality) - == RL2_OK) + if (rl2_raster_to_lossy_webp + (rst, &compr_data, &compressed, quality) == RL2_OK) { /* ok, lossy WEBP compression was successful */ uncompressed = raster->width * raster->height * raster->nBands; to_clean1 = compr_data; } @@ -2589,12 +2590,12 @@ } else if (compression == RL2_COMPRESSION_LOSSLESS_JP2) { #ifndef OMIT_OPENJPEG /* only if OpenJpeg is enabled */ /* compressing as lossless Jpeg2000 */ - if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed) == - RL2_OK) + if (rl2_raster_to_lossless_jpeg2000 (rst, &compr_data, &compressed) + == RL2_OK) { /* ok, lossless Jpeg2000 compression was successful */ uncompressed = raster->width * raster->height * raster->nBands; to_clean1 = compr_data; } @@ -2721,12 +2722,12 @@ to_clean2 = zip_buf; } else if (ret == Z_BUF_ERROR) { /* ZIP compression actually causes inflation: saving uncompressed data */ - if (rl2_delta_decode (pixels_even, size_even, delta_dist) - != RL2_OK) + if (rl2_delta_decode + (pixels_even, size_even, delta_dist) != RL2_OK) goto error; uncompressed = size_even; compressed = size_even; compr_data = pixels_even; free (zip_buf); @@ -3131,14 +3132,15 @@ *xcrc = crc; return 1; } static int -check_blob_even (const unsigned char *blob, int blob_sz, unsigned short xwidth, - unsigned short xheight, unsigned char xsample_type, - unsigned char xpixel_type, unsigned char xnum_bands, - unsigned char xcompression, uLong xcrc) +check_blob_even (const unsigned char *blob, int blob_sz, + unsigned short xwidth, unsigned short xheight, + unsigned char xsample_type, unsigned char xpixel_type, + unsigned char xnum_bands, unsigned char xcompression, + uLong xcrc) { /* checking the EvenBlock for validity */ const unsigned char *ptr; unsigned short width; unsigned short height; @@ -3216,11 +3218,12 @@ { /* checking if the encoded raster could be decoded at given scale */ switch (scale) { case RL2_SCALE_1: - if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT + if (sample_type == RL2_SAMPLE_1_BIT + || sample_type == RL2_SAMPLE_2_BIT || sample_type == RL2_SAMPLE_4_BIT) ; else if (compression == RL2_COMPRESSION_JPEG || compression == RL2_COMPRESSION_LOSSY_WEBP || compression == RL2_COMPRESSION_LOSSLESS_WEBP @@ -4192,13 +4195,14 @@ } } } static void -do_copy_uint32 (int swap, const unsigned int *p_odd, const unsigned int *p_even, - unsigned int *buf, unsigned short width, - unsigned short odd_rows, unsigned short even_rows) +do_copy_uint32 (int swap, const unsigned int *p_odd, + const unsigned int *p_even, unsigned int *buf, + unsigned short width, unsigned short odd_rows, + unsigned short even_rows) { /* reassembling an UINT32 raster - scale 1:1 */ int row; int col; unsigned int *p_out; @@ -4880,12 +4884,12 @@ RL2_DECLARE int rl2_is_valid_dbms_raster_tile (unsigned short level, unsigned int tile_width, unsigned int tile_height, const unsigned char *blob_odd, int blob_odd_sz, - const unsigned char *blob_even, int blob_even_sz, - unsigned char sample_type, + const unsigned char *blob_even, + int blob_even_sz, unsigned char sample_type, unsigned char pixel_type, unsigned char num_bands, unsigned char compression) { /* testing a serialized Raster Tile object for validity */ @@ -4939,12 +4943,12 @@ if (xsample_type == RL2_SAMPLE_UINT8 && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3 && xcompression == RL2_COMPRESSION_PNG) return RL2_OK; } - if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE - && num_bands == 1) + if (sample_type == RL2_SAMPLE_UINT8 + && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1) { /* PALETTE 8bits: expecting an RGB/PNG Pyramid tile */ if (xsample_type == RL2_SAMPLE_UINT8 && xpixel_type == RL2_PIXEL_RGB && xnum_bands == 3 && xcompression == RL2_COMPRESSION_PNG) @@ -5012,12 +5016,12 @@ &num_bands, &compression, &crc)) return NULL; if (blob_even != NULL) { if (!check_blob_even - (blob_even, blob_even_sz, width, height, sample_type, pixel_type, - num_bands, compression, crc)) + (blob_even, blob_even_sz, width, height, sample_type, + pixel_type, num_bands, compression, crc)) return NULL; } if (!check_scale (scale, sample_type, compression, blob_even)) return NULL; @@ -5148,12 +5152,12 @@ if (even_data == NULL) goto error; if (uncompress (even_data, &refLen, in, compressed_even) != Z_OK) goto error; - if (rl2_delta_decode (even_data, uncompressed_even, delta_dist) - != RL2_OK) + if (rl2_delta_decode + (even_data, uncompressed_even, delta_dist) != RL2_OK) goto error; pixels_even = even_data; } } if (compression == RL2_COMPRESSION_DEFLATE_NO @@ -5306,30 +5310,30 @@ switch (scale) { case RL2_SCALE_1: ret = rl2_decode_jpeg_scaled (1, pixels_odd, compressed_odd, - &width, &height, &pix_typ, &pixels, - &pixels_sz); + &width, &height, &pix_typ, + &pixels, &pixels_sz); break; case RL2_SCALE_2: ret = rl2_decode_jpeg_scaled (2, pixels_odd, compressed_odd, - &width, &height, &pix_typ, &pixels, - &pixels_sz); + &width, &height, &pix_typ, + &pixels, &pixels_sz); break; case RL2_SCALE_4: ret = rl2_decode_jpeg_scaled (4, pixels_odd, compressed_odd, - &width, &height, &pix_typ, &pixels, - &pixels_sz); + &width, &height, &pix_typ, + &pixels, &pixels_sz); break; case RL2_SCALE_8: ret = rl2_decode_jpeg_scaled (8, pixels_odd, compressed_odd, - &width, &height, &pix_typ, &pixels, - &pixels_sz); + &width, &height, &pix_typ, + &pixels, &pixels_sz); break; }; if (ret != RL2_OK) goto error; goto done; @@ -5382,21 +5386,22 @@ } if (compression == RL2_COMPRESSION_PNG) { /* decompressing from PNG */ int ret; - if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT + if (sample_type == RL2_SAMPLE_1_BIT + || sample_type == RL2_SAMPLE_2_BIT || sample_type == RL2_SAMPLE_4_BIT) { /* Palette or Grayscale - 1,2 or 4 bit isn't scalable */ if (scale != RL2_SCALE_1) goto error; ret = rl2_decode_png (pixels_odd, compressed_odd, - &width, &height, &sample_type, &pixel_type, - &num_bands, &pixels, &pixels_sz, &mask, - &mask_sz, &palette, 0); + &width, &height, &sample_type, + &pixel_type, &num_bands, &pixels, + &pixels_sz, &mask, &mask_sz, &palette, 0); if (ret != RL2_OK) goto error; goto done; } else @@ -5411,13 +5416,14 @@ pixels_odd = odd_data; if (scale == RL2_SCALE_1) { ret = rl2_decode_png (pixels_even, compressed_even, &width, &even_rows, &sample_type, - &pixel_type, &num_bands, &even_data, - &pixels_sz, &even_mask, - &even_mask_sz, &palette2, 0); + &pixel_type, &num_bands, + &even_data, &pixels_sz, + &even_mask, &even_mask_sz, + &palette2, 0); if (ret != RL2_OK) goto error; rl2_destroy_palette (palette2); } pixels_even = even_data; @@ -5484,33 +5490,33 @@ { case RL2_SCALE_1: ret = rl2_decode_jpeg2000_scaled (1, pixels_odd, compressed_odd, &width, &height, sample_type, - pixel_type, num_bands, &pixels, - &pixels_sz); + pixel_type, num_bands, + &pixels, &pixels_sz); break; case RL2_SCALE_2: ret = rl2_decode_jpeg2000_scaled (2, pixels_odd, compressed_odd, &width, &height, sample_type, - pixel_type, num_bands, &pixels, - &pixels_sz); + pixel_type, num_bands, + &pixels, &pixels_sz); break; case RL2_SCALE_4: ret = rl2_decode_jpeg2000_scaled (4, pixels_odd, compressed_odd, &width, &height, sample_type, - pixel_type, num_bands, &pixels, - &pixels_sz); + pixel_type, num_bands, + &pixels, &pixels_sz); break; case RL2_SCALE_8: ret = rl2_decode_jpeg2000_scaled (8, pixels_odd, compressed_odd, &width, &height, sample_type, - pixel_type, num_bands, &pixels, - &pixels_sz); + pixel_type, num_bands, + &pixels, &pixels_sz); break; }; if (ret != RL2_OK) goto error; goto done; @@ -5560,12 +5566,12 @@ unsigned char *mask_pix; int mask_pix_sz; if (uncompressed_mask != (mask_width * mask_height)) goto error; if (!unpack_rle - (mask_width, mask_height, pixels_mask, compressed_mask, &mask_pix, - &mask_pix_sz)) + (mask_width, mask_height, pixels_mask, compressed_mask, + &mask_pix, &mask_pix_sz)) goto error; if (!rescale_mask (scale, &mask_width, &mask_height, mask_pix, &mask, &mask_sz)) { free (mask_pix); @@ -5885,11 +5891,12 @@ if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands) != RL2_OK) ignore_no_data = 1; if (nbands != num_bands) ignore_no_data = 1; - if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT + if (sample_type == RL2_SAMPLE_1_BIT + || sample_type == RL2_SAMPLE_2_BIT || sample_type == RL2_SAMPLE_4_BIT || sample_type == RL2_SAMPLE_UINT8) ; else ignore_no_data = 1; @@ -6495,11 +6502,12 @@ compute_int32_histogram (width, height, pixels, mask, st, no_data); } static void compute_uint32_histogram (unsigned short width, unsigned short height, - const unsigned int *pixels, const unsigned char *mask, + const unsigned int *pixels, + const unsigned char *mask, rl2PrivRasterStatisticsPtr st, rl2PixelPtr no_data) { /* computing INT16 tile histogram */ int x; int y; Index: src/rl2dbms.c ================================================================== --- src/rl2dbms.c +++ src/rl2dbms.c @@ -77,14 +77,14 @@ unsigned char compression, int quality, unsigned int tile_width, unsigned int tile_height, int srid, double x_res, double y_res, unsigned char *blob, int blob_sz, - unsigned char *blob_no_data, int blob_no_data_sz, - int strict_resolution, int mixed_resolutions, - int section_paths, int section_md5, - int section_summary) + unsigned char *blob_no_data, + int blob_no_data_sz, int strict_resolution, + int mixed_resolutions, int section_paths, + int section_md5, int section_summary) { /* inserting into "raster_coverages" */ int ret; char *sql; sqlite3_stmt *stmt; @@ -278,12 +278,12 @@ "\ty_resolution_1_8 DOUBLE)\n", xxcoverage); ret = sqlite3_exec (handle, sql, NULL, NULL, &sql_err); sqlite3_free (sql); if (ret != SQLITE_OK) { - fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", xxcoverage, - sql_err); + fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", + xxcoverage, sql_err); sqlite3_free (sql_err); free (xxcoverage); return 0; } free (xxcoverage); @@ -338,12 +338,12 @@ free (xpk_name); free (xfk_name); free (xmother); if (ret != SQLITE_OK) { - fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", xxcoverage, - sql_err); + fprintf (stderr, "CREATE TABLE \"%s_levels\" error: %s\n", + xxcoverage, sql_err); sqlite3_free (sql_err); free (xxcoverage); return 0; } free (xxcoverage); @@ -1246,11 +1246,12 @@ return RL2_ERROR; } RL2_DECLARE int rl2_resolve_base_resolution_from_dbms (sqlite3 * handle, const char *coverage, - int by_section, sqlite3_int64 section_id, + int by_section, + sqlite3_int64 section_id, double *x_res, double *y_res) { /* resolving the Base Resolution */ int ret; char *sql; @@ -1441,12 +1442,12 @@ *duplicate = 0; table = sqlite3_mprintf ("%s_sections", coverage); xtable = rl2_double_quoted_sql (table); sqlite3_free (table); sql = - sqlite3_mprintf ("SELECT section_id FROM \"%s\" WHERE section_name = ?", - xtable); + sqlite3_mprintf + ("SELECT section_id FROM \"%s\" WHERE section_name = ?", xtable); free (xtable); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) { @@ -2388,13 +2389,14 @@ { section_summary = sqlite3_column_int (stmt, 15); ok_summary = 1; } if (ok_sample && ok_pixel && ok_num_bands && ok_compression - && ok_quality && ok_tile_width && ok_tile_height && ok_x_res - && ok_y_res && ok_srid && ok_nodata && ok_strict && ok_mixed - && ok_paths && ok_md5 && ok_summary) + && ok_quality && ok_tile_width && ok_tile_height + && ok_x_res && ok_y_res && ok_srid && ok_nodata + && ok_strict && ok_mixed && ok_paths && ok_md5 + && ok_summary) ok = 1; } } sqlite3_finalize (stmt); @@ -2422,12 +2424,12 @@ coverage); rl2_destroy_coverage (cvg); return NULL; } if (rl2_set_coverage_policies - (cvg, strict_resolution, mixed_resolutions, section_paths, section_md5, - section_summary) != RL2_OK) + (cvg, strict_resolution, mixed_resolutions, section_paths, + section_md5, section_summary) != RL2_OK) { fprintf (stderr, "ERROR: unable to set the Policies on the Coverage Object supporting \"%s\"\n", coverage); rl2_destroy_coverage (cvg); @@ -2535,12 +2537,12 @@ free (f_geometry_column); return NULL; } vector = - rl2_create_vector_layer (f_table_name, f_geometry_column, geometry_type, - srid, spatial_index); + rl2_create_vector_layer (f_table_name, f_geometry_column, + geometry_type, srid, spatial_index); free (f_table_name); free (f_geometry_column); if (vector == NULL) { fprintf (stderr, @@ -2890,11 +2892,12 @@ static void do_decode_tile (rl2AuxDecoderPtr decoder) { /* servicing an AuxDecoder Tile request */ decoder->raster = - (rl2PrivRasterPtr) rl2_raster_decode (decoder->scale, decoder->blob_odd, + (rl2PrivRasterPtr) rl2_raster_decode (decoder->scale, + decoder->blob_odd, decoder->blob_odd_sz, decoder->blob_even, decoder->blob_even_sz, (rl2PalettePtr) (decoder->palette)); @@ -3075,13 +3078,14 @@ return 0; } static int rl2_load_dbms_tiles_common (sqlite3 * handle, int max_threads, - sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data, - unsigned char *outbuf, unsigned int width, - unsigned int height, unsigned char sample_type, + sqlite3_stmt * stmt_tiles, + sqlite3_stmt * stmt_data, unsigned char *outbuf, + unsigned int width, unsigned int height, + unsigned char sample_type, unsigned char num_bands, unsigned char auto_ndvi, unsigned char red_band_index, unsigned char nir_band_index, double x_res, double y_res, double minx, double maxy, int scale, rl2PalettePtr palette, rl2PixelPtr no_data, @@ -3706,21 +3710,21 @@ "SELECT tiles data; sqlite3_step() error: %s\n", sqlite3_errmsg (handle)); goto error; } raster = - rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even, - blob_even_sz, NULL); + rl2_raster_decode (scale, blob_odd, blob_odd_sz, + blob_even, blob_even_sz, NULL); if (raster == NULL) { fprintf (stderr, ERR_FRMT64, tile_id); goto error; } if (!copy_triple_band_raw_pixels (raster, outbuf, width, height, red_band, green_band, - blue_band, x_res, y_res, minx, maxy, tile_minx, tile_maxy, - no_data)) + blue_band, x_res, y_res, minx, maxy, tile_minx, + tile_maxy, no_data)) goto error; rl2_destroy_raster (raster); raster = NULL; } else @@ -3868,13 +3872,14 @@ } static int copy_mono_band_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf, unsigned int width, unsigned int height, - unsigned char mono_band, double x_res, double y_res, - double minx, double maxy, double tile_minx, - double tile_maxy, rl2PixelPtr no_data) + unsigned char mono_band, double x_res, + double y_res, double minx, double maxy, + double tile_minx, double tile_maxy, + rl2PixelPtr no_data) { /* copying raw pixels into the output buffer */ unsigned int tile_width; unsigned int tile_height; unsigned int x; @@ -4001,13 +4006,14 @@ static int load_mono_band_dbms_tiles (sqlite3 * handle, sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data, unsigned char *outbuf, unsigned int width, unsigned int height, - unsigned char mono_band, double x_res, double y_res, - double minx, double miny, double maxx, double maxy, - int level, int scale, rl2PixelPtr no_data) + unsigned char mono_band, double x_res, + double y_res, double minx, double miny, + double maxx, double maxy, int level, int scale, + rl2PixelPtr no_data) { /* retrieving a full image from DBMS tiles */ rl2RasterPtr raster = NULL; int ret; @@ -4062,12 +4068,12 @@ "SELECT tiles data; sqlite3_step() error: %s\n", sqlite3_errmsg (handle)); goto error; } raster = - rl2_raster_decode (scale, blob_odd, blob_odd_sz, blob_even, - blob_even_sz, NULL); + rl2_raster_decode (scale, blob_odd, blob_odd_sz, + blob_even, blob_even_sz, NULL); if (raster == NULL) { fprintf (stderr, ERR_FRMT64, tile_id); goto error; } @@ -4099,15 +4105,16 @@ rl2_load_dbms_tiles (sqlite3 * handle, int max_threads, sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data, unsigned char *outbuf, unsigned int width, unsigned int height, unsigned char sample_type, unsigned char num_bands, unsigned char auto_ndvi, - unsigned char red_band_index, unsigned char nir_band_index, - double x_res, double y_res, double minx, double miny, - double maxx, double maxy, int level, int scale, - rl2PalettePtr palette, rl2PixelPtr no_data, - rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats) + unsigned char red_band_index, + unsigned char nir_band_index, double x_res, double y_res, + double minx, double miny, double maxx, double maxy, + int level, int scale, rl2PalettePtr palette, + rl2PixelPtr no_data, rl2RasterSymbolizerPtr style, + rl2RasterStatisticsPtr stats) { /* binding the query args */ sqlite3_reset (stmt_tiles); sqlite3_clear_bindings (stmt_tiles); sqlite3_bind_int (stmt_tiles, 1, level); @@ -4128,16 +4135,17 @@ rl2_load_dbms_tiles_section (sqlite3 * handle, int max_threads, sqlite3_int64 section_id, sqlite3_stmt * stmt_tiles, sqlite3_stmt * stmt_data, unsigned char *outbuf, unsigned int width, unsigned int height, - unsigned char sample_type, unsigned char num_bands, - unsigned char auto_ndvi, + unsigned char sample_type, + unsigned char num_bands, unsigned char auto_ndvi, unsigned char red_band_index, unsigned char nir_band_index, double x_res, - double y_res, double minx, double maxy, int scale, - rl2PalettePtr palette, rl2PixelPtr no_data) + double y_res, double minx, double maxy, + int scale, rl2PalettePtr palette, + rl2PixelPtr no_data) { /* binding the query args */ sqlite3_reset (stmt_tiles); sqlite3_clear_bindings (stmt_tiles); sqlite3_bind_int (stmt_tiles, 1, section_id); @@ -4585,14 +4593,14 @@ if (!ok) { /* default: white */ rl2_set_pixel_sample_uint8 (no_data, RL2_RED_BAND, 255); - rl2_set_pixel_sample_uint8 (no_data, RL2_GREEN_BAND, - 255); - rl2_set_pixel_sample_uint8 (no_data, RL2_BLUE_BAND, - 255); + rl2_set_pixel_sample_uint8 (no_data, + RL2_GREEN_BAND, 255); + rl2_set_pixel_sample_uint8 (no_data, + RL2_BLUE_BAND, 255); } } } if (plt != NULL) rl2_destroy_palette (plt); @@ -4813,12 +4821,13 @@ void_raw_buffer (bufpix, width, height, sample_type, num_bands, no_data); } if (!rl2_load_dbms_tiles (handle, max_threads, stmt_tiles, stmt_data, bufpix, width, height, - sample_type, num_bands, auto_ndvi, red_band, nir_band, xx_res, yy_res, - minx, miny, maxx, maxy, level, scale, plt, no_data, style, stats)) + sample_type, num_bands, auto_ndvi, red_band, nir_band, xx_res, + yy_res, minx, miny, maxx, maxy, level, scale, plt, no_data, style, + stats)) goto error; if (kill_no_data != NULL) rl2_destroy_pixel (kill_no_data); sqlite3_finalize (stmt_tiles); sqlite3_finalize (stmt_data); @@ -4870,23 +4879,23 @@ free (shaded_relief); return RL2_ERROR; } RL2_DECLARE int -rl2_get_raw_raster_data (sqlite3 * handle, int max_threads, rl2CoveragePtr cvg, - unsigned int width, unsigned int height, - double minx, double miny, double maxx, double maxy, - double x_res, double y_res, unsigned char **buffer, - int *buf_size, rl2PalettePtr * palette, - unsigned char out_pixel) +rl2_get_raw_raster_data (sqlite3 * handle, int max_threads, + rl2CoveragePtr cvg, unsigned int width, + unsigned int height, double minx, double miny, + double maxx, double maxy, double x_res, double y_res, + unsigned char **buffer, int *buf_size, + rl2PalettePtr * palette, unsigned char out_pixel) { /* attempting to return a buffer containing raw pixels from the DBMS Coverage */ return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 0, 0, width, height, minx, miny, maxx, - maxy, x_res, y_res, buffer, buf_size, - palette, out_pixel, NULL, NULL, - NULL); + maxy, x_res, y_res, buffer, + buf_size, palette, out_pixel, NULL, + NULL, NULL); } RL2_DECLARE int rl2_get_section_raw_raster_data (sqlite3 * handle, int max_threads, rl2CoveragePtr cvg, sqlite3_int64 section_id, @@ -4899,21 +4908,22 @@ { /* attempting to return a buffer containing raw pixels from the DBMS Coverage/Section */ return rl2_get_raw_raster_data_common (handle, max_threads, cvg, 1, section_id, width, height, minx, miny, maxx, maxy, x_res, y_res, - buffer, buf_size, palette, out_pixel, - NULL, NULL, NULL); + buffer, buf_size, palette, + out_pixel, NULL, NULL, NULL); } static int get_triple_band_raw_raster_data_common (int by_section, sqlite3 * handle, rl2CoveragePtr cvg, sqlite3_int64 section_id, - unsigned int width, unsigned int height, - double minx, double miny, double maxx, - double maxy, double x_res, double y_res, + unsigned int width, + unsigned int height, double minx, + double miny, double maxx, double maxy, + double x_res, double y_res, unsigned char red_band, unsigned char green_band, unsigned char blue_band, unsigned char **buffer, int *buf_size, rl2PixelPtr bgcolor) @@ -5074,13 +5084,14 @@ rl2PixelPtr bgcolor) { /* attempting to return a buffer containing raw pixels from the DBMS Coverage */ return get_triple_band_raw_raster_data_common (0, handle, cvg, 0, width, height, minx, miny, maxx, - maxy, x_res, y_res, red_band, - green_band, blue_band, - buffer, buf_size, bgcolor); + maxy, x_res, y_res, + red_band, green_band, + blue_band, buffer, + buf_size, bgcolor); } RL2_DECLARE int rl2_get_section_triple_band_raw_raster_data (sqlite3 * handle, rl2CoveragePtr cvg, @@ -5099,12 +5110,12 @@ /* attempting to return a buffer containing raw pixels - Section */ return get_triple_band_raw_raster_data_common (1, handle, cvg, section_id, width, height, minx, miny, maxx, maxy, x_res, y_res, red_band, green_band, - blue_band, buffer, buf_size, - bgcolor); + blue_band, buffer, + buf_size, bgcolor); } static int get_mono_band_raw_raster_data_common (int by_section, sqlite3 * handle, rl2CoveragePtr cvg, @@ -5265,17 +5276,18 @@ unsigned char **buffer, int *buf_size, rl2PixelPtr no_data) { /* attempting to return a buffer containing raw pixels from the DBMS Coverage */ return get_mono_band_raw_raster_data_common (0, handle, cvg, 0, width, - height, minx, miny, maxx, maxy, - x_res, y_res, buffer, buf_size, - mono_band, no_data); + height, minx, miny, maxx, + maxy, x_res, y_res, buffer, + buf_size, mono_band, no_data); } RL2_DECLARE int -rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle, rl2CoveragePtr cvg, +rl2_get_section_mono_band_raw_raster_data (sqlite3 * handle, + rl2CoveragePtr cvg, sqlite3_int64 section_id, unsigned int width, unsigned int height, double minx, double miny, double maxx, double maxy, double x_res, @@ -5293,16 +5305,18 @@ } RL2_DECLARE int rl2_get_raw_raster_data_bgcolor (sqlite3 * handle, int max_threads, rl2CoveragePtr cvg, unsigned int width, - unsigned int height, double minx, double miny, - double maxx, double maxy, double x_res, - double y_res, unsigned char **buffer, - int *buf_size, rl2PalettePtr * palette, - unsigned char *out_pixel, unsigned char bg_red, - unsigned char bg_green, unsigned char bg_blue, + unsigned int height, double minx, + double miny, double maxx, double maxy, + double x_res, double y_res, + unsigned char **buffer, int *buf_size, + rl2PalettePtr * palette, + unsigned char *out_pixel, + unsigned char bg_red, unsigned char bg_green, + unsigned char bg_blue, rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats) { /* attempting to return a buffer containing raw pixels from the DBMS Coverage + bgcolor */ int ret; @@ -5382,33 +5396,33 @@ /* palette color found */ switch (sample_type) { case RL2_SAMPLE_1_BIT: no_data = - rl2_create_pixel (RL2_SAMPLE_1_BIT, RL2_PIXEL_PALETTE, - 1); + rl2_create_pixel (RL2_SAMPLE_1_BIT, + RL2_PIXEL_PALETTE, 1); rl2_set_pixel_sample_1bit (no_data, (unsigned char) index); break; case RL2_SAMPLE_2_BIT: no_data = - rl2_create_pixel (RL2_SAMPLE_2_BIT, RL2_PIXEL_PALETTE, - 1); + rl2_create_pixel (RL2_SAMPLE_2_BIT, + RL2_PIXEL_PALETTE, 1); rl2_set_pixel_sample_2bit (no_data, (unsigned char) index); break; case RL2_SAMPLE_4_BIT: no_data = - rl2_create_pixel (RL2_SAMPLE_4_BIT, RL2_PIXEL_PALETTE, - 1); + rl2_create_pixel (RL2_SAMPLE_4_BIT, + RL2_PIXEL_PALETTE, 1); rl2_set_pixel_sample_4bit (no_data, (unsigned char) index); break; case RL2_SAMPLE_UINT8: no_data = - rl2_create_pixel (RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE, - 1); + rl2_create_pixel (RL2_SAMPLE_UINT8, + RL2_PIXEL_PALETTE, 1); rl2_set_pixel_sample_uint8 (no_data, RL2_PALETTE_BAND, (unsigned char) index); break; }; @@ -5705,12 +5719,13 @@ int ret; if (handle == NULL || coverage == NULL || palette == NULL) return RL2_ERROR; sql = - sqlite3_mprintf ("SELECT sample_type, pixel_type FROM raster_coverages " - "WHERE Lower(coverage_name) = Lower(%Q)", coverage); + sqlite3_mprintf + ("SELECT sample_type, pixel_type FROM raster_coverages " + "WHERE Lower(coverage_name) = Lower(%Q)", coverage); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) { fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle)); @@ -6233,11 +6248,12 @@ rl2_destroy_coverage_style (stl); return NULL; } RL2_DECLARE rl2FeatureTypeStylePtr -rl2_create_feature_type_style_from_dbms (sqlite3 * handle, const char *coverage, +rl2_create_feature_type_style_from_dbms (sqlite3 * handle, + const char *coverage, const char *style) { /* attempting to load and parse a Feature Type Style */ const char *sql; int ret; @@ -6377,15 +6393,16 @@ int columns; int i; int ok = 0; /* testing if the Layer Style exists */ char *sql = - sqlite3_mprintf ("SELECT style_name FROM SE_raster_styled_layers AS r " - "JOIN SE_raster_styles AS s ON (r.style_id = s.style_id) " - "WHERE Lower(r.coverage_name) = Lower(%Q) AND " - "Lower(s.style_name) = Lower(%Q)", namedLayer, - namedStyle); + sqlite3_mprintf + ("SELECT style_name FROM SE_raster_styled_layers AS r " + "JOIN SE_raster_styles AS s ON (r.style_id = s.style_id) " + "WHERE Lower(r.coverage_name) = Lower(%Q) AND " + "Lower(s.style_name) = Lower(%Q)", namedLayer, + namedStyle); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) return 0; for (i = 1; i <= rows; i++) @@ -7003,10 +7020,11 @@ rl2PalettePtr palette = NULL; char *title = NULL; char *abstract = NULL; unsigned char *statistics = NULL; int statistics_sz; + int ok_geo = 0; int ok_bbox = 0; double geo_minx; double geo_miny; double geo_maxx; double geo_maxy; @@ -7401,33 +7419,32 @@ if (sqlite3_column_type (stmt, 18) == SQLITE_BLOB) { statistics_sz = sqlite3_column_bytes (stmt, 18); statistics = malloc (statistics_sz); memcpy (statistics, - (const unsigned char *) sqlite3_column_blob (stmt, - 18), - statistics_sz); + (const unsigned char *) + sqlite3_column_blob (stmt, 18), statistics_sz); } if (sqlite3_column_type (stmt, 19) == SQLITE_FLOAT) { geo_minx = sqlite3_column_double (stmt, 19); - ok_bbox++; + ok_geo++; } if (sqlite3_column_type (stmt, 20) == SQLITE_FLOAT) { geo_miny = sqlite3_column_double (stmt, 20); - ok_bbox++; + ok_geo++; } if (sqlite3_column_type (stmt, 21) == SQLITE_FLOAT) { geo_maxx = sqlite3_column_double (stmt, 21); - ok_bbox++; + ok_geo++; } if (sqlite3_column_type (stmt, 22) == SQLITE_FLOAT) { geo_maxy = sqlite3_column_double (stmt, 22); - ok_bbox++; + ok_geo++; } if (sqlite3_column_type (stmt, 23) == SQLITE_FLOAT) { ext_minx = sqlite3_column_double (stmt, 23); ok_bbox++; @@ -7483,15 +7500,18 @@ sqlite3_column_blob (stmt, 33); int blob_sz = sqlite3_column_bytes (stmt, 33); palette = rl2_deserialize_dbms_palette (blob, blob_sz); } if (ok_sample && ok_pixel && ok_num_bands && ok_compression - && ok_quality && ok_tile_width && ok_tile_height && ok_x_res - && ok_y_res && ok_srid && ok_nodata && ok_strict && ok_mixed - && ok_paths && ok_md5 && ok_summary) + && ok_quality && ok_tile_width && ok_tile_height + && ok_x_res && ok_y_res && ok_srid && ok_nodata + && ok_strict && ok_mixed && ok_paths && ok_md5 + && ok_summary) ok = 1; - if (ok_bbox != 8) + if (ok_geo != 4) + ok_geo = 0; + if (ok_bbox != 4) ok_bbox = 0; } } sqlite3_finalize (stmt); stmt = NULL; @@ -7506,14 +7526,14 @@ (unsigned short) tile_height, srid, horz_res, vert_res, no_data, palette, strict_resolution, mixed_resolutions, section_paths, section_md5, section_summary); - if (no_data != NULL) - rl2_destroy_pixel(no_data); - if (palette != NULL) - rl2_destroy_palette(palette); + if (no_data != NULL) + rl2_destroy_pixel (no_data); + if (palette != NULL) + rl2_destroy_palette (palette); if (ret != RL2_OK) goto error; /* completing the destination coverage */ sql = "UPDATE main.raster_coverages SET title = ?, " @@ -7540,27 +7560,33 @@ sqlite3_bind_text (stmt, 2, abstract, strlen (abstract), free); if (statistics == NULL) sqlite3_bind_null (stmt, 3); else sqlite3_bind_blob (stmt, 3, statistics, statistics_sz, free); - if (ok_bbox) + if (ok_geo) { sqlite3_bind_double (stmt, 4, geo_minx); sqlite3_bind_double (stmt, 5, geo_miny); sqlite3_bind_double (stmt, 6, geo_maxx); sqlite3_bind_double (stmt, 7, geo_maxy); - sqlite3_bind_double (stmt, 8, ext_minx); - sqlite3_bind_double (stmt, 9, ext_miny); - sqlite3_bind_double (stmt, 10, ext_maxx); - sqlite3_bind_double (stmt, 11, ext_maxy); } else { sqlite3_bind_null (stmt, 4); sqlite3_bind_null (stmt, 5); sqlite3_bind_null (stmt, 6); sqlite3_bind_null (stmt, 7); + } + if (ok_bbox) + { + sqlite3_bind_double (stmt, 8, ext_minx); + sqlite3_bind_double (stmt, 9, ext_miny); + sqlite3_bind_double (stmt, 10, ext_maxx); + sqlite3_bind_double (stmt, 11, ext_maxy); + } + else + { sqlite3_bind_null (stmt, 8); sqlite3_bind_null (stmt, 9); sqlite3_bind_null (stmt, 10); sqlite3_bind_null (stmt, 11); } @@ -7589,11 +7615,12 @@ else sqlite3_bind_int (stmt, 17, enable_auto_ndvi); sqlite3_bind_text (stmt, 18, coverage_name, strlen (coverage_name), SQLITE_STATIC); ret = sqlite3_step (stmt); - sqlite3_finalize(stmt); + sqlite3_finalize (stmt); + stmt = NULL; if (ret == SQLITE_DONE || ret == SQLITE_ROW) goto ok_continue; fprintf (stderr, "sqlite3_step() error: UPDATE raster_coverages \"%s\"\n", sqlite3_errmsg (sqlite)); @@ -7611,26 +7638,27 @@ "y_resolution_1_2, x_resolution_1_4, y_resolution_1_4, x_resolution_1_8, " "y_resolution_1_8 FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage); free (xxcoverage); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; /* copying coverage-SECTIONS */ xcoverage = sqlite3_mprintf ("%s_sections", coverage_name); xxcoverage = rl2_double_quoted_sql (xcoverage); sqlite3_free (xcoverage); - sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (section_id, section_name, " - "width, height, file_path, md5_checksum, summary, statistics, geometry) " - "SELECT section_id, section_name, width, height, file_path, md5_checksum, " - "summary, statistics, geometry FROM \"%s\".\"%s\"", - xxcoverage, xdb, xxcoverage); + sql = + sqlite3_mprintf ("INSERT INTO main.\"%s\" (section_id, section_name, " + "width, height, file_path, md5_checksum, summary, statistics, geometry) " + "SELECT section_id, section_name, width, height, file_path, md5_checksum, " + "summary, statistics, geometry FROM \"%s\".\"%s\"", + xxcoverage, xdb, xxcoverage); free (xxcoverage); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; /* copying coverage-TILES */ xcoverage = sqlite3_mprintf ("%s_tiles", coverage_name); @@ -7639,11 +7667,11 @@ sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, pyramid_level, " "section_id, geometry) SELECT tile_id, pyramid_level, section_id, geometry " "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage); free (xxcoverage); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; /* copying coverage-TILE_DATA */ xcoverage = sqlite3_mprintf ("%s_tile_data", coverage_name); @@ -7652,30 +7680,30 @@ sql = sqlite3_mprintf ("INSERT INTO main.\"%s\" (tile_id, tile_data_odd, " "tile_data_even) SELECT tile_id, tile_data_odd, tile_data_even " "FROM \"%s\".\"%s\"", xxcoverage, xdb, xxcoverage); free (xxcoverage); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; /* copying KEYWORDS */ sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_keyword " "(coverage_name, keyword) SELECT coverage_name, keyword " "FROM \"%s\".raster_coverages_keyword", xdb); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; /* copying SRID */ sql = sqlite3_mprintf ("INSERT INTO main.raster_coverages_srid " "(coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx) " "SELECT coverage_name, srid, extent_minx, extent_miny, extent_maxx, extent_maxx " "FROM \"%s\".raster_coverages_srid", xdb); ret = sqlite3_exec (sqlite, sql, NULL, NULL, NULL); - sqlite3_free(sql); + sqlite3_free (sql); if (ret != SQLITE_OK) goto error; free (xdb); return RL2_OK; Index: src/rl2gif.c ================================================================== --- src/rl2gif.c +++ src/rl2gif.c @@ -604,12 +604,12 @@ } RL2_PRIVATE int rl2_decode_gif (const unsigned char *gif, int gif_size, unsigned int *xwidth, unsigned int *xheight, unsigned char *xsample_type, - unsigned char *xpixel_type, unsigned char **blob, int *blob_sz, - rl2PalettePtr * palette) + unsigned char *xpixel_type, unsigned char **blob, + int *blob_sz, rl2PalettePtr * palette) { /* attempting to create a raster from a GIF image - raw block */ struct gif_memory_buffer membuf; #ifdef GIFLIB_MAJOR int ErrorCode; Index: src/rl2import.c ================================================================== --- src/rl2import.c +++ src/rl2import.c @@ -102,12 +102,12 @@ rl2_destroy_raster (tile->raster); tile->raster = NULL; } static void -addTile2AuxImporter (rl2AuxImporterPtr aux, unsigned int row, unsigned int col, - double minx, double maxy) +addTile2AuxImporter (rl2AuxImporterPtr aux, unsigned int row, + unsigned int col, double minx, double maxy) { /* adding a Tile to some AuxImporter container */ rl2AuxImporterTilePtr tile; if (aux == NULL) return; @@ -348,36 +348,40 @@ case RL2_ORIGIN_ASCII_GRID: ascii_grid_origin = (rl2AsciiGridOriginPtr) (aux->origin); tile->raster = rl2_get_tile_from_ascii_grid_origin ((rl2CoveragePtr) (aux->coverage), - ascii_grid_origin, tile->row, - tile->col, aux->verbose); + ascii_grid_origin, + tile->row, tile->col, + aux->verbose); break; case RL2_ORIGIN_JPEG: raster_origin = (rl2RasterPtr) (aux->origin); tile->raster = rl2_get_tile_from_jpeg_origin ((rl2CoveragePtr) (aux->coverage), raster_origin, tile->row, - tile->col, aux->forced_conversion, + tile->col, + aux->forced_conversion, aux->verbose); break; case RL2_ORIGIN_JPEG2000: raster_origin = (rl2RasterPtr) (aux->origin); tile->raster = rl2_get_tile_from_jpeg2000_origin ((rl2CoveragePtr) - (aux->coverage), raster_origin, - tile->row, tile->col, + (aux->coverage), + raster_origin, tile->row, + tile->col, aux->forced_conversion, aux->verbose); break; case RL2_ORIGIN_TIFF: tiff_origin = (rl2TiffOriginPtr) (aux->origin); tile->raster = rl2_get_tile_from_tiff_origin ((rl2CoveragePtr) (aux->coverage), - tiff_origin, tile->row, tile->col, - aux->srid, aux->verbose); + tiff_origin, tile->row, + tile->col, aux->srid, + aux->verbose); break; case RL2_ORIGIN_RAW: raster_origin = (rl2RasterPtr) (aux->origin); tile->raster = rl2_get_tile_from_raw_pixels ((rl2CoveragePtr) (aux->coverage), @@ -639,12 +643,12 @@ } no_data = rl2_get_coverage_no_data (cvg); /* INSERTing the section */ if (!rl2_do_insert_section - (handle, src_path, section, srid, width, height, minx, miny, maxx, maxy, - xml_summary, coverage->sectionPaths, coverage->sectionMD5, + (handle, src_path, section, srid, width, height, minx, miny, maxx, + maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5, coverage->sectionSummary, stmt_sect, §ion_id)) goto error; section_stats = rl2_create_raster_statistics (sample_type, 1); if (section_stats == NULL) goto error; @@ -665,12 +669,12 @@ } /* preparing all Tile Requests */ aux = createAuxImporter (coverage, srid, maxx, miny, tile_w, tile_h, res_x, - res_y, RL2_ORIGIN_ASCII_GRID, origin, RL2_CONVERT_NO, - verbose, compression, 100); + res_y, RL2_ORIGIN_ASCII_GRID, origin, + RL2_CONVERT_NO, verbose, compression, 100); tile_maxy = maxy; for (row = 0; row < height; row += tile_h) { tile_minx = minx; for (col = 0; col < width; col += tile_w) @@ -910,11 +914,12 @@ #ifndef OMIT_OPENJPEG /* only if OpenJpeg is enabled */ static int check_jpeg2000_origin_compatibility (rl2RasterPtr raster, rl2CoveragePtr coverage, - unsigned int *width, unsigned int *height, + unsigned int *width, + unsigned int *height, unsigned char *forced_conversion) { /* checking if the Jpeg2000 and the Coverage are mutually compatible */ rl2PrivRasterPtr rst = (rl2PrivRasterPtr) raster; rl2PrivCoveragePtr cvg = (rl2PrivCoveragePtr) coverage; @@ -996,12 +1001,12 @@ *height = rst->height; *forced_conversion = RL2_CONVERT_NO; return 1; } } - if (rst->sampleType == RL2_SAMPLE_UINT16 && rst->pixelType == RL2_PIXEL_RGB - && rst->nBands == 3) + if (rst->sampleType == RL2_SAMPLE_UINT16 + && rst->pixelType == RL2_PIXEL_RGB && rst->nBands == 3) { if (cvg->sampleType == RL2_SAMPLE_UINT16 && cvg->pixelType == RL2_PIXEL_RGB && cvg->nBands == 3) { *width = rst->width; @@ -1231,12 +1236,12 @@ res_y = 1.0; } raster_in = (rl2PrivRasterPtr) rst_in; xml_summary = rl2_build_jpeg_xml_summary (width, height, raster_in->pixelType, - is_georeferenced, res_x, res_y, minx, miny, - maxx, maxy); + is_georeferenced, res_x, res_y, minx, + miny, maxx, maxy); printf ("------------------\n"); if (total > 1) printf ("%d/%d) Importing: %s\n", current, total, src_path); else @@ -1311,12 +1316,12 @@ no_data = rl2_get_coverage_no_data (cvg); /* INSERTing the section */ if (!rl2_do_insert_section - (handle, src_path, section, srid, width, height, minx, miny, maxx, maxy, - xml_summary, coverage->sectionPaths, coverage->sectionMD5, + (handle, src_path, section, srid, width, height, minx, miny, maxx, + maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5, coverage->sectionSummary, stmt_sect, §ion_id)) goto error; section_stats = rl2_create_raster_statistics (sample_type, num_bands); if (section_stats == NULL) goto error; @@ -1679,14 +1684,14 @@ res_y = 1.0; } raster_in = (rl2PrivRasterPtr) rst_in; xml_summary = rl2_build_jpeg2000_xml_summary (width, height, raster_in->sampleType, - raster_in->pixelType, raster_in->nBands, - is_georeferenced, res_x, res_y, minx, - miny, maxx, maxy, tile_width, - tile_height); + raster_in->pixelType, + raster_in->nBands, is_georeferenced, + res_x, res_y, minx, miny, maxx, maxy, + tile_width, tile_height); printf ("------------------\n"); if (total > 1) printf ("%d/%d) Importing: %s\n", current, total, src_path); else @@ -1761,12 +1766,12 @@ no_data = rl2_get_coverage_no_data (cvg); /* INSERTing the section */ if (!rl2_do_insert_section - (handle, src_path, section, srid, width, height, minx, miny, maxx, maxy, - xml_summary, coverage->sectionPaths, coverage->sectionMD5, + (handle, src_path, section, srid, width, height, minx, miny, maxx, + maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5, coverage->sectionSummary, stmt_sect, §ion_id)) goto error; section_stats = rl2_create_raster_statistics (sample_type, num_bands); if (section_stats == NULL) goto error; @@ -2072,20 +2077,21 @@ if (is_ascii_grid (src_path)) return do_import_ascii_grid (handle, max_threads, src_path, cvg, section, force_srid, tile_w, tile_h, pyramidize, sample_type, compression, - stmt_data, stmt_tils, stmt_sect, stmt_levl, - stmt_upd_sect, verbose, current, total); + stmt_data, stmt_tils, stmt_sect, + stmt_levl, stmt_upd_sect, verbose, + current, total); if (is_jpeg_image (src_path)) return do_import_jpeg_image (handle, max_threads, src_path, cvg, section, force_srid, tile_w, tile_h, pyramidize, sample_type, num_bands, - compression, quality, stmt_data, stmt_tils, - stmt_sect, stmt_levl, stmt_upd_sect, - verbose, current, total); + compression, quality, stmt_data, + stmt_tils, stmt_sect, stmt_levl, + stmt_upd_sect, verbose, current, total); #ifndef OMIT_OPENJPEG /* only if OpenJpeg is enabled */ if (is_jpeg2000_image (src_path)) return do_import_jpeg2000_image (handle, max_threads, src_path, cvg, section, force_srid, tile_w, tile_h, @@ -2221,22 +2227,22 @@ fprintf (stderr, "Mismatching Palette !!!\n"); goto error; } } - if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose) != - RL2_TRUE) + if (rl2_eval_tiff_origin_compatibility (cvg, origin, force_srid, verbose) + != RL2_TRUE) { fprintf (stderr, "Coverage/TIFF mismatch\n"); goto error; } no_data = rl2_get_coverage_no_data (cvg); /* INSERTing the section */ if (!rl2_do_insert_section - (handle, src_path, section, srid, width, height, minx, miny, maxx, maxy, - xml_summary, coverage->sectionPaths, coverage->sectionMD5, + (handle, src_path, section, srid, width, height, minx, miny, maxx, + maxy, xml_summary, coverage->sectionPaths, coverage->sectionMD5, coverage->sectionSummary, stmt_sect, §ion_id)) goto error; section_stats = rl2_create_raster_statistics (sample_type, num_bands); if (section_stats == NULL) goto error; @@ -2536,18 +2542,20 @@ { path = sqlite3_mprintf ("%s/%s", dir_path, c_file.name); ret = - do_import_file (handle, max_threads, path, cvg, - section, worldfile, force_srid, - pyramidize, sample_type, - pixel_type, num_bands, tile_w, - tile_h, compression, quality, - stmt_data, stmt_tils, stmt_sect, - stmt_levl, stmt_upd_sect, - verbose, cnt + 1, total); + do_import_file (handle, max_threads, path, + cvg, section, worldfile, + force_srid, pyramidize, + sample_type, pixel_type, + num_bands, tile_w, tile_h, + compression, quality, + stmt_data, stmt_tils, + stmt_sect, stmt_levl, + stmt_upd_sect, verbose, + cnt + 1, total); sqlite3_free (path); if (!ret) goto error; cnt++; } @@ -2774,14 +2782,14 @@ } else { /* importing all Image files from a whole directory */ if (!do_import_dir - (handle, max_threads, dir_path, file_ext, cvg, section, worldfile, - force_srid, pyramidize, sample_type, pixel_type, num_bands, - tile_w, tile_h, compression, quality, stmt_data, stmt_tils, - stmt_sect, stmt_levl, stmt_upd_sect, verbose)) + (handle, max_threads, dir_path, file_ext, cvg, section, + worldfile, force_srid, pyramidize, sample_type, pixel_type, + num_bands, tile_w, tile_h, compression, quality, stmt_data, + stmt_tils, stmt_sect, stmt_levl, stmt_upd_sect, verbose)) goto error; } sqlite3_finalize (stmt_upd_sect); sqlite3_finalize (stmt_sect); @@ -2963,16 +2971,15 @@ } } } static void -copy_uint16_outbuf_to_tile (const unsigned short *outbuf, unsigned short *tile, - unsigned char num_bands, unsigned int width, - unsigned int height, - unsigned int tile_width, - unsigned int tile_height, unsigned int base_y, - unsigned int base_x) +copy_uint16_outbuf_to_tile (const unsigned short *outbuf, + unsigned short *tile, unsigned char num_bands, + unsigned int width, unsigned int height, + unsigned int tile_width, unsigned int tile_height, + unsigned int base_y, unsigned int base_x) { /* copying UINT16 pixels from the output buffer into the tile */ unsigned int x; unsigned int y; int b; @@ -3142,12 +3149,12 @@ (char *) tile, width, height, tile_width, tile_height, base_y, base_x); break; case RL2_SAMPLE_INT16: copy_int16_outbuf_to_tile ((short *) outbuf, - (short *) tile, width, height, tile_width, - tile_height, base_y, base_x); + (short *) tile, width, height, + tile_width, tile_height, base_y, base_x); break; case RL2_SAMPLE_UINT16: copy_uint16_outbuf_to_tile ((unsigned short *) outbuf, (unsigned short *) tile, num_bands, width, height, tile_width, tile_height, @@ -3163,12 +3170,12 @@ (unsigned int *) tile, width, height, tile_width, tile_height, base_y, base_x); break; case RL2_SAMPLE_FLOAT: copy_float_outbuf_to_tile ((float *) outbuf, - (float *) tile, width, height, tile_width, - tile_height, base_y, base_x); + (float *) tile, width, height, + tile_width, tile_height, base_y, base_x); break; case RL2_SAMPLE_DOUBLE: copy_double_outbuf_to_tile ((double *) outbuf, (double *) tile, width, height, tile_width, tile_height, base_y, base_x); @@ -3181,15 +3188,15 @@ break; }; } static int -export_geotiff_common (sqlite3 * handle, int max_threads, const char *dst_path, - rl2CoveragePtr cvg, int by_section, - sqlite3_int64 section_id, double x_res, double y_res, - double minx, double miny, double maxx, double maxy, - unsigned int width, unsigned int height, +export_geotiff_common (sqlite3 * handle, int max_threads, + const char *dst_path, rl2CoveragePtr cvg, + int by_section, sqlite3_int64 section_id, double x_res, + double y_res, double minx, double miny, double maxx, + double maxy, unsigned int width, unsigned int height, unsigned char compression, unsigned int tile_sz, int with_worldfile) { /* exporting a GeoTIFF common implementation */ rl2RasterPtr raster = NULL; @@ -3256,21 +3263,21 @@ if (by_section) { /* just a single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, - pixel_type) != RL2_OK) + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, + &palette, pixel_type) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - xx_res, yy_res, &outbuf, &outbuf_size, &palette, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, pixel_type) != RL2_OK) goto error; } /* computing the sample size */ @@ -3313,12 +3320,12 @@ } if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL) rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz, no_data); else - rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type, - num_bands, no_data); + rl2_prime_void_tile (bufpix, tile_sz, tile_sz, + sample_type, num_bands, no_data); copy_from_outbuf_to_tile (outbuf, bufpix, sample_type, num_bands, width, height, tile_sz, tile_sz, base_y, base_x); plt2 = rl2_clone_palette (palette); raster = @@ -3378,11 +3385,12 @@ height, compression, tile_sz, with_worldfile); } RL2_DECLARE int rl2_export_section_geotiff_from_dbms (sqlite3 * handle, int max_threads, - const char *dst_path, rl2CoveragePtr cvg, + const char *dst_path, + rl2CoveragePtr cvg, sqlite3_int64 section_id, double x_res, double y_res, double minx, double miny, double maxx, double maxy, unsigned int width, unsigned int height, unsigned char compression, @@ -3469,21 +3477,21 @@ if (by_section) { /* just a single select Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, - pixel_type) != RL2_OK) + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, + &palette, pixel_type) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - xx_res, yy_res, &outbuf, &outbuf_size, &palette, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, pixel_type) != RL2_OK) goto error; } /* computing the sample size */ @@ -3504,13 +3512,14 @@ }; tiff = rl2_create_tiff_worldfile_destination (dst_path, width, height, sample_type, pixel_type, - num_bands, palette, compression, - 1, tile_sz, srid, minx, miny, - maxx, maxy, xx_res, yy_res); + num_bands, palette, + compression, 1, tile_sz, srid, + minx, miny, maxx, maxy, xx_res, + yy_res); if (tiff == NULL) goto error; for (base_y = 0; base_y < height; base_y += tile_sz) { for (base_x = 0; base_x < width; base_x += tile_sz) @@ -3526,12 +3535,12 @@ } if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL) rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz, no_data); else - rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type, - num_bands, no_data); + rl2_prime_void_tile (bufpix, tile_sz, tile_sz, + sample_type, num_bands, no_data); copy_from_outbuf_to_tile (outbuf, bufpix, sample_type, num_bands, width, height, tile_sz, tile_sz, base_y, base_x); plt2 = rl2_clone_palette (palette); raster = @@ -3582,16 +3591,18 @@ unsigned char compression, unsigned int tile_sz) { /* exporting a TIFF+TFW from the DBMS into the file-system */ return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 0, - 0, x_res, y_res, minx, miny, maxx, maxy, - width, height, compression, tile_sz); + 0, x_res, y_res, minx, miny, maxx, + maxy, width, height, compression, + tile_sz); } RL2_DECLARE int -rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle, int max_threads, +rl2_export_section_tiff_worldfile_from_dbms (sqlite3 * handle, + int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double x_res, double y_res, double minx, double miny, @@ -3602,12 +3613,12 @@ unsigned int tile_sz) { /* exporting a TIFF+TFW - single Section */ return export_tiff_worlfile_common (handle, max_threads, dst_path, cvg, 1, section_id, x_res, y_res, minx, miny, - maxx, maxy, width, height, compression, - tile_sz); + maxx, maxy, width, height, + compression, tile_sz); } static int export_tiff_common (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, int by_section, @@ -3683,21 +3694,21 @@ if (by_section) { /* just a single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, - pixel_type) != RL2_OK) + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, + &palette, pixel_type) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - xx_res, yy_res, &outbuf, &outbuf_size, &palette, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, xx_res, yy_res, &outbuf, &outbuf_size, &palette, pixel_type) != RL2_OK) goto error; } /* computing the sample size */ @@ -3738,12 +3749,12 @@ } if (pixel_type == RL2_PIXEL_PALETTE && palette != NULL) rl2_prime_void_tile_palette (bufpix, tile_sz, tile_sz, no_data); else - rl2_prime_void_tile (bufpix, tile_sz, tile_sz, sample_type, - num_bands, no_data); + rl2_prime_void_tile (bufpix, tile_sz, tile_sz, + sample_type, num_bands, no_data); copy_from_outbuf_to_tile (outbuf, bufpix, sample_type, num_bands, width, height, tile_sz, tile_sz, base_y, base_x); plt2 = rl2_clone_palette (palette); raster = @@ -3782,43 +3793,44 @@ } RL2_DECLARE int rl2_export_tiff_from_dbms (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, - double x_res, double y_res, double minx, double miny, - double maxx, double maxy, unsigned int width, - unsigned int height, unsigned char compression, - unsigned int tile_sz) + double x_res, double y_res, double minx, + double miny, double maxx, double maxy, + unsigned int width, unsigned int height, + unsigned char compression, unsigned int tile_sz) { /* exporting a plain TIFF from the DBMS into the file-system */ - return export_tiff_common (handle, max_threads, dst_path, cvg, 0, 0, x_res, - y_res, minx, miny, maxx, maxy, width, height, - compression, tile_sz); + return export_tiff_common (handle, max_threads, dst_path, cvg, 0, 0, + x_res, y_res, minx, miny, maxx, maxy, width, + height, compression, tile_sz); } RL2_DECLARE int rl2_export_section_tiff_from_dbms (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double x_res, double y_res, double minx, double miny, - double maxx, double maxy, unsigned int width, - unsigned int height, + double maxx, double maxy, + unsigned int width, unsigned int height, unsigned char compression, unsigned int tile_sz) { /* exporting a plain TIFF - single Section*/ return export_tiff_common (handle, max_threads, dst_path, cvg, 1, - section_id, x_res, y_res, minx, miny, maxx, maxy, - width, height, compression, tile_sz); + section_id, x_res, y_res, minx, miny, maxx, + maxy, width, height, compression, tile_sz); } static int export_triple_band_geotiff_common (int by_section, sqlite3 * handle, const char *dst_path, - rl2CoveragePtr cvg, sqlite3_int64 section_id, - double x_res, double y_res, double minx, - double miny, double maxx, double maxy, + rl2CoveragePtr cvg, + sqlite3_int64 section_id, double x_res, + double y_res, double minx, double miny, + double maxx, double maxy, unsigned int width, unsigned int height, unsigned char red_band, unsigned char green_band, unsigned char blue_band, unsigned char compression, @@ -3894,12 +3906,12 @@ tiff = rl2_create_geotiff_destination (dst_path, handle, width, height, sample_type, RL2_PIXEL_RGB, 3, NULL, compression, 1, tile_sz, srid, - minx, miny, maxx, maxy, xx_res, yy_res, - with_worldfile); + minx, miny, maxx, maxy, xx_res, + yy_res, with_worldfile); if (tiff == NULL) goto error; for (base_y = 0; base_y < height; base_y += tile_sz) { for (base_x = 0; base_x < width; base_x += tile_sz) @@ -4092,12 +4104,12 @@ tiff = rl2_create_geotiff_destination (dst_path, handle, width, height, sample_type, out_pixel, 1, NULL, compression, 1, tile_sz, srid, - minx, miny, maxx, maxy, xx_res, yy_res, - with_worldfile); + minx, miny, maxx, maxy, xx_res, + yy_res, with_worldfile); if (tiff == NULL) goto error; for (base_y = 0; base_y < height; base_y += tile_sz) { for (base_x = 0; base_x < width; base_x += tile_sz) @@ -4172,13 +4184,13 @@ unsigned char compression, unsigned int tile_sz, int with_worldfile) { /* exporting a Mono-Band GeoTIFF from the DBMS into the file-system */ - return export_mono_band_geotiff_common (0, handle, dst_path, cvg, 0, x_res, - y_res, minx, miny, maxx, maxy, - width, height, mono_band, + return export_mono_band_geotiff_common (0, handle, dst_path, cvg, 0, + x_res, y_res, minx, miny, maxx, + maxy, width, height, mono_band, compression, tile_sz, with_worldfile); } RL2_DECLARE int @@ -4208,12 +4220,13 @@ export_triple_band_tiff_worldfile_common (int by_section, sqlite3 * handle, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double x_res, double y_res, - double minx, double miny, double maxx, - double maxy, unsigned int width, + double minx, double miny, + double maxx, double maxy, + unsigned int width, unsigned int height, unsigned char red_band, unsigned char green_band, unsigned char blue_band, unsigned char compression, @@ -4288,13 +4301,13 @@ } tiff = rl2_create_tiff_worldfile_destination (dst_path, width, height, sample_type, RL2_PIXEL_RGB, - 3, NULL, compression, 1, tile_sz, - srid, minx, miny, maxx, maxy, - xx_res, yy_res); + 3, NULL, compression, 1, + tile_sz, srid, minx, miny, + maxx, maxy, xx_res, yy_res); if (tiff == NULL) goto error; for (base_y = 0; base_y < height; base_y += tile_sz) { for (base_x = 0; base_x < width; base_x += tile_sz) @@ -4390,11 +4403,12 @@ double miny, double maxx, double maxy, unsigned int width, unsigned int height, - unsigned char red_band, + unsigned char + red_band, unsigned char green_band, unsigned char blue_band, unsigned char @@ -4412,14 +4426,15 @@ static int export_mono_band_tiff_worldfile_common (int by_section, sqlite3 * handle, const char *dst_path, rl2CoveragePtr cvg, - sqlite3_int64 section_id, double x_res, - double y_res, double minx, double miny, - double maxx, double maxy, - unsigned int width, unsigned int height, + sqlite3_int64 section_id, + double x_res, double y_res, + double minx, double miny, double maxx, + double maxy, unsigned int width, + unsigned int height, unsigned char mono_band, unsigned char compression, unsigned int tile_sz) { /* exporting a Mono-Band TIFF+TFW - common implementation */ @@ -4490,13 +4505,13 @@ out_pixel = RL2_PIXEL_GRAYSCALE; tiff = rl2_create_tiff_worldfile_destination (dst_path, width, height, sample_type, out_pixel, - 1, NULL, compression, 1, tile_sz, - srid, minx, miny, maxx, maxy, - xx_res, yy_res); + 1, NULL, compression, 1, + tile_sz, srid, minx, miny, + maxx, maxy, xx_res, yy_res); if (tiff == NULL) goto error; for (base_y = 0; base_y < height; base_y += tile_sz) { for (base_x = 0; base_x < width; base_x += tile_sz) @@ -4568,29 +4583,33 @@ unsigned char mono_band, unsigned char compression, unsigned int tile_sz) { /* exporting a Mono-Band TIFF+TFW from the DBMS into the file-system */ - return export_mono_band_tiff_worldfile_common (0, handle, dst_path, cvg, 0, - x_res, y_res, minx, miny, - maxx, maxy, width, height, - mono_band, compression, - tile_sz); + return export_mono_band_tiff_worldfile_common (0, handle, dst_path, cvg, + 0, x_res, y_res, minx, + miny, maxx, maxy, width, + height, mono_band, + compression, tile_sz); } RL2_DECLARE int rl2_export_section_mono_band_tiff_worldfile_from_dbms (sqlite3 * handle, const char *dst_path, rl2CoveragePtr cvg, - sqlite3_int64 section_id, + sqlite3_int64 + section_id, double x_res, double y_res, - double minx, double miny, - double maxx, double maxy, + double minx, + double miny, + double maxx, + double maxy, unsigned int width, unsigned int height, - unsigned char mono_band, + unsigned char + mono_band, unsigned char compression, unsigned int tile_sz) { /* exporting a Mono-Band TIFF+TFW - Section */ @@ -4754,13 +4773,14 @@ unsigned char compression, unsigned int tile_sz) { /* exporting a plain Band-Composed TIFF from the DBMS into the file-system */ return export_triple_band_tiff_common (0, handle, dst_path, cvg, 0, x_res, - y_res, minx, miny, maxx, maxy, width, - height, red_band, green_band, - blue_band, compression, tile_sz); + y_res, minx, miny, maxx, maxy, + width, height, red_band, + green_band, blue_band, compression, + tile_sz); } RL2_DECLARE int rl2_export_section_triple_band_tiff_from_dbms (sqlite3 * handle, const char *dst_path, @@ -4776,14 +4796,15 @@ unsigned char blue_band, unsigned char compression, unsigned int tile_sz) { /* exporting a plain Band-Composed TIFF - Section */ - return export_triple_band_tiff_common (1, handle, dst_path, cvg, section_id, - x_res, y_res, minx, miny, maxx, maxy, - width, height, red_band, green_band, - blue_band, compression, tile_sz); + return export_triple_band_tiff_common (1, handle, dst_path, cvg, + section_id, x_res, y_res, minx, + miny, maxx, maxy, width, height, + red_band, green_band, blue_band, + compression, tile_sz); } static int export_mono_band_tiff_common (int by_section, sqlite3 * handle, const char *dst_path, rl2CoveragePtr cvg, @@ -4954,12 +4975,12 @@ unsigned int tile_sz) { /* exporting a plain Mono-Band TIFF from the DBMS - Section */ return export_mono_band_tiff_common (1, handle, dst_path, cvg, section_id, x_res, y_res, minx, miny, maxx, maxy, - width, height, mono_band, compression, - tile_sz); + width, height, mono_band, + compression, tile_sz); } static int export_ascii_grid_common (int by_section, sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, @@ -5063,21 +5084,21 @@ if (by_section) { /* single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, res, res, &pixels, &pixels_size, &palette, + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette, RL2_PIXEL_DATAGRID) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - res, res, &pixels, &pixels_size, &palette, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, res, res, &pixels, &pixels_size, &palette, RL2_PIXEL_DATAGRID) != RL2_OK) goto error; } ascii = @@ -5122,21 +5143,22 @@ unsigned int height, int is_centered, int decimal_digits) { /* exporting an ASCII Grid from the DBMS into the file-system */ return export_ascii_grid_common (0, handle, max_threads, dst_path, cvg, 0, - res, minx, miny, maxx, maxy, width, height, - is_centered, decimal_digits); + res, minx, miny, maxx, maxy, width, + height, is_centered, decimal_digits); } RL2_DECLARE int rl2_export_section_ascii_grid_from_dbms (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double res, - double minx, double miny, double maxx, - double maxy, unsigned int width, + double minx, double miny, + double maxx, double maxy, + unsigned int width, unsigned int height, int is_centered, int decimal_digits) { /* exporting an ASCII Grid - Section */ return export_ascii_grid_common (1, handle, max_threads, dst_path, cvg, @@ -5186,13 +5208,14 @@ } return 0; } static float -compute_ndvi (void *pixels, unsigned char sample_type, unsigned char num_bands, - unsigned short width, unsigned char red_band, - unsigned char nir_band, unsigned short row, unsigned short col, +compute_ndvi (void *pixels, unsigned char sample_type, + unsigned char num_bands, unsigned short width, + unsigned char red_band, unsigned char nir_band, + unsigned short row, unsigned short col, rl2PrivPixelPtr in_no_data, float out_no_data) { /* computing a Normalized Difference Vegetaion Index -NDVI */ float red; float nir; @@ -5225,12 +5248,13 @@ export_ndvi_ascii_grid_common (int by_section, sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double res, double minx, double miny, double maxx, double maxy, unsigned int width, - unsigned int height, int red_band, int nir_band, - int is_centered, int decimal_digits) + unsigned int height, int red_band, + int nir_band, int is_centered, + int decimal_digits) { /* exporting an NDVI ASCII Grid common implementation */ rl2PalettePtr palette = NULL; rl2PixelPtr in_no_data; rl2AsciiGridDestinationPtr ascii = NULL; @@ -5279,21 +5303,21 @@ if (by_section) { /* single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, res, res, &pixels, &pixels_size, &palette, + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette, RL2_PIXEL_MULTIBAND) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - res, res, &pixels, &pixels_size, &palette, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, res, res, &pixels, &pixels_size, &palette, RL2_PIXEL_MULTIBAND) != RL2_OK) goto error; } /* creating the output NDVI raster */ @@ -5305,12 +5329,12 @@ for (row = 0; row < height; row++) { /* computing NDVI */ for (col = 0; col < width; col++) *po++ = - compute_ndvi (pixels, sample_type, num_bands, width, red_band, - nir_band, row, col, + compute_ndvi (pixels, sample_type, num_bands, width, + red_band, nir_band, row, col, (rl2PrivPixelPtr) in_no_data, out_no_data); } free (pixels); pixels = NULL; @@ -5349,40 +5373,43 @@ return RL2_ERROR; } RL2_DECLARE int rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads, - const char *dst_path, rl2CoveragePtr cvg, - double res, double minx, double miny, - double maxx, double maxy, - unsigned int width, unsigned int height, - int red_band, int nir_band, - int is_centered, int decimal_digits) + const char *dst_path, + rl2CoveragePtr cvg, double res, + double minx, double miny, double maxx, + double maxy, unsigned int width, + unsigned int height, int red_band, + int nir_band, int is_centered, + int decimal_digits) { /* exporting an ASCII Grid from the DBMS into the file-system */ - return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path, cvg, - 0, res, minx, miny, maxx, maxy, width, - height, red_band, nir_band, + return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path, + cvg, 0, res, minx, miny, maxx, maxy, + width, height, red_band, nir_band, is_centered, decimal_digits); } RL2_DECLARE int -rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads, +rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle, + int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double res, double minx, double miny, double maxx, double maxy, unsigned int width, - unsigned int height, int red_band, - int nir_band, int is_centered, + unsigned int height, + int red_band, int nir_band, + int is_centered, int decimal_digits) { /* exporting an ASCII Grid - Section */ - return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path, cvg, - section_id, res, minx, miny, maxx, - maxy, width, height, red_band, + return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path, + cvg, section_id, res, minx, miny, + maxx, maxy, width, height, red_band, nir_band, is_centered, decimal_digits); } static int @@ -5429,21 +5456,21 @@ if (by_section) { /* single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, pixel_type) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - xx_res, yy_res, &outbuf, &outbuf_size, NULL, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, pixel_type) != RL2_OK) goto error; } raster = @@ -5480,42 +5507,43 @@ } RL2_DECLARE int rl2_export_jpeg_from_dbms (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, - double x_res, double y_res, double minx, double miny, - double maxx, double maxy, unsigned int width, - unsigned int height, int quality, int with_worldfile) + double x_res, double y_res, double minx, + double miny, double maxx, double maxy, + unsigned int width, unsigned int height, + int quality, int with_worldfile) { /* exporting a JPEG (with possible JGW) from the DBMS into the file-system */ - return export_jpeg_common (0, handle, max_threads, dst_path, cvg, 0, x_res, - y_res, minx, miny, maxx, maxy, width, height, - quality, with_worldfile); + return export_jpeg_common (0, handle, max_threads, dst_path, cvg, 0, + x_res, y_res, minx, miny, maxx, maxy, width, + height, quality, with_worldfile); } RL2_DECLARE int rl2_export_section_jpeg_from_dbms (sqlite3 * handle, int max_threads, const char *dst_path, rl2CoveragePtr cvg, sqlite3_int64 section_id, double x_res, double y_res, double minx, double miny, - double maxx, double maxy, unsigned int width, - unsigned int height, int quality, - int with_worldfile) + double maxx, double maxy, + unsigned int width, unsigned int height, + int quality, int with_worldfile) { /* exporting a JPEG (with possible JGW) - Section */ return export_jpeg_common (1, handle, max_threads, dst_path, cvg, - section_id, x_res, y_res, minx, miny, maxx, maxy, - width, height, quality, with_worldfile); + section_id, x_res, y_res, minx, miny, maxx, + maxy, width, height, quality, with_worldfile); } static int export_raw_pixels_common (int by_section, sqlite3 * handle, int max_threads, rl2CoveragePtr cvg, sqlite3_int64 section_id, - double x_res, double y_res, double minx, double miny, - double maxx, double maxy, unsigned int width, - unsigned int height, int big_endian, - unsigned char **blob, int *blob_size) + double x_res, double y_res, double minx, + double miny, double maxx, double maxy, + unsigned int width, unsigned int height, + int big_endian, unsigned char **blob, int *blob_size) { /* common implementation for Export RAW pixels */ unsigned char level; unsigned char scale; double xx_res = x_res; @@ -5542,21 +5570,21 @@ if (by_section) { /* single Section */ if (rl2_get_section_raw_raster_data - (handle, max_threads, cvg, section_id, width, height, minx, miny, - maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, + (handle, max_threads, cvg, section_id, width, height, minx, + miny, maxx, maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, pixel_type) != RL2_OK) goto error; } else { /* whole Coverage */ if (rl2_get_raw_raster_data - (handle, max_threads, cvg, width, height, minx, miny, maxx, maxy, - xx_res, yy_res, &outbuf, &outbuf_size, NULL, + (handle, max_threads, cvg, width, height, minx, miny, maxx, + maxy, xx_res, yy_res, &outbuf, &outbuf_size, NULL, pixel_type) != RL2_OK) goto error; } bufpix = rl2_copy_endian_raw_pixels (outbuf, outbuf_size, width, height, @@ -5582,13 +5610,14 @@ unsigned int width, unsigned int height, int big_endian, unsigned char **blob, int *blob_size) { /* exporting RAW pixel buffer and Transparency Mask from the DBMS */ - return export_raw_pixels_common (0, handle, max_threads, coverage, 0, x_res, - y_res, minx, miny, maxx, maxy, width, - height, big_endian, blob, blob_size); + return export_raw_pixels_common (0, handle, max_threads, coverage, 0, + x_res, y_res, minx, miny, maxx, maxy, + width, height, big_endian, blob, + blob_size); } RL2_DECLARE int rl2_export_section_raw_pixels_from_dbms (sqlite3 * handle, int max_threads, rl2CoveragePtr coverage, @@ -5601,13 +5630,13 @@ int big_endian, unsigned char **blob, int *blob_size) { /* exporting RAW pixel buffer and Transparency Mask - Section */ return export_raw_pixels_common (1, handle, max_threads, coverage, - section_id, x_res, y_res, minx, miny, maxx, - maxy, width, height, big_endian, blob, - blob_size); + section_id, x_res, y_res, minx, miny, + maxx, maxy, width, height, big_endian, + blob, blob_size); } RL2_DECLARE int rl2_load_raw_raster_into_dbms (sqlite3 * handle, int max_threads, rl2CoveragePtr cvg, const char *section, Index: src/rl2jpeg.c ================================================================== --- src/rl2jpeg.c +++ src/rl2jpeg.c @@ -228,11 +228,12 @@ * the first one. */ if (cinfo->src == NULL) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_PERMANENT, sizeof (struct jpeg_source_mgr)); } src = cinfo->src; src->init_source = init_mem_source; @@ -263,11 +264,12 @@ * can be written to the same buffer without re-executing jpeg_mem_dest. */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */ cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, + JPOOL_PERMANENT, sizeof (jpeg_mem_destination_mgr)); dest = (jpeg_mem_dest_ptr) cinfo->dest; dest->newbuffer = NULL; } @@ -755,12 +757,12 @@ unsigned char *blob; int blob_size; if (rst == NULL) return RL2_ERROR; - if (check_jpeg_compatibility (rst->sampleType, rst->pixelType, rst->nBands) - != RL2_OK) + if (check_jpeg_compatibility + (rst->sampleType, rst->pixelType, rst->nBands) != RL2_OK) return RL2_ERROR; if (rl2_data_to_jpeg (rst->rasterBuffer, rst->maskBuffer, (rl2PalettePtr) (rst->Palette), rst->width, rst->height, rst->sampleType, rst->pixelType, &blob, &blob_size, quality) != RL2_OK) @@ -780,32 +782,32 @@ int blob_size; if (rgb == NULL) return RL2_ERROR; if (rl2_data_to_jpeg - (rgb, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, &blob, - &blob_size, quality) != RL2_OK) + (rgb, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, + &blob, &blob_size, quality) != RL2_OK) return RL2_ERROR; *jpeg = blob; *jpeg_size = blob_size; return RL2_OK; } RL2_DECLARE int rl2_gray_to_jpeg (unsigned int width, unsigned int height, - const unsigned char *gray, int quality, unsigned char **jpeg, - int *jpeg_size) + const unsigned char *gray, int quality, + unsigned char **jpeg, int *jpeg_size) { /* creating a PNG image from a Grayscale buffer */ unsigned char *blob; int blob_size; if (gray == NULL) return RL2_ERROR; if (rl2_data_to_jpeg - (gray, NULL, NULL, width, height, RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE, - &blob, &blob_size, quality) != RL2_OK) + (gray, NULL, NULL, width, height, RL2_SAMPLE_UINT8, + RL2_PIXEL_GRAYSCALE, &blob, &blob_size, quality) != RL2_OK) return RL2_ERROR; *jpeg = blob; *jpeg_size = blob_size; return RL2_OK; } @@ -849,12 +851,13 @@ if (rst == NULL) return NULL; /* creating the raster section */ scn = - rl2_create_section (path, RL2_COMPRESSION_JPEG, RL2_TILESIZE_UNDEFINED, - RL2_TILESIZE_UNDEFINED, rst); + rl2_create_section (path, RL2_COMPRESSION_JPEG, + RL2_TILESIZE_UNDEFINED, RL2_TILESIZE_UNDEFINED, + rst); return scn; } RL2_DECLARE rl2RasterPtr rl2_raster_from_jpeg (const unsigned char *jpeg, int jpeg_size) @@ -876,12 +879,12 @@ if (pixel_type == RL2_PIXEL_RGB) nBands = 3; /* creating the raster */ rst = - rl2_create_raster (width, height, RL2_SAMPLE_UINT8, pixel_type, nBands, - data, data_size, NULL, NULL, 0, NULL); + rl2_create_raster (width, height, RL2_SAMPLE_UINT8, pixel_type, + nBands, data, data_size, NULL, NULL, 0, NULL); if (rst == NULL) goto error; return rst; error: @@ -891,12 +894,12 @@ free (data); return NULL; } RL2_DECLARE int -rl2_get_jpeg_infos (const char *path, unsigned int *width, unsigned int *height, - unsigned char *pixel_type) +rl2_get_jpeg_infos (const char *path, unsigned int *width, + unsigned int *height, unsigned char *pixel_type) { /* attempting to retrieve basic infos from a JPEG image */ int jpeg_size; unsigned char *jpeg = NULL; struct jpeg_decompress_struct cinfo; @@ -1062,12 +1065,12 @@ if (cinfo.out_color_space == JCS_CMYK) { JSAMPROW row = buffer[0]; for (i = 0; i < (int) (cinfo.output_width); i++) { - CMYK2RGB (*(row + 0), *(row + 1), *(row + 2), *(row + 3), - inverted, p_data); + CMYK2RGB (*(row + 0), *(row + 1), *(row + 2), + *(row + 3), inverted, p_data); row += 4; p_data += 3; } } else if (cinfo.out_color_space == JCS_GRAYSCALE) @@ -1296,12 +1299,12 @@ /* checking for strict compatibility */ if (coverage->sampleType == RL2_SAMPLE_UINT8 && coverage->pixelType == RL2_PIXEL_GRAYSCALE && coverage->nBands == 1) { if (raster->sampleType == RL2_SAMPLE_UINT8 - && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1 - && forced_conversion == RL2_CONVERT_NO) + && raster->pixelType == RL2_PIXEL_GRAYSCALE + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO) return 1; if (raster->sampleType == RL2_SAMPLE_UINT8 && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3 && forced_conversion == RL2_CONVERT_RGB_TO_GRAYSCALE) return 1; @@ -1312,11 +1315,12 @@ if (raster->sampleType == RL2_SAMPLE_UINT8 && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3 && forced_conversion == RL2_CONVERT_NO) return 1; if (raster->sampleType == RL2_SAMPLE_UINT8 - && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1 + && raster->pixelType == RL2_PIXEL_GRAYSCALE + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_GRAYSCALE_TO_RGB) return 1; } if (verbose) fprintf (stderr, "Mismatching JPEG colorspace !!!\n"); @@ -1530,12 +1534,13 @@ prev = xml; xml = sqlite3_mprintf ("%s", prev); sqlite3_free (prev); prev = xml; xml = - sqlite3_mprintf ("%s%1.10f", - prev, maxx - minx); + sqlite3_mprintf + ("%s%1.10f", prev, + maxx - minx); sqlite3_free (prev); prev = xml; xml = sqlite3_mprintf ("%s%1.10f", prev, maxy - miny); Index: src/rl2openjpeg.c ================================================================== --- src/rl2openjpeg.c +++ src/rl2openjpeg.c @@ -57,12 +57,16 @@ #ifndef OMIT_OPENJPEG /* only if OpenJpeg is enabled */ #ifdef HAVE_OPENJPEG_2_1_OPENJPEG_H #include +#else +#ifdef __ANDROID__ /* Android specific */ +#include #else #include +#endif #endif struct jp2_memfile { /* a struct emulating a file [memory mapped] */ @@ -690,12 +694,13 @@ RL2_PRIVATE int rl2_decode_jpeg2000_scaled (int scale, const unsigned char *jpeg2000, int jpeg2000_sz, unsigned int *xwidth, unsigned int *xheight, unsigned char xsample_type, - unsigned char xpixel_type, unsigned char xnum_bands, - unsigned char **pixels, int *pixels_size) + unsigned char xpixel_type, + unsigned char xnum_bands, unsigned char **pixels, + int *pixels_size) { /* attempting to create a raster from a Jpeg2000 image - supporting rescaled size */ unsigned char *buf = NULL; int buf_size = 0; unsigned int width; @@ -856,12 +861,13 @@ goto error; } if (sample_type == RL2_SAMPLE_UINT16) save_tile_u16 ((unsigned short *) buf, (unsigned short *) jp2_data, tile_x0 / scale, - tile_y0 / scale, tile_x1 / scale, tile_y1 / scale, - num_bands, width / scale, height / scale); + tile_y0 / scale, tile_x1 / scale, + tile_y1 / scale, num_bands, width / scale, + height / scale); else save_tile_u8 ((unsigned char *) buf, (unsigned char *) jp2_data, tile_x0 / scale, tile_y0 / scale, tile_x1 / scale, tile_y1 / scale, num_bands, width / scale, height / scale); @@ -899,12 +905,12 @@ /* checking for strict compatibility */ if (coverage->sampleType == RL2_SAMPLE_UINT8 && coverage->pixelType == RL2_PIXEL_GRAYSCALE && coverage->nBands == 1) { if (raster->sampleType == RL2_SAMPLE_UINT8 - && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1 - && forced_conversion == RL2_CONVERT_NO) + && raster->pixelType == RL2_PIXEL_GRAYSCALE + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO) return 1; if (raster->sampleType == RL2_SAMPLE_UINT8 && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3 && forced_conversion == RL2_CONVERT_RGB_TO_GRAYSCALE) return 1; @@ -915,26 +921,26 @@ if (raster->sampleType == RL2_SAMPLE_UINT8 && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3 && forced_conversion == RL2_CONVERT_NO) return 1; if (raster->sampleType == RL2_SAMPLE_UINT8 - && raster->pixelType == RL2_PIXEL_GRAYSCALE && raster->nBands == 1 + && raster->pixelType == RL2_PIXEL_GRAYSCALE + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_GRAYSCALE_TO_RGB) return 1; } if (coverage->sampleType == RL2_SAMPLE_UINT8 && coverage->pixelType == RL2_PIXEL_DATAGRID && coverage->nBands == 1) { if (raster->sampleType == RL2_SAMPLE_UINT8 - && raster->pixelType == RL2_PIXEL_DATAGRID && raster->nBands == 1 - && forced_conversion == RL2_CONVERT_NO) + && raster->pixelType == RL2_PIXEL_DATAGRID + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO) return 1; } if (coverage->sampleType == RL2_SAMPLE_UINT8 - && coverage->pixelType == RL2_PIXEL_MULTIBAND && (coverage->nBands == 3 - || coverage->nBands == - 4)) + && coverage->pixelType == RL2_PIXEL_MULTIBAND + && (coverage->nBands == 3 || coverage->nBands == 4)) { if (raster->sampleType == RL2_SAMPLE_UINT8 && raster->pixelType == RL2_PIXEL_MULTIBAND && raster->nBands == coverage->nBands && forced_conversion == RL2_CONVERT_NO) @@ -942,12 +948,12 @@ } if (coverage->sampleType == RL2_SAMPLE_UINT16 && coverage->pixelType == RL2_PIXEL_DATAGRID && coverage->nBands == 1) { if (raster->sampleType == RL2_SAMPLE_UINT16 - && raster->pixelType == RL2_PIXEL_DATAGRID && raster->nBands == 1 - && forced_conversion == RL2_CONVERT_NO) + && raster->pixelType == RL2_PIXEL_DATAGRID + && raster->nBands == 1 && forced_conversion == RL2_CONVERT_NO) return 1; } if (coverage->sampleType == RL2_SAMPLE_UINT16 && coverage->pixelType == RL2_PIXEL_RGB && coverage->nBands == 3) { @@ -955,13 +961,12 @@ && raster->pixelType == RL2_PIXEL_RGB && raster->nBands == 3 && forced_conversion == RL2_CONVERT_NO) return 1; } if (coverage->sampleType == RL2_SAMPLE_UINT16 - && coverage->pixelType == RL2_PIXEL_MULTIBAND && (coverage->nBands == 3 - || coverage->nBands == - 4)) + && coverage->pixelType == RL2_PIXEL_MULTIBAND + && (coverage->nBands == 3 || coverage->nBands == 4)) { if (raster->sampleType == RL2_SAMPLE_UINT16 && raster->pixelType == RL2_PIXEL_MULTIBAND && raster->nBands == coverage->nBands && forced_conversion == RL2_CONVERT_NO) @@ -971,12 +976,13 @@ fprintf (stderr, "Mismatching Jpeg2000 colorspace !!!\n"); return 0; } static int -read_jpeg2000_pixels_gray_to_rgb (rl2PrivRasterPtr origin, unsigned short width, - unsigned short height, unsigned int startRow, +read_jpeg2000_pixels_gray_to_rgb (rl2PrivRasterPtr origin, + unsigned short width, unsigned short height, + unsigned int startRow, unsigned int startCol, unsigned char *pixels) { /* Grayscale -> RGB */ unsigned short x; unsigned short y; @@ -1000,12 +1006,13 @@ } return 1; } static int -read_jpeg2000_pixels_rgb_to_gray (rl2PrivRasterPtr origin, unsigned short width, - unsigned short height, unsigned int startRow, +read_jpeg2000_pixels_rgb_to_gray (rl2PrivRasterPtr origin, + unsigned short width, unsigned short height, + unsigned int startRow, unsigned int startCol, unsigned char *pixels) { /* RGB -> Grayscale */ unsigned short x; unsigned short y; @@ -1188,11 +1195,12 @@ return RL2_ERROR; } RL2_DECLARE rl2RasterPtr rl2_get_tile_from_jpeg2000_origin (rl2CoveragePtr cvg, rl2RasterPtr jpeg2000, - unsigned int startRow, unsigned int startCol, + unsigned int startRow, + unsigned int startCol, unsigned char forced_conversion, int verbose) { /* attempting to create a Coverage-tile from a Jpeg2000 origin */ unsigned int x; rl2PrivCoveragePtr coverage = (rl2PrivCoveragePtr) cvg; @@ -1602,12 +1610,13 @@ prev = xml; xml = sqlite3_mprintf ("%s", prev); sqlite3_free (prev); prev = xml; xml = - sqlite3_mprintf ("%s%1.10f", - prev, maxx - minx); + sqlite3_mprintf + ("%s%1.10f", prev, + maxx - minx); sqlite3_free (prev); prev = xml; xml = sqlite3_mprintf ("%s%1.10f", prev, maxy - miny); Index: src/rl2paint.c ================================================================== --- src/rl2paint.c +++ src/rl2paint.c @@ -770,12 +770,13 @@ unsigned char blue1, unsigned char alpha1, unsigned char red2, unsigned char green2, unsigned char blue2, - unsigned char alpha2, double pen_width, - int line_cap, int line_join) + unsigned char alpha2, + double pen_width, int line_cap, + int line_join) { /* setting up a Linear Gradient Pen - solid style */ double d_red = (double) red1 / 255.0; double d_green = (double) green1 / 255.0; double d_blue = (double) blue1 / 255.0; @@ -1045,12 +1046,13 @@ RL2_DECLARE int rl2_graph_set_linear_gradient_brush (rl2GraphicsContextPtr context, double x, double y, double width, double height, unsigned char red1, unsigned char green1, - unsigned char blue1, unsigned char alpha1, - unsigned char red2, unsigned char green2, + unsigned char blue1, + unsigned char alpha1, unsigned char red2, + unsigned char green2, unsigned char blue2, unsigned char alpha2) { /* setting up a Linear Gradient Brush */ double d_red = (double) red1 / 255.0; double d_green = (double) green1 / 255.0; @@ -1556,11 +1558,13 @@ unsigned char blue; unsigned char alpha; unsigned char xred; unsigned char xgreen; unsigned char xblue; + unsigned char xalpha; int valid = 0; + int has_black = 0; unsigned char *bitmap; RL2PrivGraphPatternPtr pattern = (RL2PrivGraphPatternPtr) ptrn; if (pattern == NULL) return RL2_ERROR; @@ -1573,26 +1577,30 @@ /* checking for a Monochrome Pattern */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue, - &alpha); + aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, + &blue, &alpha); if (alpha != 0) { + if (red < 64 && green < 64 && blue < 64) + has_black++; if (valid) { - if (xred == red && xgreen == green && xblue == blue) + if (xred == red && xgreen == green + && xblue == blue && alpha == xalpha) ; else - return RL2_ERROR; + goto not_mono; } else { xred = red; xgreen = green; xblue = blue; + xalpha = alpha; valid = 1; } } } } @@ -1599,18 +1607,38 @@ /* all right, applying the new color */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue, - &alpha); + aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, + &blue, &alpha); if (alpha != 0) aux_pattern_set_pixel (x, y, width, bitmap, r, g, b, alpha); } } cairo_surface_mark_dirty (pattern->bitmap); return RL2_OK; + + not_mono: + if (has_black) + { + /* recoloring only the black pixels */ + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + aux_pattern_get_pixel (x, y, width, bitmap, &red, + &green, &blue, &alpha); + if (red < 64 && green < 64 && blue < 64) + aux_pattern_set_pixel (x, y, width, bitmap, r, g, b, + alpha); + } + } + cairo_surface_mark_dirty (pattern->bitmap); + return RL2_OK; + } + return RL2_ERROR; } RL2_DECLARE int rl2_graph_pattern_transparency (rl2GraphicsPatternPtr ptrn, unsigned char aleph) { @@ -1637,12 +1665,12 @@ /* applying the new transparency */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, &blue, - &alpha); + aux_pattern_get_pixel (x, y, width, bitmap, &red, &green, + &blue, &alpha); if (alpha != 0) aux_pattern_set_pixel (x, y, width, bitmap, red, green, blue, aleph); } } @@ -1767,12 +1795,13 @@ /* destroying the cached font */ rl2_destroy_private_tt_font (font); } RL2_DECLARE rl2GraphicsFontPtr -rl2_graph_create_TrueType_font (const void *priv_data, const unsigned char *ttf, - int ttf_bytes, double size) +rl2_graph_create_TrueType_font (const void *priv_data, + const unsigned char *ttf, int ttf_bytes, + double size) { /* creating a TrueType font */ RL2GraphFontPtr fnt; char *facename; int is_bold; @@ -2264,12 +2293,12 @@ return 1; } RL2_DECLARE int rl2_graph_draw_circle_sector (rl2GraphicsContextPtr context, double center_x, - double center_y, double radius, double from_angle, - double to_angle) + double center_y, double radius, + double from_angle, double to_angle) { /* drawing a filled circular sector */ cairo_t *cairo; RL2GraphContextPtr ctx = (RL2GraphContextPtr) context; if (ctx == NULL) @@ -2429,12 +2458,12 @@ *post_y = extents.y_advance; return 1; } RL2_DECLARE int -rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text, double x, - double y, double angle, double anchor_point_x, +rl2_graph_draw_text (rl2GraphicsContextPtr context, const char *text, + double x, double y, double angle, double anchor_point_x, double anchor_point_y) { /* drawing a text string (using the current font) */ double rads; double pre_x; @@ -2611,12 +2640,12 @@ return 1; return 0; } static rl2GeometryPtr -aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom, rl2GeometryPtr circle, - double x, double y) +aux_reduce_curve (sqlite3 * handle, rl2GeometryPtr geom, + rl2GeometryPtr circle, double x, double y) { /* reducing a Curve by discarding the alreasdy processed portion */ sqlite3_stmt *stmt = NULL; const char *sql; int ret; @@ -2683,10 +2712,64 @@ error: if (stmt != NULL) sqlite3_finalize (stmt); return NULL; } + +static int +check_reverse (rl2GeometryPtr geom) +{ +/* testing for an inverse label */ + rl2LinestringPtr ln; + double x0; + double y0; + double x1; + double y1; + double width; + double height; + int last; + + if (geom == NULL) + return 0; + ln = geom->first_linestring; + if (ln == NULL) + return 0; + if (ln->points < 2) + return 0; + last = ln->points - 1; + + rl2GetPoint (ln->coords, 0, &x0, &y0); + rl2GetPoint (ln->coords, last, &x1, &y1); + width = fabs (x0 - x1); + height = fabs (y0 - y1); + if (width > 3.0) + { + if (x0 > x1) + return 1; + } + else + { + if (y0 > y1) + return 1; + } + return 0; +} + +static void +reverse_text (const char *in, char *dest, int len) +{ +/* reversing a text string */ + char *out; + int n = 1; + while (*in != '\0') + { + out = dest + len - n; + *out = *in++; + n++; + } + *(dest + len) = '\0'; +} static rl2GeometryPtr rl2_draw_wrapped_label (sqlite3 * handle, rl2GraphicsContextPtr context, cairo_t * cairo, const char *text, rl2GeometryPtr geom) { @@ -2701,17 +2784,26 @@ double angle; char buf[2]; rl2GeometryPtr g2; rl2GeometryPtr g = rl2_clone_curve (geom); rl2GeometryPtr circle; + char *rev_text = NULL; const char *c = text; cairo_font_extents_t extents; cairo_font_extents (cairo, &extents); radius = sqrt ((extents.max_x_advance * extents.max_x_advance) + (extents.height * extents.height)) / 2.0; + if (check_reverse (g)) + { + /* reverse text */ + int len = strlen (text); + rev_text = malloc (len + 1); + reverse_text (text, rev_text, len); + c = rev_text; + } while (*c != '\0' && g != NULL) { buf[0] = *c; buf[1] = '\0'; get_aux_start_point (g, &x0, &y0); @@ -2724,26 +2816,29 @@ break; } m = (y1 - y0) / (x1 - x0); rads = atan (m); angle = rads / .0174532925199432958; - if (x1 < x0) + if (x1 < x0 && rev_text == NULL) angle += 180.0; rl2_graph_draw_text (context, buf, x0, y0, angle, 0.5, 0.5); c++; g2 = aux_reduce_curve (handle, g, circle, x0, y0); rl2_destroy_geometry (circle); rl2_destroy_geometry (g); g = g2; } + if (rev_text) + free (rev_text); return g; } RL2_DECLARE int rl2_graph_draw_warped_text (sqlite3 * handle, rl2GraphicsContextPtr context, - const char *text, int points, double *x, double *y, - double initial_gap, double gap, int repeated) + const char *text, int points, double *x, + double *y, double initial_gap, double gap, + int repeated) { /* drawing a text string warped along a modelling curve (using the current font) */ double curve_len; double text_len; double extra_len; @@ -2767,11 +2862,11 @@ if (geom == NULL) return 0; curve_len = rl2_compute_curve_length (geom); do_estimate_text_length (cairo, text, &text_len, &extra_len); - if ((text_len + (2.0 * extra_len)) > curve_len) + if ((initial_gap + text_len + (2.0 * extra_len)) > curve_len) return 0; /* not enough room to place the label */ if (repeated) { /* repeated labels */ @@ -2785,10 +2880,12 @@ first = 0; } else start = gap + extra_len; curve_len = rl2_compute_curve_length (geom3); + if ((start + text_len + extra_len) > curve_len) + break; /* not enough room to place the label */ from = start / curve_len; /* extracting the sub-path modelling the label */ geom2 = rl2_curve_substring (handle, geom3, from, 1.0); rl2_destroy_geometry (geom3); if (geom2 == NULL) Index: src/rl2png.c ================================================================== --- src/rl2png.c +++ src/rl2png.c @@ -226,15 +226,15 @@ rl2_free (blue); return RL2_ERROR; } static int -compress_grayscale_png8 (const unsigned char *pixels, const unsigned char *mask, - double opacity, unsigned int width, - unsigned int height, unsigned char sample_type, - unsigned char pixel_type, unsigned char **png, - int *png_size) +compress_grayscale_png8 (const unsigned char *pixels, + const unsigned char *mask, double opacity, + unsigned int width, unsigned int height, + unsigned char sample_type, unsigned char pixel_type, + unsigned char **png, int *png_size) { /* compressing a PNG image of the GRAYSCALE type - 8 bits */ png_structp png_ptr; png_infop info_ptr; int bit_depth; @@ -1082,12 +1082,13 @@ return RL2_OK; } RL2_DECLARE int rl2_rgb_real_alpha_to_png (unsigned int width, unsigned int height, - const unsigned char *rgb, const unsigned char *alpha, - unsigned char **png, int *png_size) + const unsigned char *rgb, + const unsigned char *alpha, unsigned char **png, + int *png_size) { /* creating a PNG image from two distinct RGB + Alpha buffer */ unsigned char *blob; int blob_size; if (rgb == NULL || alpha == NULL) @@ -1173,13 +1174,13 @@ ret = compress_grayscale_png16 (pixels, width, height, sample_type, &blob, &blob_size); else ret = - compress_grayscale_png8 (pixels, mask, opacity, width, height, - sample_type, pixel_type, &blob, - &blob_size); + compress_grayscale_png8 (pixels, mask, opacity, width, + height, sample_type, pixel_type, + &blob, &blob_size); break; case RL2_PIXEL_RGB: if (sample_type == RL2_SAMPLE_UINT8) ret = compress_rgb_png8 (pixels, mask, opacity, width, height, @@ -1191,12 +1192,12 @@ case RL2_PIXEL_MULTIBAND: if (sample_type == RL2_SAMPLE_UINT8) { if (num_bands == 3) ret = - compress_rgb_png8 (pixels, mask, opacity, width, height, - &blob, &blob_size); + compress_rgb_png8 (pixels, mask, opacity, width, + height, &blob, &blob_size); else if (num_bands == 4) ret = compress_4bands_png8 (pixels, width, height, &blob, &blob_size); } @@ -1413,12 +1414,13 @@ } if (*xpixel_type == RL2_PIXEL_DATAGRID) pixel_type = RL2_PIXEL_DATAGRID; if (pixel_type == RL2_PIXEL_PALETTE) { - if (png_get_tRNS (png_ptr, info_ptr, &transp, &nTransp, &transpValues) - == PNG_INFO_tRNS) + if (png_get_tRNS + (png_ptr, info_ptr, &transp, &nTransp, + &transpValues) == PNG_INFO_tRNS) { /* a Transparency palette is defined */ int i; for (i = 0; i < nTransp; i++) *(alpha + i) = *(transp + i); Index: src/rl2pyramid.c ================================================================== --- src/rl2pyramid.c +++ src/rl2pyramid.c @@ -257,12 +257,12 @@ table = sqlite3_mprintf ("%s_tiles", coverage); xtable = rl2_double_quoted_sql (table); sqlite3_free (table); sql = sqlite3_mprintf ("SELECT Count(*) FROM \"%s\" " - "WHERE section_id = %s AND pyramid_level > 0", xtable, - sect_id); + "WHERE section_id = %s AND pyramid_level > 0", + xtable, sect_id); free (xtable); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) return 1; @@ -349,12 +349,13 @@ stmt = NULL; if (!ok) goto error; /* Coverage's palette and no-data */ - sql = sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages " - "WHERE Lower(coverage_name) = Lower(%Q)", coverage); + sql = + sqlite3_mprintf ("SELECT palette, nodata_pixel FROM raster_coverages " + "WHERE Lower(coverage_name) = Lower(%Q)", coverage); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) { fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle)); @@ -489,13 +490,13 @@ } free (pyr); } static int -insert_tile_into_section_pyramid (SectionPyramidPtr pyr, sqlite3_int64 tile_id, - double minx, double miny, double maxx, - double maxy) +insert_tile_into_section_pyramid (SectionPyramidPtr pyr, + sqlite3_int64 tile_id, double minx, + double miny, double maxx, double maxy) { /* inserting a base tile into the Pyramid level */ SectionPyramidTileInPtr tile; if (pyr == NULL) return 0; @@ -574,12 +575,12 @@ && tile->cy < maxy) { if (first) { out = - add_pyramid_out_tile (pyr, row, col, minx, miny, maxx, - maxy); + add_pyramid_out_tile (pyr, row, col, minx, miny, + maxx, maxy); first = 0; } if (out != NULL) add_pyramid_sub_tile (out, tile); } @@ -765,12 +766,12 @@ unsigned int xx = col + x; char *p_out = p_out_base + xx; if (xx >= tileWidth) break; *p_out = - rescale_pixel_int8 (buf_in, tileWidth, tileHeight, col * 8, - row * 8, nd); + rescale_pixel_int8 (buf_in, tileWidth, tileHeight, + col * 8, row * 8, nd); } } } static double @@ -845,12 +846,12 @@ unsigned int xx = col + x; unsigned char *p_out = p_out_base + xx; if (xx >= tileWidth) break; *p_out = - rescale_pixel_uint8 (buf_in, tileWidth, tileHeight, col * 8, - row * 8, nd); + rescale_pixel_uint8 (buf_in, tileWidth, tileHeight, + col * 8, row * 8, nd); } } } static double @@ -925,12 +926,12 @@ unsigned int xx = col + x; short *p_out = p_out_base + xx; if (xx >= tileWidth) break; *p_out = - rescale_pixel_int16 (buf_in, tileWidth, tileHeight, col * 8, - row * 8, nd); + rescale_pixel_int16 (buf_in, tileWidth, tileHeight, + col * 8, row * 8, nd); } } } static double @@ -1085,12 +1086,12 @@ unsigned int xx = col + x; int *p_out = p_out_base + xx; if (xx >= tileWidth) break; *p_out = - rescale_pixel_int32 (buf_in, tileWidth, tileHeight, col * 8, - row * 8, nd); + rescale_pixel_int32 (buf_in, tileWidth, tileHeight, + col * 8, row * 8, nd); } } } static double @@ -1245,12 +1246,12 @@ unsigned int xx = col + x; float *p_out = p_out_base + xx; if (xx >= tileWidth) break; *p_out = - rescale_pixel_float (buf_in, tileWidth, tileHeight, col * 8, - row * 8, nd); + rescale_pixel_float (buf_in, tileWidth, tileHeight, + col * 8, row * 8, nd); } } } static double @@ -1346,13 +1347,13 @@ rescale_grid_int8 ((char *) buf_out, tileWidth, tileHeight, (const char *) buf_in, x, y, tic_x, tic_y, no_data); break; case RL2_SAMPLE_UINT8: - rescale_grid_uint8 ((unsigned char *) buf_out, tileWidth, tileHeight, - (const unsigned char *) buf_in, x, y, tic_x, - tic_y, no_data); + rescale_grid_uint8 ((unsigned char *) buf_out, tileWidth, + tileHeight, (const unsigned char *) buf_in, x, + y, tic_x, tic_y, no_data); break; case RL2_SAMPLE_INT16: rescale_grid_int16 ((short *) buf_out, tileWidth, tileHeight, (const short *) buf_in, x, y, tic_x, tic_y, no_data); @@ -1366,13 +1367,13 @@ rescale_grid_int32 ((int *) buf_out, tileWidth, tileHeight, (const int *) buf_in, x, y, tic_x, tic_y, no_data); break; case RL2_SAMPLE_UINT32: - rescale_grid_uint32 ((unsigned int *) buf_out, tileWidth, tileHeight, - (const unsigned int *) buf_in, x, y, tic_x, - tic_y, no_data); + rescale_grid_uint32 ((unsigned int *) buf_out, tileWidth, + tileHeight, (const unsigned int *) buf_in, x, + y, tic_x, tic_y, no_data); break; case RL2_SAMPLE_FLOAT: rescale_grid_float ((float *) buf_out, tileWidth, tileHeight, (const float *) buf_in, x, y, tic_x, tic_y, no_data); @@ -1517,12 +1518,13 @@ pos_x += geo_x; } pos_y -= geo_y; } rst = (rl2PrivRasterPtr) raster_in; - rescale_grid (buf_out, tileWidth, tileHeight, rst->rasterBuffer, - sample_type, x, y, tic_x, tic_y, no_data); + rescale_grid (buf_out, tileWidth, tileHeight, + rst->rasterBuffer, sample_type, x, y, tic_x, + tic_y, no_data); rl2_destroy_raster (raster_in); raster_in = NULL; tile_in = tile_in->next; } @@ -1548,13 +1550,14 @@ rl2_destroy_raster (raster_out); raster_out = NULL; /* INSERTing the tile */ if (!do_insert_pyramid_tile - (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level, - pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny, - tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data)) + (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, + id_level, pyr->section_id, pyr->srid, tile_out->minx, + tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils, + stmt_data)) goto error; tile_out = tile_out->next; } @@ -1572,12 +1575,12 @@ return 0; } static double rescale_mb_pixel_uint8 (const unsigned char *buf_in, unsigned int tileWidth, - unsigned int tileHeight, unsigned int x, unsigned int y, - unsigned char nd, unsigned char nb, + unsigned int tileHeight, unsigned int x, + unsigned int y, unsigned char nd, unsigned char nb, unsigned char num_bands) { /* rescaling a MultiBand pixel sample (8x8) - UINT8 */ unsigned int row; unsigned int col; @@ -1650,13 +1653,13 @@ rl2PrivSamplePtr sample = pxl->Samples + nb; nd = sample->uint8; } } *(p_out + nb) = - rescale_mb_pixel_uint8 (buf_in, tileWidth, tileHeight, - col * 8, row * 8, nd, nb, - num_bands); + rescale_mb_pixel_uint8 (buf_in, tileWidth, + tileHeight, col * 8, + row * 8, nd, nb, num_bands); } } } } @@ -1740,12 +1743,12 @@ nd = sample->uint16; } } *(p_out + nb) = rescale_mb_pixel_uint16 (buf_in, tileWidth, - tileHeight, col * 8, row * 8, - nd, nb, num_bands); + tileHeight, col * 8, + row * 8, nd, nb, num_bands); } } } } @@ -1764,12 +1767,13 @@ tileHeight, (const unsigned char *) buf_in, x, y, tic_x, tic_y, num_bands, no_data); break; case RL2_SAMPLE_UINT16: rescale_multiband_uint16 ((unsigned short *) buf_out, tileWidth, - tileHeight, (const unsigned short *) buf_in, - x, y, tic_x, tic_y, num_bands, no_data); + tileHeight, + (const unsigned short *) buf_in, x, y, + tic_x, tic_y, num_bands, no_data); break; }; } static int @@ -1898,12 +1902,12 @@ } pos_y -= geo_y; } rst = (rl2PrivRasterPtr) raster_in; rescale_multiband (buf_out, tileWidth, tileHeight, - rst->rasterBuffer, sample_type, num_bands, x, - y, tic_x, tic_y, no_data); + rst->rasterBuffer, sample_type, num_bands, + x, y, tic_x, tic_y, no_data); rl2_destroy_raster (raster_in); raster_in = NULL; tile_in = tile_in->next; } @@ -1929,13 +1933,14 @@ rl2_destroy_raster (raster_out); raster_out = NULL; /* INSERTing the tile */ if (!do_insert_pyramid_tile - (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level, - pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny, - tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data)) + (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, + id_level, pyr->section_id, pyr->srid, tile_out->minx, + tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils, + stmt_data)) goto error; tile_out = tile_out->next; } @@ -2120,24 +2125,24 @@ compression = RL2_COMPRESSION_PNG; } else nd = rl2_clone_pixel (no_data); raster = - rl2_create_raster (tileWidth, tileHeight, RL2_SAMPLE_UINT8, - RL2_PIXEL_GRAYSCALE, 1, gray, - tileWidth * tileHeight, NULL, alpha, - tileWidth * tileHeight, nd); + rl2_create_raster (tileWidth, tileHeight, + RL2_SAMPLE_UINT8, RL2_PIXEL_GRAYSCALE, + 1, gray, tileWidth * tileHeight, NULL, + alpha, tileWidth * tileHeight, nd); } else if (pyr->pixel_type == RL2_PIXEL_RGB) { /* RGB Pyramid */ nd = rl2_clone_pixel (no_data); raster = - rl2_create_raster (tileWidth, tileHeight, RL2_SAMPLE_UINT8, - RL2_PIXEL_RGB, 3, rgb, - tileWidth * tileHeight * 3, NULL, alpha, - tileWidth * tileHeight, nd); + rl2_create_raster (tileWidth, tileHeight, + RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, 3, + rgb, tileWidth * tileHeight * 3, NULL, + alpha, tileWidth * tileHeight, nd); } if (raster == NULL) { fprintf (stderr, "ERROR: unable to create a Pyramid Tile\n"); goto error; @@ -2154,13 +2159,14 @@ rl2_graph_destroy_context (ctx); ctx = NULL; /* INSERTing the tile */ if (!do_insert_pyramid_tile - (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, id_level, - pyr->section_id, pyr->srid, tile_out->minx, tile_out->miny, - tile_out->maxx, tile_out->maxy, stmt_tils, stmt_data)) + (handle, blob_odd, blob_odd_sz, blob_even, blob_even_sz, + id_level, pyr->section_id, pyr->srid, tile_out->minx, + tile_out->miny, tile_out->maxx, tile_out->maxy, stmt_tils, + stmt_data)) goto error; tile_out = tile_out->next; } @@ -2342,13 +2348,13 @@ } #define floor2(exp) ((long) exp) static rl2RasterPtr -create_124_rescaled_raster (const unsigned char *rgba, unsigned char pixel_type, - unsigned int tileWidth, unsigned int tileHeight, - int scale) +create_124_rescaled_raster (const unsigned char *rgba, + unsigned char pixel_type, unsigned int tileWidth, + unsigned int tileHeight, int scale) { /* creating a rescaled raster (1,2 or 4 bit pyramids) / / this function builds an high quality rescaled sub-image by applying pixel interpolation / @@ -2531,12 +2537,13 @@ } } } raster = - rl2_create_raster (out_width, out_height, RL2_SAMPLE_UINT8, pixel_type, - num_bands, rgb, rgb_sz, NULL, mask, mask_sz, NULL); + rl2_create_raster (out_width, out_height, RL2_SAMPLE_UINT8, + pixel_type, num_bands, rgb, rgb_sz, NULL, mask, + mask_sz, NULL); return raster; } static void copy_124_rescaled (rl2RasterPtr raster_out, rl2RasterPtr raster_in, @@ -2742,12 +2749,12 @@ rgba = load_tile_base (stmt_data, tile_id, palette, no_data); if (rgba == NULL) goto error; base_tile = - create_124_rescaled_raster (rgba, out_pixel_type, tileWidth, - tileHeight, factor); + create_124_rescaled_raster (rgba, out_pixel_type, + tileWidth, tileHeight, factor); free (rgba); if (base_tile == NULL) goto error; shift_x = tile_x - minx; shift_y = maxy - tile_y; @@ -3117,12 +3124,13 @@ free (sum); *p_msk = 1; } static void -mb_prime_nodata_u8 (unsigned char *buf, unsigned int width, unsigned int height, - unsigned char num_bands, rl2PixelPtr no_data) +mb_prime_nodata_u8 (unsigned char *buf, unsigned int width, + unsigned int height, unsigned char num_bands, + rl2PixelPtr no_data) { /* priming a void buffer */ rl2PrivPixelPtr nd = (rl2PrivPixelPtr) no_data; unsigned int x; unsigned int y; @@ -3246,13 +3254,13 @@ ox, oy, no_data); break; case RL2_SAMPLE_UINT16: rescale_multiband_u16 (tileWidth, tileHeight, num_bands, out_width, out_height, factor, - (unsigned short *) buf_in, mask_in, - (unsigned short *) buf, mask, x, y, - ox, oy, no_data); + (unsigned short *) buf_in, + mask_in, (unsigned short *) buf, + mask, x, y, ox, oy, no_data); break; }; ox++; } oy++; @@ -4038,20 +4046,20 @@ (unsigned char *) buf, mask, x, y, ox, oy, no_data_u8); break; case RL2_SAMPLE_INT16: rescale_datagrid_16 (tileWidth, tileHeight, out_width, - out_height, factor, (short *) buf_in, - (short *) buf, mask, x, y, ox, oy, - no_data_16); + out_height, factor, + (short *) buf_in, (short *) buf, + mask, x, y, ox, oy, no_data_16); break; case RL2_SAMPLE_UINT16: rescale_datagrid_u16 (tileWidth, tileHeight, out_width, out_height, factor, (unsigned short *) buf_in, - (unsigned short *) buf, mask, x, y, - ox, oy, no_data_u16); + (unsigned short *) buf, mask, x, + y, ox, oy, no_data_u16); break; case RL2_SAMPLE_INT32: rescale_datagrid_32 (tileWidth, tileHeight, out_width, out_height, factor, (int *) buf_in, (int *) buf, mask, x, y, ox, oy, @@ -4091,14 +4099,15 @@ static int rescale_monolithic_multiband (int id_level, unsigned int tileWidth, unsigned int tileHeight, unsigned char sample_type, - unsigned char num_bands, int factor, double res_x, - double res_y, double minx, double miny, - double maxx, double maxy, unsigned char *buffer, - int buf_size, unsigned char *mask, int *mask_size, + unsigned char num_bands, int factor, + double res_x, double res_y, double minx, + double miny, double maxx, double maxy, + unsigned char *buffer, int buf_size, + unsigned char *mask, int *mask_size, rl2PixelPtr no_data, sqlite3_stmt * stmt_geo, sqlite3_stmt * stmt_data) { /* rescaling monolithic MultiBand */ rl2RasterPtr raster = NULL; @@ -4120,12 +4129,12 @@ { /* priming full transparency */ for (x = 0; x < tileWidth; x++) *p_out++ = 0; } - rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type, num_bands, - no_data); + rl2_prime_void_tile (buffer, tileWidth, tileHeight, sample_type, + num_bands, no_data); /* creating the output raster */ raster = rl2_create_raster (tileWidth, tileHeight, sample_type, RL2_PIXEL_MULTIBAND, num_bands, buffer, buf_size, NULL, mask, *mask_size, nd); @@ -4331,11 +4340,12 @@ return 0; } static int prepare_section_pyramid_stmts (sqlite3 * handle, const char *coverage, - int mixed_resolutions, sqlite3_stmt ** xstmt_rd, + int mixed_resolutions, + sqlite3_stmt ** xstmt_rd, sqlite3_stmt ** xstmt_levl, sqlite3_stmt ** xstmt_tils, sqlite3_stmt ** xstmt_data) { /* preparing the section pyramid related SQL statements */ @@ -4502,12 +4512,12 @@ (handle, coverage, section_id, §_width, §_height, &minx, &miny, &maxx, &maxy, &palette, &no_data)) goto error; if (!prepare_section_pyramid_stmts - (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils, - &stmt_data)) + (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, + &stmt_tils, &stmt_data)) goto error; while (1) { /* looping on pyramid levels */ @@ -4582,17 +4592,18 @@ { pyr = alloc_sect_pyramid (section_id, sect_width, sect_height, sample_type, pixel_type, num_samples, - compression, quality, srid, - new_res_x, new_res_y, + compression, quality, + srid, new_res_x, + new_res_y, (double) tileWidth * new_res_x, (double) tileHeight * - new_res_y, minx, miny, maxx, - maxy, scale); + new_res_y, minx, miny, + maxx, maxy, scale); first = 0; if (pyr == NULL) goto error; } if (!insert_tile_into_section_pyramid @@ -4956,15 +4967,15 @@ static int get_section_raw_raster_data (sqlite3 * handle, int max_threads, const char *coverage, sqlite3_int64 sect_id, unsigned int width, unsigned int height, unsigned char sample_type, - unsigned char pixel_type, unsigned char num_bands, - double minx, double maxy, double x_res, - double y_res, unsigned char **buffer, - int *buf_size, rl2PalettePtr palette, - rl2PixelPtr no_data) + unsigned char pixel_type, + unsigned char num_bands, double minx, + double maxy, double x_res, double y_res, + unsigned char **buffer, int *buf_size, + rl2PalettePtr palette, rl2PixelPtr no_data) { /* attempting to return a buffer containing raw pixels from the whole DBMS Section */ unsigned char *bufpix = NULL; int bufpix_size; char *xtiles; @@ -5002,13 +5013,13 @@ /* preparing the "tiles" SQL query */ xtiles = sqlite3_mprintf ("%s_tiles", coverage); xxtiles = rl2_double_quoted_sql (xtiles); sql = - sqlite3_mprintf ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) " - "FROM \"%s\" " - "WHERE pyramid_level = 0 AND section_id = ?", xxtiles); + sqlite3_mprintf + ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) " + "FROM \"%s\" " "WHERE pyramid_level = 0 AND section_id = ?", xxtiles); sqlite3_free (xtiles); free (xxtiles); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) @@ -5061,11 +5072,12 @@ return 0; } static void raster_tile_124_rescaled (unsigned char *outbuf, - unsigned char pixel_type, const unsigned char *inbuf, + unsigned char pixel_type, + const unsigned char *inbuf, unsigned int section_width, unsigned int section_height, unsigned int out_width, unsigned int out_height, rl2PalettePtr palette) { /* @@ -5359,12 +5371,13 @@ sqlite3_int64 section_id, unsigned char sample_type, unsigned char pixel_type, unsigned char num_samples, int srid, unsigned int tileWidth, - unsigned int tileHeight, unsigned char bgRed, - unsigned char bgGreen, unsigned char bgBlue) + unsigned int tileHeight, + unsigned char bgRed, unsigned char bgGreen, + unsigned char bgBlue) { /* attempting to (re)build a 1,2,4-bit section pyramid from scratch */ double base_res_x; double base_res_y; unsigned int sect_width; @@ -5427,12 +5440,12 @@ sample_type, pixel_type, num_samples, minx, maxy, base_res_x, base_res_y, &inbuf, &inbuf_size, palette, no_data)) goto error; if (!prepare_section_pyramid_stmts - (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils, - &stmt_data)) + (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, + &stmt_tils, &stmt_data)) goto error; id_level = 1; scale = 2; x_res = base_res_x * 2.0; @@ -5530,16 +5543,18 @@ else { /* converting the NO-DATA pixel */ nd = rl2_create_pixel (RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, 3); - rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND, + rl2_set_pixel_sample_uint8 (nd, + RL2_RED_BAND, bgRed); rl2_set_pixel_sample_uint8 (nd, RL2_GREEN_BAND, bgGreen); - rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND, + rl2_set_pixel_sample_uint8 (nd, + RL2_BLUE_BAND, bgBlue); } } t_maxx = t_minx + (tileWidth * x_res); if (!copy_124_tile @@ -5565,12 +5580,13 @@ fprintf (stderr, "ERROR: unable to create a Pyramid Tile\n"); goto error; } if (rl2_raster_encode - (raster, RL2_COMPRESSION_PNG, &blob_odd, &blob_odd_sz, - &blob_even, &blob_even_sz, 100, 1) != RL2_OK) + (raster, RL2_COMPRESSION_PNG, &blob_odd, + &blob_odd_sz, &blob_even, &blob_even_sz, 100, + 1) != RL2_OK) { fprintf (stderr, "ERROR: unable to encode a Pyramid tile\n"); goto error; } @@ -5636,12 +5652,13 @@ static int do_build_palette_section_pyramid (sqlite3 * handle, int max_threads, const char *coverage, int mixed_resolutions, sqlite3_int64 section_id, int srid, unsigned int tileWidth, - unsigned int tileHeight, unsigned char bgRed, - unsigned char bgGreen, unsigned char bgBlue) + unsigned int tileHeight, + unsigned char bgRed, unsigned char bgGreen, + unsigned char bgBlue) { /* attempting to (re)build a Palette section pyramid from scratch */ double base_res_x; double base_res_y; unsigned int sect_width; @@ -5706,12 +5723,12 @@ RL2_SAMPLE_UINT8, RL2_PIXEL_PALETTE, 1, minx, maxy, base_res_x, base_res_y, &inbuf, &inbuf_size, palette, no_data)) goto error; if (!prepare_section_pyramid_stmts - (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, &stmt_tils, - &stmt_data)) + (handle, coverage, mixed_resolutions, &stmt_rd, &stmt_levl, + &stmt_tils, &stmt_data)) goto error; id_level = 1; scale = 2; x_res = base_res_x * 2.0; @@ -5782,13 +5799,14 @@ rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND, bgBlue); } t_maxx = t_minx + (tileWidth * x_res); if (!copy_124_tile (out_pixel_type, outbuf, &tilebuf, - &tilebuf_sz, &tilemask, &tilemask_sz, - row, col, out_width, out_height, - tileWidth, tileHeight, no_data)) + &tilebuf_sz, &tilemask, + &tilemask_sz, row, col, out_width, + out_height, tileWidth, tileHeight, + no_data)) { fprintf (stderr, "ERROR: unable to extract a Pyramid Tile\n"); goto error; } @@ -6051,12 +6069,12 @@ else { /* ordinary RGB, Grayscale, MultiBand or DataGrid Pyramid */ if (!do_build_section_pyramid (handle, coverage, section_id, sample_type, pixel_type, - num_bands, compression, ptrcvg->mixedResolutions, quality, - srid, tileWidth, tileHeight)) + num_bands, compression, ptrcvg->mixedResolutions, + quality, srid, tileWidth, tileHeight)) goto error; } if (verbose) { printf (" ----------\n"); @@ -6109,12 +6127,12 @@ break; if (ret == SQLITE_ROW) { sqlite3_int64 section_id = sqlite3_column_int64 (stmt, 0); if (rl2_build_section_pyramid - (handle, max_threads, coverage, section_id, forced_rebuild, - verbose) != RL2_OK) + (handle, max_threads, coverage, section_id, + forced_rebuild, verbose) != RL2_OK) goto error; } else { fprintf (stderr, @@ -6283,12 +6301,12 @@ out_num_bands = 3; out_compression = RL2_COMPRESSION_PNG; out_quality = 100; virt_levels = 1; } - else if (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE - && num_bands == 1) + else if (sample_type == RL2_SAMPLE_UINT8 + && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1) { /* palette 8: output colorspace is RGB compression PNG */ out_sample_type = RL2_SAMPLE_UINT8; out_pixel_type = RL2_PIXEL_RGB; out_num_bands = 3; @@ -6405,22 +6423,23 @@ if ((sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_GRAYSCALE && num_bands == 1) || (sample_type == RL2_SAMPLE_UINT8 - && pixel_type == RL2_PIXEL_RGB && num_bands == 3) + && pixel_type == RL2_PIXEL_RGB + && num_bands == 3) || (sample_type == RL2_SAMPLE_UINT8 && pixel_type == RL2_PIXEL_PALETTE && num_bands == 1)) { /* RGB, PALETTE or GRAYSCALE datasource (UINT8) */ if (!rescale_monolithic_rgba - (id_level, tileWidth, tileHeight, resize_factor, - res_x, res_y, tile_minx, tile_miny, - tile_maxx, tile_maxy, buffer, buf_size, mask, - &mask_size, palette, no_data, stmt_geo, - stmt_rd)) + (id_level, tileWidth, tileHeight, + resize_factor, res_x, res_y, tile_minx, + tile_miny, tile_maxx, tile_maxy, buffer, + buf_size, mask, &mask_size, palette, no_data, + stmt_geo, stmt_rd)) goto error; if (mask_size == 0) mask = NULL; } else if (((sample_type == RL2_SAMPLE_1_BIT @@ -6462,12 +6481,12 @@ /* DataGrid */ if (!rescale_monolithic_datagrid (id_level, tileWidth, tileHeight, sample_type, resize_factor, res_x, res_y, tile_minx, tile_miny, tile_maxx, tile_maxy, buffer, - buf_size, mask, &mask_size, no_data, stmt_geo, - stmt_rd)) + buf_size, mask, &mask_size, no_data, + stmt_geo, stmt_rd)) goto error; if (mask_size == 0) mask = NULL; } else @@ -6515,16 +6534,18 @@ nd = NULL; else { nd = rl2_create_pixel (RL2_SAMPLE_UINT8, RL2_PIXEL_RGB, 3); - rl2_set_pixel_sample_uint8 (nd, RL2_RED_BAND, + rl2_set_pixel_sample_uint8 (nd, + RL2_RED_BAND, 255); rl2_set_pixel_sample_uint8 (nd, RL2_GREEN_BAND, 255); - rl2_set_pixel_sample_uint8 (nd, RL2_BLUE_BAND, + rl2_set_pixel_sample_uint8 (nd, + RL2_BLUE_BAND, 255); } } else nd = rl2_clone_pixel (no_data); @@ -6608,12 +6629,13 @@ sqlite3_finalize (stmt_tils); sqlite3_finalize (stmt_data); if (verbose) { printf (" ----------\n"); - printf (" Monolithic Pyramid levels successfully built for: %s\n", - coverage); + printf + (" Monolithic Pyramid levels successfully built for: %s\n", + coverage); } free (buffer); free (mask); rl2_destroy_coverage (cvg); Index: src/rl2rastersym.c ================================================================== --- src/rl2rastersym.c +++ src/rl2rastersym.c @@ -692,11 +692,12 @@ } else { /* opaque pixel */ p_out = - mono_int8_pixel_handler (p_in, p_out, mono_band, + mono_int8_pixel_handler (p_in, p_out, + mono_band, mono_handling); } } else { @@ -709,11 +710,12 @@ match++; if (match != 1) { /* opaque pixel */ p_out = - mono_int8_pixel_handler (p_in, p_out, mono_band, + mono_int8_pixel_handler (p_in, p_out, + mono_band, mono_handling); } else { /* NO-DATA pixel */ @@ -760,11 +762,12 @@ if (rl2_get_pixel_type (no_data, &sample_type, &pixel_type, &nbands) != RL2_OK) ignore_no_data = 1; if (nbands != num_bands) ignore_no_data = 1; - if (sample_type == RL2_SAMPLE_1_BIT || sample_type == RL2_SAMPLE_2_BIT + if (sample_type == RL2_SAMPLE_1_BIT + || sample_type == RL2_SAMPLE_2_BIT || sample_type == RL2_SAMPLE_4_BIT || sample_type == RL2_SAMPLE_UINT8) ; else ignore_no_data = 1; @@ -879,16 +882,17 @@ static void copy_uint8_raw_selected_pixels (const unsigned char *buffer, const unsigned char *mask, unsigned char *outbuf, unsigned short width, - unsigned short height, unsigned char num_bands, - double x_res, double y_res, double minx, - double maxy, double tile_minx, double tile_maxy, + unsigned short height, + unsigned char num_bands, double x_res, + double y_res, double minx, double maxy, + double tile_minx, double tile_maxy, unsigned short tile_width, - unsigned short tile_height, rl2PixelPtr no_data, - unsigned char red_band, + unsigned short tile_height, + rl2PixelPtr no_data, unsigned char red_band, unsigned char green_band, unsigned char blue_band, rl2BandHandlingPtr red_handling, rl2BandHandlingPtr green_handling, rl2BandHandlingPtr blue_handling) @@ -967,11 +971,12 @@ } else { /* opaque pixel */ p_out = - mono_uint8_pixel_handler (p_in, p_out, red_band, + mono_uint8_pixel_handler (p_in, p_out, + red_band, red_handling); p_out = mono_uint8_pixel_handler (p_in, p_out, green_band, green_handling); @@ -995,11 +1000,12 @@ } if (match != num_bands) { /* opaque pixel */ p_out = - mono_uint8_pixel_handler (p_in, p_out, red_band, + mono_uint8_pixel_handler (p_in, p_out, + red_band, red_handling); p_out = mono_uint8_pixel_handler (p_in, p_out, green_band, green_handling); @@ -1022,13 +1028,14 @@ static void copy_uint8_raw_mono_pixels (const unsigned char *buffer, const unsigned char *mask, unsigned char *outbuf, unsigned short width, unsigned short height, unsigned char out_num_bands, - unsigned char num_bands, double x_res, double y_res, - double minx, double maxy, double tile_minx, - double tile_maxy, unsigned short tile_width, + unsigned char num_bands, double x_res, + double y_res, double minx, double maxy, + double tile_minx, double tile_maxy, + unsigned short tile_width, unsigned short tile_height, rl2PixelPtr no_data, unsigned char mono_band, rl2BandHandlingPtr mono_handling) { /* copying UINT8 raw pixels from the DBMS tile into the output image */ @@ -1395,17 +1402,17 @@ } } } static void -copy_uint16_raw_pixels (const unsigned short *buffer, const unsigned char *mask, - unsigned short *outbuf, unsigned short width, - unsigned short height, unsigned char num_bands, - double x_res, double y_res, double minx, double maxy, - double tile_minx, double tile_maxy, - unsigned short tile_width, unsigned short tile_height, - rl2PixelPtr no_data) +copy_uint16_raw_pixels (const unsigned short *buffer, + const unsigned char *mask, unsigned short *outbuf, + unsigned short width, unsigned short height, + unsigned char num_bands, double x_res, double y_res, + double minx, double maxy, double tile_minx, + double tile_maxy, unsigned short tile_width, + unsigned short tile_height, rl2PixelPtr no_data) { /* copying UINT16 raw pixels from the DBMS tile into the output image */ int x; int y; int b; @@ -1532,14 +1539,15 @@ static void copy_uint16_raw_selected_pixels (const unsigned short *buffer, const unsigned char *mask, unsigned char *outbuf, unsigned short width, - unsigned short height, unsigned char num_bands, - double x_res, double y_res, double minx, - double maxy, double tile_minx, - double tile_maxy, unsigned short tile_width, + unsigned short height, + unsigned char num_bands, double x_res, + double y_res, double minx, double maxy, + double tile_minx, double tile_maxy, + unsigned short tile_width, unsigned short tile_height, rl2PixelPtr no_data, unsigned char red_band, unsigned char green_band, unsigned char blue_band, rl2BandHandlingPtr red_handling, @@ -3077,12 +3085,12 @@ { r = malloc (sizeof (rl2BandHandling)); r->colorMap = NULL; r->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NORMALIZE; - compute_stretching (band, &(r->minValue), &(r->maxValue), - &(r->scaleFactor)); + compute_stretching (band, &(r->minValue), + &(r->maxValue), &(r->scaleFactor)); } else if (style->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NONE) { r = malloc (sizeof (rl2BandHandling)); @@ -3163,12 +3171,12 @@ { g = malloc (sizeof (rl2BandHandling)); g->colorMap = NULL; g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NORMALIZE; - compute_stretching (band, &(g->minValue), &(g->maxValue), - &(g->scaleFactor)); + compute_stretching (band, &(g->minValue), + &(g->maxValue), &(g->scaleFactor)); } else if (style->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NONE) { g = malloc (sizeof (rl2BandHandling)); @@ -3249,12 +3257,12 @@ { b = malloc (sizeof (rl2BandHandling)); b->colorMap = NULL; b->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NORMALIZE; - compute_stretching (band, &(b->minValue), &(b->maxValue), - &(b->scaleFactor)); + compute_stretching (band, &(b->minValue), + &(b->maxValue), &(b->scaleFactor)); } else if (style->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NONE) { b = malloc (sizeof (rl2BandHandling)); @@ -3601,12 +3609,12 @@ { g = malloc (sizeof (rl2BandHandling)); g->colorMap = NULL; g->contrastEnhancement = RL2_CONTRAST_ENHANCEMENT_NORMALIZE; - compute_stretching (band, &(g->minValue), &(g->maxValue), - &(g->scaleFactor)); + compute_stretching (band, &(g->minValue), + &(g->maxValue), &(g->scaleFactor)); } else if (style->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NONE) { g = malloc (sizeof (rl2BandHandling)); @@ -3895,13 +3903,14 @@ static int do_copy_raw_selected_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf, unsigned int width, unsigned int height, double x_res, double y_res, double minx, double maxy, double tile_minx, double tile_maxy, - unsigned int tile_width, unsigned int tile_height, - rl2PixelPtr no_data, unsigned char red_band, - unsigned char green_band, unsigned char blue_band, + unsigned int tile_width, + unsigned int tile_height, rl2PixelPtr no_data, + unsigned char red_band, unsigned char green_band, + unsigned char blue_band, rl2BandHandlingPtr red_handling, rl2BandHandlingPtr green_handling, rl2BandHandlingPtr blue_handling) { switch (rst->sampleType) @@ -4161,12 +4170,13 @@ static int do_copy_raw_pixels (rl2PrivRasterPtr rst, unsigned char *outbuf, unsigned int width, unsigned int height, unsigned char sample_type, unsigned char num_bands, double x_res, double y_res, double minx, double maxy, - double tile_minx, double tile_maxy, unsigned int tile_width, - unsigned int tile_height, rl2PixelPtr no_data) + double tile_minx, double tile_maxy, + unsigned int tile_width, unsigned int tile_height, + rl2PixelPtr no_data) { switch (sample_type) { @@ -4183,11 +4193,12 @@ (short *) outbuf, width, height, x_res, y_res, minx, maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data); return 1; case RL2_SAMPLE_UINT16: - copy_uint16_raw_pixels ((const unsigned short *) (rst->rasterBuffer), + copy_uint16_raw_pixels ((const unsigned short + *) (rst->rasterBuffer), (const unsigned char *) (rst->maskBuffer), (unsigned short *) outbuf, width, height, num_bands, x_res, y_res, minx, maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data); @@ -4224,12 +4235,13 @@ return 1; default: copy_uint8_raw_pixels ((const unsigned char *) (rst->rasterBuffer), (const unsigned char *) (rst->maskBuffer), (unsigned char *) outbuf, width, height, - num_bands, x_res, y_res, minx, maxy, tile_minx, - tile_maxy, tile_width, tile_height, no_data); + num_bands, x_res, y_res, minx, maxy, + tile_minx, tile_maxy, tile_width, + tile_height, no_data); return 1; }; return 0; } @@ -4236,13 +4248,14 @@ RL2_PRIVATE int rl2_copy_raw_pixels (rl2RasterPtr raster, unsigned char *outbuf, unsigned int width, unsigned int height, unsigned char sample_type, unsigned char num_bands, unsigned char auto_ndvi, - unsigned char red_band_index, unsigned char nir_band_index, - double x_res, double y_res, double minx, double maxy, - double tile_minx, double tile_maxy, rl2PixelPtr no_data, + unsigned char red_band_index, + unsigned char nir_band_index, double x_res, double y_res, + double minx, double maxy, double tile_minx, + double tile_maxy, rl2PixelPtr no_data, rl2RasterSymbolizerPtr style, rl2RasterStatisticsPtr stats) { /* copying raw pixels into the output buffer */ unsigned int tile_width; unsigned int tile_height; @@ -4254,12 +4267,12 @@ { /* attempting to apply a RasterSymbolizer */ int yes_no; int categorize; int interpolate; - if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no) == - RL2_OK) + if (rl2_is_raster_symbolizer_triple_band_selected (style, &yes_no) + == RL2_OK) { if ((rst->sampleType == RL2_SAMPLE_UINT8 || rst->sampleType == RL2_SAMPLE_UINT16) && (rst->pixelType == RL2_PIXEL_RGB || rst->pixelType == RL2_PIXEL_MULTIBAND) && yes_no) @@ -4289,14 +4302,15 @@ &blue_handling); if (red_handling == NULL || green_handling == NULL || blue_handling == NULL) return 0; if (do_copy_raw_selected_pixels - (rst, outbuf, width, height, x_res, y_res, minx, maxy, - tile_minx, tile_maxy, tile_width, tile_height, - no_data, red_band, green_band, blue_band, - red_handling, green_handling, blue_handling)) + (rst, outbuf, width, height, x_res, y_res, minx, + maxy, tile_minx, tile_maxy, tile_width, + tile_height, no_data, red_band, green_band, + blue_band, red_handling, green_handling, + blue_handling)) return 1; if (red_handling != NULL) free (red_handling); if (green_handling != NULL) free (green_handling); @@ -4318,14 +4332,14 @@ build_ndvi_handling ((rl2PrivRasterSymbolizerPtr) style, &ndvi_handling); if (ndvi_handling == NULL) return 0; if (do_auto_ndvi_pixels - (rst, outbuf, width, height, num_bands, x_res, y_res, - minx, maxy, tile_minx, tile_maxy, tile_width, - tile_height, no_data, red_band_index, nir_band_index, - ndvi_handling)) + (rst, outbuf, width, height, num_bands, x_res, + y_res, minx, maxy, tile_minx, tile_maxy, + tile_width, tile_height, no_data, red_band_index, + nir_band_index, ndvi_handling)) return 1; if (ndvi_handling != NULL) destroy_ndvi_handling (ndvi_handling); } if (((rst->sampleType == RL2_SAMPLE_UINT8 @@ -4346,23 +4360,24 @@ stats, mono_band, &mono_handling); if (mono_handling == NULL) return 0; if (do_copy_raw_mono_pixels - (rst, outbuf, width, height, num_bands, x_res, y_res, - minx, maxy, tile_minx, tile_maxy, tile_width, - tile_height, no_data, mono_band, mono_handling)) + (rst, outbuf, width, height, num_bands, x_res, + y_res, minx, maxy, tile_minx, tile_maxy, + tile_width, tile_height, no_data, mono_band, + mono_handling)) return 1; if (mono_handling != NULL) destroy_mono_handling (mono_handling); } } } if (do_copy_raw_pixels - (rst, outbuf, width, height, sample_type, num_bands, x_res, y_res, minx, - maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data)) + (rst, outbuf, width, height, sample_type, num_bands, x_res, y_res, + minx, maxy, tile_minx, tile_maxy, tile_width, tile_height, no_data)) return 1; return 0; } @@ -4453,13 +4468,13 @@ *has_no_data = 1; } } static void -get_int16_ennuple (const short *rawbuf, unsigned short row, unsigned short col, - unsigned short row_stride, rl2PixelPtr no_data, - double ennuple[], int *has_no_data) +get_int16_ennuple (const short *rawbuf, unsigned short row, + unsigned short col, unsigned short row_stride, + rl2PixelPtr no_data, double ennuple[], int *has_no_data) { /* extracting a 3x3 "super-pixel" - INT16 */ const short *p_in; short nd_val = 0; int i; @@ -4629,13 +4644,13 @@ *has_no_data = 1; } } static void -get_float_ennuple (const float *rawbuf, unsigned short row, unsigned short col, - unsigned short row_stride, rl2PixelPtr no_data, - double ennuple[], int *has_no_data) +get_float_ennuple (const float *rawbuf, unsigned short row, + unsigned short col, unsigned short row_stride, + rl2PixelPtr no_data, double ennuple[], int *has_no_data) { /* extracting a 3x3 "super-pixel" - FLOAT */ const float *p_in; float nd_val = 0.0; int i; @@ -4998,16 +5013,15 @@ /* preparing the "tiles" SQL query */ xtiles = sqlite3_mprintf ("%s_tiles", coverage); xxtiles = rl2_double_quoted_sql (xtiles); sql = - sqlite3_mprintf ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) " - "FROM \"%s\" " - "WHERE pyramid_level = ? AND ROWID IN ( " - "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q " - "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, - xtiles); + sqlite3_mprintf + ("SELECT tile_id, MbrMinX(geometry), MbrMaxY(geometry) " + "FROM \"%s\" " "WHERE pyramid_level = ? AND ROWID IN ( " + "SELECT ROWID FROM SpatialIndex WHERE f_table_name = %Q " + "AND search_frame = BuildMBR(?, ?, ?, ?))", xxtiles, xtiles); sqlite3_free (xtiles); free (xxtiles); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt_tiles, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) @@ -5114,13 +5128,13 @@ for (row = 0; row < height; row++) { for (col = 0; col < width; col++) *p_out++ = shaded_relief_value (relief_factor, scale_factor, - altRadians, azRadians, rawbuf, row, - col, row_stride, sample_type, - no_data); + altRadians, azRadians, rawbuf, + row, col, row_stride, + sample_type, no_data); } } else { /* executing as many concurrent threads */ Index: src/rl2raw.c ================================================================== --- src/rl2raw.c +++ src/rl2raw.c @@ -369,12 +369,12 @@ case RL2_PIXEL_GRAYSCALE: grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8, &transpR, &transpG, &transpB); break; case RL2_PIXEL_RGB: - rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND, - &transpR); + rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, + RL2_RED_BAND, &transpR); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_GREEN_BAND, &transpG); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_BLUE_BAND, &transpB); break; @@ -603,12 +603,12 @@ case RL2_PIXEL_GRAYSCALE: grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8, &transpR, &transpG, &transpB); break; case RL2_PIXEL_RGB: - rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND, - &transpR); + rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, + RL2_RED_BAND, &transpR); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_GREEN_BAND, &transpG); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_BLUE_BAND, &transpB); break; @@ -891,12 +891,12 @@ case RL2_PIXEL_GRAYSCALE: grayscale_as_rgb (rst->sampleType, no_data->Samples->uint8, &transpR, &transpG, &transpB); break; case RL2_PIXEL_RGB: - rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_RED_BAND, - &transpR); + rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, + RL2_RED_BAND, &transpR); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_GREEN_BAND, &transpG); rl2_get_pixel_sample_uint8 ((rl2PixelPtr) no_data, RL2_BLUE_BAND, &transpB); break; @@ -1508,12 +1508,12 @@ *buf_size = sz; return RL2_OK; } RL2_DECLARE int -rl2_raster_band_to_uint16 (rl2RasterPtr ptr, int band, unsigned short **buffer, - int *buf_size) +rl2_raster_band_to_uint16 (rl2RasterPtr ptr, int band, + unsigned short **buffer, int *buf_size) { /* attempting to export Raster BAND data as a UINT-16 array */ unsigned short *buf; int sz; unsigned int row; @@ -1973,12 +1973,12 @@ } RL2_PRIVATE unsigned char * rl2_copy_endian_raw_pixels (const unsigned char *pixels, int pixels_sz, unsigned int width, unsigned int height, - unsigned char sample_type, unsigned char num_bands, - int big_endian) + unsigned char sample_type, + unsigned char num_bands, int big_endian) { /* copying RAW pixels (in endian safe mode) */ int sample_bytes = 0; int outsize = width * height * num_bands; unsigned char *outbuf = NULL; @@ -2024,12 +2024,12 @@ case RL2_SAMPLE_INT8: copy_endian_raw_i8 ((char *) outbuf, (const char *) pixels, width, height, num_bands); break; case RL2_SAMPLE_INT16: - copy_endian_raw_i16 ((short *) outbuf, (const short *) pixels, width, - height, num_bands, big_endian); + copy_endian_raw_i16 ((short *) outbuf, (const short *) pixels, + width, height, num_bands, big_endian); break; case RL2_SAMPLE_UINT16: copy_endian_raw_u16 ((unsigned short *) outbuf, (const unsigned short *) pixels, width, height, num_bands, big_endian); @@ -2042,12 +2042,12 @@ copy_endian_raw_u32 ((unsigned int *) outbuf, (const unsigned int *) pixels, width, height, num_bands, big_endian); break; case RL2_SAMPLE_FLOAT: - copy_endian_raw_flt ((float *) outbuf, (const float *) pixels, width, - height, num_bands, big_endian); + copy_endian_raw_flt ((float *) outbuf, (const float *) pixels, + width, height, num_bands, big_endian); break; case RL2_SAMPLE_DOUBLE: copy_endian_raw_dbl ((double *) outbuf, (const double *) pixels, width, height, num_bands, big_endian); break; @@ -2067,14 +2067,14 @@ fprintf (stderr, "Mismatching RAW pixels !!!\n"); return 0; } static void -copy_tile_raw_i8 (const char *in, unsigned int in_width, unsigned int in_height, - unsigned int startRow, unsigned int startCol, char *out, - unsigned int tileWidth, unsigned int tileHeight, - unsigned char num_bands) +copy_tile_raw_i8 (const char *in, unsigned int in_width, + unsigned int in_height, unsigned int startRow, + unsigned int startCol, char *out, unsigned int tileWidth, + unsigned int tileHeight, unsigned char num_bands) { /* signed int8 */ unsigned int x; unsigned int y; unsigned char b; @@ -2189,14 +2189,14 @@ } } } static void -copy_tile_raw_i32 (const int *in, unsigned int in_width, unsigned int in_height, - unsigned int startRow, unsigned int startCol, int *out, - unsigned int tileWidth, unsigned int tileHeight, - unsigned char num_bands) +copy_tile_raw_i32 (const int *in, unsigned int in_width, + unsigned int in_height, unsigned int startRow, + unsigned int startCol, int *out, unsigned int tileWidth, + unsigned int tileHeight, unsigned char num_bands) { /* signed int32 */ unsigned int x; unsigned int y; unsigned char b; @@ -2311,11 +2311,12 @@ } } static int build_tile_from_raw_pixels (rl2PrivRasterPtr origin, unsigned int tileWidth, - unsigned int tileHeight, unsigned char sample_type, + unsigned int tileHeight, + unsigned char sample_type, unsigned char num_bands, unsigned int startRow, unsigned int startCol, rl2PixelPtr no_data, unsigned char **pixels, int *pixels_sz) { /* extracting a Tile from the RAW buffer */ @@ -2351,39 +2352,43 @@ origin->width, origin->height, startRow, startCol, (char *) out, tileWidth, tileHeight, num_bands); break; case RL2_SAMPLE_INT16: copy_tile_raw_i16 ((const short *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (short *) out, tileWidth, tileHeight, num_bands); + origin->width, origin->height, startRow, + startCol, (short *) out, tileWidth, tileHeight, + num_bands); break; case RL2_SAMPLE_UINT16: copy_tile_raw_u16 ((const unsigned short *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (unsigned short *) out, tileWidth, tileHeight, - num_bands); + origin->width, origin->height, startRow, + startCol, (unsigned short *) out, tileWidth, + tileHeight, num_bands); break; case RL2_SAMPLE_INT32: copy_tile_raw_i32 ((const int *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (int *) out, tileWidth, tileHeight, num_bands); + origin->width, origin->height, startRow, + startCol, (int *) out, tileWidth, tileHeight, + num_bands); break; case RL2_SAMPLE_UINT32: copy_tile_raw_u32 ((const unsigned int *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (unsigned int *) out, tileWidth, tileHeight, - num_bands); + origin->width, origin->height, startRow, + startCol, (unsigned int *) out, tileWidth, + tileHeight, num_bands); break; case RL2_SAMPLE_FLOAT: copy_tile_raw_flt ((const float *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (float *) out, tileWidth, tileHeight, num_bands); + origin->width, origin->height, startRow, + startCol, (float *) out, tileWidth, tileHeight, + num_bands); break; case RL2_SAMPLE_DOUBLE: copy_tile_raw_dbl ((const double *) (origin->rasterBuffer), - origin->width, origin->height, startRow, startCol, - (double *) out, tileWidth, tileHeight, num_bands); + origin->width, origin->height, startRow, + startCol, (double *) out, tileWidth, tileHeight, + num_bands); break; default: copy_tile_raw_u8 ((const unsigned char *) (origin->rasterBuffer), origin->width, origin->height, startRow, startCol, (unsigned char *) out, tileWidth, tileHeight, Index: src/rl2sql.c ================================================================== --- src/rl2sql.c +++ src/rl2sql.c @@ -659,21 +659,21 @@ blob_even = sqlite3_value_blob (argv[3]); blob_even_sz = sqlite3_value_bytes (argv[3]); } if (!get_coverage_defs - (sqlite, coverage, &tile_width, &tile_height, &sample_type, &pixel_type, - &num_bands, &compression)) + (sqlite, coverage, &tile_width, &tile_height, &sample_type, + &pixel_type, &num_bands, &compression)) { sqlite3_result_int (context, -1); return; } ret = - rl2_is_valid_dbms_raster_tile (level, tile_width, tile_height, blob_odd, - blob_odd_sz, blob_even, blob_even_sz, - sample_type, pixel_type, num_bands, - compression); + rl2_is_valid_dbms_raster_tile (level, tile_width, tile_height, + blob_odd, blob_odd_sz, blob_even, + blob_even_sz, sample_type, pixel_type, + num_bands, compression); if (ret == RL2_OK) sqlite3_result_int (context, 1); else sqlite3_result_int (context, 0); } @@ -1535,12 +1535,12 @@ if (pxl2 != NULL) rl2_destroy_pixel (pxl2); } static void -fnct_GetRasterStatistics_NoDataPixelsCount (sqlite3_context * context, int argc, - sqlite3_value ** argv) +fnct_GetRasterStatistics_NoDataPixelsCount (sqlite3_context * context, + int argc, sqlite3_value ** argv) { /* SQL function: / GetRasterStatistics_NoDataPixelsCount(BLOBencoded statistics) / / will return the total count of NoData pixels @@ -1570,12 +1570,12 @@ sqlite3_result_int64 (context, st->no_data); rl2_destroy_raster_statistics (stats); } static void -fnct_GetRasterStatistics_ValidPixelsCount (sqlite3_context * context, int argc, - sqlite3_value ** argv) +fnct_GetRasterStatistics_ValidPixelsCount (sqlite3_context * context, + int argc, sqlite3_value ** argv) { /* SQL function: / GetRasterStatistics_ValidPixelsCount(BLOBencoded statistics) / / will return the total count of valid pixels @@ -3885,12 +3885,12 @@ if (rl2_get_coverage_srid (coverage, &srid) != RL2_OK) { sqlite3_result_int (context, -1); return; } - if (rl2_get_coverage_type (coverage, &sample_type, &pixel_type, &num_bands) - != RL2_OK) + if (rl2_get_coverage_type + (coverage, &sample_type, &pixel_type, &num_bands) != RL2_OK) { sqlite3_result_int (context, -1); return; } no_data = rl2_get_coverage_no_data (coverage); @@ -4049,11 +4049,12 @@ { for (x = minx; x < maxx; x += tilew) { char *err_msg = NULL; unsigned char *rgba_tile = - do_wms_GetMap_get (NULL, url, proxy, wms_version, wms_layer, + do_wms_GetMap_get (NULL, url, proxy, wms_version, + wms_layer, wms_crs, swap_xy, x, y - tileh, x + tilew, y, tile_width, tile_height, wms_style, wms_format, opaque, 0, &err_msg); if (rgba_tile == NULL) @@ -4111,15 +4112,16 @@ retry = retry->next; continue; } retry->count += 1; rgba_tile = - do_wms_GetMap_get (NULL, url, proxy, wms_version, wms_layer, - wms_crs, swap_xy, retry->minx, - retry->miny, retry->maxx, retry->maxy, - tile_width, tile_height, wms_style, - wms_format, opaque, 0, &err_msg); + do_wms_GetMap_get (NULL, url, proxy, wms_version, + wms_layer, wms_crs, swap_xy, + retry->minx, retry->miny, retry->maxx, + retry->maxy, tile_width, tile_height, + wms_style, wms_format, opaque, 0, + &err_msg); if (rgba_tile == NULL) { retry = retry->next; continue; } @@ -4487,12 +4489,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -4517,14 +4519,15 @@ } else { /* whole Coverage */ ret = - rl2_export_geotiff_from_dbms (sqlite, max_threads, path, coverage, - horz_res, vert_res, minx, miny, - maxx, maxy, width, height, - compression, tile_sz, worldfile); + rl2_export_geotiff_from_dbms (sqlite, max_threads, path, + coverage, horz_res, vert_res, + minx, miny, maxx, maxy, width, + height, compression, tile_sz, + worldfile); } if (ret != RL2_OK) { errcode = 0; goto error; @@ -4866,12 +4869,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -4889,14 +4892,14 @@ ret = rl2_export_section_triple_band_geotiff_from_dbms (sqlite, path, coverage, section_id, horz_res, - vert_res, minx, - miny, maxx, - maxy, width, - height, + vert_res, + minx, miny, + maxx, maxy, + width, height, red_band, green_band, blue_band, compression, tile_sz, @@ -4905,14 +4908,15 @@ else { /* whole Coverage */ ret = - rl2_export_triple_band_geotiff_from_dbms (sqlite, path, coverage, - horz_res, vert_res, - minx, miny, maxx, maxy, - width, height, red_band, + rl2_export_triple_band_geotiff_from_dbms (sqlite, path, + coverage, horz_res, + vert_res, minx, miny, + maxx, maxy, width, + height, red_band, green_band, blue_band, compression, tile_sz, worldfile); } if (ret != RL2_OK) @@ -5246,12 +5250,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -5270,12 +5274,13 @@ rl2_export_section_mono_band_geotiff_from_dbms (sqlite, path, coverage, section_id, horz_res, vert_res, minx, - miny, maxx, maxy, - width, height, + miny, maxx, + maxy, width, + height, mono_band, compression, tile_sz, worldfile); } @@ -5282,15 +5287,15 @@ else { /* whole Coverage */ ret = rl2_export_mono_band_geotiff_from_dbms (sqlite, path, coverage, - horz_res, vert_res, minx, - miny, maxx, maxy, width, - height, mono_band, - compression, tile_sz, - worldfile); + horz_res, vert_res, + minx, miny, maxx, maxy, + width, height, + mono_band, compression, + tile_sz, worldfile); } if (ret != RL2_OK) { errcode = 0; @@ -5600,12 +5605,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -5623,16 +5628,18 @@ { /* TIFF + Worldfile */ ret = rl2_export_section_tiff_worldfile_from_dbms (sqlite, max_threads, - path, coverage, + path, + coverage, section_id, horz_res, - vert_res, minx, - miny, maxx, - maxy, width, + vert_res, + minx, miny, + maxx, maxy, + width, height, compression, tile_sz); } else @@ -5656,12 +5663,12 @@ /* TIFF + Worldfile */ ret = rl2_export_tiff_worldfile_from_dbms (sqlite, max_threads, path, coverage, horz_res, vert_res, - minx, miny, maxx, maxy, - width, height, + minx, miny, maxx, + maxy, width, height, compression, tile_sz); } else { /* plain TIFF, no Worldfile */ @@ -5971,12 +5978,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -5991,13 +5998,14 @@ if (by_section) { /* single Section */ ret = rl2_export_section_jpeg_from_dbms (sqlite, max_threads, path, - coverage, section_id, horz_res, - vert_res, minx, miny, maxx, - maxy, width, height, quality, + coverage, section_id, + horz_res, vert_res, minx, + miny, maxx, maxy, width, + height, quality, with_worldfile); } else { /* whole Coverage */ @@ -6368,12 +6376,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -6399,11 +6407,12 @@ } else { /* plain TIFF, no Worldfile */ ret = - rl2_export_section_triple_band_tiff_from_dbms (sqlite, path, + rl2_export_section_triple_band_tiff_from_dbms (sqlite, + path, coverage, section_id, horz_res, vert_res, minx, miny, @@ -6427,12 +6436,14 @@ rl2_export_triple_band_tiff_worldfile_from_dbms (sqlite, path, coverage, horz_res, vert_res, - minx, miny, - maxx, maxy, + minx, + miny, + maxx, + maxy, width, height, red_band, green_band, blue_band, @@ -6443,13 +6454,14 @@ { /* plain TIFF, no Worldfile */ ret = rl2_export_triple_band_tiff_from_dbms (sqlite, path, coverage, horz_res, - vert_res, minx, miny, - maxx, maxy, width, - height, red_band, + vert_res, minx, + miny, maxx, maxy, + width, height, + red_band, green_band, blue_band, compression, tile_sz); } @@ -6817,12 +6829,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -6852,13 +6864,14 @@ ret = rl2_export_section_mono_band_tiff_from_dbms (sqlite, path, coverage, section_id, horz_res, - vert_res, minx, - miny, maxx, - maxy, width, + vert_res, + minx, miny, + maxx, maxy, + width, height, mono_band, compression, tile_sz); } @@ -6868,11 +6881,12 @@ /* whole Coverage */ if (with_worldfile) { /* TIFF + Worldfile */ ret = - rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite, path, + rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite, + path, coverage, horz_res, vert_res, minx, miny, maxx, maxy, @@ -6884,16 +6898,16 @@ } else { /* plain TIFF, no Worldfile */ ret = - rl2_export_mono_band_tiff_from_dbms (sqlite, path, coverage, - horz_res, vert_res, - minx, miny, maxx, maxy, - width, height, - mono_band, compression, - tile_sz); + rl2_export_mono_band_tiff_from_dbms (sqlite, path, + coverage, horz_res, + vert_res, minx, miny, + maxx, maxy, width, + height, mono_band, + compression, tile_sz); } } if (ret != RL2_OK) { errcode = 0; @@ -7190,12 +7204,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -7222,13 +7236,14 @@ else { /* whole Coverage */ ret = rl2_export_ascii_grid_from_dbms (sqlite, max_threads, path, - coverage, resolution, minx, miny, - maxx, maxy, width, height, - is_centered, decimal_digits); + coverage, resolution, minx, + miny, maxx, maxy, width, + height, is_centered, + decimal_digits); } if (ret != RL2_OK) { errcode = 0; goto error; @@ -7479,12 +7494,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) { errcode = -1; goto error; } @@ -7498,29 +7513,31 @@ if (by_section) { /* single Section */ ret = - rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite, max_threads, - path, coverage, + rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite, + max_threads, path, + coverage, section_id, resolution, minx, miny, maxx, maxy, width, height, - red_band, nir_band, + red_band, + nir_band, is_centered, decimal_digits); } else { /* whole Coverage */ ret = rl2_export_ndvi_ascii_grid_from_dbms (sqlite, max_threads, path, - coverage, resolution, minx, - miny, maxx, maxy, width, - height, red_band, nir_band, - is_centered, + coverage, resolution, + minx, miny, maxx, maxy, + width, height, red_band, + nir_band, is_centered, decimal_digits); } if (ret != RL2_OK) { errcode = 0; @@ -7581,10 +7598,65 @@ / or -1 (INVALID ARGS) / */ common_write_ndvi_ascii_grid (1, context, argc, argv); } + +static int +test_geographic_srid (sqlite3 * handle, int srid) +{ +/* testing if some SRID is of the Geographic type */ + int ret; + int is_geographic = 0; + sqlite3_stmt *stmt = NULL; + const char *sql; + + sql = "SELECT SridIsGeographic(?)"; + ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); + if (ret != SQLITE_OK) + return 0; + + sqlite3_reset (stmt); + sqlite3_clear_bindings (stmt); + sqlite3_bind_int (stmt, 1, srid); + while (1) + { + /* scrolling the result set rows */ + ret = sqlite3_step (stmt); + if (ret == SQLITE_DONE) + break; /* end of result set */ + if (ret == SQLITE_ROW) + is_geographic = sqlite3_column_int (stmt, 0); + } + sqlite3_finalize (stmt); + return is_geographic; +} + +static double +standard_scale (sqlite3 * handle, int srid, int width, int height, + double ext_x, double ext_y) +{ +/* computing the standard (normalized) scale */ + double linear_res; + double factor; + int is_geographic = test_geographic_srid (handle, srid); + if (is_geographic) + { + /* geographic (long/lat) CRS */ + double metres = ext_x * (6378137.0 * 2.0 * 3.141592653589793) / 360.0; + linear_res = metres / (double) width; + } + else + { + /* planar (projected) CRS */ + double x_res = ext_x / (double) width; + double y_res = ext_y / (double) height; + linear_res = sqrt (x_res * y_res); + } + factor = linear_res / 0.000254; + return factor * (0.28 / 0.254); +} static void fnct_GetMapImageFromRaster (sqlite3_context * context, int argc, sqlite3_value ** argv) { @@ -7643,10 +7715,11 @@ double y_res; int srid; int level_id; int scale; int xscale; + double map_scale; double xx_res; double yy_res; double aspect_org; double aspect_dst; int ok_style; @@ -7792,10 +7865,11 @@ return; } x_res = ext_x / (double) width; y_res = ext_y / (double) height; + map_scale = standard_scale (sqlite, out_srid, width, height, ext_x, ext_y); /* validating the style */ ok_style = 0; if (strcasecmp (style, "default") == 0) ok_style = 1; else @@ -7803,13 +7877,21 @@ /* attempting to get a Coverage Style */ cvg_stl = rl2_create_coverage_style_from_dbms (sqlite, cvg_name, style); if (cvg_stl == NULL) goto error; - symbolizer = rl2_get_symbolizer_from_coverage_style (cvg_stl, 1.0); + symbolizer = + rl2_get_symbolizer_from_coverage_style (cvg_stl, map_scale); if (symbolizer == NULL) - goto error; + { + /* invisible at the currect scale */ + if (!rl2_aux_default_image + (width, height, bg_red, bg_green, bg_blue, format_id, + transparent, quality, &image, &image_size)) + goto error; + goto done; + } stats = rl2_create_raster_statistics_from_dbms (sqlite, cvg_name); if (stats == NULL) goto error; ok_style = 1; } @@ -7978,12 +8060,12 @@ { /* ordinary Coverage */ by_section = 0; /* retrieving the optimal resolution level */ if (!rl2_find_best_resolution_level - (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale, &xscale, - &xx_res, &yy_res)) + (sqlite, cvg_name, 0, 0, x_res, y_res, &level_id, &scale, + &xscale, &xx_res, &yy_res)) goto error; } base_width = (int) (ext_x / xx_res); base_height = (int) (ext_y / yy_res); if ((base_width <= 0 && base_width >= USHRT_MAX) @@ -8098,10 +8180,12 @@ aux.outbuf = outbuf; aux.palette = palette; aux.out_pixel = out_pixel; if (!rl2_aux_render_image (&aux, &image, &image_size)) goto error; + + done: sqlite3_result_blob (context, image, image_size, free); rl2_destroy_coverage (coverage); if (palette != NULL) rl2_destroy_palette (palette); if (cvg_stl != NULL) @@ -8120,65 +8204,10 @@ if (stats != NULL) rl2_destroy_raster_statistics (stats); sqlite3_result_null (context); } -static int -test_geographic_srid (sqlite3 * handle, int srid) -{ -/* testing if some SRID is of the Geographic type */ - int ret; - int is_geographic = 0; - sqlite3_stmt *stmt = NULL; - const char *sql; - - sql = "SELECT SridIsGeographic(?)"; - ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); - if (ret != SQLITE_OK) - return 0; - - sqlite3_reset (stmt); - sqlite3_clear_bindings (stmt); - sqlite3_bind_int (stmt, 1, srid); - while (1) - { - /* scrolling the result set rows */ - ret = sqlite3_step (stmt); - if (ret == SQLITE_DONE) - break; /* end of result set */ - if (ret == SQLITE_ROW) - is_geographic = sqlite3_column_int (stmt, 0); - } - sqlite3_finalize (stmt); - return is_geographic; -} - -static double -standard_scale (sqlite3 * handle, int srid, int width, int height, double ext_x, - double ext_y) -{ -/* computing the standard (normalized) scale */ - double linear_res; - double factor; - int is_geographic = test_geographic_srid (handle, srid); - if (is_geographic) - { - /* geographic (long/lat) CRS */ - double metres = ext_x * (6378137.0 * 2.0 * 3.141592653589793) / 360.0; - linear_res = metres / (double) width; - } - else - { - /* planar (projected) CRS */ - double x_res = ext_x / (double) width; - double y_res = ext_y / (double) height; - linear_res = sqrt (x_res * y_res); - } - factor = linear_res / 0.000254; - return factor * (0.28 / 0.254); -} - static void fnct_GetMapImageFromVector (sqlite3_context * context, int argc, sqlite3_value ** argv) { /* SQL function: @@ -8221,10 +8250,11 @@ int transparent = 0; int quality = 80; int reaspect = 0; sqlite3 *sqlite; sqlite3_stmt *stmt = NULL; + const void *data; double minx; double maxx; double miny; double maxy; double ext_x; @@ -8302,10 +8332,11 @@ if (argc > 9) reaspect = sqlite3_value_int (argv[9]); /* coarse args validation */ sqlite = sqlite3_context_db_handle (context); + data = sqlite3_user_data (context); if (width < 64) goto error; if (height < 64) goto error; /* validating the format */ @@ -8503,11 +8534,12 @@ rl2_set_variant_int (variant, i, col_name, sqlite3_column_int64 (stmt, i + 1)); break; case SQLITE_FLOAT: - rl2_set_variant_double (variant, i, col_name, + rl2_set_variant_double (variant, i, + col_name, sqlite3_column_double (stmt, i + 1)); break; case SQLITE_TEXT: rl2_set_variant_text (variant, i, col_name, @@ -8531,19 +8563,20 @@ } } if (geom != NULL) { /* drawing a styled Feature */ - int scale_forbidden; + int scale_forbidden = 0; symbolizer = NULL; if (lyr_stl != NULL) symbolizer = rl2_get_symbolizer_from_feature_type_style (lyr_stl, scale, variant, &scale_forbidden); if (!scale_forbidden) - rl2_draw_vector_feature (ctx, sqlite, symbolizer, - height, minx, miny, x_res, + rl2_draw_vector_feature (ctx, sqlite, data, + symbolizer, height, minx, + miny, maxx, maxy, x_res, y_res, geom, variant); rl2_destroy_geometry (geom); } } } @@ -8807,19 +8840,20 @@ } switch (pixel_type) { case RL2_PIXEL_MONOCHROME: ret = - get_rgba_from_monochrome_mask (width, height, buffer, - mask, no_data, rgba); + get_rgba_from_monochrome_mask (width, height, + buffer, mask, + no_data, rgba); buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -8849,12 +8883,12 @@ buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -8883,12 +8917,12 @@ buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -8918,12 +8952,12 @@ buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -8947,12 +8981,12 @@ break; case RL2_PIXEL_RGB: if (sample_type == RL2_SAMPLE_UINT16) { ret = - get_rgba_from_multiband16 (width, height, 0, 1, - 2, 3, + get_rgba_from_multiband16 (width, height, 0, + 1, 2, 3, (unsigned short *) buffer, mask, no_data, rgba); } else @@ -8964,12 +8998,12 @@ buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -8992,20 +9026,20 @@ sqlite3_result_blob (context, image, image_size, free); break; case RL2_PIXEL_MULTIBAND: ret = get_rgba_from_multiband_mask (width, height, - sample_type, num_bands, - buffer, mask, no_data, - rgba); + sample_type, + num_bands, buffer, + mask, no_data, rgba); buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -9240,12 +9274,12 @@ buffer = NULL; mask = NULL; if (!ret) goto error; if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -9270,15 +9304,16 @@ case RL2_SAMPLE_UINT16: ret = get_rgba_from_multiband16 (width, height, red_band, green_band, blue_band, num_bands, - (unsigned short *) buffer, - mask, no_data, rgba); + (unsigned short *) + buffer, mask, no_data, + rgba); if (!build_rgb_alpha - (width, height, rgba, &rgb, &alpha, bg_red, bg_green, - bg_blue)) + (width, height, rgba, &rgb, &alpha, bg_red, + bg_green, bg_blue)) goto error; free (rgba); rgba = NULL; if (transparent) { @@ -9663,12 +9698,12 @@ minx = pt_x - ext_x / 2.0; maxx = minx + ext_x; miny = pt_y - ext_y / 2.0; maxy = miny + ext_y; } - else if (rl2_parse_bbox (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) - != RL2_OK) + else if (rl2_parse_bbox + (sqlite, blob, blob_sz, &minx, &miny, &maxx, &maxy) != RL2_OK) goto error; /* attempting to load the Coverage definitions from the DBMS */ coverage = rl2_create_coverage_from_dbms (sqlite, cvg_name); if (coverage == NULL) @@ -9677,14 +9712,15 @@ { /* only a single Section */ ret = rl2_export_section_raw_pixels_from_dbms (sqlite, max_threads, coverage, section_id, - horz_res, vert_res, minx, - miny, maxx, maxy, width, - height, big_endian, - &xblob, &xblob_sz); + horz_res, vert_res, + minx, miny, maxx, maxy, + width, height, + big_endian, &xblob, + &xblob_sz); } else { /* whole Coverage */ ret = @@ -9880,12 +9916,12 @@ { errcode = -1; goto error; } - if (rl2_get_coverage_type (coverage, &sample_type, &pixel_type, &num_bands) - != RL2_OK) + if (rl2_get_coverage_type + (coverage, &sample_type, &pixel_type, &num_bands) != RL2_OK) { errcode = -1; goto error; } if (rl2_get_coverage_srid (coverage, &cov_srid) != RL2_OK) @@ -9949,12 +9985,12 @@ { errcode = -1; goto error; } /* georeferencing the raster */ - if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy) != - RL2_OK) + if (rl2_raster_georeference_frame (raster, srid, minx, miny, maxx, maxy) + != RL2_OK) { errcode = -1; goto error; } @@ -9969,12 +10005,12 @@ sqlite3_result_int (context, -1); return; } } ret = - rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage, sctn_name, - raster, pyramidize); + rl2_load_raw_raster_into_dbms (sqlite, max_threads, coverage, + sctn_name, raster, pyramidize); rl2_destroy_coverage (coverage); rl2_destroy_raster (raster); if (ret != RL2_OK) { if (transaction) @@ -10139,24 +10175,24 @@ SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0); sqlite3_create_function (db, "RL2_DropRasterCoverage", 2, SQLITE_UTF8, 0, fnct_DropRasterCoverage, 0, 0); sqlite3_create_function (db, "SetRasterCoverageInfos", 3, SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0); - sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3, - SQLITE_UTF8, 0, fnct_SetRasterCoverageInfos, 0, 0); + sqlite3_create_function (db, "RL2_SetRasterCoverageInfos", 3, SQLITE_UTF8, + 0, fnct_SetRasterCoverageInfos, 0, 0); sqlite3_create_function (db, "SetRasterCoverageDefaultBands", 5, - SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands, - 0, 0); + SQLITE_UTF8, 0, + fnct_SetRasterCoverageDefaultBands, 0, 0); sqlite3_create_function (db, "RL2_SetRasterCoverageDefaultBands", 5, - SQLITE_UTF8, 0, fnct_SetRasterCoverageDefaultBands, - 0, 0); + SQLITE_UTF8, 0, + fnct_SetRasterCoverageDefaultBands, 0, 0); sqlite3_create_function (db, "EnableRasterCoverageAutoNDVI", 2, - SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI, - 0, 0); + SQLITE_UTF8, 0, + fnct_EnableRasterCoverageAutoNDVI, 0, 0); sqlite3_create_function (db, "RL2_EnableRasterCoverageAutoNDVI", 2, - SQLITE_UTF8, 0, fnct_EnableRasterCoverageAutoNDVI, - 0, 0); + SQLITE_UTF8, 0, + fnct_EnableRasterCoverageAutoNDVI, 0, 0); sqlite3_create_function (db, "IsRasterCoverageAutoNdviEnabled", 1, SQLITE_UTF8, 0, fnct_IsRasterCoverageAutoNdviEnabled, 0, 0); sqlite3_create_function (db, "RL2_IsRasterCoverageAutoNdviEnabled", 1, SQLITE_UTF8, 0, @@ -10288,18 +10324,18 @@ SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_IsFontItalic, 0, 0); sqlite3_create_function (db, "GetRasterStatistics_NoDataPixelsCount", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0); - sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount", 1, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + sqlite3_create_function (db, "RL2_GetRasterStatistics_NoDataPixelsCount", + 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_GetRasterStatistics_NoDataPixelsCount, 0, 0); sqlite3_create_function (db, "GetRasterStatistics_ValidPixelsCount", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_GetRasterStatistics_ValidPixelsCount, 0, 0); - sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount", 1, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + sqlite3_create_function (db, "RL2_GetRasterStatistics_ValidPixelsCount", + 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_GetRasterStatistics_ValidPixelsCount, 0, 0); sqlite3_create_function (db, "GetRasterStatistics_SampleType", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, fnct_GetRasterStatistics_SampleType, 0, 0); sqlite3_create_function (db, "RL2_GetRasterStatistics_SampleType", 1, @@ -10370,20 +10406,20 @@ fnct_Pyramidize, 0, 0); sqlite3_create_function (db, "RL2_Pyramidize", 4, SQLITE_UTF8, priv_data, fnct_Pyramidize, 0, 0); sqlite3_create_function (db, "PyramidizeMonolithic", 1, SQLITE_UTF8, 0, fnct_PyramidizeMonolithic, 0, 0); - sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8, 0, - fnct_PyramidizeMonolithic, 0, 0); + sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 1, SQLITE_UTF8, + 0, fnct_PyramidizeMonolithic, 0, 0); sqlite3_create_function (db, "PyramidizeMonolithic", 2, SQLITE_UTF8, 0, fnct_PyramidizeMonolithic, 0, 0); - sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8, 0, - fnct_PyramidizeMonolithic, 0, 0); + sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 2, SQLITE_UTF8, + 0, fnct_PyramidizeMonolithic, 0, 0); sqlite3_create_function (db, "PyramidizeMonolithic", 3, SQLITE_UTF8, 0, fnct_PyramidizeMonolithic, 0, 0); - sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8, 0, - fnct_PyramidizeMonolithic, 0, 0); + sqlite3_create_function (db, "RL2_PyramidizeMonolithic", 3, SQLITE_UTF8, + 0, fnct_PyramidizeMonolithic, 0, 0); sqlite3_create_function (db, "DePyramidize", 1, SQLITE_UTF8, 0, fnct_DePyramidize, 0, 0); sqlite3_create_function (db, "RL2_DePyramidize", 1, SQLITE_UTF8, 0, fnct_DePyramidize, 0, 0); sqlite3_create_function (db, "DePyramidize", 2, SQLITE_UTF8, 0, @@ -10441,56 +10477,56 @@ fnct_GetMapImageFromRaster, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromRaster", 11, SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromRaster, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 4, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 4, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 5, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 5, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 6, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 6, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 7, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 7, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 8, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 8, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 9, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 9, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 10, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 10, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetMapImageFromVector", 11, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "RL2_GetMapImageFromVector", 11, - SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, + SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetMapImageFromVector, 0, 0); sqlite3_create_function (db, "GetTileImage", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data, fnct_GetTileImage, 0, 0); sqlite3_create_function (db, "RL2_GetTileImage", 2, @@ -10637,20 +10673,20 @@ 0, fnct_LoadFontFromFile, 0, 0); sqlite3_create_function (db, "ExportFontToFile", 2, SQLITE_UTF8, 0, fnct_ExportFontToFile, 0, 0); sqlite3_create_function (db, "RL2_ExportFontToFile", 2, SQLITE_UTF8, 0, fnct_ExportFontToFile, 0, 0); - sqlite3_create_function (db, "LoadRaster", 2, SQLITE_UTF8, priv_data, - fnct_LoadRaster, 0, 0); - sqlite3_create_function (db, "LoadRaster", 3, SQLITE_UTF8, priv_data, - fnct_LoadRaster, 0, 0); - sqlite3_create_function (db, "LoadRaster", 4, SQLITE_UTF8, priv_data, - fnct_LoadRaster, 0, 0); - sqlite3_create_function (db, "LoadRaster", 5, SQLITE_UTF8, priv_data, - fnct_LoadRaster, 0, 0); - sqlite3_create_function (db, "LoadRaster", 6, SQLITE_UTF8, priv_data, - fnct_LoadRaster, 0, 0); + sqlite3_create_function (db, "LoadRaster", 2, SQLITE_UTF8, + priv_data, fnct_LoadRaster, 0, 0); + sqlite3_create_function (db, "LoadRaster", 3, SQLITE_UTF8, + priv_data, fnct_LoadRaster, 0, 0); + sqlite3_create_function (db, "LoadRaster", 4, SQLITE_UTF8, + priv_data, fnct_LoadRaster, 0, 0); + sqlite3_create_function (db, "LoadRaster", 5, SQLITE_UTF8, + priv_data, fnct_LoadRaster, 0, 0); + sqlite3_create_function (db, "LoadRaster", 6, SQLITE_UTF8, + priv_data, fnct_LoadRaster, 0, 0); sqlite3_create_function (db, "RL2_LoadRaster", 2, SQLITE_UTF8, priv_data, fnct_LoadRaster, 0, 0); sqlite3_create_function (db, "RL2_LoadRaster", 3, SQLITE_UTF8, priv_data, fnct_LoadRaster, 0, 0); sqlite3_create_function (db, "RL2_LoadRaster", 4, SQLITE_UTF8, @@ -10669,46 +10705,58 @@ priv_data, fnct_LoadRastersFromDir, 0, 0); sqlite3_create_function (db, "LoadRastersFromDir", 6, SQLITE_UTF8, priv_data, fnct_LoadRastersFromDir, 0, 0); sqlite3_create_function (db, "LoadRastersFromDir", 7, SQLITE_UTF8, priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 2, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 3, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 4, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 5, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 6, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); - sqlite3_create_function (db, "RL2_LoadRastersFromDir", 7, SQLITE_UTF8, - priv_data, fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 2, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 3, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 4, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 5, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 6, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); + sqlite3_create_function (db, "RL2_LoadRastersFromDir", 7, + SQLITE_UTF8, priv_data, + fnct_LoadRastersFromDir, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 9, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9, SQLITE_UTF8, - priv_data, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 9, + SQLITE_UTF8, priv_data, + fnct_LoadRasterFromWMS, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 10, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10, SQLITE_UTF8, - priv_data, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 10, + SQLITE_UTF8, priv_data, + fnct_LoadRasterFromWMS, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 11, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11, SQLITE_UTF8, - priv_data, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 11, + SQLITE_UTF8, priv_data, + fnct_LoadRasterFromWMS, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 12, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12, SQLITE_UTF8, - priv_data, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 12, + SQLITE_UTF8, priv_data, + fnct_LoadRasterFromWMS, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 13, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13, SQLITE_UTF8, - priv_data, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 13, + SQLITE_UTF8, priv_data, + fnct_LoadRasterFromWMS, 0, 0); sqlite3_create_function (db, "LoadRasterFromWMS", 14, SQLITE_UTF8, priv_data, fnct_LoadRasterFromWMS, 0, 0); - sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14, SQLITE_UTF8, - 0, fnct_LoadRasterFromWMS, 0, 0); + sqlite3_create_function (db, "RL2_LoadRasterFromWMS", 14, + SQLITE_UTF8, 0, fnct_LoadRasterFromWMS, 0, + 0); sqlite3_create_function (db, "WriteGeoTiff", 6, SQLITE_UTF8, priv_data, fnct_WriteGeoTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteGeoTiff", 6, SQLITE_UTF8, priv_data, fnct_WriteGeoTiff, 0, 0); sqlite3_create_function (db, "WriteGeoTiff", 7, SQLITE_UTF8, @@ -10815,12 +10863,13 @@ priv_data, fnct_WriteSectionTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionTiff", 9, SQLITE_UTF8, priv_data, fnct_WriteSectionTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTiff", 10, SQLITE_UTF8, priv_data, fnct_WriteSectionTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTiff", 10, SQLITE_UTF8, - priv_data, fnct_WriteSectionTiff, 0, 0); + sqlite3_create_function (db, "RL2_WriteSectionTiff", 10, + SQLITE_UTF8, priv_data, + fnct_WriteSectionTiff, 0, 0); sqlite3_create_function (db, "WriteJpegJgw", 6, SQLITE_UTF8, priv_data, fnct_WriteJpegJgw, 0, 0); sqlite3_create_function (db, "RL2_WriteJpegJgw", 6, SQLITE_UTF8, priv_data, fnct_WriteJpegJgw, 0, 0); sqlite3_create_function (db, "WriteJpegJgw", 7, SQLITE_UTF8, @@ -10868,13 +10917,13 @@ priv_data, fnct_WriteSectionJpeg, 0, 0); sqlite3_create_function (db, "WriteSectionJpeg", 9, SQLITE_UTF8, priv_data, fnct_WriteSectionJpeg, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionJpeg", 9, SQLITE_UTF8, priv_data, fnct_WriteSectionJpeg, 0, 0); - sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9, SQLITE_UTF8, - priv_data, fnct_WriteTripleBandGeoTiff, 0, - 0); + sqlite3_create_function (db, "WriteTripleBandGeoTiff", 9, + SQLITE_UTF8, priv_data, + fnct_WriteTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteTripleBandGeoTiff", 9, SQLITE_UTF8, priv_data, fnct_WriteTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteTripleBandGeoTiff", 10, SQLITE_UTF8, priv_data, @@ -10901,36 +10950,36 @@ SQLITE_UTF8, priv_data, fnct_WriteTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 10, SQLITE_UTF8, 0, fnct_WriteSectionTripleBandGeoTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 10, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", + 10, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 11, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 11, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", + 11, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 12, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 12, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", + 12, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 13, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 13, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", + 13, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandGeoTiff", 14, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", 14, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandGeoTiff", + 14, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteMonoBandGeoTiff", 7, SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 7, SQLITE_UTF8, priv_data, @@ -10943,17 +10992,19 @@ sqlite3_create_function (db, "WriteMonoBandGeoTiff", 9, SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 9, SQLITE_UTF8, priv_data, fnct_WriteMonoBandGeoTiff, 0, 0); - sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10, SQLITE_UTF8, - 0, fnct_WriteMonoBandGeoTiff, 0, 0); + sqlite3_create_function (db, "WriteMonoBandGeoTiff", 10, + SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff, + 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 10, SQLITE_UTF8, priv_data, fnct_WriteMonoBandGeoTiff, 0, 0); - sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11, SQLITE_UTF8, - 0, fnct_WriteMonoBandGeoTiff, 0, 0); + sqlite3_create_function (db, "WriteMonoBandGeoTiff", 11, + SQLITE_UTF8, 0, fnct_WriteMonoBandGeoTiff, + 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandGeoTiff", 11, SQLITE_UTF8, priv_data, fnct_WriteMonoBandGeoTiff, 0, 0); sqlite3_create_function (db, "WriteSectionMonoBandGeoTiff", 8, SQLITE_UTF8, priv_data, @@ -10983,13 +11034,13 @@ SQLITE_UTF8, priv_data, fnct_WriteSectionMonoBandGeoTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionMonoBandGeoTiff", 12, SQLITE_UTF8, priv_data, fnct_WriteSectionMonoBandGeoTiff, 0, 0); - sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9, SQLITE_UTF8, - priv_data, fnct_WriteTripleBandTiffTfw, 0, - 0); + sqlite3_create_function (db, "WriteTripleBandTiffTfw", 9, + SQLITE_UTF8, priv_data, + fnct_WriteTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "RL2_WriteTripleBandTiffTfw", 9, SQLITE_UTF8, priv_data, fnct_WriteTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteTripleBandTiffTfw", 10, SQLITE_UTF8, priv_data, @@ -11010,30 +11061,30 @@ SQLITE_UTF8, priv_data, fnct_WriteTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 10, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 10, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", + 10, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 11, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 11, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", + 11, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 12, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 12, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", + 12, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteSectionTripleBandTiffTfw", 13, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); - sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", 13, - SQLITE_UTF8, priv_data, + sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiffTfw", + 13, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiffTfw, 0, 0); sqlite3_create_function (db, "WriteSectionMonoBandTiffTfw", 8, SQLITE_UTF8, priv_data, fnct_WriteSectionMonoBandTiffTfw, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiffTfw", 8, @@ -11070,17 +11121,18 @@ sqlite3_create_function (db, "WriteMonoBandTiffTfw", 9, SQLITE_UTF8, priv_data, fnct_WriteMonoBandTiffTfw, 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 9, SQLITE_UTF8, priv_data, fnct_WriteMonoBandTiffTfw, 0, 0); - sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10, SQLITE_UTF8, - priv_data, fnct_WriteMonoBandTiffTfw, 0, 0); + sqlite3_create_function (db, "WriteMonoBandTiffTfw", 10, + SQLITE_UTF8, priv_data, + fnct_WriteMonoBandTiffTfw, 0, 0); sqlite3_create_function (db, "RL2_WriteMonoBandTiffTfw", 10, SQLITE_UTF8, priv_data, fnct_WriteMonoBandTiffTfw, 0, 0); - sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8, 0, - fnct_WriteTripleBandTiff, 0, 0); + sqlite3_create_function (db, "WriteTripleBandTiff", 9, SQLITE_UTF8, + 0, fnct_WriteTripleBandTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteTripleBandTiff", 9, SQLITE_UTF8, priv_data, fnct_WriteTripleBandTiff, 0, 0); sqlite3_create_function (db, "WriteTripleBandTiff", 10, SQLITE_UTF8, 0, fnct_WriteTripleBandTiff, 0, 0); @@ -11121,24 +11173,28 @@ sqlite3_create_function (db, "RL2_WriteSectionTripleBandTiff", 13, SQLITE_UTF8, priv_data, fnct_WriteSectionTripleBandTiff, 0, 0); sqlite3_create_function (db, "WriteMonoBandTiff", 7, SQLITE_UTF8, 0, fnct_WriteMonoBandTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7, SQLITE_UTF8, - priv_data, fnct_WriteMonoBandTiff, 0, 0); + sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 7, + SQLITE_UTF8, priv_data, + fnct_WriteMonoBandTiff, 0, 0); sqlite3_create_function (db, "WriteMonoBandTiff", 8, SQLITE_UTF8, 0, fnct_WriteMonoBandTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8, SQLITE_UTF8, - priv_data, fnct_WriteMonoBandTiff, 0, 0); + sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 8, + SQLITE_UTF8, priv_data, + fnct_WriteMonoBandTiff, 0, 0); sqlite3_create_function (db, "WriteMonoBandTiff", 9, SQLITE_UTF8, priv_data, fnct_WriteMonoBandTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9, SQLITE_UTF8, - priv_data, fnct_WriteMonoBandTiff, 0, 0); + sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 9, + SQLITE_UTF8, priv_data, + fnct_WriteMonoBandTiff, 0, 0); sqlite3_create_function (db, "WriteMonoBandTiff", 10, SQLITE_UTF8, priv_data, fnct_WriteMonoBandTiff, 0, 0); - sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10, SQLITE_UTF8, - priv_data, fnct_WriteMonoBandTiff, 0, 0); + sqlite3_create_function (db, "RL2_WriteMonoBandTiff", 10, + SQLITE_UTF8, priv_data, + fnct_WriteMonoBandTiff, 0, 0); sqlite3_create_function (db, "WriteSectionMonoBandTiff", 8, SQLITE_UTF8, priv_data, fnct_WriteSectionMonoBandTiff, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionMonoBandTiff", 8, SQLITE_UTF8, priv_data, @@ -11171,33 +11227,38 @@ priv_data, fnct_WriteAsciiGrid, 0, 0); sqlite3_create_function (db, "WriteAsciiGrid", 8, SQLITE_UTF8, priv_data, fnct_WriteAsciiGrid, 0, 0); sqlite3_create_function (db, "RL2_WriteAsciiGrid", 8, SQLITE_UTF8, priv_data, fnct_WriteAsciiGrid, 0, 0); - sqlite3_create_function (db, "WriteSectionAsciiGrid", 7, SQLITE_UTF8, - priv_data, fnct_WriteSectionAsciiGrid, 0, 0); + sqlite3_create_function (db, "WriteSectionAsciiGrid", 7, + SQLITE_UTF8, priv_data, + fnct_WriteSectionAsciiGrid, 0, 0); sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 7, SQLITE_UTF8, priv_data, fnct_WriteSectionAsciiGrid, 0, 0); - sqlite3_create_function (db, "WriteSectionAsciiGrid", 8, SQLITE_UTF8, - 0, fnct_WriteSectionAsciiGrid, 0, 0); + sqlite3_create_function (db, "WriteSectionAsciiGrid", 8, + SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid, + 0, 0); sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 8, SQLITE_UTF8, priv_data, fnct_WriteSectionAsciiGrid, 0, 0); - sqlite3_create_function (db, "WriteSectionAsciiGrid", 9, SQLITE_UTF8, - 0, fnct_WriteSectionAsciiGrid, 0, 0); + sqlite3_create_function (db, "WriteSectionAsciiGrid", 9, + SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid, + 0, 0); sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 9, SQLITE_UTF8, priv_data, fnct_WriteSectionAsciiGrid, 0, 0); sqlite3_create_function (db, "WriteNdviAsciiGrid", 8, SQLITE_UTF8, priv_data, fnct_WriteNdviAsciiGrid, 0, 0); - sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8, SQLITE_UTF8, - priv_data, fnct_WriteNdviAsciiGrid, 0, 0); + sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8, + SQLITE_UTF8, priv_data, + fnct_WriteNdviAsciiGrid, 0, 0); sqlite3_create_function (db, "WriteNdviAsciiGrid", 9, SQLITE_UTF8, priv_data, fnct_WriteNdviAsciiGrid, 0, 0); - sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9, SQLITE_UTF8, - priv_data, fnct_WriteNdviAsciiGrid, 0, 0); + sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9, + SQLITE_UTF8, priv_data, + fnct_WriteNdviAsciiGrid, 0, 0); sqlite3_create_function (db, "WriteNdviAsciiGrid", 10, SQLITE_UTF8, priv_data, fnct_WriteNdviAsciiGrid, 0, 0); sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 10, SQLITE_UTF8, priv_data, fnct_WriteNdviAsciiGrid, 0, 0); Index: src/rl2sqlaux.c ================================================================== --- src/rl2sqlaux.c +++ src/rl2sqlaux.c @@ -83,12 +83,13 @@ int bands; unsigned char xsample_type = RL2_SAMPLE_UNKNOWN; unsigned char xnum_bands = RL2_BANDS_UNKNOWN; sql = - sqlite3_mprintf ("SELECT sample_type, num_bands FROM raster_coverages " - "WHERE Lower(coverage_name) = Lower(%Q)", coverage); + sqlite3_mprintf + ("SELECT sample_type, num_bands FROM raster_coverages " + "WHERE Lower(coverage_name) = Lower(%Q)", coverage); ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL); sqlite3_free (sql); if (ret != SQLITE_OK) return 0; if (rows < 1) @@ -736,18 +737,19 @@ sqlite3_finalize (stmt); return RL2_ERROR; } static int -do_insert_wms_tile (sqlite3 * handle, unsigned char *blob_odd, int blob_odd_sz, - unsigned char *blob_even, int blob_even_sz, - sqlite3_int64 section_id, int srid, double res_x, - double res_y, unsigned int tile_w, unsigned int tile_h, - double miny, double maxx, double tile_minx, - double tile_miny, double tile_maxx, double tile_maxy, - rl2PalettePtr aux_palette, rl2PixelPtr no_data, - sqlite3_stmt * stmt_tils, sqlite3_stmt * stmt_data, +do_insert_wms_tile (sqlite3 * handle, unsigned char *blob_odd, + int blob_odd_sz, unsigned char *blob_even, + int blob_even_sz, sqlite3_int64 section_id, int srid, + double res_x, double res_y, unsigned int tile_w, + unsigned int tile_h, double miny, double maxx, + double tile_minx, double tile_miny, double tile_maxx, + double tile_maxy, rl2PalettePtr aux_palette, + rl2PixelPtr no_data, sqlite3_stmt * stmt_tils, + sqlite3_stmt * stmt_data, rl2RasterStatisticsPtr section_stats) { /* INSERTing the tile */ int ret; sqlite3_int64 tile_id; @@ -1001,12 +1003,13 @@ RL2_PRIVATE int rl2_do_insert_section (sqlite3 * handle, const char *src_path, const char *section, int srid, unsigned int width, unsigned int height, double minx, double miny, double maxx, double maxy, char *xml_summary, - int section_paths, int section_md5, int section_summary, - sqlite3_stmt * stmt_sect, sqlite3_int64 * id) + int section_paths, int section_md5, + int section_summary, sqlite3_stmt * stmt_sect, + sqlite3_int64 * id) { /* INSERTing the section */ int ret; unsigned char *blob; int blob_size; @@ -1053,12 +1056,12 @@ if (xml_summary != NULL) free (xml_summary); } sqlite3_bind_int (stmt_sect, 5, width); sqlite3_bind_int (stmt_sect, 6, height); - if (rl2_build_bbox (handle, srid, minx, miny, maxx, maxy, &blob, &blob_size) - != RL2_OK) + if (rl2_build_bbox + (handle, srid, minx, miny, maxx, maxy, &blob, &blob_size) != RL2_OK) goto error; sqlite3_bind_blob (stmt_sect, 7, blob, blob_size, free); ret = sqlite3_step (stmt_sect); if (ret == SQLITE_DONE || ret == SQLITE_ROW) section_id = sqlite3_last_insert_rowid (handle); @@ -1215,22 +1218,23 @@ int blob_even_sz; rl2RasterPtr raster = NULL; double base_res_x; double base_res_y; - if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y) != - RL2_OK) + if (rl2_get_coverage_resolution (ptr->coverage, &base_res_x, &base_res_y) + != RL2_OK) goto error; if (*first) { /* INSERTing the section */ *first = 0; if (!rl2_do_insert_section (ptr->sqlite, "WMS Service", ptr->sect_name, ptr->srid, ptr->width, ptr->height, ptr->minx, ptr->miny, ptr->maxx, - ptr->maxy, ptr->xml_summary, ptr->sectionPaths, ptr->sectionMD5, - ptr->sectionSummary, ptr->stmt_sect, section_id)) + ptr->maxy, ptr->xml_summary, ptr->sectionPaths, + ptr->sectionMD5, ptr->sectionSummary, ptr->stmt_sect, + section_id)) goto error; *section_stats = rl2_create_raster_statistics (ptr->sample_type, ptr->num_bands); if (*section_stats == NULL) goto error; @@ -1273,13 +1277,13 @@ tile_maxx = tile_minx + ptr->tilew; tile_maxy = ptr->y; tile_miny = tile_maxy - ptr->tileh; if (!do_insert_wms_tile (ptr->sqlite, blob_odd, blob_odd_sz, blob_even, blob_even_sz, - *section_id, ptr->srid, ptr->horz_res, ptr->vert_res, ptr->tile_width, - ptr->tile_height, ptr->miny, ptr->maxx, tile_minx, tile_miny, - tile_maxx, tile_maxy, NULL, ptr->no_data, ptr->stmt_tils, + *section_id, ptr->srid, ptr->horz_res, ptr->vert_res, + ptr->tile_width, ptr->tile_height, ptr->miny, ptr->maxx, tile_minx, + tile_miny, tile_maxx, tile_maxy, NULL, ptr->no_data, ptr->stmt_tils, ptr->stmt_data, *section_stats)) goto error; blob_odd = NULL; blob_even = NULL; rl2_destroy_raster (raster); @@ -1403,12 +1407,12 @@ sql = sqlite3_mprintf ("SELECT pyramid_level, x_resolution_1_8, y_resolution_1_8, " "x_resolution_1_4, y_resolution_1_4, x_resolution_1_2, y_resolution_1_2, " "x_resolution_1_1, y_resolution_1_1 FROM \"%s\" " - "WHERE section_id = %s ORDER BY pyramid_level DESC", xxcoverage, - sctn); + "WHERE section_id = %s ORDER BY pyramid_level DESC", + xxcoverage, sctn); } else { /* ordinary Coverage */ xcoverage = sqlite3_mprintf ("%s_levels", coverage); @@ -1614,15 +1618,15 @@ return rgba; } RL2_PRIVATE int get_payload_from_monochrome_opaque (unsigned int width, unsigned int height, - sqlite3 * handle, double minx, double miny, - double maxx, double maxy, int srid, - unsigned char *pixels, unsigned char format, - int quality, unsigned char **image, - int *image_sz) + sqlite3 * handle, double minx, + double miny, double maxx, double maxy, + int srid, unsigned char *pixels, + unsigned char format, int quality, + unsigned char **image, int *image_sz) { /* input: Monochrome output: Grayscale */ int ret; unsigned char *p_in; unsigned char *p_out; @@ -1662,12 +1666,12 @@ else if (format == RL2_OUTPUT_FORMAT_TIFF) { if (srid > 0) { if (rl2_gray_to_geotiff - (width, height, handle, minx, miny, maxx, maxy, srid, gray, - image, image_sz) != RL2_OK) + (width, height, handle, minx, miny, maxx, maxy, srid, + gray, image, image_sz) != RL2_OK) goto error; } else { if (rl2_gray_to_tiff (width, height, gray, image, image_sz) != @@ -1831,18 +1835,18 @@ else if (format == RL2_OUTPUT_FORMAT_TIFF) { if (srid > 0) { if (rl2_rgb_to_geotiff - (width, height, handle, minx, miny, maxx, maxy, srid, - rgb, image, image_sz) != RL2_OK) + (width, height, handle, minx, miny, maxx, maxy, + srid, rgb, image, image_sz) != RL2_OK) goto error; } else { - if (rl2_rgb_to_tiff (width, height, rgb, image, image_sz) - != RL2_OK) + if (rl2_rgb_to_tiff + (width, height, rgb, image, image_sz) != RL2_OK) goto error; } } else if (format == RL2_OUTPUT_FORMAT_PDF) { @@ -1894,12 +1898,12 @@ else if (format == RL2_OUTPUT_FORMAT_TIFF) { if (srid > 0) { if (rl2_gray_to_geotiff - (width, height, handle, minx, miny, maxx, maxy, srid, - gray, image, image_sz) != RL2_OK) + (width, height, handle, minx, miny, maxx, maxy, + srid, gray, image, image_sz) != RL2_OK) goto error; } else { if (rl2_gray_to_tiff @@ -2072,22 +2076,22 @@ RL2_PRIVATE int get_payload_from_grayscale_opaque (unsigned int width, unsigned int height, sqlite3 * handle, double minx, double miny, double maxx, double maxy, int srid, - unsigned char *pixels, unsigned char format, - int quality, unsigned char **image, - int *image_sz) + unsigned char *pixels, + unsigned char format, int quality, + unsigned char **image, int *image_sz) { /* input: Grayscale output: Grayscale */ int ret; unsigned char *rgba = NULL; if (format == RL2_OUTPUT_FORMAT_JPEG) { - if (rl2_gray_to_jpeg (width, height, pixels, quality, image, image_sz) - != RL2_OK) + if (rl2_gray_to_jpeg + (width, height, pixels, quality, image, image_sz) != RL2_OK) goto error; } else if (format == RL2_OUTPUT_FORMAT_PNG) { if (rl2_gray_to_png (width, height, pixels, image, image_sz) != @@ -2103,12 +2107,12 @@ pixels, image, image_sz) != RL2_OK) goto error; } else { - if (rl2_gray_to_tiff (width, height, pixels, image, image_sz) != - RL2_OK) + if (rl2_gray_to_tiff (width, height, pixels, image, image_sz) + != RL2_OK) goto error; } } else if (format == RL2_OUTPUT_FORMAT_PDF) { @@ -2194,12 +2198,12 @@ int ret; unsigned char *rgba = NULL; if (format == RL2_OUTPUT_FORMAT_JPEG) { - if (rl2_rgb_to_jpeg (width, height, pixels, quality, image, image_sz) - != RL2_OK) + if (rl2_rgb_to_jpeg + (width, height, pixels, quality, image, image_sz) != RL2_OK) goto error; } else if (format == RL2_OUTPUT_FORMAT_PNG) { if (rl2_rgb_to_png (width, height, pixels, image, image_sz) != RL2_OK) @@ -2214,12 +2218,12 @@ pixels, image, image_sz) != RL2_OK) goto error; } else { - if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz) != - RL2_OK) + if (rl2_rgb_to_tiff (width, height, pixels, image, image_sz) + != RL2_OK) goto error; } } else if (format == RL2_OUTPUT_FORMAT_PDF) { @@ -2246,12 +2250,12 @@ RL2_PRIVATE int get_payload_from_rgb_transparent (unsigned int width, unsigned int height, unsigned char *pixels, unsigned char format, int quality, unsigned char **image, int *image_sz, unsigned char bg_red, - unsigned char bg_green, unsigned char bg_blue, - double opacity) + unsigned char bg_green, + unsigned char bg_blue, double opacity) { /* input: RGB output: RGB */ unsigned char *p_in; unsigned char *p_msk; unsigned char *mask = NULL; @@ -2770,12 +2774,13 @@ return 0; } RL2_PRIVATE int get_rgba_from_palette_transparent (unsigned int width, unsigned int height, - unsigned char *pixels, rl2PalettePtr palette, - unsigned char *rgba, unsigned char bg_red, + unsigned char *pixels, + rl2PalettePtr palette, unsigned char *rgba, + unsigned char bg_red, unsigned char bg_green, unsigned char bg_blue) { /* input: Palette output: Grayscale or RGB */ rl2PrivPalettePtr plt = (rl2PrivPalettePtr) palette; @@ -2927,12 +2932,12 @@ } RL2_PRIVATE int get_rgba_from_grayscale_transparent (unsigned int width, unsigned int height, - unsigned char *pixels, unsigned char *rgba, - unsigned char bg_gray) + unsigned char *pixels, + unsigned char *rgba, unsigned char bg_gray) { /* input: Grayscale output: Grayscale */ unsigned char *p_in; unsigned char *p_out; unsigned int row; @@ -3890,12 +3895,12 @@ return 1; } RL2_PRIVATE int rgba_from_double (unsigned int width, unsigned int height, - double *pixels, unsigned char *mask, rl2PrivPixelPtr no_data, - unsigned char *rgba) + double *pixels, unsigned char *mask, + rl2PrivPixelPtr no_data, unsigned char *rgba) { /* input: DataGrid DOUBLE output: Grayscale */ double *p_in; unsigned char *p_out; unsigned char *p_msk; @@ -4061,12 +4066,12 @@ rgba_from_int16 (width, height, (short *) pixels, mask, no_data, rgba); break; case RL2_SAMPLE_UINT16: ret = - rgba_from_uint16 (width, height, (unsigned short *) pixels, mask, - no_data, rgba); + rgba_from_uint16 (width, height, (unsigned short *) pixels, + mask, no_data, rgba); break; case RL2_SAMPLE_INT32: ret = rgba_from_int32 (width, height, (int *) pixels, mask, no_data, rgba); @@ -4081,12 +4086,12 @@ rgba_from_float (width, height, (float *) pixels, mask, no_data, rgba); break; case RL2_SAMPLE_DOUBLE: ret = - rgba_from_double (width, height, (double *) pixels, mask, no_data, - rgba); + rgba_from_double (width, height, (double *) pixels, mask, + no_data, rgba); break; }; return ret; } @@ -4307,12 +4312,12 @@ rgba); break; case RL2_SAMPLE_UINT16: ret = rgba_from_multi_uint16 (width, height, num_bands, - (unsigned short *) pixels, mask, no_data, - rgba); + (unsigned short *) pixels, mask, + no_data, rgba); break; }; return ret; } @@ -4359,12 +4364,12 @@ else if (format == RL2_OUTPUT_FORMAT_TIFF) { if (srid > 0) { if (rl2_gray_to_geotiff - (width, height, handle, minx, miny, maxx, maxy, srid, gray, - image, image_sz) != RL2_OK) + (width, height, handle, minx, miny, maxx, maxy, srid, + gray, image, image_sz) != RL2_OK) goto error; } else { if (rl2_gray_to_tiff (width, height, gray, image, image_sz) != @@ -4466,12 +4471,12 @@ int ret; unsigned char *rgba = NULL; if (format == RL2_OUTPUT_FORMAT_JPEG) { - if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz) != - RL2_OK) + if (rl2_rgb_to_jpeg (width, height, rgb, quality, image, image_sz) + != RL2_OK) goto error; } else if (format == RL2_OUTPUT_FORMAT_PNG) { if (rl2_rgb_to_png (width, height, rgb, image, image_sz) != RL2_OK) @@ -4513,11 +4518,12 @@ } RL2_PRIVATE int get_payload_from_rgb_rgba_transparent (unsigned int width, unsigned int height, - unsigned char *rgb, unsigned char *alpha, + unsigned char *rgb, + unsigned char *alpha, unsigned char format, int quality, unsigned char **image, int *image_sz, double opacity, int half_transparency) { /* RGB, Transparent */ Index: src/rl2svg.c ================================================================== --- src/rl2svg.c +++ src/rl2svg.c @@ -229,12 +229,14 @@ grad->y2); svg_apply_gradient_transformations (pattern, grad); stop = grad->first_stop; while (stop) { - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, - stop->red, stop->green, + cairo_pattern_add_color_stop_rgba (pattern, + stop->offset, + stop->red, + stop->green, stop->blue, stop->opacity * style->opacity); stop = stop->next; } @@ -259,12 +261,14 @@ grad->fx, grad->fy, grad->r); svg_apply_gradient_transformations (pattern, grad); stop = grad->first_stop; while (stop) { - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, - stop->red, stop->green, + cairo_pattern_add_color_stop_rgba (pattern, + stop->offset, + stop->red, + stop->green, stop->blue, stop->opacity * style->opacity); stop = stop->next; } @@ -290,12 +294,12 @@ cairo_set_line_join (cairo, style->stroke_linejoin); cairo_set_miter_limit (cairo, style->stroke_miterlimit); if (style->stroke_dashitems == 0 || style->stroke_dasharray == NULL) cairo_set_dash (cairo, lengths, 0, 0.0); else - cairo_set_dash (cairo, style->stroke_dasharray, style->stroke_dashitems, - style->stroke_dashoffset); + cairo_set_dash (cairo, style->stroke_dasharray, + style->stroke_dashitems, style->stroke_dashoffset); } static void svg_set_brush (cairo_t * cairo, rl2PrivSvgStylePtr style) { @@ -312,12 +316,14 @@ grad->y2); svg_apply_gradient_transformations (pattern, grad); stop = grad->first_stop; while (stop) { - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, - stop->red, stop->green, + cairo_pattern_add_color_stop_rgba (pattern, + stop->offset, + stop->red, + stop->green, stop->blue, stop->opacity * style->opacity); stop = stop->next; } @@ -332,12 +338,14 @@ grad->fx, grad->fy, grad->r); svg_apply_gradient_transformations (pattern, grad); stop = grad->first_stop; while (stop) { - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, - stop->red, stop->green, + cairo_pattern_add_color_stop_rgba (pattern, + stop->offset, + stop->red, + stop->green, stop->blue, stop->opacity * style->opacity); stop = stop->next; } @@ -848,15 +856,17 @@ bezier->y2, bezier->x, bezier->y); break; case RL2_SVG_CURVE_4: bezier = item->data; cairo_get_current_point (cairo, &x0, &y0); - cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, + cairo_curve_to (cairo, + 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0, - 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2, - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2, - bezier->y1, bezier->y2); + 2.0 / 3.0 * bezier->x1 + + 1.0 / 3.0 * bezier->x2, + 2.0 / 3.0 * bezier->y1 + + 1.0 / 3.0 * bezier->y2, bezier->y1, bezier->y2); break; case RL2_SVG_ELLIPT_ARC: arc = item->data; cairo_get_current_point (cairo, &x0, &y0); svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation, @@ -945,15 +955,17 @@ bezier->y2, bezier->x, bezier->y); break; case RL2_SVG_CURVE_4: bezier = item->data; cairo_get_current_point (cairo, &x0, &y0); - cairo_curve_to (cairo, 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, + cairo_curve_to (cairo, + 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * x0, 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * y0, - 2.0 / 3.0 * bezier->x1 + 1.0 / 3.0 * bezier->x2, - 2.0 / 3.0 * bezier->y1 + 1.0 / 3.0 * bezier->y2, - bezier->y1, bezier->y2); + 2.0 / 3.0 * bezier->x1 + + 1.0 / 3.0 * bezier->x2, + 2.0 / 3.0 * bezier->y1 + + 1.0 / 3.0 * bezier->y2, bezier->y1, bezier->y2); break; case RL2_SVG_ELLIPT_ARC: arc = item->data; cairo_get_current_point (cairo, &x0, &y0); svg_arc_to_cairo (arc, x0, y0, &xc, &yc, &rx, &rotation, Index: src/rl2symbaux.c ================================================================== --- src/rl2symbaux.c +++ src/rl2symbaux.c @@ -784,18 +784,20 @@ eval_filter (rl2PrivStyleRulePtr rule, rl2VariantArrayPtr variant) { /* evaluating a Rule Filter */ int i; rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant; - if (rule == NULL || var == NULL) - return 1; + if (rule->column_name == NULL) + return 1; /* there is no comparison: surely true */ + if (var == NULL) + return 0; for (i = 0; i < var->count; i++) { rl2PrivVariantValuePtr val = *(var->array + i); if (val == NULL) return 0; - if (rule->column_name == NULL || val->column_name == NULL) + if (val->column_name == NULL) return 0; if (strcasecmp (rule->column_name, val->column_name) != 0) continue; switch (rule->comparison_op) { @@ -826,11 +828,12 @@ } RL2_DECLARE rl2VectorSymbolizerPtr rl2_get_symbolizer_from_feature_type_style (rl2FeatureTypeStylePtr style, double scale, - rl2VariantArrayPtr variant, int *scale_forbidden) + rl2VariantArrayPtr variant, + int *scale_forbidden) { /* return the VectorSymbolizer matching a given scale/filter from a FeatureTypeStyle */ rl2PrivVectorSymbolizerPtr symbolizer = NULL; rl2PrivStyleRulePtr pR; rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style; @@ -847,12 +850,14 @@ { /* skipping any invalid rule */ pR = pR->next; continue; } + if (eval_filter (pR, variant)) { + *scale_forbidden = 0; if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX) { if (scale >= pR->min_scale && scale < pR->max_scale) symbolizer = pR->style; } @@ -866,19 +871,21 @@ if (scale < pR->max_scale) symbolizer = pR->style; } else symbolizer = pR->style; - if (symbolizer == NULL) + if (symbolizer == NULL) *scale_forbidden = 1; - return (rl2VectorSymbolizerPtr) symbolizer; + else + return (rl2VectorSymbolizerPtr) symbolizer; } pR = pR->next; } if (stl->else_rule != NULL) { /* applyhing the ELSE rule */ + *scale_forbidden = 0; pR = stl->else_rule; if (pR->min_scale != DBL_MAX && pR->max_scale != DBL_MAX) { if (scale >= pR->min_scale && scale < pR->max_scale) symbolizer = pR->style; @@ -893,12 +900,12 @@ if (scale < pR->max_scale) symbolizer = pR->style; } else symbolizer = pR->style; - if (symbolizer == NULL) - *scale_forbidden = 1; + if (symbolizer == NULL) + *scale_forbidden = 1; } return (rl2VectorSymbolizerPtr) symbolizer; } RL2_DECLARE int @@ -909,10 +916,15 @@ int visible; rl2PrivStyleRulePtr pR; rl2PrivFeatureTypeStylePtr stl = (rl2PrivFeatureTypeStylePtr) style; if (stl == NULL) return 0; + if (stl->first_rule == NULL) + { + /* there are no rules: unconditional visibility */ + return 1; + } pR = stl->first_rule; while (pR != NULL) { if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) @@ -1104,13 +1116,14 @@ *selected = 1; *categorize = 0; *interpolate = 1; return RL2_OK; } - if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) + if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE + || stl->contrastEnhancement == + RL2_CONTRAST_ENHANCEMENT_HISTOGRAM + || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) { /* Contrast Enhancement */ *selected = 1; *categorize = 0; *interpolate = 0; @@ -1173,13 +1186,14 @@ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; if (stl->bandSelection == NULL) { - if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) + if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE + || stl->contrastEnhancement == + RL2_CONTRAST_ENHANCEMENT_HISTOGRAM + || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) { /* Contrast Enhancement */ *selected = 1; return RL2_OK; } @@ -1203,13 +1217,14 @@ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; if (stl->bandSelection == NULL) { - if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_HISTOGRAM || - stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) + if (stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_NORMALIZE + || stl->contrastEnhancement == + RL2_CONTRAST_ENHANCEMENT_HISTOGRAM + || stl->contrastEnhancement == RL2_CONTRAST_ENHANCEMENT_GAMMA) { /* Contrast Enhancement */ *red_band = 0; *green_band = 1; *blue_band = 2; @@ -1244,15 +1259,13 @@ *gamma_value = stl->gammaValue; return RL2_OK; } RL2_DECLARE int -rl2_get_raster_symbolizer_red_band_contrast_enhancement (rl2RasterSymbolizerPtr - style, - unsigned char - *contrast_enhancement, - double *gamma_value) + rl2_get_raster_symbolizer_red_band_contrast_enhancement + (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement, + double *gamma_value) { /* return the RasterSymbolizer RedBand ContrastEnhancement */ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; @@ -1286,15 +1299,13 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_get_raster_symbolizer_blue_band_contrast_enhancement (rl2RasterSymbolizerPtr - style, - unsigned char - *contrast_enhancement, - double *gamma_value) + rl2_get_raster_symbolizer_blue_band_contrast_enhancement + (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement, + double *gamma_value) { /* return the RasterSymbolizer BlueBand ContrastEnhancement */ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; @@ -1308,15 +1319,13 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_get_raster_symbolizer_gray_band_contrast_enhancement (rl2RasterSymbolizerPtr - style, - unsigned char - *contrast_enhancement, - double *gamma_value) + rl2_get_raster_symbolizer_gray_band_contrast_enhancement + (rl2RasterSymbolizerPtr style, unsigned char *contrast_enhancement, + double *gamma_value) { /* return the RasterSymbolizer GrayBand ContrastEnhancement */ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; @@ -1360,12 +1369,12 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr style, - int *interpolated) +rl2_has_raster_symbolizer_color_map_interpolated (rl2RasterSymbolizerPtr + style, int *interpolated) { /* return if the RasterSymbolizer has an Interpolated ColorMap */ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; if (stl == NULL) return RL2_ERROR; @@ -1417,12 +1426,12 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr style, - unsigned char *red, +rl2_get_raster_symbolizer_color_map_category_base (rl2RasterSymbolizerPtr + style, unsigned char *red, unsigned char *green, unsigned char *blue) { /* return the RasterSymbolizer ColorMap Category base-color */ rl2PrivRasterSymbolizerPtr stl = (rl2PrivRasterSymbolizerPtr) style; @@ -1579,12 +1588,12 @@ graphic->first = NULL; graphic->last = NULL; graphic->opacity = 1.0; graphic->size = 10.0; graphic->rotation = 0.0; - graphic->anchor_point_x = 0.0; - graphic->anchor_point_y = 0.0; + graphic->anchor_point_x = 0.5; + graphic->anchor_point_y = 0.5; graphic->displacement_x = 0.0; graphic->displacement_y = 0.0; return graphic; } @@ -1610,12 +1619,12 @@ RL2_PRIVATE rl2PrivPointPlacementPtr rl2_create_default_point_placement () { /* creating a default PointPlacement object */ rl2PrivPointPlacementPtr place = malloc (sizeof (rl2PrivPointPlacement)); - place->anchor_point_x = 0.0; - place->anchor_point_y = 0.0; + place->anchor_point_x = 0.5; + place->anchor_point_y = 0.5; place->displacement_x = 0.0; place->displacement_y = 0.0; place->rotation = 0.0; return place; } @@ -2265,12 +2274,12 @@ ext = (rl2PrivExternalGraphicPtr) (sym->stroke->graphic->first->item); return ext->xlink_href; } RL2_DECLARE int -rl2_polygon_symbolizer_get_graphic_stroke_recode_count (rl2PolygonSymbolizerPtr - symbolizer, int *count) + rl2_polygon_symbolizer_get_graphic_stroke_recode_count + (rl2PolygonSymbolizerPtr symbolizer, int *count) { /* return how many ColorReplacement items are in a Graphic Stroke (PolygonSymbolizer) */ rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer; if (sym == NULL) return RL2_ERROR; @@ -2303,16 +2312,13 @@ } return RL2_OK; } RL2_DECLARE int -rl2_polygon_symbolizer_get_graphic_stroke_recode_color (rl2PolygonSymbolizerPtr - symbolizer, int index, - int *color_index, - unsigned char *red, - unsigned char *green, - unsigned char *blue) + rl2_polygon_symbolizer_get_graphic_stroke_recode_color + (rl2PolygonSymbolizerPtr symbolizer, int index, int *color_index, + unsigned char *red, unsigned char *green, unsigned char *blue) { /* return a ColorReplacement item from a Graphic Stroke (PolygonSymbolizer) */ rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer; if (sym == NULL) return RL2_ERROR; @@ -2397,12 +2403,12 @@ *width = sym->stroke->width; return RL2_OK; } RL2_DECLARE int -rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr symbolizer, - unsigned char *linejoin) +rl2_polygon_symbolizer_get_stroke_linejoin (rl2PolygonSymbolizerPtr + symbolizer, unsigned char *linejoin) { /* return the Polygon Symbolizer Stroke Linejoin mode */ rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer; if (sym == NULL) return RL2_ERROR; @@ -2439,12 +2445,13 @@ *count = sym->stroke->dash_count; return RL2_OK; } RL2_DECLARE int -rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr symbolizer, - int index, double *item) +rl2_polygon_symbolizer_get_stroke_dash_item (rl2PolygonSymbolizerPtr + symbolizer, int index, + double *item) { /* return a Polygon Symbolizer Stroke Dash item */ rl2PrivPolygonSymbolizerPtr sym = (rl2PrivPolygonSymbolizerPtr) symbolizer; if (sym == NULL) return RL2_ERROR; @@ -3113,11 +3120,12 @@ } RL2_DECLARE int rl2_point_symbolizer_get_graphic_recode_color (rl2PointSymbolizerPtr symbolizer, int index, - int repl_index, int *color_index, + int repl_index, + int *color_index, unsigned char *red, unsigned char *green, unsigned char *blue) { /* return a ColorReplacement item from an External Graphic (PointSymbolizer) */ @@ -3190,12 +3198,13 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr symbolizer, - int index, unsigned char *type) +rl2_point_symbolizer_mark_get_well_known_type (rl2PointSymbolizerPtr + symbolizer, int index, + unsigned char *type) { /* return the Point Symbolizer Mark WellKnownType */ int count = 0; rl2PrivMarkPtr mark; rl2PrivGraphicItemPtr item; @@ -3338,12 +3347,12 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr symbolizer, - int index, +rl2_point_symbolizer_mark_get_stroke_linejoin (rl2PointSymbolizerPtr + symbolizer, int index, unsigned char *linejoin) { /* return the Point Symbolizer Mark Stroke Linejoin mode */ int count = 0; rl2PrivMarkPtr mark; @@ -3372,12 +3381,13 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr symbolizer, - int index, unsigned char *linecap) +rl2_point_symbolizer_mark_get_stroke_linecap (rl2PointSymbolizerPtr + symbolizer, int index, + unsigned char *linecap) { /* return the Point Symbolizer Stroke Mark Linecap mode */ int count = 0; rl2PrivMarkPtr mark; rl2PrivGraphicItemPtr item; @@ -3513,12 +3523,12 @@ } return RL2_ERROR; } RL2_DECLARE int -rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer, int index, - int *fill) +rl2_point_symbolizer_mark_has_fill (rl2PointSymbolizerPtr symbolizer, + int index, int *fill) { /* checks if a Point Symbolizer Mark has a Fill */ int count = 0; rl2PrivMarkPtr mark; rl2PrivGraphicItemPtr item; @@ -4196,12 +4206,12 @@ *(var->array + index) = val; return RL2_OK; } RL2_DECLARE int -rl2_set_variant_double (rl2VariantArrayPtr variant, int index, const char *name, - double value) +rl2_set_variant_double (rl2VariantArrayPtr variant, int index, + const char *name, double value) { /* setting a DOUBLE VariantValue into a VariantArray object */ rl2PrivVariantArrayPtr var = (rl2PrivVariantArrayPtr) variant; rl2PrivVariantValuePtr val; if (var == NULL) Index: src/rl2symbolizer.c ================================================================== --- src/rl2symbolizer.c +++ src/rl2symbolizer.c @@ -542,12 +542,12 @@ *val = value; return 1; } static int -parse_sld_se_color (const char *color, unsigned char *red, unsigned char *green, - unsigned char *blue) +parse_sld_se_color (const char *color, unsigned char *red, + unsigned char *green, unsigned char *blue) { /* attempting to parse a #RRGGBB hexadecimal color */ unsigned char r; unsigned char g; unsigned char b; @@ -662,13 +662,12 @@ if (style->categorize->last == NULL) { style->categorize->baseRed = red; - style-> - categorize->baseGreen = - green; + style->categorize->baseGreen + = green; style-> categorize->baseBlue = blue; } else @@ -978,12 +977,12 @@ { const char *value = (const char *) (text->content); if (value != NULL) - style->brightnessOnly = - atoi (value); + style->brightnessOnly + = atoi (value); } text = text->next; } } if (strcmp (xmode, "ReliefFactor") == 0) @@ -1058,11 +1057,12 @@ name = (const char *) (child->name); if (strcmp (name, "RasterSymbolizer") == 0) { rl2PrivStyleRulePtr rule = rl2_create_default_style_rule (); - rl2PrivRasterSymbolizerPtr symbolizer = + rl2PrivRasterSymbolizerPtr symbolizer + = rl2_create_default_raster_symbolizer (); if (symbolizer == NULL || rule == NULL) { if (symbolizer != NULL) @@ -1374,12 +1374,12 @@ { unsigned char red; unsigned char green; unsigned char blue; if (parse_sld_se_color - ((const char *) (child->content), &red, &green, - &blue)) + ((const char *) (child->content), &red, + &green, &blue)) { repl->red = red; repl->green = green; repl->blue = blue; } @@ -1548,39 +1548,39 @@ mark->stroke->red = red; mark->stroke->green = green; mark->stroke->blue = blue; } } - if (strcmp (svg_name, "stroke-width") == - 0) + if (strcmp (svg_name, "stroke-width") + == 0) mark->stroke->width = atof ((const char *) svg_value); - if (strcmp (svg_name, "stroke-linejoin") - == 0) + if (strcmp + (svg_name, "stroke-linejoin") == 0) { - if (strcmp (svg_value, "mitre") == - 0) + if (strcmp (svg_value, "mitre") + == 0) mark->stroke->linejoin = RL2_STROKE_LINEJOIN_MITRE; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) mark->stroke->linejoin = RL2_STROKE_LINEJOIN_ROUND; - if (strcmp (svg_value, "bevel") == - 0) + if (strcmp (svg_value, "bevel") + == 0) mark->stroke->linejoin = RL2_STROKE_LINEJOIN_BEVEL; } - if (strcmp (svg_name, "stroke-linecap") - == 0) + if (strcmp + (svg_name, "stroke-linecap") == 0) { - if (strcmp (svg_value, "butt") == - 0) + if (strcmp (svg_value, "butt") + == 0) mark->stroke->linecap = RL2_STROKE_LINECAP_BUTT; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) mark->stroke->linecap = RL2_STROKE_LINECAP_ROUND; if (strcmp (svg_value, "square") == 0) mark->stroke->linecap = @@ -1827,43 +1827,43 @@ sym->stroke->red = red; sym->stroke->green = green; sym->stroke->blue = blue; } } - if (strcmp (svg_name, "stroke-opacity") - == 0) + if (strcmp + (svg_name, "stroke-opacity") == 0) sym->stroke->opacity = atof ((const char *) svg_value); - if (strcmp (svg_name, "stroke-width") == - 0) + if (strcmp (svg_name, "stroke-width") + == 0) sym->stroke->width = atof ((const char *) svg_value); - if (strcmp (svg_name, "stroke-linejoin") - == 0) + if (strcmp + (svg_name, "stroke-linejoin") == 0) { - if (strcmp (svg_value, "mitre") == - 0) + if (strcmp (svg_value, "mitre") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_MITRE; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_ROUND; - if (strcmp (svg_value, "bevel") == - 0) + if (strcmp (svg_value, "bevel") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_BEVEL; } - if (strcmp (svg_name, "stroke-linecap") - == 0) + if (strcmp + (svg_name, "stroke-linecap") == 0) { - if (strcmp (svg_value, "butt") == - 0) + if (strcmp (svg_value, "butt") + == 0) sym->stroke->linecap = RL2_STROKE_LINECAP_BUTT; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) sym->stroke->linecap = RL2_STROKE_LINECAP_ROUND; if (strcmp (svg_value, "square") == 0) sym->stroke->linecap = @@ -2026,43 +2026,43 @@ sym->stroke->red = red; sym->stroke->green = green; sym->stroke->blue = blue; } } - if (strcmp (svg_name, "stroke-opacity") - == 0) + if (strcmp + (svg_name, "stroke-opacity") == 0) sym->stroke->opacity = atof ((const char *) svg_value); - if (strcmp (svg_name, "stroke-width") == - 0) + if (strcmp (svg_name, "stroke-width") + == 0) sym->stroke->width = atof ((const char *) svg_value); - if (strcmp (svg_name, "stroke-linejoin") - == 0) + if (strcmp + (svg_name, "stroke-linejoin") == 0) { - if (strcmp (svg_value, "mitre") == - 0) + if (strcmp (svg_value, "mitre") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_MITRE; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_ROUND; - if (strcmp (svg_value, "bevel") == - 0) + if (strcmp (svg_value, "bevel") + == 0) sym->stroke->linejoin = RL2_STROKE_LINEJOIN_BEVEL; } - if (strcmp (svg_name, "stroke-linecap") - == 0) + if (strcmp + (svg_name, "stroke-linecap") == 0) { - if (strcmp (svg_value, "butt") == - 0) + if (strcmp (svg_value, "butt") + == 0) sym->stroke->linecap = RL2_STROKE_LINECAP_BUTT; - if (strcmp (svg_value, "round") == - 0) + if (strcmp (svg_value, "round") + == 0) sym->stroke->linecap = RL2_STROKE_LINECAP_ROUND; if (strcmp (svg_value, "square") == 0) sym->stroke->linecap = @@ -2168,12 +2168,12 @@ sym->fill->red = red; sym->fill->green = green; sym->fill->blue = blue; } } - if (strcmp (svg_name, "fill-opacity") == - 0) + if (strcmp (svg_name, "fill-opacity") + == 0) sym->fill->opacity = atof (svg_value); } } child = child->next; @@ -2619,12 +2619,12 @@ (child, &svg_name, &svg_value)) { child = child->next; continue; } - if (strcmp (svg_name, "font-family") == - 0) + if (strcmp (svg_name, "font-family") + == 0) { if (sym->font_families_count < RL2_MAX_FONT_FAMILIES) { int idx = @@ -2652,19 +2652,19 @@ if (strcasecmp (svg_value, "oblique") == 0) sym->font_style = RL2_FONT_STYLE_OBLIQUE; } - if (strcmp (svg_name, "font-weight") == - 0) + if (strcmp (svg_name, "font-weight") + == 0) { if (strcasecmp (svg_value, "normal") == 0) sym->font_weight = RL2_FONT_WEIGHT_NORMAL; - if (strcasecmp (svg_value, "bold") - == 0) + if (strcasecmp + (svg_value, "bold") == 0) sym->font_weight = RL2_FONT_WEIGHT_BOLD; } if (strcmp (svg_name, "font-size") == 0) sym->font_size = atof (svg_value); @@ -3018,14 +3018,16 @@ { const char *name = (const char *) (node->name); if (strcmp (name, "LabelPlacement") == 0) { xmlNodePtr child = node->children; - if (sym->label_placement_type == RL2_LABEL_PLACEMENT_POINT + if (sym->label_placement_type == + RL2_LABEL_PLACEMENT_POINT && sym->label_placement != NULL) rl2_destroy_point_placement ((rl2PrivPointPlacementPtr) (sym->label_placement)); - if (sym->label_placement_type == RL2_LABEL_PLACEMENT_LINE + if (sym->label_placement_type == + RL2_LABEL_PLACEMENT_LINE && sym->label_placement != NULL) rl2_destroy_line_placement ((rl2PrivLinePlacementPtr) (sym->label_placement)); sym->label_placement_type = RL2_LABEL_PLACEMENT_UNKNOWN; sym->label_placement = NULL; @@ -3995,56 +3997,50 @@ pR = style->first_rule; while (pR != NULL) { /* counting max column names */ if (pR->column_name != NULL) + count++; + if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) { - count++; - if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + pV = (rl2PrivVectorSymbolizerPtr) (pR->style); + item = pV->first; + while (item != NULL) { - pV = (rl2PrivVectorSymbolizerPtr) (pR->style); - item = pV->first; - while (item != NULL) + if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER + && item->symbolizer != NULL) { - if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER - && item->symbolizer != NULL) - { - text = - (rl2PrivTextSymbolizerPtr) - (item->symbolizer); - if (text->label != NULL) - count++; - } - item = item->next; + text = + (rl2PrivTextSymbolizerPtr) (item->symbolizer); + if (text->label != NULL) + count++; } + item = item->next; } } pR = pR->next; } pR = style->else_rule; if (pR != NULL) { if (pR->column_name != NULL) + count++; + if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) { - count++; - if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + pV = (rl2PrivVectorSymbolizerPtr) (pR->style); + item = pV->first; + while (item != NULL) { - pV = (rl2PrivVectorSymbolizerPtr) (pR->style); - item = pV->first; - while (item != NULL) + if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER + && item->symbolizer != NULL) { - if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER - && item->symbolizer != NULL) - { - text = - (rl2PrivTextSymbolizerPtr) - (item->symbolizer); - if (text->label != NULL) - count++; - } - item = item->next; + text = + (rl2PrivTextSymbolizerPtr) (item->symbolizer); + if (text->label != NULL) + count++; } + item = item->next; } } } if (count == 0) return; @@ -4061,33 +4057,32 @@ len = strlen (pR->column_name); *(strings + i) = malloc (len + 1); strcpy (*(strings + i), pR->column_name); *(dupl + i) = 'N'; i++; - if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + } + if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + { + pV = (rl2PrivVectorSymbolizerPtr) (pR->style); + item = pV->first; + while (item != NULL) { - pV = (rl2PrivVectorSymbolizerPtr) (pR->style); - item = pV->first; - while (item != NULL) + if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER + && item->symbolizer != NULL) { - if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER - && item->symbolizer != NULL) + text = + (rl2PrivTextSymbolizerPtr) (item->symbolizer); + if (text->label != NULL) { - text = - (rl2PrivTextSymbolizerPtr) - (item->symbolizer); - if (text->label != NULL) - { - len = strlen (text->label); - *(strings + i) = malloc (len + 1); - strcpy (*(strings + i), text->label); - *(dupl + i) = 'N'; - i++; - } + len = strlen (text->label); + *(strings + i) = malloc (len + 1); + strcpy (*(strings + i), text->label); + *(dupl + i) = 'N'; + i++; } - item = item->next; } + item = item->next; } } pR = pR->next; } pR = style->else_rule; @@ -4098,33 +4093,32 @@ len = strlen (pR->column_name); *(strings + i) = malloc (len + 1); strcpy (*(strings + i), pR->column_name); *(dupl + i) = 'N'; i++; - if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + } + if (pR->style_type == RL2_VECTOR_STYLE && pR->style != NULL) + { + pV = (rl2PrivVectorSymbolizerPtr) (pR->style); + item = pV->first; + while (item != NULL) { - pV = (rl2PrivVectorSymbolizerPtr) (pR->style); - item = pV->first; - while (item != NULL) + if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER + && item->symbolizer != NULL) { - if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER - && item->symbolizer != NULL) + text = + (rl2PrivTextSymbolizerPtr) (item->symbolizer); + if (text->label != NULL) { - text = - (rl2PrivTextSymbolizerPtr) - (item->symbolizer); - if (text->label != NULL) - { - len = strlen (text->label); - *(strings + i) = malloc (len + 1); - strcpy (*(strings + i), text->label); - *(dupl + i) = 'N'; - i++; - } + len = strlen (text->label); + *(strings + i) = malloc (len + 1); + strcpy (*(strings + i), text->label); + *(dupl + i) = 'N'; + i++; } - item = item->next; } + item = item->next; } } } for (i = 0; i < count; i++) @@ -4436,11 +4430,12 @@ return ptr; } static int rl2_group_renderer_set_raster (rl2PrivGroupRendererPtr group, int index, - const char *layer_name, rl2CoveragePtr coverage, + const char *layer_name, + rl2CoveragePtr coverage, sqlite3_int64 style_id, rl2RasterSymbolizerPtr symbolizer, rl2RasterStatisticsPtr stats) { /* setting up one of the Layers within the Group */ Index: src/rl2tiff.c ================================================================== --- src/rl2tiff.c +++ src/rl2tiff.c @@ -1417,11 +1417,12 @@ origin->planarConfig = PLANARCONFIG_CONTIG; } else origin->planarConfig = value16; - if (origin->bitsPerSample == 16 && origin->sampleFormat == SAMPLEFORMAT_UINT + if (origin->bitsPerSample == 16 + && origin->sampleFormat == SAMPLEFORMAT_UINT && origin->planarConfig == PLANARCONFIG_SEPARATE) ; else if (origin->bitsPerSample == 8 && origin->sampleFormat == SAMPLEFORMAT_UINT && origin->planarConfig == PLANARCONFIG_SEPARATE) @@ -2734,12 +2735,12 @@ if (skip) { /* skipping any not required tile */ continue; } - if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0) < - 0) + if (TIFFReadTile (origin->in, tiff_tile, tile_x, tile_y, 0, 0) + < 0) goto error; if (convert != RL2_CONVERT_NO) { /* applying some format conversion */ copy_convert_tile (origin, tiff_tile, pixels, startRow, @@ -2764,12 +2765,12 @@ p_in_8 = (char *) tiff_tile; p_in_8 += y * origin->tileWidth; p_in_8 += x; p_out_8 = (char *) pixels; p_out_8 += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; case RL2_SAMPLE_UINT8: p_in_u8 = (unsigned char *) tiff_tile; p_in_u8 += y * origin->tileWidth * num_bands; p_in_u8 += x * num_bands; @@ -2783,12 +2784,12 @@ p_in_16 = (short *) tiff_tile; p_in_16 += y * origin->tileWidth; p_in_16 += x; p_out_16 = (short *) pixels; p_out_16 += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; case RL2_SAMPLE_UINT16: p_in_u16 = (unsigned short *) tiff_tile; p_in_u16 += y * origin->tileWidth * num_bands; p_in_u16 += x * num_bands; @@ -2802,39 +2803,39 @@ p_in_32 = (int *) tiff_tile; p_in_32 += y * origin->tileWidth; p_in_32 += x; p_out_32 = (int *) pixels; p_out_32 += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; case RL2_SAMPLE_UINT32: p_in_u32 = (unsigned int *) tiff_tile; p_in_u32 += y * origin->tileWidth; p_in_u32 += x; p_out_u32 = (unsigned int *) pixels; p_out_u32 += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; case RL2_SAMPLE_FLOAT: p_in_flt = (float *) tiff_tile; p_in_flt += y * origin->tileWidth; p_in_flt += x; p_out_flt = (float *) pixels; p_out_flt += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; case RL2_SAMPLE_DOUBLE: p_in_dbl = (double *) tiff_tile; p_in_dbl += y * origin->tileWidth; p_in_dbl += x; p_out_dbl = (double *) pixels; p_out_dbl += - ((dest_y - startRow) * width) + (dest_x - - startCol); + ((dest_y - startRow) * width) + + (dest_x - startCol); break; }; for (bnd = 0; bnd < num_bands; bnd++) { switch (sample_type) @@ -3643,12 +3644,12 @@ p_in_u16 += x; p_out_u16 = (unsigned short *) pixels; p_out_u16 += ((dest_y - startRow) * width * num_bands) + - ((dest_x - startCol) * num_bands) + - band; + ((dest_x - + startCol) * num_bands) + band; *p_out_u16 = *p_in_u16; } if (sample_type == RL2_SAMPLE_UINT8) { p_in_u8 = (unsigned char *) tiff_tile; @@ -3656,12 +3657,12 @@ p_in_u8 += x; p_out_u8 = (unsigned char *) pixels; p_out_u8 += ((dest_y - startRow) * width * num_bands) + - ((dest_x - startCol) * num_bands) + - band; + ((dest_x - + startCol) * num_bands) + band; *p_out_u8 = *p_in_u8; } } } } @@ -3675,12 +3676,13 @@ free (tiff_tile); return RL2_ERROR; } static int -read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin, unsigned short width, - unsigned short height, unsigned char sample_type, +read_raw_separate_scanlines (rl2PrivTiffOriginPtr origin, + unsigned short width, unsigned short height, + unsigned char sample_type, unsigned char num_bands, unsigned int startRow, unsigned int startCol, void *pixels) { /* reading TIFF raw strips - separate planes */ uint32 line_no; @@ -4174,11 +4176,12 @@ else { /* contiguous planar configuration */ if (origin->bitsPerSample <= 8 && origin->sampleFormat == SAMPLEFORMAT_UINT - && (origin->samplesPerPixel == 1 || origin->samplesPerPixel == 3) + && (origin->samplesPerPixel == 1 + || origin->samplesPerPixel == 3) && (pixel_type == RL2_PIXEL_MONOCHROME || pixel_type == RL2_PIXEL_PALETTE || pixel_type == RL2_PIXEL_GRAYSCALE || pixel_type == RL2_PIXEL_RGB)) { @@ -4204,13 +4207,13 @@ read_raw_tiles (origin, width, height, sample_type, num_bands, startRow, startCol, bufPixels); else ret = - read_raw_scanlines (origin, width, height, sample_type, - num_bands, startRow, startCol, - bufPixels); + read_raw_scanlines (origin, width, height, + sample_type, num_bands, startRow, + startCol, bufPixels); if (ret != RL2_OK) goto error; } } @@ -4384,12 +4387,12 @@ } /* attempting to create the tile */ if (read_from_tiff (origin, coverage->tileWidth, coverage->tileHeight, - coverage->sampleType, coverage->pixelType, coverage->nBands, startRow, - startCol, &pixels, &pixels_sz, palette) != RL2_OK) + coverage->sampleType, coverage->pixelType, coverage->nBands, + startRow, startCol, &pixels, &pixels_sz, palette) != RL2_OK) goto error; if (startCol + coverage->tileWidth > origin->width) unused_width = (startCol + coverage->tileWidth) - origin->width; if (startRow + coverage->tileHeight > origin->height) unused_height = (startRow + coverage->tileHeight) - origin->height; @@ -5080,13 +5083,14 @@ } RL2_DECLARE rl2TiffDestinationPtr rl2_create_tiff_destination (const char *path, unsigned int width, unsigned int height, unsigned char sample_type, - unsigned char pixel_type, unsigned char num_bands, - rl2PalettePtr plt, unsigned char tiff_compression, - int tiled, unsigned int tile_size) + unsigned char pixel_type, + unsigned char num_bands, rl2PalettePtr plt, + unsigned char tiff_compression, int tiled, + unsigned int tile_size) { /* attempting to create a file-based TIFF destination (no georeferencing) */ rl2PrivTiffDestinationPtr destination = NULL; if (!check_color_model (sample_type, pixel_type, num_bands, plt, tiff_compression)) @@ -5762,12 +5766,12 @@ return 0; return 1; } static int -tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster, - unsigned int row) +tiff_write_strip_gray (rl2PrivTiffDestinationPtr tiff, + rl2PrivRasterPtr raster, unsigned int row) { /* writing a TIFF Grayscale scanline */ unsigned int x; unsigned char *p_in = raster->rasterBuffer; unsigned char *p_out = tiff->tiffBuffer; @@ -6165,12 +6169,13 @@ } return 1; } static int -tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff, rl2PrivRasterPtr raster, - unsigned int row, unsigned int col) +tiff_write_tile_rgb_u8 (rl2PrivTiffDestinationPtr tiff, + rl2PrivRasterPtr raster, unsigned int row, + unsigned int col) { /* writing a TIFF RGB tile - UINT8 */ unsigned int y; unsigned int x; unsigned char *p_in = raster->rasterBuffer; @@ -6541,11 +6546,12 @@ && destination->tileHeight == rst->height) ret = tiff_write_tile_multiband16 (destination, rst, startRow, startCol); else if (destination->sampleFormat == SAMPLEFORMAT_UINT && destination->samplesPerPixel == 1 - && destination->photometric < 2 && destination->bitsPerSample == 8 + && destination->photometric < 2 + && destination->bitsPerSample == 8 && rst->sampleType == RL2_SAMPLE_UINT8 && rst->pixelType == RL2_PIXEL_GRAYSCALE && rst->nBands == 1 && destination->tileWidth == rst->width && destination->tileHeight == rst->height) ret = tiff_write_tile_gray (destination, rst, startRow, startCol); @@ -6660,11 +6666,12 @@ return RL2_ERROR; tfw = fopen (destination->tfw_path, "w"); if (tfw == NULL) { - fprintf (stderr, "RL2-TIFF writer: unable to open Worldfile \"%s\"\n", + fprintf (stderr, + "RL2-TIFF writer: unable to open Worldfile \"%s\"\n", destination->tfw_path); return RL2_ERROR; } fprintf (tfw, " %1.16f\n", destination->hResolution); fprintf (tfw, " 0.0\n"); @@ -6977,12 +6984,12 @@ free (tiff_buffer); return RL2_ERROR; } static int -rgb_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width, - unsigned short height) +rgb_tiff_common (TIFF * out, const unsigned char *buffer, + unsigned short width, unsigned short height) { /* common implementation of RGB TIFF export */ tsize_t buf_size; void *tiff_buffer = NULL; int y; @@ -7260,12 +7267,12 @@ static int output_palette_tiff (const unsigned char *buffer, unsigned short width, unsigned short height, unsigned char *red, - unsigned char *green, unsigned char *blue, int max_palette, - unsigned char **blob, int *blob_size) + unsigned char *green, unsigned char *blue, + int max_palette, unsigned char **blob, int *blob_size) { /* generating a PALETTE TIFF - actual work */ struct memfile clientdata; TIFF *out = (TIFF *) 0; @@ -7509,12 +7516,12 @@ } return RL2_OK; } static int -gray_tiff_common (TIFF * out, const unsigned char *buffer, unsigned short width, - unsigned short height) +gray_tiff_common (TIFF * out, const unsigned char *buffer, + unsigned short width, unsigned short height) { /* common implementation of Grayscale TIFF export */ tsize_t buf_size; void *tiff_buffer = NULL; int y; @@ -7989,12 +7996,12 @@ org->compression); sqlite3_free (prev); prev = xml; if (org->sampleFormat == SAMPLEFORMAT_UINT) xml = - sqlite3_mprintf ("%sunsigned integer", - prev); + sqlite3_mprintf + ("%sunsigned integer", prev); else if (org->sampleFormat == SAMPLEFORMAT_INT) xml = sqlite3_mprintf ("%ssigned integer", prev); else if (org->sampleFormat == SAMPLEFORMAT_IEEEFP) @@ -8084,12 +8091,13 @@ prev = xml; xml = sqlite3_mprintf ("%s", prev); sqlite3_free (prev); prev = xml; xml = - sqlite3_mprintf ("%s%1.10f", - prev, org->maxX - org->minX); + sqlite3_mprintf + ("%s%1.10f", prev, + org->maxX - org->minX); sqlite3_free (prev); prev = xml; xml = sqlite3_mprintf ("%s%1.10f", prev, org->maxY - org->minY); Index: src/rl2webp.c ================================================================== --- src/rl2webp.c +++ src/rl2webp.c @@ -156,12 +156,12 @@ } return RL2_OK; } static void -copy_pixels (unsigned char *out, const unsigned char *in, int width, int height, - int num_bands) +copy_pixels (unsigned char *out, const unsigned char *in, int width, + int height, int num_bands) { /* copying pixels */ int x; int y; int ib; @@ -295,12 +295,12 @@ if (quality > 100) quality = 100; if (quality < 0) quality = 75; size = - WebPEncodeRGBA (rgba, rst->width, rst->height, rst->width * 4, quality, - &output); + WebPEncodeRGBA (rgba, rst->width, rst->height, rst->width * 4, + quality, &output); free (rgba); if (size == 0) return RL2_ERROR; *webp = output; *webp_size = size; Index: src/rl2wms.c ================================================================== --- src/rl2wms.c +++ src/rl2wms.c @@ -536,12 +536,12 @@ /* populating the array */ *(cache->SortedByUrl + pos) = pI; pos++; pI = pI->Next; } - qsort (cache->SortedByUrl, cache->NumCachedItems, sizeof (wmsCachedItemPtr), - compare_url); + qsort (cache->SortedByUrl, cache->NumCachedItems, + sizeof (wmsCachedItemPtr), compare_url); } static void wmsCacheSqueeze (wmsCachePtr cache, int limit) { @@ -594,12 +594,12 @@ cache->TotalDownload += (double) size; } static void -wmsAddCachedItem (wmsCachePtr cache, const char *url, const unsigned char *item, - int size, const char *image_format) +wmsAddCachedItem (wmsCachePtr cache, const char *url, + const unsigned char *item, int size, const char *image_format) { /* adding a new WMS Cached Item */ wmsCachedItemPtr ptr; if (cache == NULL) return; @@ -1101,12 +1101,12 @@ ptr->last->next = arg; ptr->last = arg; } static void -parse_pattern_bbox (const char *value, double *minx, double *miny, double *maxx, - double *maxy) +parse_pattern_bbox (const char *value, double *minx, double *miny, + double *maxx, double *maxy) { /* parsing a BBOX arg [minx,miny,maxx,maxy] */ int step = 0; const char *p_start = value; const char *p_end = value; @@ -2029,15 +2029,15 @@ } if (cdata) { /* masking XML special characters */ if (*(p_in + i) == '<') - wmsMemBufferAppend (&outbuf, (const unsigned char *) "<", - 4); + wmsMemBufferAppend (&outbuf, + (const unsigned char *) "<", 4); else if (*(p_in + i) == '>') - wmsMemBufferAppend (&outbuf, (const unsigned char *) ">", - 4); + wmsMemBufferAppend (&outbuf, + (const unsigned char *) ">", 4); else if (*(p_in + i) == '&') wmsMemBufferAppend (&outbuf, (const unsigned char *) "&", 5); else if (*(p_in + i) == '>') wmsMemBufferAppend (&outbuf, @@ -2121,15 +2121,15 @@ } if (cdata) { /* masking XML special characters */ if (*(p_in + i) == '<') - wmsMemBufferAppend (&outbuf, (const unsigned char *) "<", - 4); + wmsMemBufferAppend (&outbuf, + (const unsigned char *) "<", 4); else if (*(p_in + i) == '>') - wmsMemBufferAppend (&outbuf, (const unsigned char *) ">", - 4); + wmsMemBufferAppend (&outbuf, + (const unsigned char *) ">", 4); else if (*(p_in + i) == '&') wmsMemBufferAppend (&outbuf, (const unsigned char *) "&", 5); else if (*(p_in + i) == '>') wmsMemBufferAppend (&outbuf, @@ -2707,12 +2707,12 @@ if (child_node->type == XML_TEXT_NODE) *contact_organization = (const char *) (child_node->content); } } - if (strcmp ((const char *) (cur_node->name), "ContactPerson") == - 0) + if (strcmp ((const char *) (cur_node->name), "ContactPerson") + == 0) { child_node = cur_node->children; if (child_node != NULL) { if (child_node->type == XML_TEXT_NODE) @@ -2754,12 +2754,12 @@ { if (child_node->type == XML_TEXT_NODE) *city = (const char *) (child_node->content); } } - if (strcmp ((const char *) (cur_node->name), "StateOrProvince") - == 0) + if (strcmp + ((const char *) (cur_node->name), "StateOrProvince") == 0) { child_node = cur_node->children; if (child_node != NULL) { if (child_node->type == XML_TEXT_NODE) @@ -2807,12 +2807,12 @@ for (cur_node = node; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { - if (strcmp ((const char *) (cur_node->name), "ContactPosition") - == 0) + if (strcmp + ((const char *) (cur_node->name), "ContactPosition") == 0) { child_node = cur_node->children; if (child_node != NULL) { if (child_node->type == XML_TEXT_NODE) @@ -2936,12 +2936,13 @@ parse_wms_contact_information (cur_node->children, &contact_person, &contact_organization, &contact_position, &postal_address, &city, - &state_province, &post_code, - &country, &voice_telephone, + &state_province, + &post_code, &country, + &voice_telephone, &fax_telephone, &email_address); if (strcmp ((const char *) (cur_node->name), "Fees") == 0) { child_node = cur_node->children; @@ -3247,12 +3248,13 @@ p = (const char *) (text->content); len = strlen (p); cap->GetTileServiceURLGet = malloc (len + 1); - strcpy (cap->GetTileServiceURLGet, - p); + strcpy + (cap->GetTileServiceURLGet, + p); } } } attr = attr->next; } @@ -3286,12 +3288,12 @@ "href") == 0) { xmlNodePtr text = attr->children; if (text->type == XML_TEXT_NODE) { - if (cap->GetTileServiceURLPost != - NULL) + if (cap->GetTileServiceURLPost + != NULL) { free (cap-> GetTileServiceURLPost); cap->GetTileServiceURLPost = NULL; @@ -3351,12 +3353,13 @@ p = (const char *) (text->content); len = strlen (p); cap->GetFeatureInfoURLGet = malloc (len + 1); - strcpy (cap->GetFeatureInfoURLGet, - p); + strcpy + (cap->GetFeatureInfoURLGet, + p); } } } attr = attr->next; } @@ -3390,12 +3393,12 @@ "href") == 0) { xmlNodePtr text = attr->children; if (text->type == XML_TEXT_NODE) { - if (cap->GetFeatureInfoURLPost != - NULL) + if (cap->GetFeatureInfoURLPost + != NULL) { free (cap->GetFeatureInfoURLPost); cap->GetFeatureInfoURLPost = NULL; } @@ -3584,12 +3587,12 @@ (format, "application/vnd.ogc.gml") == 0) ok = 1; if (strcmp (format, - "application/vnd.ogc.gml/3.1.1") == - 0) + "application/vnd.ogc.gml/3.1.1") + == 0) ok = 1; if (ok) { int len = strlen (format); cap->GmlMimeType = @@ -4379,12 +4382,12 @@ { if (cur_node->type == XML_ELEMENT_NODE) { if (strcmp ((const char *) (cur_node->name), "Service") == 0) parse_tile_service_info (cur_node, cap); - if (strcmp ((const char *) (cur_node->name), "TiledPatterns") == - 0) + if (strcmp ((const char *) (cur_node->name), "TiledPatterns") + == 0) parse_tiled_patterns (cur_node, cap); } } } @@ -4761,12 +4764,12 @@ for (; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { - if (strcmp ((const char *) (cur_node->name), "featureMember") == - 0) + if (strcmp ((const char *) (cur_node->name), "featureMember") + == 0) parse_wms_feature_member (cur_node->children, coll); } } } @@ -4831,12 +4834,12 @@ return coll; } static int -query_TileService (rl2WmsCachePtr cache_handle, wmsCapabilitiesPtr capabilities, - const char *proxy) +query_TileService (rl2WmsCachePtr cache_handle, + wmsCapabilitiesPtr capabilities, const char *proxy) { /* attempting to get and parse a WMS GetTileService request */ CURL *curl = NULL; CURLcode res; wmsMemBuffer headerBuf; @@ -6947,11 +6950,12 @@ return NULL; } RL2_DECLARE int get_wms_feature_attribute_blob_geometry (rl2WmsFeatureMemberPtr handle, - int index, const unsigned char **blob, + int index, + const unsigned char **blob, int *blob_size) { /* attempting to get the Nth FeatureAttribute (Geometry) from some WMS-FeatureMember object */ int count = 0; wmsFeatureAttributePtr attr; @@ -7065,22 +7069,22 @@ request = sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s" "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s" "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url, - version, layer, crs_prefix, crs, miny, minx, - maxy, maxx, width, height, style, format, - (opaque == 0) ? "TRUE" : "FALSE"); + version, layer, crs_prefix, crs, miny, + minx, maxy, maxx, width, height, style, + format, (opaque == 0) ? "TRUE" : "FALSE"); else request = sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetMap&VERSION=%s" "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s" "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url, - version, layer, crs_prefix, crs, minx, miny, - maxx, maxy, width, height, style, format, - (opaque == 0) ? "TRUE" : "FALSE"); + version, layer, crs_prefix, crs, minx, + miny, maxx, maxy, width, height, style, + format, (opaque == 0) ? "TRUE" : "FALSE"); } else { /* "?" marker already defined */ if (swap_xy) @@ -7087,22 +7091,22 @@ request = sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s" "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s" "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url, - version, layer, crs_prefix, crs, miny, minx, - maxy, maxx, width, height, style, format, - (opaque == 0) ? "TRUE" : "FALSE"); + version, layer, crs_prefix, crs, miny, + minx, maxy, maxx, width, height, style, + format, (opaque == 0) ? "TRUE" : "FALSE"); else request = sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetMap&VERSION=%s" "&LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&STYLES=%s&FORMAT=%s" "&TRANSPARENT=%s&BGCOLOR=0xFFFFFF", url, - version, layer, crs_prefix, crs, minx, miny, - maxx, maxy, width, height, style, format, - (opaque == 0) ? "TRUE" : "FALSE"); + version, layer, crs_prefix, crs, minx, + miny, maxx, maxy, width, height, style, + format, (opaque == 0) ? "TRUE" : "FALSE"); } if (cache != NULL) { /* checks if it's already stored into the WMS Cache */ @@ -7273,15 +7277,15 @@ int from_cache, char **err_msg) { /* attempting to execute a WMS GepMap request [method POST] */ /* not yet implemented: just a stupid placeholder always returning NULL */ - if (cache_handle == NULL || url == NULL || proxy == NULL || version == NULL - || layer == NULL || crs == NULL) + if (cache_handle == NULL || url == NULL || proxy == NULL + || version == NULL || layer == NULL || crs == NULL) return NULL; - if (minx == miny || maxx == maxy || width == height || opaque == from_cache - || width == swap_xy) + if (minx == miny || maxx == maxy || width == height + || opaque == from_cache || width == swap_xy) return NULL; if (style == NULL || format == NULL || err_msg == NULL) return NULL; return NULL; } @@ -7531,43 +7535,43 @@ request = sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s" "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s" - "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix, - crs, miny, minx, maxy, maxx, width, height, mouse_x, - mouse_y, format); + "&FEATURE_COUNT=50", url, version, layer, layer, + crs_prefix, crs, miny, minx, maxy, maxx, width, height, + mouse_x, mouse_y, format); else request = sqlite3_mprintf ("%s?SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s" "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s" - "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix, - crs, minx, miny, maxx, maxy, width, height, mouse_x, - mouse_y, format); + "&FEATURE_COUNT=50", url, version, layer, layer, + crs_prefix, crs, minx, miny, maxx, maxy, width, height, + mouse_x, mouse_y, format); } else { if (swap_xy) request = sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s" "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s" - "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix, - crs, miny, minx, maxy, maxx, width, height, mouse_x, - mouse_y, format); + "&FEATURE_COUNT=50", url, version, layer, layer, + crs_prefix, crs, miny, minx, maxy, maxx, width, height, + mouse_x, mouse_y, format); else request = sqlite3_mprintf ("%sSERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=%s&LAYERS=%s" "&QUERY_LAYERS=%s&%s=%s&BBOX=%1.6f,%1.6f,%1.6f,%1.6f" "&WIDTH=%d&HEIGHT=%d&X=%d&Y=%d&INFO_FORMAT=%s" - "&FEATURE_COUNT=50", url, version, layer, layer, crs_prefix, - crs, minx, miny, maxx, maxy, width, height, mouse_x, - mouse_y, format); + "&FEATURE_COUNT=50", url, version, layer, layer, + crs_prefix, crs, minx, miny, maxx, maxy, width, height, + mouse_x, mouse_y, format); } curl = curl_easy_init (); if (curl) { @@ -7701,13 +7705,13 @@ RL2_DECLARE rl2WmsFeatureCollectionPtr do_wms_GetFeatureInfo_post (const char *url, const char *proxy, const char *version, const char *format, const char *layer, const char *crs, int swap_xy, - double minx, double miny, double maxx, double maxy, - int width, int height, int mouse_x, int mouse_y, - char **err_msg) + double minx, double miny, double maxx, + double maxy, int width, int height, int mouse_x, + int mouse_y, char **err_msg) { /* attempting to execute a WMS GepFeatureInfo request [method POST] */ /* not yet implemented: just a stupid placeholder always returning NULL */ if (url == NULL || proxy == NULL || version == NULL || format == NULL Index: test/Makefile.in ================================================================== --- test/Makefile.in +++ test/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -12,11 +12,21 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -102,19 +112,18 @@ test_line_symbolizer$(EXEEXT) test_polygon_symbolizer$(EXEEXT) \ test_point_symbolizer$(EXEEXT) test_text_symbolizer$(EXEEXT) \ test_vectors$(EXEEXT) test_font$(EXEEXT) \ test_copy_rastercov$(EXEEXT) subdir = test -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(top_srcdir)/test-driver ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = check_sql_stmt_SOURCES = check_sql_stmt.c @@ -620,10 +629,12 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ @@ -887,11 +898,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -1393,11 +1403,11 @@ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ - else \ + elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ @@ -2143,10 +2153,12 @@ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ uninstall uninstall-am + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: test/sql_stmt_security_tests/Makefile.in ================================================================== --- test/sql_stmt_security_tests/Makefile.in +++ test/sql_stmt_security_tests/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -12,11 +12,21 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -76,18 +86,18 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = test/sql_stmt_security_tests -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -108,10 +118,11 @@ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ @@ -898,11 +909,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/sql_stmt_security_tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test/sql_stmt_security_tests/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -1072,10 +1082,12 @@ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: test/sql_stmt_tests/Makefile.in ================================================================== --- test/sql_stmt_tests/Makefile.in +++ test/sql_stmt_tests/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -12,11 +12,21 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -76,18 +86,18 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = test/sql_stmt_tests -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -108,10 +118,11 @@ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ @@ -870,11 +881,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test/sql_stmt_tests/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -1044,11 +1054,13 @@ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am + +.PRECIOUS: Makefile version.testcase # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: test/symbolizers.sqlite ================================================================== --- test/symbolizers.sqlite +++ test/symbolizers.sqlite cannot compute difference between binary files Index: test/test_line_symbolizer.c ================================================================== --- test/test_line_symbolizer.c +++ test/test_line_symbolizer.c @@ -1074,11 +1074,11 @@ { fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #4\n"); *retcode += 18; return 0; } - if (red != 0x00 || green != 0x00 || blue != 0xff) + if (red != 0x80 || green != 0x80 || blue != 0x80) { fprintf (stderr, "Unexpected Line Symbolizer GetStrokeColor #4: %02x%02x%02x\n", red, green, blue); *retcode += 19; @@ -1313,11 +1313,11 @@ { fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #9\n"); *retcode += 48; return 0; } - if (red != 0x00 || green != 0x00 || blue != 0xff) + if (red != 0x80 || green != 0x80 || blue != 0x80) { fprintf (stderr, "Unexpected Line Symbolizer GetStrokeColor #9: %02x%02x%02x\n", red, green, blue); *retcode += 49; @@ -1361,11 +1361,11 @@ fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #10\n"); *retcode += 54; return 0; } - if (red != 0x00 || green != 0x00 || blue != 0xff) + if (red != 0x80 || green != 0x80 || blue != 0x80) { fprintf (stderr, "Unexpected Line Symbolizer GetStrokeColor #10: %02x%02x%02x\n", red, green, blue); *retcode += 55; @@ -1409,11 +1409,11 @@ fprintf (stderr, "Unable to get Line Symbolizer GetStrokeColor #11\n"); *retcode += 60; return 0; } - if (red != 0x00 || green != 0x00 || blue != 0xff) + if (red != 0x80 || green != 0x80 || blue != 0x80) { fprintf (stderr, "Unexpected Line Symbolizer GetStrokeColor #11: %02x%02x%02x\n", red, green, blue); *retcode += 61; Index: test/test_point_symbolizer.c ================================================================== --- test/test_point_symbolizer.c +++ test/test_point_symbolizer.c @@ -788,11 +788,11 @@ if (dblval == 3.0 && dblval2 == 2.0) intval = 1; } else { - if (dblval == 0.0 && dblval2 == 0.0) + if (dblval == 0.5 && dblval2 == 0.5) intval = 1; } if (intval != 1) { fprintf (stderr, Index: test/test_polygon_symbolizer.c ================================================================== --- test/test_polygon_symbolizer.c +++ test/test_polygon_symbolizer.c @@ -1508,11 +1508,11 @@ fprintf (stderr, "Unexpected NULL VectorSymbolizer (%s) #6\n", style_name); *retcode += 22; return 0; } - polyg = rl2_get_polygon_symbolizer (symbolizer, 0); + polyg = rl2_get_polygon_symbolizer (symbolizer, 1); if (polyg == NULL) { fprintf (stderr, "Unable to get Polygon Symbolizer #5\n"); *retcode += 23; return 0; @@ -1523,11 +1523,11 @@ fprintf (stderr, "Unable to get Polygon Symbolizer GetFillColor #4\n"); *retcode += 24; return 0; } - if (red != 0x70 || green != 0xff || blue != 0xc0) + if (red != 0x37 || green != 0x81 || blue != 0xf2) { fprintf (stderr, "Unexpected Polygon Symbolizer GetStrokeColor #5: %02x%02x%02x\n", red, green, blue); *retcode += 25; Index: tools/Makefile.in ================================================================== --- tools/Makefile.in +++ tools/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,11 +13,21 @@ # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ @@ -78,19 +88,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = rl2sniff$(EXEEXT) rl2tool$(EXEEXT) wmslite$(EXEEXT) subdir = tools -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" @@ -167,10 +176,11 @@ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ @@ -355,11 +365,10 @@ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tools/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ @@ -676,10 +685,12 @@ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Index: tools/wmslite.c ================================================================== --- tools/wmslite.c +++ tools/wmslite.c @@ -3401,11 +3401,12 @@ } if (args->request_type == WMS_GET_MAP) { /* preparing the WMS GetMap payload */ args->db_handle = req->conn->handle; - args->stmt_get_map = req->conn->stmt_get_map; + args->stmt_get_map_raster = req->conn->stmt_get_map_raster; + args->stmt_get_map_vector = req->conn->stmt_get_map_vector; log_get_map_1 (req->log, timestamp, http_status, method, url, args); wms_get_map (args, req->socket, req->log); } goto end_request; @@ -4442,11 +4443,11 @@ { /* retrieving all declared Raster Styles */ int ret; sqlite3_stmt *stmt; const char *sql = "SELECT coverage_name, name, title, abstract " - "FROM SE_raster_styled_layers_view ORDER BY coverage_name, style_id"; + "FROM SE_raster_styled_layers_view ORDER BY coverage_name, name"; ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); if (ret != SQLITE_OK) return; while (1) { @@ -4477,11 +4478,11 @@ { /* retrieving all declared Vector Styles */ int ret; sqlite3_stmt *stmt; const char *sql = "SELECT coverage_name, name, title, abstract " - "FROM SE_vector_styled_layers_view ORDER BY coverage_name, style_id"; + "FROM SE_vector_styled_layers_view ORDER BY coverage_name, name"; ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); if (ret != SQLITE_OK) return; while (1) {